4 """usage: %(program)s [options] file...
9 -a addr Set the address text to include at the end of the generated
10 HTML; this should be used for contact information.
12 -c cols Set the number of columns each index section should be
13 displayed in. The default is 1.
15 -h Display this help message.
17 -l Split the output into sections by letter.
19 -o file Write output to 'file' instead of standard out.
20 --iconserver is Use 'is' as the directory containing icons for the
21 navigation bar. The default is 'icons'.
22 --title str Set the page title to 'str'. The default is 'Global
24 --uplink url Set the upward link URL. The default is './'.
25 --uptitle str Set the upward link title. The default is 'Python
36 class IndexOptions(support
.Options
):
38 support
.Options
.__init
__(self
)
39 self
.add_args("l", ["letters"])
42 def handle_option(self
, opt
, val
):
43 if opt
in ("-l", "--letters"):
47 program
= os
.path
.basename(sys
.argv
[0])
48 print __doc__
% {"program": program
}
51 class Node(buildindex
.Node
):
52 def __init__(self
, link
, str, seqno
, platinfo
):
53 self
.annotation
= platinfo
or None
54 if str[0][-5:] == "</tt>":
57 buildindex
.Node
.__init
__(self
, link
, self
.modname
, seqno
)
59 s
= '<tt class="module">%s</tt> %s' \
60 % (self
.modname
, self
.annotation
)
62 s
= '<tt class="module">%s</tt>' % str
67 return '<tt class="module">%s</tt> %s' \
68 % (self
.modname
, self
.annotation
)
70 return '<tt class="module">%s</tt>' % self
.modname
73 "<dt><a href=['\"](module-.*\.html)(?:#l2h-\d+)?['\"]>"
74 "<tt class=['\"]module['\"]>([a-zA-Z_][a-zA-Z0-9_.]*)</tt>\s*(<em>"
75 "\(<span class=['\"]platform['\"]>.*</span>\)</em>)?</a>")
78 options
= IndexOptions()
79 options
.variables
["title"] = "Global Module Index"
80 options
.parse(sys
.argv
[1:])
85 # Collect the input data:
95 dirname
= os
.path
.dirname(ifn
)
102 # This line specifies a module!
103 basename
, modname
, platinfo
= m
.group(1, 2, 3)
104 has_plat_flag
= has_plat_flag
or platinfo
105 linkfile
= os
.path
.join(dirname
, basename
)
106 nodes
.append(Node('<a href="%s">' % linkfile
, modname
,
107 len(nodes
), platinfo
))
110 # Generate all output:
112 num_nodes
= len(nodes
)
113 # Here's the HTML generation:
114 parts
= [options
.get_header(),
115 buildindex
.process_nodes(nodes
, options
.columns
, options
.letters
),
116 options
.get_footer(),
119 parts
.insert(1, PLAT_DISCUSS
)
120 html
= string
.join(parts
, '')
121 program
= os
.path
.basename(sys
.argv
[0])
122 fp
= options
.get_output_file()
123 fp
.write(string
.rstrip(html
) + "\n")
124 if options
.outputfile
== "-":
125 sys
.stderr
.write("%s: %d index nodes\n" % (program
, num_nodes
))
128 print "%s: %d index nodes" % (program
, num_nodes
)
132 <p> Some module names are followed by an annotation indicating what
133 platform they are available on.</p>
138 if __name__
== "__main__":