2024-07-14 00:01:47 -05:00
|
|
|
.. highlight:: rst
|
2016-02-14 01:07:32 -06:00
|
|
|
|
|
|
|
:mod:`sphinx.ext.autosectionlabel` -- Allow reference sections using its title
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
.. module:: sphinx.ext.autosectionlabel
|
|
|
|
:synopsis: Allow reference section its title.
|
|
|
|
|
|
|
|
.. versionadded:: 1.4
|
|
|
|
|
|
|
|
This extension allows you to refer sections its title. This affects to the
|
|
|
|
reference role (:rst:role:`ref`).
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
A Plain Title
|
|
|
|
-------------
|
|
|
|
|
|
|
|
This is the text of the section.
|
|
|
|
|
|
|
|
It refers to the section title, see :ref:`A Plain Title`.
|
|
|
|
|
|
|
|
|
|
|
|
Internally, this extension generates the labels for each section. If same
|
2017-02-03 18:23:16 -06:00
|
|
|
section names are used in whole of document, any one is used for a target by
|
|
|
|
default. The ``autosectionlabel_prefix_document`` configuration variable can be
|
|
|
|
used to make headings which appear multiple times but in different documents
|
|
|
|
unique.
|
|
|
|
|
2018-06-08 11:27:13 -05:00
|
|
|
|
2017-02-03 18:23:16 -06:00
|
|
|
Configuration
|
|
|
|
-------------
|
|
|
|
|
|
|
|
.. confval:: autosectionlabel_prefix_document
|
|
|
|
|
|
|
|
True to prefix each section label with the name of the document it is in,
|
|
|
|
followed by a colon. For example, ``index:Introduction`` for a section
|
|
|
|
called ``Introduction`` that appears in document ``index.rst``. Useful for
|
|
|
|
avoiding ambiguity when the same section heading appears in different
|
|
|
|
documents.
|
2019-02-11 03:15:31 -06:00
|
|
|
|
|
|
|
.. confval:: autosectionlabel_maxdepth
|
|
|
|
|
|
|
|
If set, autosectionlabel chooses the sections for labeling by its depth. For
|
|
|
|
example, when set 1 to ``autosectionlabel_maxdepth``, labels are generated
|
|
|
|
only for top level sections, and deeper sections are not labeled. It
|
|
|
|
defaults to ``None`` (disabled).
|
2022-10-04 09:25:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
Debugging
|
|
|
|
---------
|
|
|
|
|
|
|
|
The ``WARNING: undefined label`` indicates that your reference in
|
2024-04-24 12:59:30 -05:00
|
|
|
:rst:role:`ref` is mis-spelled. Invoking :program:`sphinx-build` with ``-vvv``
|
2022-10-04 09:25:06 -05:00
|
|
|
(see :option:`-v`) will print all section names and the labels that have been
|
|
|
|
generated for them. This output can help finding the right reference label.
|