summaryrefslogtreecommitdiff
path: root/make-directive-index.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-14 21:02:49 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-15 11:30:41 -0500
commiteeb019b5b5db785feb0666f3238b1240e7f3e42e (patch)
tree47458bd2fede87201297f45a677884e65c44c848 /make-directive-index.py
parent4a431c9ab1475b38868c9e240a5615739a3d6458 (diff)
make-directive-index: remove duplicated list of sections
Diffstat (limited to 'make-directive-index.py')
-rwxr-xr-xmake-directive-index.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/make-directive-index.py b/make-directive-index.py
index b35735e109..51d28c4fae 100755
--- a/make-directive-index.py
+++ b/make-directive-index.py
@@ -106,8 +106,8 @@ def _extract_directives(directive_groups, page):
text = ''.join(varname.text.partition('=')[:2])
stor[text].append((pagename, section))
-def _make_section(refentry, name, directives):
- varlist = refentry.find(".//*[@id='{}']".format(name))
+def _make_section(template, name, directives):
+ varlist = template.find(".//*[@id='{}']".format(name))
for varname, manpages in sorted(directives.items()):
entry = tree.SubElement(varlist, 'varlistentry')
a = tree.SubElement(tree.SubElement(entry, 'term'), 'varname')
@@ -125,7 +125,7 @@ def _make_section(refentry, name, directives):
d.text = manvolume
entry.tail = '\n\n'
-def _make_page(directive_groups):
+def _make_page(template, directive_groups):
"""Create an XML tree from directive_groups.
directive_groups = {
@@ -134,26 +134,21 @@ def _make_page(directive_groups):
...
}
"""
- refentry = tree.fromstring(TEMPLATE)
-
for name, directives in directive_groups.items():
- _make_section(refentry, name, directives)
+ _make_section(template, name, directives)
- return refentry
+ return template
def make_page(xml_files):
"Extract directives from xml_files and return XML index tree."
+ template = tree.fromstring(TEMPLATE)
+ names = [vl.get('id') for vl in template.iterfind('.//variablelist')]
directive_groups = {name:collections.defaultdict(list)
- for name in ['unit-directives',
- 'udev-directives',
- 'systemd-directives',
- 'journal-directives',
- 'bootchart-directives',
- ]}
+ for name in names}
for page in xml_files:
_extract_directives(directive_groups, page)
- return _make_page(directive_groups)
+ return _make_page(template, directive_groups)
if __name__ == '__main__':
tree.dump(make_page(sys.argv[1:]))