From 2ef38a7a42d9d02b0bd95b65d2d187ce34877f8a Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Wed, 24 Feb 1999 17:33:07 +0000 Subject: Script to combine module index files. Given a list of files that look like modindex.html, create a combined modindex.html file that lists all the modules. Takes the same parameters as buildindex.py. --- Doc/tools/mkmodindex | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 Doc/tools/mkmodindex diff --git a/Doc/tools/mkmodindex b/Doc/tools/mkmodindex new file mode 100755 index 0000000..893771e --- /dev/null +++ b/Doc/tools/mkmodindex @@ -0,0 +1,136 @@ +#! /usr/bin/env python +# -*- Python -*- + +import buildindex +import getopt +import os +import re +import string +import sys + + +_rx = re.compile( + '
([a-zA-Z_][a-zA-Z0-9_.]*)') + +def main(): + outputfile = "-" + columns = 1 + letters = 0 + opts, args = getopt.getopt(sys.argv[1:], "c:lo:", + ["columns=", "letters", "output="]) + for opt, val in opts: + if opt in ("-o", "--output"): + outputfile = val + elif opt in ("-c", "--columns"): + columns = string.atoi(val) + elif opt in ("-l", "--letters"): + letters = 1 + if not args: + args = ["-"] + # + # Collect the input data: + # + nodes = [] + seqno = 0 + for ifn in args: + if ifn == "-": + ifp = sys.stdin + dirname = '' + else: + ifp = open(ifn) + dirname = os.path.dirname(ifn) + while 1: + line = ifp.readline() + if not line: + break + m = _rx.match(line) + if m: + # This line specifies a module! + basename, modname = m.group(1, 2) + linkfile = os.path.join(dirname, basename) + nodes.append(buildindex.Node('' % linkfile, + "%s" % modname, + seqno)) + seqno = seqno + 1 + ifp.close() + num_nodes = len(nodes) + html = HEAD + buildindex.process_nodes(nodes, columns, letters) + TAIL + program = os.path.basename(sys.argv[0]) + if outputfile == "-": + sys.stdout.write(html) + sys.stderr.write("%s: %d index nodes\n" % (program, num_nodes)) + else: + open(outputfile, "w").write(html) + print + print "%s: %d index nodes" % (program, num_nodes) + + +HEAD = """\ + + + +Global Module Index + + + + + + + +""" + +TAIL = """ + + +
+
Send comments to +python-docs@python.org. +
+ + +""" + + +if __name__ == "__main__": + main() -- cgit v0.12