mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7324: Emit a warning if multiple files for same document found
This commit is contained in:
parent
6f60864d03
commit
2360473012
2
CHANGES
2
CHANGES
@ -114,6 +114,8 @@ Features added
|
||||
|
||||
* Added ``SphinxDirective.get_source_info()``
|
||||
and ``SphinxRole.get_source_info()``.
|
||||
* #7324: sphinx-build: Emit a warning if multiple files having different file
|
||||
extensions for same document found
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
@ -9,6 +9,7 @@
|
||||
"""
|
||||
|
||||
import os
|
||||
from glob import glob
|
||||
|
||||
from sphinx.locale import __
|
||||
from sphinx.util import get_matching_files
|
||||
@ -55,7 +56,13 @@ class Project:
|
||||
for filename in get_matching_files(self.srcdir, excludes): # type: ignore
|
||||
docname = self.path2doc(filename)
|
||||
if docname:
|
||||
if os.access(os.path.join(self.srcdir, filename), os.R_OK):
|
||||
if docname in self.docnames:
|
||||
pattern = os.path.join(self.srcdir, docname) + '.*'
|
||||
files = [relpath(f, self.srcdir) for f in glob(pattern)]
|
||||
logger.warning(__('multiple files found for the document "%s": %r\n'
|
||||
'Use %r for the build.'),
|
||||
docname, files, self.doc2path(docname), once=True)
|
||||
elif os.access(os.path.join(self.srcdir, filename), os.R_OK):
|
||||
self.docnames.add(docname)
|
||||
else:
|
||||
logger.warning(__("document not readable. Ignored."), location=docname)
|
||||
|
Loading…
Reference in New Issue
Block a user