From 3aeeabcc236a7fc6a6ad5a5b04a6089fd2aefa4d Mon Sep 17 00:00:00 2001 From: Vecko <36369090+VeckoTheGecko@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:05:53 +0200 Subject: [PATCH] update linkcode resolve --- docs/conf.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3a2d29f..82a8fb5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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.""" @@ -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}" )