1
1
"""A mkdocs hook that injects an HTML syntax used to generate badges at build time."""
2
+
2
3
import re
3
4
from re import Match
4
5
from mkdocs .config .defaults import MkDocsConfig
@@ -30,11 +31,13 @@ def replace(match: Match):
30
31
# -----------------------------------------------------------------------------
31
32
# Helper functions
32
33
34
+
33
35
def _badge_for_flags (arg , page : Page , files : Files ):
34
36
if arg == "experimental" :
35
37
return _badge_for_experimental (page , files )
36
38
raise ValueError (f"Unsupported badge flag: { arg } " )
37
39
40
+
38
41
# Create badge
39
42
def _badge (icon : str , text : str = "" ):
40
43
return "" .join (
@@ -50,10 +53,12 @@ def _badge(icon: str, text: str = ""):
50
53
# Create badge for version
51
54
def _badge_for_version (text : str , page : Page , files : Files ):
52
55
icon = "material-tag-outline"
53
- href = f"https://github.com/cpp-linter/cpp-linter-action/releases/v{ text } "
56
+ href = "https://github.com/cpp-linter/cpp-linter-action/releases/" + (
57
+ f"v{ text } " if text [0 :1 ].isdigit () else text
58
+ )
54
59
return _badge (
55
- icon = f'[:{ icon } :]({ href } "required version")' ,
56
- text = f'[{ text } ]({ href } "required version")' ,
60
+ icon = f'[:{ icon } :]({ href } "minimum version")' ,
61
+ text = f'[{ text } ]({ href } "minimum version")' ,
57
62
)
58
63
59
64
0 commit comments