-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_release_notes.py
68 lines (55 loc) · 2.45 KB
/
generate_release_notes.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
"""Generates the release notes from the library json files"""
import json
import os
from datetime import date
TEMPLATE_DIR = "templates"
if __name__ == "__main__":
# Load paperlibgroups
paperlibgroups = []
for subdir, dirs, files in os.walk(TEMPLATE_DIR):
for file in files:
if file == "paperlibgroup.json":
with open(os.path.join(subdir, file), "r") as f:
paperlibgroup_dict = json.load(f)
paperlibgroups.append(
[paperlibgroup_dict["group_name"], subdir, paperlibgroup_dict["description"]])
paperlibgroups.sort()
# Load paperlibcategories
paperlibcategories = []
for subdir, dirs, files in os.walk(TEMPLATE_DIR):
for file in files:
if file == "paperlibcategory.json":
with open(os.path.join(subdir, file), "r") as f:
paperlibcategories_dict = json.load(f)
paperlibcategories.append(
[paperlibcategories_dict["category_name"],
subdir,
paperlibcategories_dict["description"]])
paperlibcategories.sort()
with open("./output/README.md", "w") as f:
f.write("Version {}\n\n---\n\n".format(date.today().strftime("%Y-%m-%d")))
f.write("# Included templates\n")
for lib in paperlibgroups:
f.write("\n## {}\n{}\n".format(
lib[0],
lib[2]
))
for cat in paperlibcategories:
if not(cat[1].startswith(lib[1]+"/")):
break
f.write("\n### {}\n{}\n\n".format(
cat[0],
cat[2]
))
for subdir, dirs, files in os.walk(TEMPLATE_DIR):
for file in files:
if file == "printablepaperlib.json":
if subdir.startswith(lib[1]+"/") and subdir.startswith(cat[1]+"/"):
with open(os.path.join(subdir, file), "r") as j:
printablepaperlib_dict = json.load(j)
f.write(
"- {} (v{})\n".format(
printablepaperlib_dict["template_name"].replace(
"_", "\\_"),
printablepaperlib_dict["version"]
))