Skip to content

Commit 3aeeabc

Browse files
committed
update linkcode resolve
1 parent 24f087c commit 3aeeabc

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

docs/conf.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686

8787
myst_enable_extensions = ["dollarmath", "amsmath"]
8888

89+
def is_non_standard_version(version):
90+
"""
91+
Determine if the given version string has more than 3 components (e.g., from a developer version).
92+
"""
93+
94+
return len(version.split(".")) > 3
95+
8996
# based on pandas doc/source/conf.py
9097
def linkcode_resolve(domain, info):
9198
"""Determine the URL corresponding to Python object."""
@@ -136,10 +143,10 @@ def linkcode_resolve(domain, info):
136143

137144
fn = os.path.relpath(fn, start=os.path.dirname(plasticparcels.__file__))
138145

139-
if "-" in plasticparcels.__version__:
140-
return f"https://github.com/OceanParcels/plasticparcels/blob/master/plasticparcels/{fn}{linespec}"
146+
if is_non_standard_version(plasticparcels.__version__):
147+
return f"https://github.com/OceanParcels/plasticparcels/blob/main/plasticparcels/{fn}{linespec}"
141148
else:
142149
return (
143150
f"https://github.com/OceanParcels/plasticparcels/blob/"
144-
f"{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
151+
f"v{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
145152
)

0 commit comments

Comments
 (0)