From 8187382f7122a6e826e4b9f756242df561e95464 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 3 Dec 2022 01:20:08 -0500 Subject: [PATCH] DOC: Don't try to link paths that are on a different drive This may happen if Python is installed on C: and Matplotlib is installed on some other drive. As the point of this extension is to create GitHub links for Matplotlib *only*, we should ignore all paths that cannot be relativized to it. Fixes #24574 --- doc/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 654040c95b1c..80282c70a7bb 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -682,7 +682,10 @@ def linkcode_resolve(domain, info): if lineno else "") startdir = Path(matplotlib.__file__).parent.parent - fn = os.path.relpath(fn, start=startdir).replace(os.path.sep, '/') + try: + fn = os.path.relpath(fn, start=startdir).replace(os.path.sep, '/') + except ValueError: + return None if not fn.startswith(('matplotlib/', 'mpl_toolkits/')): return None