Skip to content

Commit

Permalink
Merge pull request #1680 from getnikola/dependency-injection
Browse files Browse the repository at this point in the history
Dependency injection
  • Loading branch information
ralsina committed May 4, 2015
2 parents a3e27f7 + 3717534 commit e427fc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Plugins can manipulate task dependencies (Issue #1679)
* LINK_CHECK_WHITELIST now works with output relative and full fs paths
* Four new filters: html_tidy_nowrap, html_tidy_wrap, html_tidy_wrap_attr,
and html_tidy_mini for prettification and minification. Requires tidy5.
Expand Down
4 changes: 4 additions & 0 deletions nikola/nikola.py
Expand Up @@ -286,6 +286,7 @@ def __init__(self, **config):
self.quiet = config.pop('__quiet__', False)
self.configuration_filename = config.pop('__configuration_filename__', False)
self.configured = bool(config)
self.injected_deps = defaultdict(list)

self.rst_transforms = []
self.template_hooks = {
Expand Down Expand Up @@ -1319,6 +1320,9 @@ def flatten(task):
for task in flatten(pluginInfo.plugin_object.gen_tasks()):
assert 'basename' in task
task = self.clean_task_paths(task)
if 'task_dep' not in task:
task['task_dep'] = []
task['task_dep'].extend(self.injected_deps[task['basename']])
yield task
for multi in self.plugin_manager.getPluginsOfCategory("TaskMultiplier"):
flag = False
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -75,6 +75,10 @@ def inject_templates(self):
# so let’s just ignore it and be done with it.
pass

def inject_dependency(self, target, dependency):
"""Add 'dependency' to the target task's task_deps"""
self.site.injected_deps[target].append(dependency)


class Command(BasePlugin, DoitCommand):
"""These plugins are exposed via the command line.
Expand Down

0 comments on commit e427fc0

Please sign in to comment.