diff options
author | Fred Drake <fdrake@acm.org> | 2000-04-03 04:19:14 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-04-03 04:19:14 (GMT) |
commit | ba82878a3bee6395a8ff13c9c307416a886f93cc (patch) | |
tree | 0711fbad046195399f506dc7b3dcf76ef452ea33 /Doc/tools/buildindex.py | |
parent | a22b576d05d7f7b8f70341268a46c219a3fd6a9c (diff) | |
download | cpython-ba82878a3bee6395a8ff13c9c307416a886f93cc.zip cpython-ba82878a3bee6395a8ff13c9c307416a886f93cc.tar.gz cpython-ba82878a3bee6395a8ff13c9c307416a886f93cc.tar.bz2 |
Merged changes from the 1.5.2p2 release.
Diffstat (limited to 'Doc/tools/buildindex.py')
-rwxr-xr-x | Doc/tools/buildindex.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/Doc/tools/buildindex.py b/Doc/tools/buildindex.py index 81bd311..2451221 100755 --- a/Doc/tools/buildindex.py +++ b/Doc/tools/buildindex.py @@ -11,6 +11,8 @@ import sys class Node: __rmjunk = re.compile("<#\d+#>") + continuation = 0 + def __init__(self, link, str, seqno): self.links = [link] self.seqno = seqno @@ -77,7 +79,7 @@ def split_entry(str, which): return stuff -_rmtt = re.compile(r"(.*)<tt(?: class=[a-z0-9]+)?>(.*)</tt>(.*)$", +_rmtt = re.compile(r"""(.*)<tt(?: class=['"][a-z0-9]+["'])?>(.*)</tt>(.*)$""", re.IGNORECASE) _rmparens = re.compile(r"\(\)") @@ -175,6 +177,22 @@ def split_columns(nodes, columns=1): start = i * colheight end = start + colheight cols.append(nodes[start:end]) + # + # If items continue across columns, make sure they are marked + # as continuations so the user knows to look at the previous column. + # + for i in range(len(cols) - 1): + try: + prev = cols[i][-1] + next = cols[i + 1][0] + except IndexError: + return cols + else: + n = min(len(prev.key), len(next.key)) + for j in range(n): + if prev.key[j] != next.key[j]: + break + next.continuation = j + 1 return cols @@ -204,8 +222,12 @@ def format_column(nodes): for i in range(count, len(current) - 1): term = node.text[i] level = level + 1 - append("\n<dt>%s\n<dd>\n%s<dl compact>" - % (term, level * DL_LEVEL_INDENT)) + if node.continuation > i: + extra = " (continued)" + else: + extra = "" + append("\n<dt>%s%s\n<dd>\n%s<dl compact>" + % (term, extra, level * DL_LEVEL_INDENT)) append("\n%s<dt>%s%s</a>" % (level * DL_LEVEL_INDENT, node.links[0], node.text[-1])) for link in node.links[1:]: |