Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7552daf5
Commit
7552daf5
authored
Aug 07, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow multi-column indexes to be produced.
parent
4b521697
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
6 deletions
+60
-6
Doc/tools/buildindex.py
Doc/tools/buildindex.py
+60
-6
No files found.
Doc/tools/buildindex.py
View file @
7552daf5
...
...
@@ -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
=
[
"<dl compact>"
]
append
=
strings
.
append
level
=
0
previous
=
[]
for
node
in
nodes
:
current
=
node
.
text
...
...
@@ -183,6 +214,26 @@ def format_nodes(nodes):
previous
=
current
append
(
"
\
n
"
)
append
(
"</dl>"
*
(
level
+
1
))
return
string
.
join
(
strings
,
''
)
def
format_nodes
(
nodes
,
columns
=
1
):
strings
=
[]
append
=
strings
.
append
if
columns
>
1
:
colnos
=
range
(
columns
)
colheight
=
len
(
nodes
)
/
columns
if
len
(
nodes
)
%
columns
:
colheight
=
colheight
+
1
colwidth
=
100
/
columns
append
(
'<table width="100%"><tr valign="top">'
)
for
col
in
split_columns
(
nodes
,
columns
):
append
(
'<td width="%d%%">
\
n
'
%
colwidth
)
append
(
format_column
(
col
))
append
(
"
\
n
</td>"
)
append
(
"
\
n
</tr></table>"
)
else
:
append
(
format_column
(
nodes
))
append
(
"
\
n
<p>
\
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
=
[
"<hr><center>
\
n
%s</center>
\
n
"
%
string
.
join
(
items
,
" |
\
n
"
)]
for
letter
,
nodes
in
letter_groups
:
s
.
append
(
format_letter
(
letter
))
s
.
append
(
format_nodes
(
nodes
))
s
.
append
(
format_nodes
(
nodes
,
columns
))
return
string
.
join
(
s
,
''
)
...
...
@@ -237,10 +288,13 @@ def main():
import
getopt
ifn
=
"-"
ofn
=
"-"
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"o:"
,
[
"output="
])
columns
=
1
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"c:o:"
,
[
"columns="
,
"output="
])
for
opt
,
val
in
opts
:
if
opt
in
(
"-o"
,
"--output"
):
ofn
=
val
elif
opt
in
(
"-c"
,
"--columns"
):
columns
=
string
.
atoi
(
val
)
if
not
args
:
args
=
[
ifn
]
nodes
=
[]
...
...
@@ -248,7 +302,7 @@ def main():
nodes
=
nodes
+
load
(
open
(
fn
))
nodes
.
sort
()
collapse
(
nodes
)
html
=
format_html
(
nodes
)
html
=
format_html
(
nodes
,
columns
)
if
ofn
==
"-"
:
sys
.
stdout
.
write
(
html
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment