diff --git a/Doc/tools/mkmodindex b/Doc/tools/mkmodindex
new file mode 100755
index 00000000000..893771e3146
--- /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()