Repository: getnikola/nikola

Issue:
Compiler plugins should add dependency on config options
For example, the markdown compiler plugin will do different things if you change MARKDOWN_EXTENSIONS so the compiler plugins should declare those somewhere so Nikola can rebuild those as needed.



Discussion:
The new dependency injection system in #1529 should make that quite simple, by calling `Post`'s `add_dependency_uptodate` from `PostCompiler`'s `register_extra_dependencies` function.


Resolving patch:
diff --git a/nikola/plugins/compile/markdown/__init__.py b/nikola/plugins/compile/markdown/__init__.py
--- a/nikola/plugins/compile/markdown/__init__.py
+++ b/nikola/plugins/compile/markdown/__init__.py
@@ -53,16 +53,18 @@ class CompileMarkdown(PageCompiler):
     site = None
 
     def set_site(self, site):
+        self.enabled_extensions = []
         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)
             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")
         return super(CompileMarkdown, self).set_site(site)
 
     def compile_html(self, source, dest, is_two_file=True):
@@ -96,3 +98,7 @@ 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(self.enabled_extensions)
diff --git a/nikola/plugins/compile/pandoc.py b/nikola/plugins/compile/pandoc.py
--- a/nikola/plugins/compile/pandoc.py
+++ b/nikola/plugins/compile/pandoc.py
@@ -70,3 +70,7 @@ 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(self.site.config['PANDOC_OPTIONS'])
diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py
--- a/nikola/plugins/compile/rest/__init__.py
+++ b/nikola/plugins/compile/rest/__init__.py
@@ -63,6 +63,7 @@ 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(self.enabled_plugins)
 
     def compile_html(self, source, dest, is_two_file=True):
         """Compile reSt into HTML."""
@@ -128,12 +129,14 @@ def create_post(self, path, **kw):
             fd.write(content)
 
     def set_site(self, site):
+        self.enabled_plugins = []
         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)
             plugin_info.plugin_object.set_site(site)
             plugin_info.plugin_object.short_help = plugin_info.description
 


Test patch: