Skip to content

Commit

Permalink
Moved activate_compiler_extensions() from Nikola to PageCompiler as g…
Browse files Browse the repository at this point in the history
…et_compiler_extensions().
  • Loading branch information
felixfontein committed Jul 5, 2015
1 parent 2b19136 commit d98d60e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
8 changes: 0 additions & 8 deletions nikola/nikola.py
Expand Up @@ -837,14 +837,6 @@ def _activate_plugins_of_category(self, category):
plugins.append(plugin_info)
return plugins

def activate_compiler_extensions(self, compiler_name):
"""Activate all the compiler extension plugins for a given compiler and return them."""
plugins = []
for plugin_info in self.compiler_extensions:
if plugin_info.plugin_object.compiler_name == compiler_name:
plugins.append(plugin_info)
return plugins

def _get_themes(self):
if self._THEMES is None:
try:
Expand Down
9 changes: 9 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -283,6 +283,15 @@ def split_metadata(self, data):
# ['metadata', '\n\n', 'post content']
return split_result[0], split_result[-1]

def get_compiler_extensions(self):
"""Activate all the compiler extension plugins for a given compiler and return them."""
plugins = []
for plugin_info in self.site.compiler_extensions:
if plugin_info.plugin_object.compiler_name == self.name:
plugins.append(plugin_info)
return plugins



class CompilerExtension(BasePlugin):

Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/compile/markdown/__init__.py
Expand Up @@ -53,14 +53,14 @@ class CompileMarkdown(PageCompiler):
site = None

def set_site(self, site):
super(CompileMarkdown, self).set_site(site)
self.config_dependencies = []
for plugin_info in site.activate_compiler_extensions('markdown'):
for plugin_info in self.get_compiler_extensions():
self.config_dependencies.append(plugin_info.name)
self.extensions.append(plugin_info.plugin_object)
plugin_info.plugin_object.short_help = plugin_info.description

self.config_dependencies.append(str(sorted(site.config.get("MARKDOWN_EXTENSIONS"))))
return super(CompileMarkdown, self).set_site(site)

def compile_html(self, source, dest, is_two_file=True):
if markdown is None:
Expand Down
5 changes: 2 additions & 3 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -127,17 +127,16 @@ def create_post(self, path, **kw):
fd.write(content)

def set_site(self, site):
super(CompileRest, self).set_site(site)
self.config_dependencies = []
for plugin_info in site.activate_compiler_extensions('rest'):
for plugin_info in self.get_compiler_extensions():
self.config_dependencies.append(plugin_info.name)
plugin_info.plugin_object.short_help = plugin_info.description

self.logger = get_logger('compile_rest', site.loghandlers)
if not site.debug:
self.logger.level = 4

return super(CompileRest, self).set_site(site)


def get_observer(settings):
"""Return an observer for the docutils Reporter."""
Expand Down
4 changes: 1 addition & 3 deletions tests/base.py
Expand Up @@ -214,6 +214,7 @@ def __init__(self):
"TaskMultiplier": TaskMultiplier,
"CompilerExtension": CompilerExtension
})
self.compiler_extensions = []
self.loghandlers = [nikola.utils.STDERR_HANDLER]
self.plugin_manager.setPluginInfoExtension('plugin')
if sys.version_info[0] == 3:
Expand All @@ -237,8 +238,5 @@ def __init__(self):
self.template_system = self
self.name = 'mako'

def activate_compiler_extensions(self, compiler_name):
return []

def render_template(self, name, _, context):
return('<img src="IMG.jpg">')

0 comments on commit d98d60e

Please sign in to comment.