在 Sphinx 中链接外部文档

Linking external documentation in Sphinx

我正在尝试 link 从我们项目的扩展文档到 Sphinx 中的核心文档。我已经尝试过 intersphinx,但据我所知,它只支持对象,而我们的文档没有提到对象,它只是普通的 .rst。

我已经添加了

intersphinx_mapping = {
    'project': ('http://link-to-readthedocs/index.html', None),
}

到 conf.py 并将 link 编辑到 :ref:\`Documentation\` 和后来的 :doc:\`Documentation\` 。没用。

问题:

如何在 Sphinx 中 link 从一个项目的文档到另一个项目的普通 .rst 文件(不是对象)?

编辑:我已经完成 make html,找到了我的 objects.inv,但现在我想我只能在本地找到它?我不确定自己在做什么,但是当我尝试检查 时,我得到:

UserWarning: intersphinx inventory 'http://myproject.com/index.html/objects.inv' not fetchable due to <class 'urllib.error.HTTPError'>: HTTP Error 404: Not Found
  '%s: %s' % (inv, err.__class__, err))

这里首先要修复的是 link 你已经包含在项目文档的基础 URL 中:

intersphinx_mapping = { 'project': ('http://link-to-readthedocs/index.html', None), }

根据 intersphinx docs:

A dictionary mapping unique identifiers to a tuple (target, inventory). Each target is the base URI of a foreign Sphinx documentation set and can be a local path or an HTTP URI. The inventory indicates where the inventory file can be found: it can be None (at the same location as the base URI) or another local or HTTP URI.

因此,错误在于 index.htmltarget 的末尾。它应该看起来像这样:

intersphinx_mapping = { 'project': ('http://project.readthedocs.io/en/latest', None), }

如果需要,将 en 替换为首选的文档语言,并将 latest 替换为首选的 RtD 构建版本的文档。