X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=make-directive-index.py;h=48d830e96f01ea7123b33cb8896c98ded909962f;hb=2e3d069236777cd62f755a02f4a239306b4ad21a;hp=49d1028edb8778b8187a1451c6611b1815788361;hpb=e1abd3efabb95a30d0702ed1c7c33c57bf898297;p=elogind.git
diff --git a/make-directive-index.py b/make-directive-index.py
old mode 100644
new mode 100755
index 49d1028ed..48d830e96
--- a/make-directive-index.py
+++ b/make-directive-index.py
@@ -1,4 +1,22 @@
-# -*- coding: utf-8 -*-
+# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
+#
+# This file is part of systemd.
+#
+# Copyright 2012 Zbigniew JÄdrzejewski-Szmek
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# systemd is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with systemd; If not, see .
+
import sys
import collections
import xml.etree.ElementTree as tree
@@ -22,7 +40,7 @@ TEMPLATE = '''\
systemd.directives
- 5
+ 7
@@ -39,6 +57,32 @@ TEMPLATE = '''\
+
+ System manager directives
+
+ Directives for configuring the behaviour of the
+ systemd process.
+
+
+
+
+
+ Options on the kernel command line
+
+ Kernel boot options for configuring the behaviour of the
+ systemd process.
+
+
+
+
+
+ Environment variables
+
+ Environment variables understood by the systemd process.
+
+
+
+
UDEV directives
@@ -47,9 +91,37 @@ TEMPLATE = '''\
+
+
+ Journal directives
+
+ Directives for configuring the behaviour of the
+ journald process.
+
+
+
+
+
+ bootchart.conf directives
+
+ Directives for configuring the behaviour of the
+ systemd-bootchart process.
+
+
+
+
+
+ Colophon
+
+
'''
+COLOPHON = '''\
+This index contains {count} entries in {sections} sections,
+referring to {pages} individual manual pages.
+'''
+
def _extract_directives(directive_groups, page):
t = tree.parse(page)
section = t.find('./refmeta/manvolnum').text
@@ -61,8 +133,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')
@@ -80,7 +152,20 @@ def _make_section(refentry, name, directives):
d.text = manvolume
entry.tail = '\n\n'
-def _make_page(directive_groups):
+def _make_colophon(template, groups):
+ count = 0
+ pages = set()
+ for group in groups:
+ count += len(group)
+ for pagelist in group.values():
+ pages |= set(pagelist)
+
+ para = template.find(".//para[@id='colophon']")
+ para.text = COLOPHON.format(count=count,
+ sections=len(groups),
+ pages=len(pages))
+
+def _make_page(template, directive_groups):
"""Create an XML tree from directive_groups.
directive_groups = {
@@ -89,23 +174,23 @@ 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)
+
+ _make_colophon(template, directive_groups.values())
- 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',
- ]}
+ 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:]))