Skip to content

Commit 6d3e5c7

Browse files
authored
Fix warning on not finding documents in toctree glob (#12720)
1 parent be73e64 commit 6d3e5c7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

sphinx/directives/other.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,20 @@ def parse_content(self, toctree: addnodes.toctree) -> None:
111111
url_match = url_re.match(entry) is not None
112112
if glob and glob_re.match(entry) and not explicit and not url_match:
113113
pat_name = docname_join(current_docname, entry)
114-
doc_names = sorted(patfilter(all_docnames, pat_name))
114+
doc_names = sorted(
115+
docname for docname in patfilter(all_docnames, pat_name)
116+
# don't include generated documents in globs
117+
if docname not in generated_docnames
118+
)
119+
if not doc_names:
120+
logger.warning(
121+
__("toctree glob pattern %r didn't match any documents"),
122+
entry, location=toctree)
123+
115124
for docname in doc_names:
116-
if docname in generated_docnames:
117-
# don't include generated documents in globs
118-
continue
119125
all_docnames.remove(docname) # don't include it again
120126
toctree['entries'].append((None, docname))
121127
toctree['includefiles'].append(docname)
122-
if not doc_names:
123-
logger.warning(__("toctree glob pattern %r didn't match any documents"),
124-
entry, location=toctree)
125128
continue
126129

127130
if explicit:

0 commit comments

Comments
 (0)