From fc45f523363640fc6e7ef57530f751af9a755133 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 18 Sep 2023 19:36:02 +0200 Subject: [PATCH] Added first example to documentation --- .gitignore | 4 ---- docs/setup/setting-up-tags.md | 1 + material/.overrides/hooks/shortcodes.py | 9 +++++++++ src/.overrides/hooks/shortcodes.py | 9 +++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a5569039b..4e015a043 100644 --- a/.gitignore +++ b/.gitignore @@ -55,10 +55,6 @@ example.zip # Never ignore .gitkeep files !**/.gitkeep -# Husky hooks -.husky/.gitignore -.husky/_ - # macOS internals .DS_Store diff --git a/docs/setup/setting-up-tags.md b/docs/setup/setting-up-tags.md index 4da70873c..a34fb5b63 100644 --- a/docs/setup/setting-up-tags.md +++ b/docs/setup/setting-up-tags.md @@ -31,6 +31,7 @@ For a list of all settings, please consult the [plugin documentation]. + Each tag can be associated with an icon, which is then rendered inside the tag. Before assigning icons to tags, associate each tag with a unique identifier, diff --git a/material/.overrides/hooks/shortcodes.py b/material/.overrides/hooks/shortcodes.py index 3746e8e7a..99dc0121f 100644 --- a/material/.overrides/hooks/shortcodes.py +++ b/material/.overrides/hooks/shortcodes.py @@ -54,6 +54,7 @@ def on_page_markdown( elif type == "plugin": return _badge_for_plugin(args, page, files) elif type == "extension": return _badge_for_extension(args, page, files) elif type == "utility": return _badge_for_utility(args, page, files) + elif type == "download": return _badge_for_download(args, page, files) elif type == "default": if args == "none": return _badge_for_default_none(page, files) elif args == "computed": return _badge_for_default_computed(page, files) @@ -190,6 +191,14 @@ def _badge_for_utility(text: str, page: Page, files: Files): text = text ) +# Create badge for download +def _badge_for_download(text: str, page: Page, files: Files): + icon = "material-folder-download" + href = f"https://mkdocs-material.github.io/examples/{text}/" + return _badge( + icon = f"[:{icon}:]({href} 'View example and download as .zip')" + ) + # Create badge for default value def _badge_for_default(text: str, page: Page, files: Files): icon = "material-water" diff --git a/src/.overrides/hooks/shortcodes.py b/src/.overrides/hooks/shortcodes.py index 3746e8e7a..99dc0121f 100644 --- a/src/.overrides/hooks/shortcodes.py +++ b/src/.overrides/hooks/shortcodes.py @@ -54,6 +54,7 @@ def on_page_markdown( elif type == "plugin": return _badge_for_plugin(args, page, files) elif type == "extension": return _badge_for_extension(args, page, files) elif type == "utility": return _badge_for_utility(args, page, files) + elif type == "download": return _badge_for_download(args, page, files) elif type == "default": if args == "none": return _badge_for_default_none(page, files) elif args == "computed": return _badge_for_default_computed(page, files) @@ -190,6 +191,14 @@ def _badge_for_utility(text: str, page: Page, files: Files): text = text ) +# Create badge for download +def _badge_for_download(text: str, page: Page, files: Files): + icon = "material-folder-download" + href = f"https://mkdocs-material.github.io/examples/{text}/" + return _badge( + icon = f"[:{icon}:]({href} 'View example and download as .zip')" + ) + # Create badge for default value def _badge_for_default(text: str, page: Page, files: Files): icon = "material-water"