X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=make-man-index.py;h=d9ab5cc7525f35222de6e0c0f4f7f004b465dfc0;hb=dafb75912a65e72c3989143f79367a652323a69f;hp=5fa90aefdbcc13b1f5362191eea720fb7fc7a20a;hpb=f6b6728d1dc92754026a7f04d26f83e2290778f4;p=elogind.git
diff --git a/make-man-index.py b/make-man-index.py
index 5fa90aefd..d9ab5cc75 100755
--- a/make-man-index.py
+++ b/make-man-index.py
@@ -19,11 +19,18 @@
# along with systemd; If not, see .
import collections
-import xml.etree.ElementTree as tree
+try:
+ from lxml import etree as tree
+ PRETTY = dict(pretty_print=True)
+except ImportError:
+ import xml.etree.ElementTree as tree
+ PRETTY = {}
import sys
+import re
+MDASH = ' â ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
-
+
systemd.index
@@ -65,10 +72,16 @@ SUMMARY = '''\
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
+def check_id(page, t):
+ id = t.getroot().get('id')
+ if not re.search('/' + id + '[.]', page):
+ raise ValueError("id='{}' is not the same as page name '{}'".format(id, page))
+
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
t = tree.parse(p)
+ check_id(p, t)
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
purpose = ' '.join(t.find('./refnamediv/refpurpose').text.split())
@@ -91,7 +104,7 @@ def add_letter(template, letter, pages):
d = tree.SubElement(b, 'manvolnum')
d.text = section
- b.tail = ' â ' + purpose # + ' (' + p + ')'
+ b.tail = MDASH + purpose # + ' (' + p + ')'
tree.SubElement(para, 'sbr')
@@ -122,4 +135,4 @@ def make_page(xml_files):
return template
if __name__ == '__main__':
- tree.dump(make_page(sys.argv[1:]))
+ tree.dump(make_page(sys.argv[1:]), **PRETTY)