mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve lookup in `Project.path2doc()
`
This commit is contained in:
parent
2ccbc3209a
commit
6f0c8f75ac
@ -96,10 +96,10 @@ class Project:
|
|||||||
|
|
||||||
*filename* should be absolute or relative to the source directory.
|
*filename* should be absolute or relative to the source directory.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
return self._path_to_docname[filename] # type: ignore[index]
|
|
||||||
except KeyError:
|
|
||||||
path = Path(filename)
|
path = Path(filename)
|
||||||
|
try:
|
||||||
|
return self._path_to_docname[path]
|
||||||
|
except KeyError:
|
||||||
if path.is_absolute():
|
if path.is_absolute():
|
||||||
with contextlib.suppress(ValueError):
|
with contextlib.suppress(ValueError):
|
||||||
path = path.relative_to(self.srcdir)
|
path = path.relative_to(self.srcdir)
|
||||||
|
Loading…
Reference in New Issue
Block a user