29

如何在 Sphinx 文档中创建内部超链接?我在用:

:role:`target`

但它不起作用。

4

2 回答 2

32

交叉引用是使用ref

:ref:`label-name`

您可以使用以下方式提供标签:

.. _label-name:

请参阅:https ://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref

角色用于创建自定义解释文本。请参阅:http ://docutils.sourceforge.net/docs/ref/rst/directives.html#role

于 2010-12-08T08:10:30.113 回答
3

在某处,标题是,

.. _HeaderTag:

Header
------

参考上面的标题(可能不是同一个文件)

:ref:`HeaderTag`

# or with custom text
:ref:`custom header<HeaderTag>`
于 2020-07-09T15:20:24.370 回答