我使用intersphinx扩展程序使用sphinx(Sphinx == 1.7.0)构建文档。我注意到它默认链接到python 2文档,但我更喜欢链接到python 3文档,所以我将conf.py中的intersphinx_mapping
更改为以下内容:
# conf.py
...
intersphinx_mapping = {
'python': ('https://docs.python.org/3/': None),
}
...
但是,当我在源文件中引用python对象时,我看到这些仍然默认链接到python 2.如果我在str
前加上它,它可以解决这个问题,使它读取python:str
(如docs中所述),它明确指出要使用的intersphinx映射。例如:
# index.rst
:any:`str` # surprisingly, this links to https://docs.python.org/2/library/functions.html#str
:any:`python:str` # as expected, this links to https://docs.python.org/3/library/stdtypes.html#str
供参考,这是文档所说的:
使用“新”格式(见下文)时,您甚至可以通过为链接目标添加适当的前缀来强制在外部集合中查找。像:ref:
comparison manual <python:comparisons>
之类的链接将链接到文档集“python”中的标签“comparisons”(如果存在)。
我的问题是:如何使默认的,不合格的intersphinx链接指向python 3 docs而不是python 2 docs?