Sphinx的替换扩展,允许在代码块中进行替换。
项目描述
Sphinx Substitution Extensions
Sphinx的扩展,允许在代码块中进行替换。
安装
Sphinx Substitution Extensions与Python 3.10+兼容,兼容Sphinx 7.2.0+。
$ pip install Sphinx-Substitution-Extensions
rST 设置
将以下内容添加到conf.py中启用扩展
extensions += ['sphinx_substitution_extensions']
在conf.py中设置以下变量以定义替换
rst_prolog = """
.. |release| replace:: 0.1
.. |author| replace:: Eleanor
"""
这将用0.1替换新指令中的|release|,并用Eleanor替换|author|。
在rST文档中使用替换
代码块
这为Sphinx内置的code-block指令添加了:substitutions:选项。
.. code-block:: bash
:substitutions:
echo "|author| released version |release|"
内联 :substitution-code:
:substitution-code:`echo "|author| released version |release|"`
替换下载
:substitution-download:`|author|'s manuscript <|author|_manuscript.txt>`
MyST Markdown 设置
将以下内容添加到conf.py中启用扩展
extensions += ['sphinx_substitution_extensions']
在conf.py中设置以下变量以定义替换
myst_enable_extensions += ['substitution']
myst_substitutions = {
"release": "0.1",
"author": "Eleanor",
}
这将用0.1替换新指令中的|release|,并用Eleanor替换|author|。
在MyST Markdown中使用替换
代码块
这为Sphinx内置的code-block指令添加了:substitutions:选项。
```{code-block} bash
:substitutions:
echo "|author| released version |release|"
```
鸣谢
ClusterHQ 开发者
本软件包在很大程度上受到了ClusterHQ为Flocker编写的代码的启发。相关代码的开发者至少包括Jon Giddy和Tom Prince。
贡献
请参阅CONTRIBUTING.rst。
项目详情
关闭
sphinx_substitution_extensions-2024.8.6.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0088b2f59967bb68dda3692e88daa12af78c6d3e6268375402b42f9d5fc9608b |
|
MD5 | 8d7e4fab7472b4b82dcc6c2ad9101435 |
|
BLAKE2b-256 | 51e528478a3cd206e850ac72eb764ef5acf7d2b0c658b78ae3faa206f6cfe9d7 |
关闭
sphinx_substitution_extensions-2024.8.6-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bf459460008036e94ca4e488b3aa860d6ddfa4575b2a13a0551aca5df1ee04bf |
|
MD5 | f545146842a5c750e2a06859afd3a700 |
|
BLAKE2b-256 | 5bd0e3246fee409dd2c836ea6073520ff12845c79e7927352d599f257a75d7c1 |