Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Features added
Bugs fixed
----------

* #13230: Fix the ``toc.empty_glob`` warning sub-type not being suppressible
via :confval:`suppress_warnings`, due to a missing ``type='toc'`` argument
in the toctree directive's warning call.
Patch by Ferdinand Schwenk.
* #14189: autodoc: Fix duplicate ``:no-index-entry:`` for modules.
Patch by Adam Turner
* #13713: Fix compatibility with MyST-Parser.
Expand Down
1 change: 1 addition & 0 deletions sphinx/directives/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def parse_content(self, toctree: addnodes.toctree) -> None:
__("toctree glob pattern %r didn't match any documents"),
entry,
location=toctree,
type='toc',
subtype='empty_glob',
)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_directives/test_directive_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ def test_toctree_glob_and_url(app):
)


@pytest.mark.sphinx('html', testroot='toctree-glob')
def test_toctree_glob_empty_emits_warning(app):
"""An unmatched glob pattern emits a toc.empty_glob warning."""
text = '.. toctree::\n :glob:\n\n nonexistent*\n'
app.env.find_files(app.config, app.builder)
restructuredtext.parse(app, text, 'index')
assert "toctree glob pattern 'nonexistent*' didn't match any documents" in app._warning.getvalue()


@pytest.mark.sphinx(
'html',
testroot='toctree-glob',
confoverrides={'suppress_warnings': ['toc.empty_glob']},
)
def test_toctree_glob_empty_suppressed(app):
"""suppress_warnings=['toc.empty_glob'] must suppress the empty glob warning."""
text = '.. toctree::\n :glob:\n\n nonexistent*\n'
app.env.find_files(app.config, app.builder)
restructuredtext.parse(app, text, 'index')
assert app._warning.getvalue() == ''


@pytest.mark.sphinx('html', testroot='toctree-glob')
def test_reversed_toctree(app):
text = '.. toctree::\n :reversed:\n\n foo\n bar/index\n baz\n'
Expand Down
Loading