Skip to content

Commit 886e704

Browse files
committed
adapt to all scource_suffix
1 parent a9d0393 commit 886e704

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sphinx/builders/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
from os import path
99
from typing import TYPE_CHECKING, Any
10+
from fnmatch import fnmatch, translate
1011

1112
from docutils import nodes
1213
from docutils.utils import DependencyList
@@ -420,18 +421,20 @@ def read(self) -> list[str]:
420421
self._read_serial(docnames)
421422

422423
if self.config.root_doc not in self.env.all_docs:
424+
root_doc_path = self.env.doc2path(self.config.root_doc)
423425
if ("**" in self.config.exclude_patterns or
424-
"**.rst" in self.config.exclude_patterns):
426+
any([fnmatch(root_doc_path, pat) or root_doc_path.endswith(pat) for pat in self.config.exclude_patterns])):
425427
raise SphinxError('customized exclude_patterns is set ' +
426428
'and root file %s is in the exclude_patterns' %
427-
self.env.doc2path(self.config.root_doc))
428-
elif "**" not in self.config.include_patterns:
429+
root_doc_path)
430+
elif ("**" not in self.config.include_patterns and
431+
not any([(fnmatch(root_doc_path, pat) or root_doc_path.endswith(pat)) for pat in self.config.include_patterns])):
429432
raise SphinxError('customized include_patterns is set, ' +
430433
'but root file %s is not in the include_patterns' %
431-
self.env.doc2path(self.config.root_doc))
434+
root_doc_path)
432435
else:
433436
raise SphinxError('root file %s not found' %
434-
self.env.doc2path(self.config.root_doc))
437+
root_doc_path)
435438

436439
for retval in self.events.emit('env-updated', self.env):
437440
if retval is not None:

0 commit comments

Comments
 (0)