Skip to content

Instantly share code, notes, and snippets.

@ericholscher
Created December 2, 2015 23:23
Show Gist options
  • Save ericholscher/f560d339c452c5a010da to your computer and use it in GitHub Desktop.
Save ericholscher/f560d339c452c5a010da to your computer and use it in GitHub Desktop.
A basic extension that parses the RST as a jinja template before rendering as RST
def on_source_read(app, docname, source):
src = source[0]
if hasattr(app.builder, 'globalcontext'):
app.info('Using global context')
source[0] = app.builder.templates.render_string(src, app.builder.globalcontext)
else:
source[0] = app.builder.templates.render_string(src, {})
def setup(app):
app.connect("source-read", on_source_read)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment