-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate_mkdocs_yml.py
executable file
·72 lines (63 loc) · 2.14 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
#!/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/master/{}/'.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"
]
}
# 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.laminas.dev/"
if mkdocs["extra"]["project"] == "Components":
mkdocs["extra"]["project_url"] = "https://docs.laminas.dev/components/"
elif (mkdocs["extra"]["project"] == "MVC") or (mkdocs["extra"]["project"] == "Mvc"):
mkdocs["extra"]["project_url"] = "https://docs.laminas.dev/mvc/"
elif mkdocs["extra"]["project"] == "Mezzio":
mkdocs["extra"]["project_url"] = "https://docs.mezzio.dev/"
# 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)