如何从 Sphinx 文档创建到本地 index.html 的链接?

fre*_*rik 4 restructuredtext python-sphinx

我正在为 Sphinx/rst 编写一些文档。如何链接到本地​​磁盘上与您正在查看的页面相关的内容?

例如:

====================
My App documentation
====================

The official My App documentation can be found here:
https://myapp.com/docs

A local mirror is available:
../../_static/docs_mirror/index.html
Run Code Online (Sandbox Code Playgroud)

在我的机器上,_static 文件夹位于:

file:///Users/fredrik/code/repos/myapp/docs/_static
Run Code Online (Sandbox Code Playgroud)

...但我不想对该路径进行硬编码,因为对于已下载克隆存储库的另一个用户而言,该路径可能与该路径不同。

mzj*_*zjn 5

这是一种方法:

`local mirror <_static/docs_mirror/index.html>`_
Run Code Online (Sandbox Code Playgroud)

另外一个选项:

`local mirror`_

.. _local mirror: _static/docs_mirror/index.html
Run Code Online (Sandbox Code Playgroud)

参考:http : //docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-references

  • 仅当您在文档根目录中使用此链接时,这才有效。在其他地方,“本地镜像”将被插入到当前 URL 分支的末尾并解析为无效页面。 (3认同)