Skip to content

Commit

Permalink
docs - fix linkcode for installed library on rtd
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Jan 11, 2023
1 parent 3fa083e commit 9169f63
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import importlib
import inspect
from pathlib import Path

project = "aiopenapi3"
copyright = "2022, Markus Kötter"
Expand Down Expand Up @@ -60,11 +61,11 @@ def linkcode_resolve(domain, info):
except TypeError:
# e.g. object is a typing.Union
return None
file = os.path.relpath(file, os.path.abspath(".."))
if not file.startswith("aiopenapi3/"):
# e.g. object is a typing.NewType
return None
start, end = lines[1], lines[1] + len(lines[0]) - 1

# Path("…/aiopenapi3/__init__.py").parent.parent == "…"
libdir = Path(mod.__file__).parent.parent
file = Path(file).relative_to(libdir)
start, end = lines[1] - 1, lines[1] - 1 + len(lines[0]) - 1

return f"{linkcode_url}/{file}#L{start}-L{end}"

Expand Down

0 comments on commit 9169f63

Please sign in to comment.