gpt4 book ai didi

python-sphinx - URL 中的 Sphinx 替换

转载 作者:行者123 更新时间:2023-12-04 06:27:58 25 4
gpt4 key购买 nike

我有两个项目 A 和 B,项目 A 的文档托管在不同的版本中,因此文档 url 具有以下格式

http://example.org/A/1.0.0/+d/index.html
http://example.org/A/1.0.1/+d/index.html
http://example.org/A/1.2.3/+d/index.html

项目 B 取决于特定版本的 A。在 B 的文档中,我想像这样留下指向 A 文档的链接:

“另见 A's documentation (v 1.0.1)”

是否可以将版本变量传递给 URL?我尝试使用 rst_prolog :
conf.py :

rst_prolog = '''
.. |a-ver| replace:: {ver}
'''.format(
ver=meta.__a_dep_version__,
)
index.rst :
A's version: |a-ver| # this produces the correct output
See also `framework docs <http://example.com/A/|a-ver|/index.html>`_.

但得到 URL https://example.com/A/%7Ca-ver%7C/+d/index.html在建立文档之后。

最佳答案

您可以使用 sphinx.ext.extlinks 为此的扩展。

例子

狮身人面像配置

extlinks = {'docs': ('http://example.org/A/%s/+d/index.html', 'framework docs ')}

您的文件
:docs:`1.0.1`
.. Result -> framework docs 1.0.1

:docs:`documentation (1.2.3) <1.2.3>`
.. Result -> documentation (1.2.3)

关于python-sphinx - URL 中的 Sphinx 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39150774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com