Skip to content

Commit

Permalink
Fix #10057: Failed to scan documents on the root directory
Browse files Browse the repository at this point in the history
get_matching_files() incorrectly drops the first character of each
path on scanning documents.  It will help users to exclude paths
via exclude_patterns setting.

Note: Users need to configure `exclude_patterns` to put their document
on the root directory.  This does not help to avoid recursive symlinks
(ex. /proc, /sys)
  • Loading branch information
tk0miya committed Jan 8, 2022
1 parent 87eda92 commit ce99cd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -67,6 +67,8 @@ Bugs fixed
at info-field-list
* #9390: texinfo: Do not emit labels inside footnotes
* #9979: Error level messages were displayed as warning messages
* #10057: Failed to scan documents if the project is placed onto the root
directory

Testing
--------
Expand Down
5 changes: 3 additions & 2 deletions sphinx/util/__init__.py
Expand Up @@ -72,10 +72,11 @@ def get_matching_files(dirname: str,
"""
# dirname is a normalized absolute path.
dirname = path.normpath(path.abspath(dirname))
dirlen = len(dirname) + 1 # exclude final os.path.sep

for root, dirs, files in os.walk(dirname, followlinks=True):
relativeroot = root[dirlen:]
relativeroot = path.relpath(root, dirname)
if relativeroot == ".":
relativeroot = "" # suppress dirname for files on the target dir

qdirs = enumerate(path_stabilize(path.join(relativeroot, dn))
for dn in dirs) # type: Iterable[Tuple[int, str]]
Expand Down

0 comments on commit ce99cd4

Please sign in to comment.