【发布时间】:2023-03-13 01:01:01
【问题描述】:
我在我的项目中启用了sphinx.ext.intersphinx,并添加了如下配置:
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'pyserial': ('https://pythonhosted.org/pyserial/', None),
}
我的index.rst 中有以下内容:
This project depends on the :ref:`pyserial <pyserial:???>` library.
我希望链接指向http://pythonhosted.org/pyserial/,即intersphinx_mapping 中的根URL,但我不知道??? 应该是什么。
如果我输入:ref:`pyserial` 或:ref:`pyserial <pyserial>`,我会得到WARNING: undefined label: pyserial (if the link has no caption the label must precede a section header)
如果我这样做:ref:`pyserial <>`,我会得到WARNING: undefined label: (if the link has no caption the label must precede a section header)
我可以将:ref: 替换为`pyserial <@987654321@,但我真的很想通过intersphinx 引用该页面,以避免断开链接。
我在 Anaconda 的 Python 3.6.2 上使用 sphinx 1.6.3。我并没有过度关注我试图链接到的图书馆。我怀疑答案不会真正与图书馆联系在一起。
如果有任何问题,对 pyserial 文档的常规引用可以正常工作。例如:py:class:`serial.Serial` 链接到https://pythonhosted.org/pyserial/pyserial_api.html#serial.Serial。
【问题讨论】:
标签: python python-sphinx restructuredtext