-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ (docs): Replace prepare-docs script with MkDocs plugins
- Loading branch information
Showing
7 changed files
with
89 additions
and
30 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 was deleted.
Oops, something went wrong.
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,41 @@ | ||
import os | ||
|
||
from mkdocs.config.base import Config | ||
from mkdocs.structure.files import File, Files | ||
|
||
|
||
def main(files: Files, config: Config): | ||
files.append(readme_file(config)) | ||
|
||
charts = [] | ||
for root, dirs, dirFiles in os.walk("../charts"): | ||
for file in dirFiles: | ||
if file.endswith(".md"): | ||
charts.append(os.path.join(root, file)) | ||
charts.sort() | ||
for path in charts: | ||
files.append(chart_file(path, config)) | ||
|
||
return files | ||
|
||
|
||
def readme_file(config: Config): | ||
return File( | ||
path="README.md", | ||
src_dir="..", | ||
dest_dir=config.site_dir, | ||
use_directory_urls=config.use_directory_urls | ||
) | ||
|
||
|
||
def chart_file(src_path: str, config: Config): | ||
src_dir = os.path.dirname(src_path) | ||
chart_name = os.path.basename(src_dir) | ||
f = File( | ||
path=os.path.join("charts", chart_name + ".md"), | ||
src_dir=src_dir, | ||
dest_dir=config.site_dir, | ||
use_directory_urls=config.use_directory_urls | ||
) | ||
f.abs_src_path = src_path | ||
return f |
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,35 @@ | ||
import re | ||
|
||
from mkdocs.config.base import Config | ||
from mkdocs.structure.files import Files | ||
from mkdocs.structure.pages import Page | ||
|
||
|
||
def main(markdown: str, page: Page, config: Config, files: Files): | ||
if page.title == "Charts": | ||
return filter_repo_readme(markdown, page, config) | ||
elif page.url.startswith("charts"): | ||
return filter_chart_readme(markdown, page, config) | ||
|
||
|
||
def filter_repo_readme(markdown: str, page: Page, config: Config): | ||
# Update page title | ||
page.title = "Introduction" | ||
markdown = markdown.split('\n', 1)[-1] | ||
markdown = "# Introduction\n" + markdown | ||
|
||
# Exclude chart overview from search | ||
overview_re = re.compile(r"^(## Chart Overview)", re.MULTILINE) | ||
markdown = overview_re.sub(r"\1 { data-search-exclude }", markdown) | ||
|
||
return markdown | ||
|
||
|
||
def filter_chart_readme(markdown: str, page: Page, config: Config): | ||
homepage_re = re.compile(r"^\*\*Homepage:\*\*.*$", re.MULTILINE) | ||
markdown = homepage_re.sub("", markdown) | ||
|
||
yaml_re = re.compile(r"\(\./(.*\.yaml)\)") | ||
markdown = yaml_re.sub(f"({config.repo_url}/blob/main/{page.url}\\1)", markdown) | ||
|
||
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,7 @@ | ||
import os | ||
|
||
from mkdocs.config.base import Config | ||
|
||
|
||
def main(config: Config): | ||
os.remove(os.path.join(config.site_dir, "sitemap.xml.gz")) |
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