Skip to content

Commit

Permalink
Allowing compilers to specify additional targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Oct 25, 2016
1 parent 6470755 commit 9e80b59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,8 @@ Bugfixes
Features
--------

* Improving handling of .dep files, and allowing compilers to specify
additional targets for the render_posts task (Issue #2536)
* Allow posts to set custom ``URL_TYPE`` by using the ``url_type``
meta tag (useful for HTML fragments inserted using JavaScript)
* Plugins can depend on other plugins being installed (Issue #2533)
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -275,6 +275,10 @@ 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 get_extra_targets(self, post, lang, dest):
"""Returns a list of extra targets for the render_posts task when compiling the post for the specified language."""
return []

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
# For backwards compatibility, call `compile_html`
Expand Down
3 changes: 2 additions & 1 deletion nikola/plugins/task/posts.py
Expand Up @@ -86,11 +86,12 @@ def tl_ch():
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],
'targets': [dest, dep_file] + extra_targets,
'actions': [(post.compile, (lang, )),
(update_deps, (post, lang, )),
],
Expand Down

0 comments on commit 9e80b59

Please sign in to comment.