diff --git a/sphinx/ext/autosectionlabel.py b/sphinx/ext/autosectionlabel.py index 35eaa0f34..4c353049c 100644 --- a/sphinx/ext/autosectionlabel.py +++ b/sphinx/ext/autosectionlabel.py @@ -45,7 +45,7 @@ def register_sections_as_label(app, document): anonlabels = app.env.domaindata['std']['anonlabels'] for node in document.traverse(nodes.section): if (app.config.autosectionlabel_maxdepth and - get_node_depth(node) > app.config.autosectionlabel_maxdepth): + get_node_depth(node) >= app.config.autosectionlabel_maxdepth): continue labelid = node['ids'][0] docname = app.env.docname diff --git a/tests/test_ext_autosectionlabel.py b/tests/test_ext_autosectionlabel.py index 6dcd9e57b..7960e2943 100644 --- a/tests/test_ext_autosectionlabel.py +++ b/tests/test_ext_autosectionlabel.py @@ -71,7 +71,7 @@ def test_autosectionlabel_prefix_document_html(app, status, warning): @pytest.mark.sphinx('html', testroot='ext-autosectionlabel', - confoverrides={'autosectionlabel_maxdepth': 2}) + confoverrides={'autosectionlabel_maxdepth': 3}) def test_autosectionlabel_maxdepth(app, status, warning): return test_autosectionlabel_html(app, status, warning, skipped_labels=True)