blob: 1333521a589944a5526d4f13fc8a027ac28fb380 [file] [log] [blame]
Lennart Poettering9c4fa6e2012-07-16 17:19:39 +02001#!/usr/bin/env python
2
3from xml.etree.ElementTree import parse, Element, SubElement, tostring
4import sys
5
6index = {}
7
8for p in sys.argv[1:]:
9 t = parse(p)
10 section = t.find('./refmeta/manvolnum').text;
11 for f in t.findall('./refnamediv/refname'):
12 index[f.text] = (p, section)
13
14k = index.keys()
15k.sort(key = str.lower)
16
17
18html = Element('html')
19
20head = SubElement(html, 'head')
21title = SubElement(head, 'title')
22title.text = 'Manual Page Index'
23
24body = SubElement(html, 'body')
25h1 = SubElement(body, 'h1')
26h1.text = 'Manual Page Index'
27
28letter = None
29
30for n in k:
31 path, section = index[n]
32
33 if path.endswith('.xml'):
34 path = path[:-4] + ".html"
35
36 c = path.rfind('/')
37 if c >= 0:
38 path = path[c+1:]
39
40 if letter is None or n[0].upper() != letter:
41 letter = n[0].upper()
42
43 h2 = SubElement(body, 'h1')
44 h2.text = letter
45
46 ul = SubElement(body, 'ul')
47 ul.set('style', 'list-style-type:none')
48
49 li = SubElement(ul, 'li');
50
51 a = SubElement(li, 'a');
52 a.set('href', path)
53 a.text = n + '(' + section + ')'
54
55print tostring(html)