Skip to content

Commit

Permalink
update linkcode resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
VeckoTheGecko committed Sep 30, 2024
1 parent 24f087c commit 3aeeabc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@

myst_enable_extensions = ["dollarmath", "amsmath"]

def is_non_standard_version(version):
"""
Determine if the given version string has more than 3 components (e.g., from a developer version).
"""

return len(version.split(".")) > 3

# based on pandas doc/source/conf.py
def linkcode_resolve(domain, info):
"""Determine the URL corresponding to Python object."""
Expand Down Expand Up @@ -136,10 +143,10 @@ def linkcode_resolve(domain, info):

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

if "-" in plasticparcels.__version__:
return f"https://github.com/OceanParcels/plasticparcels/blob/master/plasticparcels/{fn}{linespec}"
if is_non_standard_version(plasticparcels.__version__):
return f"https://github.com/OceanParcels/plasticparcels/blob/main/plasticparcels/{fn}{linespec}"
else:
return (
f"https://github.com/OceanParcels/plasticparcels/blob/"
f"{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
f"v{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
)

0 comments on commit 3aeeabc

Please sign in to comment.