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