-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgenerate.py
More file actions
30 lines (26 loc) · 811 Bytes
/
generate.py
File metadata and controls
30 lines (26 loc) · 811 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
from glob import glob
import json
import os
versions = [e.replace('\\', '/') for e in glob('*/*.md')]
changes = []
for name in versions:
[group, version] = name.removesuffix('.md').split('/')
with open(name, 'r') as f:
text = f.read().split('\n\n')
for change in text:
i = change.index('|')
tags = change[0:i].strip().split(' ')
content = change[i+1:].strip().replace('->', '→').replace('\n...\n', '\n\n')
changes.append({
'group': group,
'version': version,
'tags': tags,
'content': content,
})
os.makedirs('generated', exist_ok=True)
with open('generated/changes.json', 'w') as f:
json.dump(changes, f, indent=2)
f.write('\n')
with open('generated/changes.min.json', 'w') as f:
json.dump(changes, f)
print(f'Generated {len(changes)} changes from {len(versions)} versions')