diff --git a/docs/.theme/marcos/main.py b/docs/.theme/marcos/main.py index a367ea6..9fc28f8 100644 --- a/docs/.theme/marcos/main.py +++ b/docs/.theme/marcos/main.py @@ -13,14 +13,21 @@ repo = "engity-com/bifroest" repo_http_url = "https://github.com/" + repo repo_raw_url = "https://raw.githubusercontent.com/" + repo +repo_container_uri = "ghcr.io/" + repo raw_version = pos.getenv('VERSION') -release = (("v" if raw_version.__len__() > 0 and raw_version[0].isdigit() else "") +raw_version) if raw_version is not None and raw_version.__len__() > 0 else "latest" -branch = (("v" if raw_version.__len__() > 0 and raw_version[0].isdigit() else "") +raw_version) if raw_version is not None and raw_version.__len__() > 0 else "main" +release = (("v" if raw_version.__len__() > 0 and raw_version[0].isdigit() else "") + raw_version) if raw_version is not None and raw_version.__len__() > 0 else "latest" +branch = (("v" if raw_version.__len__() > 0 and raw_version[0].isdigit() else "") + raw_version) if raw_version is not None and raw_version.__len__() > 0 else "main" + + +class Packaging(str, Enum): + archive = 'archive' + image = 'image' class Os(str, Enum): linux = 'linux' windows = 'windows' + class Arch(str, Enum): i386 = '386' amd64 = 'amd64' @@ -438,6 +445,23 @@ def flag_with_holder( aliases=aliases, ) + @env.macro + def container_image_uri( + tag: str | None = None + ) -> str: + if tag is not None and tag.find("*") >= 0: + if raw_version is not None: + tag = tag.replace("*", f"{"-" if tag.find("*") > 0 else ""}{raw_version}") + else: + tag = tag.replace("*", "") + + return f"{repo_container_uri}{f":{tag}" if tag is not None else ""}" + + @env.macro + def container_packages_url() -> str: + return f"{repo_http_url}/pkgs/container/bifroest" + + @env.macro def asset_url(file: str, raw: bool = False) -> str: if raw: @@ -519,22 +543,27 @@ def is_image_supported(o: Os | str, arch: Arch | str, kind: EditionKind | str) - @env.macro def compatibility_matrix( os: Os | None = None, + packaging: str | Packaging | None = None, ) -> str: + if type(packaging) is str: + packaging = Packaging[packaging] + result = '
Architecture | ' + result += f'||||||||
---|---|---|---|---|---|---|---|---|
Architecture | ' if os is not None: - result += f'{dist(os)} | ' + result += f'{dist(os)} | ' else: for osv in Os: - result += f'{dist(osv)} | ' + result += f'{dist(osv)} | ' result += "Binary | Image | ' - else: - for _ in Os: + if packaging is None: + if os is not None: result += 'Binary | Image | ' - result += '' + else: + for _ in Os: + result += 'Binary | Image | ' + result += '' result += '' @@ -544,14 +573,18 @@ def compatibility_matrix( if os is not None: generic = support_matrix.lookup(os, arch, EditionKind.generic) extended = support_matrix.lookup(os, arch, EditionKind.extended) - result += f'{compatibility_editions(True if generic and generic.binary_supported else None, True if extended and extended.binary_supported else None, os)} | ' - result += f'{compatibility_editions(True if generic and generic.image_supported else None, True if extended and extended.image_supported else None, os)} | ' + if packaging == Packaging.archive or packaging is None: + result += f'{compatibility_editions(True if generic and generic.binary_supported else None, True if extended and extended.binary_supported else None, os)} | ' + if packaging == Packaging.image or packaging is None: + result += f'{compatibility_editions(True if generic and generic.image_supported else None, True if extended and extended.image_supported else None, os)} | ' else: for osv in Os: generic = support_matrix.lookup(osv, arch, EditionKind.generic) extended = support_matrix.lookup(osv, arch, EditionKind.extended) - result += f'{compatibility_editions(True if generic and generic.binary_supported else None, True if extended and extended.binary_supported else None, osv)} | ' - result += f'{compatibility_editions(True if generic and generic.image_supported else None, True if extended and extended.image_supported else None, osv)} | ' + if packaging == Packaging.archive or packaging is None: + result += f'{compatibility_editions(True if generic and generic.binary_supported else None, True if extended and extended.binary_supported else None, osv)} | ' + if packaging == Packaging.image or packaging is None: + result += f'{compatibility_editions(True if generic and generic.image_supported else None, True if extended and extended.image_supported else None, osv)} | ' result += '