Skip to content

Commit 66f1fc6

Browse files
authored
Added demo repository badge (#7915)
* docs(shortcodes): Add example repository badge * docs(shortcodes): Update description for 'Example Repository' * docs(relations): link example repos in docs pages * docs(shortcodes): Fix permanent link for convention page * docs(shortcodes): Revert to commit 365dc24 * docs(shortcodes): Rename md:example to md:demonstration * docs(shortcodes): Fix examples url * docs(shortcodes): Add demo badge * docs(shortcodes): Add badges for demo repositories * docs(shortcodes): Replace md:demonstration with md:example * docs(shortcodes): Replace demonstration with example * docs(shortcodes): Replace demonstration with example * docs(shortcodes): Build new theme * docs(shortcodes): Build with pymdownx
1 parent 2c52fa2 commit 66f1fc6

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

docs/conventions.md

+1
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ Besides plugins, there are some utilities that build on top of MkDocs in order
9191
to provide extended functionality, like for example support for versioning.
9292

9393
[Insiders]: insiders/index.md
94+

docs/setup/setting-up-a-blog.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ __Check out our [blog], which is created with the new [built-in blog plugin]!__
2222
<!-- md:version 9.2.0 -->
2323
<!-- md:plugin -->
2424
<!-- md:flag experimental -->
25+
<!-- md:demo create-blog -->
2526

2627
The built-in blog plugin adds support for building a blog from a folder of
2728
posts, which are annotated with dates and other structured data. First, add the

docs/setup/setting-up-social-cards.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Social card of our [formatting] reference
3737
<!-- md:version 8.5.0 -->
3838
<!-- md:plugin -->
3939
<!-- md:flag experimental -->
40+
<!-- md:demo create-social-cards -->
4041

4142
The built-in social plugin automatically generate a custom preview image for
4243
each page. Install all [dependencies for image processing] and add the

docs/setup/setting-up-versioning.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ documentation remain untouched.
1313

1414
<!-- md:version 7.0.0 -->
1515
<!-- md:utility [mike] -->
16+
<!-- md:demo example-versioning -->
1617

1718
[mike] makes it easy to deploy multiple versions of your project documentation.
1819
It integrates natively with Material for MkDocs and can be enabled via

material/overrides/hooks/shortcodes.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def replace(match: Match):
5454
elif type == "plugin": return _badge_for_plugin(args, page, files)
5555
elif type == "extension": return _badge_for_extension(args, page, files)
5656
elif type == "utility": return _badge_for_utility(args, page, files)
57-
elif type == "example": return _badge_for_example(args, page, files)
57+
elif type == "example": return _badge_for_example(args, page, files)
58+
elif type == "demo": return _badge_for_demo(args, page, files)
5859
elif type == "default":
5960
if args == "none": return _badge_for_default_none(page, files)
6061
elif args == "computed": return _badge_for_default_computed(page, files)
@@ -212,11 +213,21 @@ def _badge_for_example_download(text: str, page: Page, files: Files):
212213
icon = "material-folder-download"
213214
href = f"https://mkdocs-material.github.io/examples/{text}.zip"
214215
return _badge(
215-
icon = f"[:{icon}:]({href} 'Download example')",
216+
icon = f"[:{icon}:]({href} 'Download example files')",
216217
text = f"[`.zip`]({href})",
217218
type = "right"
218219
)
219220

221+
# Create badge for demo repository
222+
def _badge_for_demo(text: str, page: Page, files: Files):
223+
icon = "material-github"
224+
href = f"https://github.com/mkdocs-material/{text}"
225+
return _badge(
226+
icon = f"[:{icon}:]({href} 'Demo repository')",
227+
text = text,
228+
type = "right"
229+
)
230+
220231
# Create badge for default value
221232
def _badge_for_default(text: str, page: Page, files: Files):
222233
icon = "material-water"
@@ -280,4 +291,4 @@ def _badge_for_experimental(page: Page, files: Files):
280291
href = _resolve_path("conventions.md#experimental", page, files)
281292
return _badge(
282293
icon = f"[:{icon}:]({href} 'Experimental')"
283-
)
294+
)

src/overrides/hooks/shortcodes.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def replace(match: Match):
5454
elif type == "plugin": return _badge_for_plugin(args, page, files)
5555
elif type == "extension": return _badge_for_extension(args, page, files)
5656
elif type == "utility": return _badge_for_utility(args, page, files)
57-
elif type == "example": return _badge_for_example(args, page, files)
57+
elif type == "example": return _badge_for_example(args, page, files)
58+
elif type == "demo": return _badge_for_demo(args, page, files)
5859
elif type == "default":
5960
if args == "none": return _badge_for_default_none(page, files)
6061
elif args == "computed": return _badge_for_default_computed(page, files)
@@ -212,11 +213,21 @@ def _badge_for_example_download(text: str, page: Page, files: Files):
212213
icon = "material-folder-download"
213214
href = f"https://mkdocs-material.github.io/examples/{text}.zip"
214215
return _badge(
215-
icon = f"[:{icon}:]({href} 'Download example')",
216+
icon = f"[:{icon}:]({href} 'Download example files')",
216217
text = f"[`.zip`]({href})",
217218
type = "right"
218219
)
219220

221+
# Create badge for demo repository
222+
def _badge_for_demo(text: str, page: Page, files: Files):
223+
icon = "material-github"
224+
href = f"https://github.com/mkdocs-material/{text}"
225+
return _badge(
226+
icon = f"[:{icon}:]({href} 'Demo repository')",
227+
text = text,
228+
type = "right"
229+
)
230+
220231
# Create badge for default value
221232
def _badge_for_default(text: str, page: Page, files: Files):
222233
icon = "material-water"
@@ -280,4 +291,4 @@ def _badge_for_experimental(page: Page, files: Files):
280291
href = _resolve_path("conventions.md#experimental", page, files)
281292
return _badge(
282293
icon = f"[:{icon}:]({href} 'Experimental')"
283-
)
294+
)

0 commit comments

Comments
 (0)