Skip to content

Commit

Permalink
Add debug logging to autosectionlabel (#10881)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Patz <martin@recogni.com>
  • Loading branch information
patzm and Martin Patz committed Oct 4, 2022
1 parent 0a91adb commit 3e29abf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -15,6 +15,7 @@ Features added

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

Bugs fixed
----------
Expand Down
9 changes: 9 additions & 0 deletions doc/usage/extensions/autosectionlabel.rst
Expand Up @@ -45,3 +45,12 @@ Configuration
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).


Debugging
---------

The ``WARNING: undefined label`` indicates that your reference in
:rst:role:`ref` is mis-spelled. Invoking :program:`sphinx-build` with ``-vv``
(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.
3 changes: 3 additions & 0 deletions sphinx/ext/autosectionlabel.py
Expand Up @@ -40,6 +40,9 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None:
name = nodes.fully_normalize_name(ref_name)
sectname = clean_astext(title)

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

0 comments on commit 3e29abf

Please sign in to comment.