Registry / serialization / sphinx-jinja

sphinx-jinja

JSON →
library2.0.2pypypi✓ verified 24d ago

Sphinx Jinja is a Python library that enables the embedding of Jinja2 templates directly within Sphinx documentation. It allows dynamic content generation, variable injection, and custom logic using Jinja2 syntax in reStructuredText or MyST files. The current version is 2.0.2, and releases are generally made as needed, with significant changes between major versions.

pip install sphinx-jinja
INSTALL
IMPORT
SIG · SPHINX-JINJA
S
sphinx-jinja
serializationpythonv2.0.2
Install
5.7s avg
Import
Disk
94MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 92.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.7s · import 0.000s · 93MB
94MB installed
● package 94MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Extension Configuration
extensions = ['sphinx_jinja'] jinja_contexts = {...}
from sphinx_jinja import SomeClass
sphinx-jinja is typically integrated by adding 'sphinx_jinja' to the 'extensions' list in conf.py, not through direct Python imports of its internal components. Configuration is done via global variables in conf.py.

To get started, add 'sphinx_jinja' to your `extensions` list in `conf.py`. Then, configure Jinja contexts, filters, globals, and environment options using `jinja_contexts`, `jinja_filters`, `jinja_globals`, `jinja_tests`, and `jinja_env_kwargs` variables. Finally, use the `.. jinja::` directive in your reStructuredText or MyST files to render templates. The provided example shows a `conf.py` setup and a conceptual `.rst` usage.

# conf.py project = 'My Jinja Project' copyright = '2024, Your Name' html_theme = 'alabaster' extensions = [ 'sphinx_jinja' ] jinja_contexts = { 'global_vars': { 'product_name': 'Awesome App', 'version': '1.0.0' } } jinja_filters = { 'upper': lambda s: s.upper() } jinja_env_kwargs = { 'trim_blocks': True, 'lstrip_blocks': True } # docs/index.rst # .. jinja:: global_vars # # Welcome to {{ product_name }} ({{ version }}). # This text will be uppercased: {{ "hello world" | upper }}
Debug
Known issues
breakingThe configuration parameters in `conf.py` for setting up Jinja2 environments, contexts, filters, globals, and tests have changed significantly in version 2.0.0.
fix
Migrate your `conf.py` configuration from `jinja_contexts`, `jinja_env`, `jinja_filters`, `jinja_globals`, `jinja_tests` (pre-2.0.0) to the new style using `jinja_contexts`, `jinja_filters`, `jinja_globals`, `jinja_tests`, and `jinja_env_kwargs` (2.0.0+). Consult the official documentation for detailed migration guides.
affects: 2.0.0 and later
breakingVersion 2.0.0 dropped support for Python 3.6. It now requires Python 3.7 or newer.
fix
Ensure your project is running on Python 3.7 or a later version before upgrading to sphinx-jinja 2.x.
affects: 2.0.0 and later
breakingVersion 2.0.0 tightened its dependency on Sphinx, requiring Sphinx 4.0.0 or newer.
fix
Upgrade your Sphinx installation to version 4.0.0 or higher: `pip install 'sphinx>=4.0.0'`.
affects: 2.0.0 and later
breakingVersion 2.0.0 updated its dependency on Jinja2, requiring Jinja2 3.0.0 or newer.
fix
Upgrade your Jinja2 installation to version 3.0.0 or higher: `pip install 'Jinja2>=3.0.0'`.
affects: 2.0.0 and later
Upgrade
Version history
2.0.2latest on PyPI · released Jul 5, 2022
Audit
Dependencies
SphinxrequiredRequired for Sphinx documentation projects.
Jinja2requiredThe templating engine used by the extension.
Agent activity
12 hits · last 30 days
node
10
Resources
sphinx-jinja — pip install sphinx-jinja · libregistry