-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-docs.py
More file actions
29 lines (29 loc) · 1.03 KB
/
generate-docs.py
File metadata and controls
29 lines (29 loc) · 1.03 KB
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
import sys
import os
import yaml
import glob
import re
input_file = sys.argv[1]
start_pattern="<!-- ACTION_TABLE_START -->"
end_pattern="<!-- ACTION_TABLE_END -->"
f = open(input_file, "r")
file_data = f.read()
f.close()
data = {}
for file_path in glob.glob('**/action.yml', recursive=True):
if 'archive/' in file_path:
continue
with open(file_path, 'r') as file:
yaml_content = yaml.safe_load(file)
parent_dir_name=os.path.basename(os.path.dirname(file_path))
data[parent_dir_name] = {
**yaml.safe_load(yaml_content["description"]),
"path": file_path
}
action_table_rows = "\n".join(f"| [{name}]({action['path']}) | {action['description']} | {'✅' if action['local'] else '❌'} |" for name, action in dict(sorted(data.items())).items())
action_table = f'''\
| Action | Description | Local usage |
| --- | --- | --- |
{action_table_rows}\
'''
sys.stdout.write(re.sub(f"{start_pattern}.*{end_pattern}", f"{start_pattern}\n{action_table}\n{end_pattern}", file_data, flags=re.DOTALL))