Skip to content

Commit 6f0c8f7

Browse files
committed
Improve lookup in Project.path2doc()
1 parent 2ccbc32 commit 6f0c8f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sphinx/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def path2doc(self, filename: str | os.PathLike[str]) -> str | None:
9696
9797
*filename* should be absolute or relative to the source directory.
9898
"""
99+
path = Path(filename)
99100
try:
100-
return self._path_to_docname[filename] # type: ignore[index]
101+
return self._path_to_docname[path]
101102
except KeyError:
102-
path = Path(filename)
103103
if path.is_absolute():
104104
with contextlib.suppress(ValueError):
105105
path = path.relative_to(self.srcdir)

0 commit comments

Comments
 (0)