skillfed

sphinx-substitution-extensions

Extensions for Sphinx which allow for substitutions.

sphinx-substitution-extensions v2026.8.13.1 253.8K downloads/30d#8,509 on PyPI41
Permissive license MIT Active released

What it is and what it does

This package extends Sphinx with directives that perform variable substitution in documentation content. It works by registering new options (`:substitutions:`, `:content-substitutions:`, `:path-substitutions:`) on Sphinx's built-in directives like `code-block`, `literalinclude`, `include`, and `image`, plus adds new directives like `:substitution-code:` and `:substitution-download:`. Substitutions are defined in `conf.py` via `rst_prolog` for reStructuredText or `myst_substitutions` for MyST Markdown.

The package supports both reStructuredText and MyST Markdown syntax. Variables can be scoped globally (in `rst_prolog` or `myst_substitutions`) or per-document (in frontmatter for Markdown). By default, substitution flags must be added explicitly to each directive; a `substitutions_default_enabled` setting applies them automatically across all compatible directives. It depends on sphinx, docutils, myst-parser, and beartype, and requires Python 3.11 or later.

Use it for:

  • Document version numbers and release dates that appear in code examples and download links without manual updates
  • Replace author names, product names, or environment-specific values across code blocks and file paths in multi-author or multi-environment docs
  • Generate dynamic file paths in `literalinclude` and `include` directives based on substitution variables
  • Maintain consistent branding or configuration values in inline code snippets and hyperlink targets

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds substitution support to Sphinx directives, allowing variable replacement within code blocks, file paths, and other content during documentation builds.

Yes. Active maintenance, low install friction, no known vulnerabilities, and permissive MIT license. Install if you maintain Sphinx documentation with repeated variable values in code examples or file paths. Skip if your documentation is static and does not benefit from templating.

Install

sphinx-substitution-extensions on PyPI

pip

pip install sphinx-substitution-extensions

uv

uv add sphinx-substitution-extensions

poetry

poetry add sphinx-substitution-extensions

Installing sphinx-substitution-extensions

Before you install

Low friction install with a wheel distribution. Active maintenance as of 2026-08-14 with recent release. Depends on sphinx, docutils, myst-parser, and beartype—all standard documentation tooling.

License in practice

MIT license permits use in open-source and commercial projects with minimal restrictions; attribution required.

Quickstart

pip install sphinx-substitution-extensions

# In conf.py:
extensions = ["sphinx_substitution_extensions"]
rst_prolog = """
.. |version| replace:: 1.0
.. |author| replace:: Jane
"""

# In your .rst file:
.. code-block:: shell
   :substitutions:

   echo "|author| released |version|"

Requires Python 3.11 or later and Sphinx 8.2.0 or later.

Verify before relying

  • Whether substitution syntax conflicts with existing Sphinx extensions in real projects
  • Performance impact when substitutions_default_enabled is true on large documentation sets
  • Exact scope of MyST Markdown support beyond the documented examples

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 4 — beartype, docutils, myst-parser, sphinx
Maintenance actively maintained — 1 days since the last release
Last repo commit
First released
Downloads 253,757/month — #8,509 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sphinx_substitution_extensions-2026.8.13.1-py3-none-any.whl

Keywords: documentation, rst, sphinx

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: PytestOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

sphinx variable substitutionsphinx code block substitutionssphinx template variablessphinx dynamic content replacementsphinx rst substitutionssphinx markdown substitutionssphinx literal include substitutions
sphinx-extensiondocumentation-tooling

More Sphinx packages

docstring-parser

Parses Python docstrings in ReST, Google,…

permissive · top 1,000 on PyPI

Sphinx

Sphinx generates professional documentation…

permissive · top 1,000 on PyPI

sphinxcontrib-serializinghtml

A Sphinx extension that outputs documentation…

permissive · top 1,000 on PyPI

alabaster

Alabaster is a clean, responsive Sphinx theme…

permissive · top 1,000 on PyPI

sphinxcontrib-htmlhelp

A Sphinx extension that generates HTML help…

permissive · top 1,000 on PyPI

sphinxcontrib-qthelp

A Sphinx extension that converts documentation…

permissive · top 1,000 on PyPI

sphinx-jinja

A Sphinx extension that lets you embed Jinja2…

permissive · top 5,000 on PyPI

sphinxcontrib-jquery

A Sphinx extension that ensures jQuery is…

permissive · top 5,000 on PyPI

sphinxemoji

Sphinx extension that replaces emoji codes…

permissive · top 15,000 on PyPI

sphinx_mdinclude

Sphinx extension that lets you include and…

permissive · top 15,000 on PyPI

sphinx-issues

A Sphinx extension that adds roles for linking…

permissive · top 15,000 on PyPI

sphinx-needs

Sphinx-Needs is a Sphinx extension that lets…

permissive · top 15,000 on PyPI

sphinx-math-dollar

A Sphinx extension that lets you write LaTeX…

permissive · top 15,000 on PyPI

sphinxcontrib-images

A Sphinx extension that replaces standard image…

permissive · top 15,000 on PyPI

sphinx-thebe

Adds interactive, executable code blocks to…

unclear · top 15,000 on PyPI

sphinx-markdown-builder

A Sphinx extension that generates Markdown…

permissive · top 15,000 on PyPI