adamtheturtle / sphinx-substitution-extensions

Extensions for Sphinx which allow substitutions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status codecov PyPI

Extensions for Sphinx which allow substitutions within code blocks.

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

$ pip install Sphinx-Substitution-Extensions
  1. Add the following to conf.py to enable the extension:
extensions += ['sphinx_substitution_extensions']
  1. Set the following variable in conf.py to define substitutions:
rst_prolog = """
.. |release| replace:: 0.1
.. |author| replace:: Eleanor
"""

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

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

.. code-block:: bash
   :substitutions:

   echo "|author| released version |release|"

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

.. prompt:: bash
   :substitutions:

   echo "|author| released version |release|"
:substitution-code:`echo "|author| released version |release|"`
:substitution-download:`|author|'s manuscript <|author|_manuscript.txt>`
  1. Add the following to conf.py to enable the extension:
extensions += ['sphinx_substitution_extensions']
  1. Set the following variables in conf.py to define substitutions:
myst_enable_extensions += ['substitution']
myst_substitutions = {
      "release": "0.1",
      "author": "Eleanor",
}

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

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

```{code-block} bash
   :substitutions:

   echo "|author| released version |release|"
```

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

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.

See CONTRIBUTING.rst.

About

Extensions for Sphinx which allow substitutions

License:Apache License 2.0


Languages

Language:Python 98.2%Language:Makefile 1.8%