forked from tcprescott/sahasrahbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_docs.py
executable file
·48 lines (39 loc) · 1.97 KB
/
update_docs.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
#!/usr/bin/python3
import yaml
import os
# update presets
markdown_contents = """---
layout: default
title: Presets
---
* Table of contents
{:toc}
# SahasrahBot Presets
"""
for game in [d for d in sorted(os.listdir('presets')) if os.path.isdir(os.path.join('presets', d))]:
markdown_contents += f"## {game.upper()}\n\n| Preset | Description | |\n|---|---|---|\n"
for preset in [f for f in sorted(os.listdir(f'presets/{game}')) if f.endswith('.yaml')]:
with open(os.path.join('presets', game, preset)) as f:
preset_file = yaml.safe_load(f)
description = preset_file.get('description', '').replace('\n', ' ')
markdown_contents += f"| [{preset.split('.')[0]}](https://github.com/tcprescott/sahasrahbot/blob/master/presets/{game}/{preset}) |"
markdown_contents += f"{description}| {'*Customizer*' if preset_file.get('customizer', False) else ''} {'*Festive-only*' if preset_file.get('festive', False) else ''} |\n"
markdown_contents += "\n"
with open(os.path.join('docs', 'presets.md'), mode='w+') as f:
f.write(markdown_contents)
markdown_contents = """---
layout: default
title: Mystery Weights
---
* Table of contents
{: toc}
# SahasrahBot Mystery Weightsets
"""
markdown_contents += "| Preset | Description | |\n|---|---|---|\n"
for weight in [f for f in sorted(os.listdir(f'weights')) if f.endswith('.yaml') and not f == 'bot_testing.yaml']:
with open(os.path.join('weights', weight)) as f:
weight_file = yaml.safe_load(f)
description = weight_file.get('description', '').replace('\n', ' ')
markdown_contents += f"| [{weight.split('.')[0]}](https://github.com/tcprescott/sahasrahbot/blob/master/weights/{weight}) | {description} | {'*Customizer*' if weight_file.get('customizer', False) else ''}{'*Festive-only*' if weight_file.get('festive', False) else ''}{'*Subweights*' if weight_file.get('subweights', False) else ''} |\n"
with open(os.path.join('docs', 'mystery.md'), mode='w+') as f:
f.write(markdown_contents)