From 2bb8a4cf1cbfa7b3f9d1bbce386c16fa21a23c2a Mon Sep 17 00:00:00 2001 From: kakwa Date: Sat, 10 Sep 2016 00:48:24 +0200 Subject: [PATCH] python script to gen doc from conf file comments --- goodies/build_param_table.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 goodies/build_param_table.py diff --git a/goodies/build_param_table.py b/goodies/build_param_table.py new file mode 100755 index 0000000..3653ac7 --- /dev/null +++ b/goodies/build_param_table.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +import re +import os + +import pprint + +tsq_path = os.path.join(os.path.dirname(__file__),'../conf/uts-server.cnf') + +docs = {} + +text_buf = "" +cur_section = "" + +with open(tsq_path) as f: + for line in f.readlines(): + m = re.search('\[ (\w+) \]', line) + if m: + section = m.group(1) + docs[section] = {'text': text_buf, 'vars': {}} + cur_section = section + text_buf = "" + + m = re.search('^#[\t ](.*)', line) + if m: + text = m.group(1) + if text_buf: + text_buf += '\n ' + text_buf += text + + m = re.search('^#?([^\s]*)\s*=.*', line) + if m: + var = m.group(1) + docs[cur_section]['vars'][var] = text_buf + text_buf = "" + +#print docs +for section in docs: + print('### ' + section) + print('') + print(docs[section]['text']) + print('') + for var in docs[section]['vars']: + if docs[section]['vars'][var]: + print('* ```' + var + '```: ' + docs[section]['vars'][var]) + print('')