-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakedoc.py
executable file
·89 lines (67 loc) · 2.16 KB
/
makedoc.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/python3
import os
from glob import glob
from helpers import *
from utilities import *
from io import StringIO
class StringBuilder:
_file_str = None
def __init__(self):
self._file_str = StringIO()
def Add(self, str):
self._file_str.write(str)
def AddNl(self, str):
self.Add(str)
self.Add('\n')
def __str__(self):
return self._file_str.getvalue()
def getYamlForRecipeFile(filename):
dirName = filename[:-3] # remove the '.py' extension
yamlFilename = "recipes/{}/{}.yaml".format(dirName, filename)
p = Path(yamlFilename)
if not p.is_file():
# dont care
return None
with open(yamlFilename) as f:
yamlData = yaml.safe_load(f)
yamlData['recipename'] = dirName
return yamlData
def buildMd(yamls):
sb = StringBuilder()
sb.AddNl('# Recipe Overview')
sb.AddNl('')
for yaml in yamls:
sb.AddNl("## {}".format(yaml['name']))
sb.AddNl('')
sb.AddNl("* {}".format(yaml['chain']))
if yaml['description'] is not None:
sb.AddNl("* {}".format(yaml['description']))
if yaml['reference'] is not None:
sb.AddNl("* [{}]({})".format(yaml['reference'], yaml['reference']))
if yaml['binaries'] is not None:
sb.AddNl("* Contains binaries without source")
if yaml['modify_filesystem'] is not None:
sb.AddNl("* Modifies filesystem or registry")
sb.AddNl('')
sb.AddNl("![{}](https://github.com/dobin/ace-firefist/blob/main/docs/gifs/{}.gif?raw=true)".format(
yaml['recipename'], yaml['recipename']))
sb.AddNl('')
sb.AddNl('```')
sb.AddNl("python3 ace.py --recipe {}".format(yaml['recipename']))
sb.AddNl('```')
sb.AddNl('')
sb.AddNl("Entry path: {}".format(yaml['entryurl']))
sb.AddNl('')
sb.AddNl('')
return str(sb)
def main():
yamls = []
files = []
files = getRecipePyFiles()
for file in files:
yamlData = getYamlForRecipeFile(file)
yamls.append(yamlData)
md = buildMd(yamls)
print(md)
if __name__ == "__main__":
main()