Sphinx:交叉引用索引项

Unb*_*own 7 restructuredtext python-sphinx

如何在reStructuredText文档中交叉引用索引项?

例如,我如何交叉引用SectionB:

.. index::
    pair: SectionA; SectionB

SectionB
--------

SectionB description.
Run Code Online (Sandbox Code Playgroud)

我试着用:ref:'SectionB':index:'SectionB',但他们没有工作.

谢谢.

Kev*_*orn 3

请参阅:交叉引用任意位置

在 Sphinx 文档中。

我认为你可能缺少的是参考标签,

尝试类似的方法:

.. index::
pair: SectionA; SectionB

.. _section-b-label:

SectionB
--------

SectionB description.
Run Code Online (Sandbox Code Playgroud)

然后在其他地方做:

:ref:`section-b-label`
Run Code Online (Sandbox Code Playgroud)

  • 我知道我可以使用参考标签。我试图避免的是必须添加索引和参考标签。似乎有点多余。 (8认同)