Question

I'd like to implement custom navigation to my sphinx docs. I use my custom theme based on basic sphinx theme. But I don't know how to create new tag for template system or use my custom sphinx plugin's directive in html templates.

Any ideas where I can plug in?

Update

As I can see in sphinx sources, jinja2 environment constructed in websupport jinja2glue module. Though I can't understand the way it can be reconfigured besides monkey-patching.

Was it helpful?

Solution

I've found a good way to do this. Sphinx's configuration parameter template_bridge allows to control over TemplateBribge object - which is responsible for themes rendering.

Standard sphinx.jinja2glue.TemplateBridge constructs environment attribute in init method (it's not a constructor, unfortunate name for method) - which is jinja2's environment itself used for templates rendering. So just subclass TemplateBridge and override init method.

OTHER TIPS

Have a look at http://jinja.pocoo.org/docs/extensions/#module-jinja2.ext , extensions are used for adding custom tags in Jinja

Also have a look at Django : How to use 3rd party app templatetags with Jinja 2?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top