使用autosectionlabel

时间:2019-11-04 11:37:36

标签: python-sphinx

启用autosectionlabel和autosectionlabel_prefix_document后,如何使用sphinx引用本地文档中的小节标题。我的文档有详细的嵌套文件夹安排,并希望用代表本地文件的内容替换长路径。 #,或本地文件名不起作用

示例

Heading 1
---------

subheading
^^^^^^^^^^

:ref:`/full/path/relative_to_config_file:subheading` works 

2 个答案:

答案 0 :(得分:0)

我对autosectionlabel的文档一无所知。我认为您可以在没有绝对参考的情况下做您想做的事情:

Heading 1
---------

subheading
^^^^^^^^^^

:ref:`relative/to/config/file:subheading`

或者也许:

:ref:`relative-to-config-file:subheading`

否则,您将必须使用任意cross-references

  

如果将标签直接放在节标题之前,则可以使用:ref:label-name对其进行引用。例如:

.. _my-reference-label:

Section to cross-reference
--------------------------

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.

答案 1 :(得分:0)

似乎唯一的方法是使用html样式链接 例如

`Text to display instead of subheading <#subheading>`_