在 Sphinx 中使用 rst_epilog 的动态 URL

Dynamic URLs using rst_epilog in Sphinx

我最近一直在使用 python 编写 Sphinx 文档。在我的文档中,我有一些动态 URL,这些 URL 将在每次构建文档时更新,并且来自我已经配置并且工作正常的数据库。这些值包含在 rst_epilog in conf.py 中,像这样。

rst_epilog = """
.. |value1| replace:: www.google.com
.. |value2| replace:: www.fb.com
"""

在我的文档中,我使用的是类似这样的东西

For more information search `here`_

.. _`here`: |value1|

但有些 |value1| 没有被 www.google.com 替换(它在段落中工作正常)并且它变成了内部 link.

如果我做错了什么或者有解决这个问题的方法,那么我可以解决这个问题。

正如史蒂夫在他的回答中提到的 。可以同时使用替换和 rst_epilog。对于上面的例子,变化看起来像这样

在conf.py

rst_epilog = """
.. |value1| replace:: value1
.. _value1: www.google.com
.. |value2| replace:: value2
.. _value2: www.fb.com
"""

并且在 .rst 文件中

For more information search |value1|_

这将导致替换,然后为 rst_epilog 动态生成超链接。