Tidy some grammar and remove a silly colloquialism.
[dcpomatic.git] / doc / manual / config.py
1 import sys
2 current_tag = None
3 current_doc = None
4 current_opt = False
5 print('<itemizedlist>')
6 with open(sys.argv[1]) as f:
7     for line in f:
8         line = line.strip();
9         if line.startswith('/* [XML'):
10             code = line.split()[1]
11             current_tag = line.split()[2]
12             current_opt = code == '[XML:opt]'
13             line = line[5+len(code)+len(current_tag):]
14             current_doc = ''
15         if current_tag is not None:
16             current_doc += line.replace('/* [XML] ', '').replace('*/', '').strip() + ' '
17         if line.find('*/') != -1 and current_tag is not None:
18             if current_opt:
19                 optional = ' (optional)'
20             else:
21                 optional = ''
22             print('<listitem><code>&lt;%s&gt;</code>%s &#8212; %s</listitem>' % (current_tag, optional, current_doc.strip()))
23             current_tag = None
24 print('</itemizedlist>')