:模式:sphinx.ext.autosectionlabel–允许引用节使用其标题¶
Added in version 1.4.
此扩展允许您引用其标题部分。这会影响引用角色(:rst:角色:ref)。
例如:
A Plain Title
-------------
This is the text of the section.
It refers to the section title, see :ref:`A Plain Title`.
在内部,这个扩展为每个部分生成标签。若在整个文档中使用相同的节名称,则默认情况下,任何一个节名称都将用于目标。“autosectionlabel_prefix_document”配置变量可用于使多次出现但在不同文档中的标题唯一。
配置¶
- autosectionlabel_prefix_document¶
如果为True,则在每个节标签前面加上它所在文档的名称,后跟冒号。例如``索引:简介``对于文档中出现的名为“简介”的部分``索引.rst``. 当同一节标题出现在不同的文档中时,有助于避免歧义。
- autosectionlabel_maxdepth¶
如果已设置,autosectionlabel将按深度选择要标记的节。例如,当将1设置为“autosectionlabel_maxdepth”时,仅为顶层节生成标签,而不为深层节生成标签。默认为“无”(已禁用)。
Debugging¶
The WARNING: undefined label
indicates that your reference in
ref
is mis-spelled. Invoking sphinx-build with -vvv
(see -v
) will print all section names and the labels that have been
generated for them. This output can help finding the right reference label.