diff --git a/doc/conf.py b/doc/conf.py index 55cabd84d1c7..9a46f513dea1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -662,7 +662,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