-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_update.py
More file actions
33 lines (23 loc) · 692 Bytes
/
_update.py
File metadata and controls
33 lines (23 loc) · 692 Bytes
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
"""
Update descriptions for scripts.
"""
import pathlib
import code
readmes = {}
for file in sorted(pathlib.Path(".").glob("*.py")):
co = compile(open(file).read(), file, "exec")
if co.co_consts and isinstance(co.co_consts[0], str):
doc = co.co_consts[0].replace("\n", " ")
else:
doc = "No description provided."
readmes[file.name] = doc.strip()
with open("readme.md", "w") as f:
text = f"""# random
Random junk I may or may not want to use again but don't want to rewrite.
# descriptions
| Script | Description |
| --- | --- |
"""
for script, doc in readmes.items():
text += f"| [`{script}`]({script}) | {doc} |\n"
f.write(text)