diff --git a/tools/mkhtml.py b/tools/mkhtml.py index d1da748f98b..f6affc3e98f 100644 --- a/tools/mkhtml.py +++ b/tools/mkhtml.py @@ -76,8 +76,13 @@ def decode(bytes_): src_file = "%s.html" % pgm tmp_file = "%s.tmp.html" % pgm -trunk_url = "https://github.com/OSGeo/grass/tree/master/" -addons_url = "https://github.com/OSGeo/grass-addons/tree/master/" +grass_version = os.getenv("VERSION_NUMBER", "unknown") +trunk_url = "" +addons_url = "" +if grass_version != "unknown": + major, minor, patch = grass_version.split(".") + trunk_url = "https://github.com/OSGeo/grass/tree/main/" + addons_url = f"https://github.com/OSGeo/grass-addons/tree/grass{major}/" header_base = """ @@ -391,7 +396,6 @@ def to_title(name): index_name = index_names.get(mod_class, '') index_name_cap = index_titles.get(mod_class, '') -grass_version = os.getenv("VERSION_NUMBER", "unknown") year = os.getenv("VERSION_DATE") if not year: year = str(datetime.now().year) @@ -410,10 +414,17 @@ def to_title(name): if os.getenv("SOURCE_URL", ""): addon_path = get_addon_path() if addon_path: - url_source = urlparse.urljoin( - os.environ["SOURCE_URL"].split("src")[0], - addon_path, - ) + # Addon is installed from the local dir + if os.path.exists(os.getenv("SOURCE_URL")): + url_source = urlparse.urljoin( + addons_url, + addon_path, + ) + else: + url_source = urlparse.urljoin( + os.environ["SOURCE_URL"].split("src")[0], + addon_path, + ) else: url_source = urlparse.urljoin(source_url, pgmdir) if sys.platform == 'win32':