【发布时间】:2017-08-17 02:07:50
【问题描述】:
我正在尝试在我的一份 reST 文档中引用以下链接:https://docs.python.org/3/library/stdtypes.html#typecontextmanager。我正在尝试使用 :ref: 内联指令而不是链接。
我跑了python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv。结果显示,除其他外:
加粗的 URL 正是我正在寻找的,因为我的 intersphinx_mapping 看起来像这样:
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
我使用以下指令:
:ref:`context manager <python:typecontextmanager>`
这似乎指向正确的标签,但我收到以下警告:
WARNING: undefined label: python:typecontextmanager (if the link has no caption the label must precede a section header)
:ref: 被字符串 context manager 替换,但没有链接。
我错过了什么?
我在 Python 3.6.2 的 Anaconda 安装上使用 sphinx 1.6.3
注 1
根据库存行(也在std:label下),我使用:ref:`with <python:with>`也有同样的问题,它应该指向https://docs.python.org/3/reference/compound_stmts.html#with:
with The with statement : reference/compound_stmts.html#with
我猜主要问题的解决方案很可能也能解决这个问题。
注2
可能不是 100% 相关,但我可以毫无问题地链接到同一部分中的 :py:meth:`~contextmanager.__enter__`。
【问题讨论】:
标签: python python-sphinx restructuredtext