sphinx-jinja2-compat

0.4.1 · active · verified Mon Apr 13

sphinx-jinja2-compat, current version 0.4.1, is a utility library designed to patch Jinja2 v3, restoring compatibility with earlier Sphinx versions. It also addresses issues to ensure some Sphinx versions function correctly on Python 3.10. This library primarily serves as a compatibility layer to bridge gaps between major versions of its dependencies, rather than providing new user-facing features. Releases are made on an as-needed basis to address specific compatibility challenges.

Warnings

Install

Quickstart

Installation of `sphinx-jinja2-compat` is typically sufficient; it works by applying patches on import of relevant modules within Sphinx, rather than requiring explicit inclusion in `conf.py`'s `extensions` list. The primary effect is restoring compatibility for older Sphinx versions with Jinja2 v3 and ensuring Python 3.10 compatibility for certain Sphinx versions. The patches can be disabled by setting the environment variable `NO_SPHINX_JINJA2_COMPAT` to `1`.

# Simply install the package. No direct code import or configuration in conf.py is typically needed.
# The patch is applied automatically upon import of related modules within Sphinx.
# To disable the patches, set the environment variable before running Sphinx:
import os
os.environ['NO_SPHINX_JINJA2_COMPAT'] = '1'
# Then run Sphinx as usual, e.g., via command line:
# sphinx-build -b html source build

print("sphinx-jinja2-compat is active once installed, patching Jinja2 for Sphinx compatibility.")

view raw JSON →