forked from confluentinc/cp-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.py
44 lines (34 loc) · 1.42 KB
/
doc.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
"""
Reads variable files with variables documented like:
### Description
variable: default
And writes to formatted markdown file
"""
def parse_variable_file(role_name, docs_file):
docs_file.write("# confluent." + role_name)
docs_file.write("\n\n")
docs_file.write("Below are the supported variables for the role confluent." + role_name)
docs_file.write("\n\n")
docs_file.write("***")
docs_file.write("\n\n")
variables_file = open("roles/confluent." + role_name + "/defaults/main.yml", "r")
lines = variables_file.read().split('\n')
for i in range(len(lines)):
if lines[i].startswith("### "):
description = lines[i][4:]
colon_index = lines[i+1].index(":")
variable = lines[i+1][:colon_index]
default = lines[i+1][colon_index+1:]
docs_file.write("### " + variable)
docs_file.write("\n\n")
docs_file.write(description)
docs_file.write("\n\n")
docs_file.write("Default: " + default)
docs_file.write("\n\n")
docs_file.write("***")
docs_file.write("\n\n")
variables_file.close
docs_file = open("VARIABLES.md", "w")
for role_name in ["variables", "common", "control_center", "kafka_broker", "kafka_connect", "kafka_rest", "ksql", "schema_registry", "zookeeper", "kafka_connect_replicator", "ssl"]:
parse_variable_file(role_name, docs_file)
docs_file.close