Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement depend-on-config-options for reSt extensions (Fix Issue #1919)
  • Loading branch information
ralsina committed Aug 5, 2015
1 parent 32845cd commit b565553
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@ New in master
Features
--------

* Added mechanism for rest extensions to depend on configuration options
(Issue #1919)
* Render Jupyter notebooks (ipynb) in listings (Issue #1900)

Bugfixes
Expand Down
9 changes: 9 additions & 0 deletions docs/extending.txt
Expand Up @@ -384,6 +384,15 @@ RestExtension Plugins

Implement directives for reStructuredText, see `media.py <https://github.com/getnikola/nikola/blob/master/nikola/plugins/compile/rest/media.py>`__ for a simple example.

If your output depends on a config value, you need to make your post record a dependency on a pseudo-path like this::

####MAGIC####CONFIG:OPTIONNAME

Then, whenever the ``OPTIONNAME`` option is changed in conf.py, the file will be rebuilt.

If your directive depends or may depend on the whole timeline like, for example, the post-list directive, where adding new posts
to the site could make it stale, you should record a dependency on the pseudo-path ``####MAGIC####TIMELINE``

MarkdownExtension Plugins
-------------------------

Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/task/posts.py
Expand Up @@ -77,7 +77,11 @@ def tl_ch():
deps_dict = copy(kw)
deps_dict.pop('timeline')
for post in kw['timeline']:

# Extra config dependencies picked from config
for p in post.fragment_deps(lang):
if p.startswith('####MAGIC####CONFIG:'):
k = p.split('####MAGIC####CONFIG:',1)[-1]
deps_dict[k] = self.site.config.get(k)
dest = post.translated_base_path(lang)
file_dep = [p for p in post.fragment_deps(lang) if not p.startswith("####MAGIC####")]
task = {
Expand Down

0 comments on commit b565553

Please sign in to comment.