X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=make-man-index.py;h=d38d5b63f64feaf6328a1877058d03b23f006746;hp=5fa90aefdbcc13b1f5362191eea720fb7fc7a20a;hb=2f6eb835ca05816142899188a3c9da30d3138efe;hpb=f6b6728d1dc92754026a7f04d26f83e2290778f4 diff --git a/make-man-index.py b/make-man-index.py index 5fa90aefd..d38d5b63f 100755 --- a/make-man-index.py +++ b/make-man-index.py @@ -21,9 +21,11 @@ import collections import xml.etree.ElementTree as tree import sys +import re +MDASH = ' — ' if sys.version_info.major >= 3 else ' -- ' TEMPLATE = '''\ - + systemd.index @@ -65,10 +67,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 +99,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')