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
37 program
= os
.path
.basename(sys
.argv
[0])
38 print __doc__
% {"program": program
}
42 sys
.stdout
= sys
.stderr
50 "<dt><a href='(module-.*\.html)#l2h-\d+'><tt class='module'>"
51 "([a-zA-Z_][a-zA-Z0-9_.]*</tt>(\s*<em>"
52 "\(<span class='platform'>.*</span>\)</em>)?)</a>")
59 uptitle
= "Python Documentation Index"
60 variables
= {"address": "",
61 "iconserver": "icons",
63 "title": "Global Module Index",
68 opts
, args
= getopt
.getopt(sys
.argv
[1:], "a:c:hlo:",
70 "columns=", "help", "letters", "output=",
72 "address=", "iconserver=",
73 "title=", "uplink=", "uptitle="])
74 except getopt
.error
, msg
:
77 if opt
in ("-a", "--address"):
78 val
= string
.strip(val
)
79 variables
["address"] = val
and "<address>\n%s\n</address>\n" % val
80 elif opt
in ("-h", "--help"):
83 elif opt
in ("-o", "--output"):
85 elif opt
in ("-c", "--columns"):
86 columns
= string
.atoi(val
)
87 elif opt
in ("-l", "--letters"):
89 elif opt
== "--title":
90 variables
["title"] = string
.strip(val
)
91 elif opt
== "--uplink":
92 uplink
= string
.strip(val
)
93 elif opt
== "--uptitle":
94 uptitle
= string
.strip(val
)
95 elif opt
== "--iconserver":
96 variables
["iconserver"] = string
.strip(val
) or "."
97 if uplink
and uptitle
:
98 variables
["uplinkalt"] = "up"
99 variables
["uplinkicon"] = "up"
101 variables
["uplinkalt"] = ""
102 variables
["uplinkicon"] = "blank"
103 variables
["uplink"] = uplink
104 variables
["uptitle"] = uptitle
108 # Collect the input data:
119 dirname
= os
.path
.dirname(ifn
)
121 line
= ifp
.readline()
126 # This line specifies a module!
127 basename
, modname
= m
.group(1, 2)
128 has_plat_flag
= has_plat_flag
or m
.group(3)
129 linkfile
= os
.path
.join(dirname
, basename
)
130 nodes
.append(buildindex
.Node(
131 '<a href="%s">' % linkfile
,
132 "<tt class=module>%s</tt>" % modname
,
137 # Generate all output:
139 num_nodes
= len(nodes
)
140 # Here's the HTML generation:
141 parts
= [HEAD
% variables
,
142 buildindex
.process_nodes(nodes
, columns
, letters
),
146 parts
.insert(1, PLAT_DISCUSS
)
147 html
= string
.join(parts
, '')
148 program
= os
.path
.basename(sys
.argv
[0])
149 if outputfile
== "-":
150 sys
.stdout
.write(html
)
151 sys
.stderr
.write("%s: %d index nodes\n" % (program
, num_nodes
))
153 open(outputfile
, "w").write(html
)
155 print "%s: %d index nodes" % (program
, num_nodes
)
159 <p> Some module names are followed by an annotation indicating what
160 platform they are available on.</p>
165 <div class=navigation>
166 <table width="100%%" cellpadding=0 cellspacing=2>
168 <td><img width=32 height=32 align=bottom border=0 alt=""
169 src="%(iconserver)s/blank.%(imgtype)s"></td>
170 <td><a href="%(uplink)s"
171 title="%(uptitle)s"><img width=32 height=32 align=bottom border=0
173 src="%(iconserver)s/%(uplinkicon)s.%(imgtype)s"></a></td>
174 <td><img width=32 height=32 align=bottom border=0 alt=""
175 src="%(iconserver)s/blank.%(imgtype)s"></td>
176 <td align=center bgcolor="#99CCFF" width="100%%">
177 <b class=title>%(title)s</b></td>
178 <td><img width=32 height=32 align=bottom border=0 alt=""
179 src="%(iconserver)s/blank.%(imgtype)s"></td>
180 <td><img width=32 height=32 align=bottom border=0 alt=""
181 src="%(iconserver)s/blank.%(imgtype)s"></td>
182 <td><img width=32 height=32 align=bottom border=0 alt=""
183 src="%(iconserver)s/blank.%(imgtype)s"></td>
185 <b class=navlabel>Up:</b> <span class=sectref><a href="%(uplink)s"
186 title="%(uptitle)s">%(uptitle)s</A></span>
191 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
194 <title>Global Module Index</title>
195 <meta name="description" content="%(title)s">
196 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
197 <link rel="STYLESHEET" href="lib/lib.css">
200 """ + NAVIGATION
+ """\
207 TAIL
= "<hr>\n" + NAVIGATION
+ """\
212 if __name__
== "__main__":