Skip to content

Commit

Permalink
Allow plugins to manipulate task dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed May 3, 2015
1 parent 6eeff35 commit 35698da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nikola/nikola.py
Expand Up @@ -286,7 +286,8 @@ 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 = {
'extra_head': utils.TemplateHookRegistry('extra_head', self),
Expand Down Expand Up @@ -1319,6 +1320,11 @@ 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']])
if task['task_dep']:
print(task['basename'], task['task_dep'])
yield task
for multi in self.plugin_manager.getPluginsOfCategory("TaskMultiplier"):
flag = False
Expand Down
3 changes: 3 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -75,6 +75,9 @@ 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 35698da

Please sign in to comment.