Skip to content

Commit 3e29abf

Browse files
patzmMartin Patz
and
Martin Patz
authored
Add debug logging to autosectionlabel (#10881)
Co-authored-by: Martin Patz <[email protected]>
1 parent 0a91adb commit 3e29abf

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Features added
1515

1616
* #10840: One can cross-reference including an option value: ``:option:`--module=foobar```.
1717
Patch by Martin Liska.
18+
* #10881: autosectionlabel: Record the generated section label to the debug log.
1819

1920
Bugs fixed
2021
----------

doc/usage/extensions/autosectionlabel.rst

+9
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ Configuration
4545
example, when set 1 to ``autosectionlabel_maxdepth``, labels are generated
4646
only for top level sections, and deeper sections are not labeled. It
4747
defaults to ``None`` (disabled).
48+
49+
50+
Debugging
51+
---------
52+
53+
The ``WARNING: undefined label`` indicates that your reference in
54+
:rst:role:`ref` is mis-spelled. Invoking :program:`sphinx-build` with ``-vv``
55+
(see :option:`-v`) will print all section names and the labels that have been
56+
generated for them. This output can help finding the right reference label.

sphinx/ext/autosectionlabel.py

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None:
4040
name = nodes.fully_normalize_name(ref_name)
4141
sectname = clean_astext(title)
4242

43+
logger.debug(__('section "%s" gets labeled as "%s"'),
44+
ref_name, name,
45+
location=node, type='autosectionlabel', subtype=docname)
4346
if name in domain.labels:
4447
logger.warning(__('duplicate label %s, other instance in %s'),
4548
name, app.env.doc2path(domain.labels[name][0]),

0 commit comments

Comments
 (0)