-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgenerate_readme.py
More file actions
77 lines (62 loc) · 2.18 KB
/
generate_readme.py
File metadata and controls
77 lines (62 loc) · 2.18 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
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
import pathlib
import json
from pprint import pprint as pp
title = "Eris' Cogs"
desc = "Welcome to my cogs! If you have any questions please [join my discord!](http://discord.gg/ee3NyDq)"
readme = (
f"# {title}\n{desc}\n\nThe table below lists all available cogs, "
"as well as their current state. If a cog is listed as 'not ready' "
"that simply means that I haven't gone through to productionalize / standardize "
"the code. They still work, I just haven't cleaned them up entirely yet. "
"Use at your own risk!\n\nIf you're on windows, "
f"you'll need to delete the symlinked `eris_event_lib.py` "
f"files in the directories of the cogs you wish to install "
f"and replace it with a copy of the root-level file.\n\n"
)
meta_keys = [
"short",
"description",
# "author",
]
all_dirs = [
d for d in pathlib.Path().glob("*") if not d.name.startswith(".") and d.is_dir()
]
all_dirs = sorted(all_dirs)
all_entries = []
table = []
for d in all_dirs:
name = d.name.capitalize()
meta = json.loads((d / "info.json").read_text(encoding="utf-8"))
ready = meta.get("ready", False)
if ready:
new_entry = f"## {name}\n"
demofile = d / "demo.png"
if demofile.exists():
new_entry += f"\n\n"
meta_entries = []
for k in meta_keys:
val = meta.get(k)
if k == "author":
val = ", ".join(val)
if val:
val = val.replace("\n", "\n\n")
meta_entries.append(f"{k.capitalize()}: {val}")
new_entry += "\n\n".join(meta_entries)
all_entries.append(new_entry)
table.append(
(
name,
f"[{name}](#{name.lower()})",
f"{meta.get('short')}",
f"{'✅' if ready else '❌'}",
)
)
table = sorted(table, key=lambda tup: (tup[3] != "✅", tup[0]))
table = ["| " + " | ".join(row[1:]) + " |" for row in table]
table = ["| Cog Name | Short | Ready? |", "| --- | --- | --- |"] + table
readme += "\n".join(table)
readme += "\n\n"
readme += "\n".join(all_entries)
readmefile = pathlib.Path() / "README.md"
readmefile.write_text(readme)