]> git.ipfire.org Git - thirdparty/systemd.git/blame - make-man-index.py
journal: use tail/head timestamps from header for cutoff logic
[thirdparty/systemd.git] / make-man-index.py
CommitLineData
9c4fa6ed
LP
1#!/usr/bin/env python
2
3from xml.etree.ElementTree import parse, Element, SubElement, tostring
88641113 4from sys import argv, stdout
9c4fa6ed
LP
5
6index = {}
7
88641113 8for p in argv[1:]:
9c4fa6ed 9 t = parse(p)
88641113
LP
10 section = t.find('./refmeta/manvolnum').text
11 purpose = t.find('./refnamediv/refpurpose').text
9c4fa6ed 12 for f in t.findall('./refnamediv/refname'):
88641113 13 index[f.text] = (p, section, purpose)
9c4fa6ed
LP
14
15html = Element('html')
16
17head = SubElement(html, 'head')
18title = SubElement(head, 'title')
19title.text = 'Manual Page Index'
20
21body = SubElement(html, 'body')
22h1 = SubElement(body, 'h1')
23h1.text = 'Manual Page Index'
24
25letter = None
88641113
LP
26for n in sorted(index.keys(), key = str.lower):
27 path, section, purpose = index[n]
9c4fa6ed
LP
28
29 if path.endswith('.xml'):
30 path = path[:-4] + ".html"
31
32 c = path.rfind('/')
33 if c >= 0:
34 path = path[c+1:]
35
36 if letter is None or n[0].upper() != letter:
37 letter = n[0].upper()
38
a6c9b1c4 39 h2 = SubElement(body, 'h2')
9c4fa6ed
LP
40 h2.text = letter
41
42 ul = SubElement(body, 'ul')
43 ul.set('style', 'list-style-type:none')
44
92e1ecc6 45 li = SubElement(ul, 'li')
9c4fa6ed 46
92e1ecc6 47 a = SubElement(li, 'a')
9c4fa6ed
LP
48 a.set('href', path)
49 a.text = n + '(' + section + ')'
92e1ecc6
LP
50 a.tail = ' -- '
51
52 i = SubElement(li, 'i')
53 i.text = purpose
9c4fa6ed 54
051eaebb
LP
55hr = SubElement(body, 'hr')
56
57p = SubElement(body, 'p')
58p.text = "This index contains %s entries, referring to %i individual manual pages." % (len(index), len(argv)-1)
59
88641113 60stdout.write(tostring(html))