Skip to main content

Extensions for Sphinx which allow for substitutions.

Project description

Build Status codecov PyPI

Sphinx Substitution Extensions

Extensions for Sphinx which allow substitutions within code blocks.

Installation

Sphinx Substitution Extensions is compatible with Sphinx 4.0+ using Python 3.10+.

$ pip install Sphinx-Substitution-Extensions

Setup

  1. Add the following to conf.py:

extensions += ['sphinx_substitution_extensions']
  1. Set the following variable in conf.py:

rst_prolog = """
.. |release| replace:: 0.1
.. |author| replace:: Eleanor
"""

This will replace |release| in the new directives with 0.1, and |author| with Eleanor.

Directives

code-block

This adds a :substitutions: option to Sphinx’s built-in code-block directive.

.. code-block:: bash
   :substitutions:

   echo "|author| released version |release|"

prompt

This adds a :substitutions: option to sphinx-prompt.

.. prompt:: bash
   :substitutions:

   echo "|author| released version |release|"

Inline :substitution-code:

:substitution-code:`echo "|author| released version |release|"`

Credits

sphinx-prompt authors

Thanks to @sbrunner and other contributors for sphinx-prompt. substitution-prompt is based on sphinx-prompt.

ClusterHQ Developers

This package is largely inspired by code written for Flocker by ClusterHQ. Developers of the relevant code include, at least, Jon Giddy and Tom Prince.

Contributing

See CONTRIBUTING.rst.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

sphinx_substitution_extensions-2024.2.24-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sphinx-substitution-extensions-2024.2.24.tar.gz.

File metadata

File hashes

Hashes for sphinx-substitution-extensions-2024.2.24.tar.gz
Algorithm Hash digest
SHA256 5307da69078ceb81e6f825c2dbd7d3afe2e2ae945bf108952d1335020436e38e
MD5 dd888bca2b475f385cd5b763c1c26337
BLAKE2b-256 58cddb5d9f4e92d2ddc6d37a83dfb4e9a5469a3c4e7705dea42f7be6c7a39e15

See more details on using hashes here.

File details

Details for the file sphinx_substitution_extensions-2024.2.24-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_substitution_extensions-2024.2.24-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 da00244e62515517534210882807debf312c23693fb5f4d6fddffc94c45f9449
MD5 864de80919f87ab63a24ef64bc22f48e
BLAKE2b-256 2a28db63690db397cffb8c3563ff84b298e8f3b04b19c2c9f2e4f5606be9c79c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page