Skip to content
Permalink
Browse files

Compilers must explicitly state that they use the .dep file for it to…

… be always created and added as a target.
  • Loading branch information
felixfontein committed Oct 29, 2016
1 parent 6953d3d commit 022dbec9b2e58fd3d7609ae561663db6d374a5eb
@@ -250,6 +250,7 @@ class PageCompiler(BasePlugin):
friendly_name = ''
demote_headers = False
supports_onefile = True
use_dep_file = False # If set to true, the .dep file is always written and added as a target
default_metadata = {
'title': '',
'slug': '',
@@ -277,7 +278,10 @@ def register_extra_dependencies(self, post):

def get_extra_targets(self, post, lang, dest):
"""Return a list of extra targets for the render_posts task when compiling the post for the specified language."""
return []
if self.use_dep_file:
return [post.base_path + '.dep']
else:
return []

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
@@ -40,6 +40,7 @@ class CompileHtml(PageCompiler):

name = "html"
friendly_name = "HTML"
use_dep_file = True

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
@@ -70,6 +70,7 @@ class CompileIPynb(PageCompiler):
name = "ipynb"
friendly_name = "Jupyter/IPython Notebook"
demote_headers = True
use_dep_file = True
default_kernel = 'python2' if sys.version_info[0] == 2 else 'python3'

def set_site(self, site):
@@ -49,6 +49,7 @@ class CompileMarkdown(PageCompiler):
name = "markdown"
friendly_name = "Markdown"
demote_headers = True
use_dep_file = True
extensions = []
site = None

@@ -44,6 +44,7 @@ class CompilePandoc(PageCompiler):

name = "pandoc"
friendly_name = "pandoc"
use_dep_file = True

def set_site(self, site):
"""Set Nikola site."""
@@ -57,6 +57,7 @@ class CompileRest(PageCompiler):
name = "rest"
friendly_name = "reStructuredText"
demote_headers = True
use_dep_file = True
logger = None

def compile_string(self, data, source_path=None, is_two_file=True):
@@ -84,14 +84,13 @@ def tl_ch():
k = p.split('####MAGIC####CONFIG:', 1)[-1]
deps_dict[k] = self.site.config.get(k)
dest = post.translated_base_path(lang)
dep_file = dest + '.dep'
file_dep = [p for p in post.fragment_deps(lang) if not p.startswith("####MAGIC####")]
extra_targets = post.compiler.get_extra_targets(post, lang, dest)
task = {
'basename': self.name,
'name': dest,
'file_dep': file_dep,
'targets': [dest, dep_file] + extra_targets,
'targets': [dest] + extra_targets,
'actions': [(post.compile, (lang, )),
(update_deps, (post, lang, )),
],
@@ -464,9 +464,13 @@ def register_depfile(self, dep, dest=None, lang=None):
def write_depfile(dest, deps_list):
"""Write a depfile for a given language."""
deps_path = dest + '.dep'
deps_list = [p for p in deps_list if p != dest] # Don't depend on yourself (#1671)
with io.open(deps_path, "w+", encoding="utf8") as deps_file:
deps_file.write('\n'.join(deps_list))
if deps_list or self.compiler.use_dep_file:
deps_list = [p for p in deps_list if p != dest] # Don't depend on yourself (#1671)
with io.open(deps_path, "w+", encoding="utf8") as deps_file:
deps_file.write('\n'.join(deps_list))
else:
if os.path.isfile(deps_path):
os.unlink(deps_path)

def _get_dependencies(self, deps_list):
deps = []

0 comments on commit 022dbec

Please sign in to comment.
You can’t perform that action at this time.