diff --git a/Doc/tools/buildindex.py b/Doc/tools/buildindex.py index 909fb090db5..428100b37ed 100755 --- a/Doc/tools/buildindex.py +++ b/Doc/tools/buildindex.py @@ -148,12 +148,43 @@ def split_letters(nodes): return letter_groups +# need a function to separate the nodes into columns... +def split_columns(nodes, columns=1): + if columns <= 1: + return (nodes,) + # This is a rough height; we may have to increase to avoid breaks before + # a subitem. + colheight = len(nodes) / columns + numlong = len(nodes) % columns + if numlong: + colheight = colheight + 1 + else: + numlong = columns + cols = [] + for i in range(numlong): + start = i * colheight + end = start + colheight + cols.append(nodes[start:end]) + del nodes[:end] + colheight = colheight - 1 + try: + numshort = len(nodes) / colheight + except ZeroDivisionError: + cols = cols + (columns - len(cols)) * [[]] + else: + for i in range(numshort): + start = i * colheight + end = start + colheight + cols.append(nodes[start:end]) + return tuple(cols) + + DL_LEVEL_INDENT = " " -def format_nodes(nodes): - level = 0 +def format_column(nodes): strings = ["
| \n' % colwidth) + append(format_column(col)) + append("\n | ") + append("\n
\n") return string.join(strings, '') @@ -198,7 +249,7 @@ def format_letter(letter): % (letter, lettername) -def format_html(nodes): +def format_html(nodes, columns=1): letter_groups = split_letters(nodes) items = [] for letter, nodes in letter_groups: @@ -207,7 +258,7 @@ def format_html(nodes): s = ["