Skip to content

Commit

Permalink
Read .dep files in all compilers
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 30, 2016
1 parent dddfec6 commit 0c0680c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
18 changes: 12 additions & 6 deletions nikola/plugin_categories.py
Expand Up @@ -249,13 +249,19 @@ class PageCompiler(BasePlugin):
}
config_dependencies = []

def register_extra_dependencies(self, post):
"""Add additional dependencies to the post object.

Current main use is the ReST page compiler, which puts extra
dependencies into a .dep file.
"""
pass
def _read_extra_deps(self, post):
"""Read contents of .dep file and return them as a list."""
dep_path = post.base_path + '.dep'
if os.path.isfile(dep_path):
with io.open(dep_path, 'r+', encoding='utf8') as depf:
deps = [l.strip() for l in depf.readlines()]
return deps
return []

def register_extra_dependencies(self, post):
"""Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')

def compile_html(self, source, dest, is_two_file=False):
"""Compile the source, save it on dest."""
Expand Down
13 changes: 0 additions & 13 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -52,19 +52,6 @@ class CompileRest(PageCompiler):
demote_headers = True
logger = None

def _read_extra_deps(self, post):
"""Read contents of .dep file and returns them as a list."""
dep_path = post.base_path + '.dep'
if os.path.isfile(dep_path):
with io.open(dep_path, 'r+', encoding='utf8') as depf:
deps = [l.strip() for l in depf.readlines()]
return deps
return []

def register_extra_dependencies(self, post):
"""Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')

def compile_html_string(self, data, source_path=None, is_two_file=True):
"""Compile reST into HTML strings."""
# If errors occur, this will be added to the line number reported by
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugins/compile/rest/post_list.py
Expand Up @@ -191,12 +191,16 @@ def _do_post_list(start=None, stop=None, reverse=False, tags=None, categories=No
post_list_id = id or 'post_list_' + 'fixedvaluethatisnotauuid'
else:
post_list_id = id or 'post_list_' + uuid.uuid4().hex

# Get post from filename if available
if filename:
self_post = site.post_per_file.get(filename)
else:
self_post = None

if self_post:
self_post.add_depepdency("####MAGIC####TIMELINE")

# If we get strings for start/stop, make them integers
if start is not None:
start = int(start)
Expand Down

0 comments on commit 0c0680c

Please sign in to comment.