Skip to content
Permalink
Browse files

let's approach this in a different way

  • Loading branch information
ralsina committed Jan 18, 2015
1 parent 1df4d08 commit 3a09ac89f5d2e7da11da2a84c8a7a7a24eb82d1a
@@ -224,6 +224,7 @@ class PageCompiler(BasePlugin):
'description': '',
'type': 'text',
}
config_dependencies = []

def register_extra_dependencies(self, post):
"""Add additional dependencies to the post object.
@@ -53,18 +53,18 @@ class CompileMarkdown(PageCompiler):
site = None

def set_site(self, site):
self.enabled_extensions = []
self.config_dependencies = []
for plugin_info in site.plugin_manager.getPluginsOfCategory("MarkdownExtension"):
if plugin_info.name in site.config['DISABLED_PLUGINS']:
site.plugin_manager.removePluginFromCategory(plugin_info, "MarkdownExtension")
continue
self.enabled_extensions.append(plugin_info.name)
self.config_dependencies.append(plugin_info.name)
site.plugin_manager.activatePluginByName(plugin_info.name)
plugin_info.plugin_object.set_site(site)
self.extensions.append(plugin_info.plugin_object)
plugin_info.plugin_object.short_help = plugin_info.description

self.enabled_extensions += site.config.get("MARKDOWN_EXTENSIONS")
self.config_dependencies.append(site.config.get("MARKDOWN_EXTENSIONS"))
return super(CompileMarkdown, self).set_site(site)

def compile_html(self, source, dest, is_two_file=True):
@@ -98,7 +98,3 @@ def create_post(self, path, **kw):
fd.write(write_metadata(metadata))
fd.write('-->\n\n')
fd.write(content)

def register_extra_dependencies(self, post):
"""Adds dependency to post object to check .dep file."""
post.add_dependency_uptodate(config_changed({1: self.enabled_extensions}, self.name))
@@ -45,6 +45,9 @@ class CompilePandoc(PageCompiler):

name = "pandoc"

def set_site(self, site):
self.config_dependencies = [self.site.config['PANDOC_OPTIONS']]

def compile_html(self, source, dest, is_two_file=True):
makedirs(os.path.dirname(dest))
try:
@@ -70,7 +73,3 @@ def create_post(self, path, **kw):
fd.write(write_metadata(metadata))
fd.write('-->\n\n')
fd.write(content)

def register_extra_dependencies(self, post):
"""Adds dependency to post object to check .dep file."""
post.add_dependency_uptodate(config_changed({1: self.site.config['PANDOC_OPTIONS']}, self.name))
@@ -63,7 +63,6 @@ def _read_extra_deps(self, post):
def register_extra_dependencies(self, post):
"""Adds dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')
post.add_dependency_uptodate(config_changed({1: self.enabled_plugins}, self.name))

def compile_html(self, source, dest, is_two_file=True):
"""Compile reSt into HTML."""
@@ -129,14 +128,14 @@ def create_post(self, path, **kw):
fd.write(content)

def set_site(self, site):
self.enabled_plugins = []
self.config_dependencies = []
for plugin_info in site.plugin_manager.getPluginsOfCategory("RestExtension"):
if plugin_info.name in site.config['DISABLED_PLUGINS']:
site.plugin_manager.removePluginFromCategory(plugin_info, "RestExtension")
continue

site.plugin_manager.activatePluginByName(plugin_info.name)
self.enabled_plugins.append(plugin_info.name)
self.config_dependencies.append(plugin_info.name)
plugin_info.plugin_object.set_site(site)
plugin_info.plugin_object.short_help = plugin_info.description

@@ -414,6 +414,7 @@ def deps_uptodate(self, lang):
deps = []
deps += self._get_dependencies(self._dependency_uptodate_page[lang])
deps += self._get_dependencies(self._dependency_uptodate_page[None])
deps += self.compiler.config_dependencies
return deps

def compile(self, lang):

0 comments on commit 3a09ac8

Please sign in to comment.
You can’t perform that action at this time.