Skip to content

Commit

Permalink
allow use of latest tag in minimum-version of docs/actions.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Mar 25, 2024
1 parent 709c995 commit b935cc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/badge_hook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A mkdocs hook that injects an HTML syntax used to generate badges at build time."""

import re
from re import Match
from mkdocs.config.defaults import MkDocsConfig
Expand Down Expand Up @@ -30,11 +31,13 @@ def replace(match: Match):
# -----------------------------------------------------------------------------
# Helper functions


def _badge_for_flags(arg, page: Page, files: Files):
if arg == "experimental":
return _badge_for_experimental(page, files)
raise ValueError(f"Unsupported badge flag: {arg}")


# Create badge
def _badge(icon: str, text: str = ""):
return "".join(
Expand All @@ -50,10 +53,12 @@ def _badge(icon: str, text: str = ""):
# Create badge for version
def _badge_for_version(text: str, page: Page, files: Files):
icon = "material-tag-outline"
href = f"https://github.com/cpp-linter/cpp-linter-action/releases/v{text}"
href = "https://github.com/cpp-linter/cpp-linter-action/releases/" + (
f"v{text}" if text[0:1].isdigit() else text
)
return _badge(
icon=f'[:{icon}:]({href} "required version")',
text=f'[{text}]({href} "required version")',
icon=f'[:{icon}:]({href} "minimum version")',
text=f'[{text}]({href} "minimum version")',
)


Expand Down

0 comments on commit b935cc2

Please sign in to comment.