diff options
author | Fred Drake <fdrake@acm.org> | 1998-08-07 20:49:54 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1998-08-07 20:49:54 (GMT) |
commit | 077fffa87411a3a80e694723514c2bdf98ab5ec9 (patch) | |
tree | 68cdc2c29702ac3cb95d827bbbd340edb30c9850 /Doc/tools/buildindex.py | |
parent | aa3f9fb7d5e3e02c2f02b7b3c7fcbdeab4bad59a (diff) | |
download | cpython-077fffa87411a3a80e694723514c2bdf98ab5ec9.zip cpython-077fffa87411a3a80e694723514c2bdf98ab5ec9.tar.gz cpython-077fffa87411a3a80e694723514c2bdf98ab5ec9.tar.bz2 |
The letter headings must be requested explicitly with --letters.
Diffstat (limited to 'Doc/tools/buildindex.py')
-rwxr-xr-x | Doc/tools/buildindex.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Doc/tools/buildindex.py b/Doc/tools/buildindex.py index 428100b..01805f3 100755 --- a/Doc/tools/buildindex.py +++ b/Doc/tools/buildindex.py @@ -151,7 +151,7 @@ def split_letters(nodes): # need a function to separate the nodes into columns... def split_columns(nodes, columns=1): if columns <= 1: - return (nodes,) + return [nodes] # This is a rough height; we may have to increase to avoid breaks before # a subitem. colheight = len(nodes) / columns @@ -176,7 +176,7 @@ def split_columns(nodes, columns=1): start = i * colheight end = start + colheight cols.append(nodes[start:end]) - return tuple(cols) + return cols DL_LEVEL_INDENT = " " @@ -249,7 +249,7 @@ def format_letter(letter): % (letter, lettername) -def format_html(nodes, columns=1): +def format_html_letters(nodes, columns=1): letter_groups = split_letters(nodes) items = [] for letter, nodes in letter_groups: @@ -261,6 +261,9 @@ def format_html(nodes, columns=1): s.append(format_nodes(nodes, columns)) return string.join(s, '') +def format_html(nodes, columns): + return format_nodes(nodes, columns) + def collapse(nodes): """Collapse sequences of nodes with matching keys into a single node. @@ -289,12 +292,16 @@ def main(): ifn = "-" ofn = "-" columns = 1 - opts, args = getopt.getopt(sys.argv[1:], "c:o:", ["columns=", "output="]) + letters = 0 + opts, args = getopt.getopt(sys.argv[1:], "c:lo:", + ["columns=", "letters", "output="]) for opt, val in opts: if opt in ("-o", "--output"): ofn = val elif opt in ("-c", "--columns"): columns = string.atoi(val) + elif opt in ("-l", "--letters"): + letters = 1 if not args: args = [ifn] nodes = [] @@ -302,7 +309,10 @@ def main(): nodes = nodes + load(open(fn)) nodes.sort() collapse(nodes) - html = format_html(nodes, columns) + if letters: + html = format_html_letters(nodes, columns) + else: + html = format_html(nodes, columns) if ofn == "-": sys.stdout.write(html) else: |