python-sphinx - 在 Sphinx 中链接外部文档

标签 python-sphinx

我正在尝试将我们项目的扩展文档链接到 Sphinx 中的核心文档。我试过 intersphinx,但从我看来它只支持对象,而我们的文档不涉及对象,它只是普通的 .rst。

我已经添加

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

到 conf.py 并编辑链接到 :ref:`Documentation` 和更高版本的 :doc:`Documentation`。它没有用。

问题:

如何从一个项目的文档链接到 Sphinx 中的另一个以获取纯 .rst 文件(不是对象)?

编辑 :我已经完成了'make html',找到了我的objects.inv,但现在我想我只有本地有它???我不知道我在做什么了,但是当我尝试检查 object references 时,我得到:
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))

最佳答案

此处要修复的第一件事是您在项目文档的基本 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.html在您的 target 的末尾.它应该看起来像这样:
intersphinx_mapping = { 'project': ('http://project.readthedocs.io/en/latest', None), }
如果需要,替换 en使用首选文档语言,以及 latest使用文档的首选 RtD 构建版本。

关于python-sphinx - 在 Sphinx 中链接外部文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38611045/

相关文章:

python - 如何在 Python 中记录类型参数?

python - Python 文件无法编译时如何使用 Sphinx 自动文档

python-sphinx - 如何链接/引用文档中的另一个 reST 文件?

jinja2 - 模板化 Sphinx 的侧边栏目录树

Python 文档字符串 : What do these docstring parameters mean exactly?

python - 狮身人面像 : "No module named"

rest - 带有Sphinx的RESTful Web服务API文档

python-sphinx - sphinx 用于多个单独的文档

python - 始终重新生成包含特定指令的 Sphinx 文档

python - 如何让 Sphinx 使用来自 Python stub 文件的类型注释