Skip to content

Commit 8b2cd6a

Browse files
committed
rtd - mangle linkcode urls for READTHEDOCS_VERSION stable & latest
1 parent eb11f53 commit 8b2cd6a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/source/conf.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
autosectionlabel_prefix_document = True
3434

3535
linkcode_commit = os.environ.get("READTHEDOCS_VERSION", "next")
36+
if linkcode_commit == "stable":
37+
import aiopenapi3.version
38+
39+
linkcode_commit = f"v{aiopenapi3.version.__version__}"
40+
elif linkcode_commit == "latest":
41+
linkcode_commit = "master"
42+
elif linkcode_commit == "next":
43+
pass
3644
linkcode_url = f"https://github.com/commonism/aiopenapi3/blob/{linkcode_commit}"
3745

3846

@@ -65,7 +73,7 @@ def linkcode_resolve(domain, info):
6573
# Path("…/aiopenapi3/__init__.py").parent.parent == "…"
6674
libdir = Path(mod.__file__).parent.parent
6775
file = Path(file).relative_to(libdir)
68-
start, end = lines[1] - 1, lines[1] - 1 + len(lines[0]) - 1
76+
start, end = lines[1], lines[1] + len(lines[0]) - 1
6977

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

0 commit comments

Comments
 (0)