|
7 | 7 | import time |
8 | 8 | from os import path |
9 | 9 | from typing import TYPE_CHECKING, Any |
| 10 | +from fnmatch import fnmatch, translate |
10 | 11 |
|
11 | 12 | from docutils import nodes |
12 | 13 | from docutils.utils import DependencyList |
@@ -420,18 +421,20 @@ def read(self) -> list[str]: |
420 | 421 | self._read_serial(docnames) |
421 | 422 |
|
422 | 423 | if self.config.root_doc not in self.env.all_docs: |
| 424 | + root_doc_path = self.env.doc2path(self.config.root_doc) |
423 | 425 | 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])): |
425 | 427 | raise SphinxError('customized exclude_patterns is set ' + |
426 | 428 | '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])): |
429 | 432 | raise SphinxError('customized include_patterns is set, ' + |
430 | 433 | 'but root file %s is not in the include_patterns' % |
431 | | - self.env.doc2path(self.config.root_doc)) |
| 434 | + root_doc_path) |
432 | 435 | else: |
433 | 436 | raise SphinxError('root file %s not found' % |
434 | | - self.env.doc2path(self.config.root_doc)) |
| 437 | + root_doc_path) |
435 | 438 |
|
436 | 439 | for retval in self.events.emit('env-updated', self.env): |
437 | 440 | if retval is not None: |
|
0 commit comments