Skip to content
Permalink
Browse files
Allow plugins to manipulate task dependencies
  • Loading branch information
ralsina committed May 3, 2015
1 parent 6eeff35 commit 35698daf0db51bfdc171c5c89849d686c4cbb66c
Showing with 10 additions and 1 deletion.
  1. +7 −1 nikola/nikola.py
  2. +3 −0 nikola/plugin_categories.py
@@ -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),
@@ -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
@@ -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.

0 comments on commit 35698da

Please sign in to comment.