-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Update for GitLab support (#487)
- Loading branch information
Showing
19 changed files
with
450 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Adds a badgge shortcode in the form: | ||
<!-- gs:badge ICON TEXT --> | ||
Where ICON is a mkdocs-material icon name | ||
and TEXT is the text to display. | ||
""" | ||
|
||
import re | ||
|
||
from mkdocs.config.defaults import MkDocsConfig | ||
from mkdocs.structure.files import Files | ||
from mkdocs.structure.pages import Page | ||
|
||
_tag_re = re.compile(r'<!-- gs:badge ([^ ]+) (.+?) -->') | ||
|
||
|
||
def on_page_markdown( | ||
markdown: str, | ||
page: Page, | ||
config: MkDocsConfig, | ||
files: Files, | ||
**kwargs | ||
) -> str: | ||
def replace(match: re.Match) -> str: | ||
icon = match.group(1) | ||
text = match.group(2) | ||
return ''.join([ | ||
'<span class="mdx-badge">', | ||
*[ | ||
'<span class="mdx-badge__icon">', | ||
f':{icon}:', | ||
'</span>', | ||
], | ||
*[ | ||
'<span class="mdx-badge__text">', | ||
text, | ||
'</span>', | ||
], | ||
'</span>' | ||
]) | ||
|
||
return _tag_re.sub(replace, markdown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Simple text replacement hooks. | ||
""" | ||
|
||
from mkdocs.config.defaults import MkDocsConfig | ||
from mkdocs.structure.files import Files | ||
from mkdocs.structure.pages import Page | ||
|
||
|
||
REPLACEMENTS = { | ||
'<!-- gs:github -->': ':simple-github: GitHub', | ||
'<!-- gs:gitlab -->': ':simple-gitlab: GitLab', | ||
'<!-- gs:badge:github ': '<!-- gs:badge simple-github GitHub ', | ||
'<!-- gs:badge:gitlab ': '<!-- gs:badge simple-gitlab GitLab ', | ||
} | ||
|
||
|
||
def on_page_markdown( | ||
markdown: str, | ||
page: Page, | ||
config: MkDocsConfig, | ||
files: Files, | ||
**kwargs | ||
) -> str: | ||
for key, value in REPLACEMENTS.items(): | ||
markdown = markdown.replace(key, value) | ||
return markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[1;92mSelect a Forge[0m: [0K | ||
[0K | ||
▶ [93mgithub[0m[0K | ||
gitlab[0K |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.