【问题标题】:How to make an internal hyperlink in Sphinx documentation [duplicate]如何在 Sphinx 文档中创建内部超链接 [重复]
【发布时间】:2024-01-06 04:31:01
【问题描述】:

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

:role:`target`

但它不起作用。

【问题讨论】:

    标签: python python-sphinx


    【解决方案1】:

    使用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

    【讨论】:

      【解决方案2】:

      标题在某处,

      .. _HeaderTag:
      
      Header
      ------
      

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

      :ref:`HeaderTag`
      
      # or with custom text
      :ref:`custom header<HeaderTag>`
      

      【讨论】: