Extensions for Sphinx which allow for substitutions.
Project description
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.8+.
$ pip install Sphinx-Substitution-Extensions
Setup
Add the following to conf.py:
extensions += ['sphinx_substitution_extensions']
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.
Optional: sphinx-prompt
Sphinx Substitution Extensions supports the third-party extension sphinx-prompt.
If you don’t have sphinx-prompt installed, you can include the extension with the extra dependency prompt:
$ pip install Sphinx-Substitution-Extensions[prompt]
2. Make sure sphinx-prompt dependency is loaded before sphinx_substitution_extensions. For example, your conf.py should look like:
# sphinx-prompt must be the first of these two.
extensions += ['sphinx-prompt', 'sphinx_substitution_extensions']
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
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
Release history Release notifications | RSS feed
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
File details
Details for the file Sphinx Substitution Extensions-2022.2.16.tar.gz
.
File metadata
- Download URL: Sphinx Substitution Extensions-2022.2.16.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7d05bd00e8b2d7eb8a403b9f317d70411d4e9b6812bf91534a50df22190c75 |
|
MD5 | 2f47b07423b50f5dae227337687f5fb8 |
|
BLAKE2b-256 | 16beb006c82d61c1f64d1c90276f4c5d1a35d03c79a2904f581d8b457887aba6 |
File details
Details for the file Sphinx_Substitution_Extensions-2022.2.16-py3-none-any.whl
.
File metadata
- Download URL: Sphinx_Substitution_Extensions-2022.2.16-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a8ca34dac3984486344e95c36e3ed4766d402a71bdee7390d600f153db9795b |
|
MD5 | 628cb582cc71cc6e8ccff3be0144d431 |
|
BLAKE2b-256 | 45edf684f94a7ace29ab3032e1be95803147120522207c1f0519b7012e278bed |