斯芬克斯内联包括
Sphinx inline include
我想使用 .. include::
内联函数,但如果我用两个新行将它与之前的文本分开,我只能让它真正包含我想要的文件。
在有人问之前,我想包含的文件是一个协议号,所以不,它根本不会从换行中受益。我希望能够轻松更改它,以便我可以在文档的多个位置使用它。我想一个例子是 "We currently use the protocol (proto.txt)." 我是 Sphinx 的新手,所以也许有一个我还没有找到的非常明显的解决方案。
Sphinx 无法使用内联包含。
但是,您可以定义 global aliases in the rst_epilog
variable of your build configuration file.
例如,您可以将以下行添加到您的 conf.py
文件中:
rst_epilog = """
.. |version| replace:: 4.1
.. |protocol| replace:: httpx
"""
现在,您可以从项目中的任何 .rst 文件访问变量 |version|
和 |protocol|
,例如:
Version |version| uses the |protocol| protocol.
变成
Version 4.1 uses the httpx protocol.
如果您的软件的其他部分需要在特定文件或格式中指定 protocol
(或其他变量),您可以编写脚本将其作为变量从那里读取到 Sphinx 配置文件中.
我想使用 .. include::
内联函数,但如果我用两个新行将它与之前的文本分开,我只能让它真正包含我想要的文件。
在有人问之前,我想包含的文件是一个协议号,所以不,它根本不会从换行中受益。我希望能够轻松更改它,以便我可以在文档的多个位置使用它。我想一个例子是 "We currently use the protocol (proto.txt)." 我是 Sphinx 的新手,所以也许有一个我还没有找到的非常明显的解决方案。
Sphinx 无法使用内联包含。
但是,您可以定义 global aliases in the rst_epilog
variable of your build configuration file.
例如,您可以将以下行添加到您的 conf.py
文件中:
rst_epilog = """
.. |version| replace:: 4.1
.. |protocol| replace:: httpx
"""
现在,您可以从项目中的任何 .rst 文件访问变量 |version|
和 |protocol|
,例如:
Version |version| uses the |protocol| protocol.
变成
Version 4.1 uses the httpx protocol.
如果您的软件的其他部分需要在特定文件或格式中指定 protocol
(或其他变量),您可以编写脚本将其作为变量从那里读取到 Sphinx 配置文件中.