3 from xml.etree.ElementTree import parse, Element, SubElement, tostring
4 from sys import argv, stdout
10 section = t.find('./refmeta/manvolnum').text
11 purpose = t.find('./refnamediv/refpurpose').text
12 for f in t.findall('./refnamediv/refname'):
13 index[f.text] = (p, section, purpose)
15 html = Element('html')
17 head = SubElement(html, 'head')
18 title = SubElement(head, 'title')
19 title.text = 'Manual Page Index'
21 body = SubElement(html, 'body')
22 h1 = SubElement(body, 'h1')
23 h1.text = 'Manual Page Index'
26 for n in sorted(index.keys(), key = str.lower):
27 path, section, purpose = index[n]
29 if path.endswith('.xml'):
30 path = path[:-4] + ".html"
36 if letter is None or n[0].upper() != letter:
39 h2 = SubElement(body, 'h1')
42 ul = SubElement(body, 'ul')
43 ul.set('style', 'list-style-type:none')
45 li = SubElement(ul, 'li')
47 a = SubElement(li, 'a')
49 a.text = n + '(' + section + ')'
52 i = SubElement(li, 'i')
55 stdout.write(tostring(html))