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.