Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
Latest commit
executable file
·69 lines (50 loc) · 2.33 KB
/
Copy pathbuild.py
File metadata and controls
executable file
·69 lines (50 loc) · 2.33 KB
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
#!/usr/bin/python
frompathlibimportPath
importmkdocs_gen_files
importsys
importre
CATEGORIES=sorted(f.nameforfinPath("cogs").iterdir() iff.is_dir() andnotf.name.startswith("."))
nav=mkdocs_gen_files.Nav()
forcategoryinmap(Path(__file__).parent.joinpath("cogs").joinpath, CATEGORIES):
ifnotcategory.is_dir():
print(f"::warning::Could not find category {category.name}")
continue
forcoginsorted(category.iterdir()):
ifnotcog.is_dir():
continue
docs=cog.joinpath("documentation.md")
ifnotdocs.is_file():
print(f"::warning::Could not find documentation for {category.name}/{cog.name}")
continue
path=f"cogs/{category.name}/{cog.name}.md"
withdocs.open() assrc, mkdocs_gen_files.open(path, "w") asdst:
content=src.read()
dst.write(content)
name=re.match(r"^#? *(.*)$", content.splitlines()[0])[1].strip()
nav[(category.name.capitalize(), name)] =f"{category.name}/{cog.name}.md"
mkdocs_gen_files.set_edit_path(path, f"https://github.com/PyDrocsid/cogs/edit/develop/{category.name}/{cog.name}/documentation.md")
nav[("PubSub Channels",)] ="pubsub.md"
withopen("cogs/pubsub.md") assrc, mkdocs_gen_files.open("cogs/pubsub.md", "w") asdst:
dst.write(src.read())
withmkdocs_gen_files.open("cogs/SUMMARY.md", "w") asnav_file:
nav_file.writelines(nav.build_literate_nav())
nav=mkdocs_gen_files.Nav()
forpathinsorted(Path("library/PyDrocsid").rglob("*.py")):
module_path=path.relative_to("library").with_suffix("")
doc_path=path.relative_to("library").with_suffix(".md")
full_doc_path=Path("library", doc_path)
parts=list(module_path.parts)
ifparts[-1] =="__init__":
parts=parts[:-1]
doc_path=doc_path.with_name("index.md")
full_doc_path=full_doc_path.with_name("index.md")
elifparts[-1] =="__main__":
continue
nav[parts] =doc_path.as_posix()
withmkdocs_gen_files.open(full_doc_path, "w") asfd:
identifier=".".join(parts)
print(f"::: {identifier}", file=fd)
mkdocs_gen_files.set_edit_path(full_doc_path, path)
withmkdocs_gen_files.open("library/SUMMARY.md", "w") asnav_file:
nav_file.writelines(nav.build_literate_nav())
sys.path.insert(0, "library")