-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_mkdocs_yml.py
executable file
·120 lines (109 loc) · 4.03 KB
/
update_mkdocs_yml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
import sys
import yaml
if len(sys.argv) < 3:
print("Missing required arguments to update_mkdocs_yml.py.\n")
print("Usage:\n")
print(" update_mkdocs_yml.py <SITE_URL> <DOCS_DIR>\n")
exit(1)
site_url = sys.argv[1]
docs_dir = sys.argv[2]
with open("mkdocs.yml") as f:
mkdocs = yaml.load(f, Loader=yaml.SafeLoader)
mkdocs["site_url"] = site_url
mkdocs["edit_uri"] = 'edit/main/{}/'.format(docs_dir)
mkdocs["markdown_extensions"] = [
{
"markdown.extensions.codehilite": {
"use_pygments": False
}
},
"markdown.extensions.attr_list",
"markdown.extensions.md_in_html",
"markdown.extensions.def_list",
"pymdownx.superfences",
"pymdownx.tabbed",
{
"pymdownx.snippets": {
"url_download": True,
"base_path": [
"docs/snippets"
]
}
},
{
"toc": {
"toc_depth": 2
}
},
"callouts"
]
mkdocs["theme"] = {
"name": None,
"custom_dir": "documentation-theme/theme",
"static_templates": [
"pages/404.html"
]
}
mkdocs["extra"]["dotkernel_blog_url"] = "https://www.dotkernel.com/blog/"
mkdocs["extra"]["dotkernel_rss_url"] = "https://www.dotkernel.com/feed/"
mkdocs["extra"]["docs_api_url"] = "https://docs.dotkernel.org/api-documentation/"
mkdocs["extra"]["docs_admin_url"] = "https://docs.dotkernel.org/admin-documentation/"
mkdocs["extra"]["docs_frontend_url"] = "https://docs.dotkernel.org/frontend-documentation/"
mkdocs["extra"]["docs_light_url"] = "https://docs.dotkernel.org/light-documentation/"
mkdocs["extra"]["docs_packages_url"] = "https://docs.dotkernel.org/packages/"
mkdocs["extra"]["docs_development_url"] = "https://docs.dotkernel.org/development/"
# Remove any trailing slashes from the end of the repo_url
mkdocs["repo_url"] = mkdocs["repo_url"].rstrip("/")
mkdocs["extra"]["repo_name"] = mkdocs["repo_url"].replace("https://github.com/", "")
mkdocs["extra"]["base_url"] = "https://docs.dotkernel.org/"
if mkdocs["extra"]["project"] == "DotKernel API":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_api_url"]
elif mkdocs["extra"]["project"] == "DotKernel Admin":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_admin_url"]
elif mkdocs["extra"]["project"] == "DotKernel Frontend":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_frontend_url"]
elif mkdocs["extra"]["project"] == "DotKernel Light":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_light_url"]
elif mkdocs["extra"]["project"] == "Packages":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_packages_url"]
elif mkdocs["extra"]["project"] == "Development":
mkdocs["extra"]["project_url"] = mkdocs["extra"]["docs_development_url"]
mkdocs["extra"]["projects"] = [
{
"name": "API",
"description": "DotKernel API",
"docs_url": mkdocs["extra"]["docs_api_url"],
},
{
"name": "Admin",
"description": "DotKernel Admin application",
"docs_url": mkdocs["extra"]["docs_admin_url"],
},
{
"name": "Frontend",
"description": "DotKernel Frontend application",
"docs_url": mkdocs["extra"]["docs_frontend_url"],
},
{
"name": "Light",
"description": "DotKernel Light application",
"docs_url": mkdocs["extra"]["docs_light_url"],
},
{
"name": "Packages",
"description": "DotKernel packages",
"docs_url": mkdocs["extra"]["docs_packages_url"],
},
{
"name": "Development",
"description": "WSL2 Development Environment",
"docs_url": mkdocs["extra"]["docs_development_url"],
},
]
# If plugins are set, check if search exists
# https://www.mkdocs.org/user-guide/configuration/#plugins
if "plugins" in mkdocs and not "search" in mkdocs["plugins"]:
mkdocs["plugins"].append("search")
with open("mkdocs.yml", "w") as f:
yaml.dump(mkdocs, f, default_flow_style=False)