From 843e9ff8f5aced144a0443349189ceffef9bbc17 Mon Sep 17 00:00:00 2001 From: Martin Patz <5219726+patzm@users.noreply.github.com> Date: Wed, 28 Sep 2022 14:18:19 +0200 Subject: [PATCH 1/6] add debug logging to autosectionlabel --- sphinx/ext/autosectionlabel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py index ff2f695ec88..c1061db17d3 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -38,7 +38,8 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None: else: name = nodes.fully_normalize_name(ref_name) sectname = clean_astext(title) - + + logger.debug('section "%s" gets labeled as "%s%', title, name) if name in domain.labels: logger.warning(__('duplicate label %s, other instance in %s'), name, app.env.doc2path(domain.labels[name][0]), From 5fab8b08f0c9ce3520f52fef07d7e719d04ddd2a Mon Sep 17 00:00:00 2001 From: Martin Patz Date: Wed, 28 Sep 2022 14:36:10 +0200 Subject: [PATCH 2/6] fix bug in format specifiers, add metadata, remove line whitespace --- sphinx/ext/autosectionlabel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py index c1061db17d3..8101fc30ea6 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -38,8 +38,10 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None: else: name = nodes.fully_normalize_name(ref_name) sectname = clean_astext(title) - - logger.debug('section "%s" gets labeled as "%s%', title, name) + + 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]), From 25f2ae8fb29cdaf2a910b18e6104701796a8876d Mon Sep 17 00:00:00 2001 From: Martin Patz Date: Thu, 29 Sep 2022 11:21:14 +0200 Subject: [PATCH 3/6] add documentation --- doc/usage/extensions/autosectionlabel.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/usage/extensions/autosectionlabel.rst b/doc/usage/extensions/autosectionlabel.rst index caaa5db2663..c021d6336aa 100644 --- a/doc/usage/extensions/autosectionlabel.rst +++ b/doc/usage/extensions/autosectionlabel.rst @@ -45,3 +45,11 @@ 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. From d12756953eb8b150b9a7167f4fc167659d6535c9 Mon Sep 17 00:00:00 2001 From: Martin Patz Date: Thu, 29 Sep 2022 11:24:01 +0200 Subject: [PATCH 4/6] add changes --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 79f6b80e0bc..a988b376fad 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,8 @@ Deprecated Features added -------------- +* #10881: make debugging automatically generated section labels by + ``sphinx.ext.autosectionlabel`` easier. * #10840: One can cross-reference including an option value: ``:option:`--module=foobar```. Patch by Martin Liska. From 9454361129e8f20f41c3a1672cd517e21e14ddf4 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 4 Oct 2022 15:22:16 +0100 Subject: [PATCH 5/6] Update doc/usage/extensions/autosectionlabel.rst --- doc/usage/extensions/autosectionlabel.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/usage/extensions/autosectionlabel.rst b/doc/usage/extensions/autosectionlabel.rst index c021d6336aa..b5b9b51a994 100644 --- a/doc/usage/extensions/autosectionlabel.rst +++ b/doc/usage/extensions/autosectionlabel.rst @@ -49,6 +49,7 @@ Configuration 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 From d0f1c23b733760f13e30257e338eadbb2df595c2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 4 Oct 2022 15:23:46 +0100 Subject: [PATCH 6/6] Update CHANGES --- CHANGES | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 60e404d6cc8..e3c91d72e01 100644 --- a/CHANGES +++ b/CHANGES @@ -12,11 +12,10 @@ Deprecated Features added -------------- -* #10881: make debugging automatically generated section labels by - ``sphinx.ext.autosectionlabel`` easier. * #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 ----------