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
01a110be
Commit
01a110be
authored
Oct 05, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new support module instead of including all the getopt
processing and style information directly.
parent
ca2b2e04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
113 deletions
+23
-113
Doc/tools/mkmodindex
Doc/tools/mkmodindex
+23
-113
No files found.
Doc/tools/mkmodindex
View file @
01a110be
...
@@ -26,24 +26,26 @@ Supported options:
...
@@ -26,24 +26,26 @@ Supported options:
Documentation Index'.
Documentation Index'.
"""
"""
import
buildindex
import
buildindex
import getopt
import
os
import
os
import
re
import
re
import
string
import
string
import
support
import
sys
import
sys
def usage():
class
IndexOptions
(
support
.
Options
):
program = os.path.basename(sys.argv[0])
def
__init__
(
self
):
print __doc__ % {"program": program}
support
.
Options
.
__init__
(
self
)
self
.
add_args
(
"l"
,
[
"letters"
])
self
.
letters
=
0
def
handle_option
(
self
,
opt
,
val
):
if
opt
in
(
"-l"
,
"--letters"
):
self
.
letters
=
1
def error(msg, rc=2):
def
usage
(
self
):
sys.stdout = sys.stderr
program
=
os
.
path
.
basename
(
sys
.
argv
[
0
])
print msg
print
__doc__
%
{
"program"
:
program
}
print
usage()
sys.exit(rc)
_rx
=
re
.
compile
(
_rx
=
re
.
compile
(
...
@@ -52,56 +54,10 @@ _rx = re.compile(
...
@@ -52,56 +54,10 @@ _rx = re.compile(
"
\
(
<
span
class
=
'platform'
>
.
*</
span
>
\
)
</
em
>
)
?
)
</
a
>
")
"
\
(
<
span
class
=
'platform'
>
.
*</
span
>
\
)
</
em
>
)
?
)
</
a
>
")
def main():
def main():
outputfile = "-"
options = IndexOptions()
columns = 1
options.variables["
title
"] = "
Global
Module
Index
"
letters = 0
options.parse(sys.argv[1:])
uplink = "./"
args = options.args
uptitle = "Python Documentation Index"
variables = {"address": "",
"iconserver": "icons",
"imgtype": "gif",
"title": "Global Module Index",
"uplinkalt": "up",
"uplinkicon": "up",
}
try:
opts, args = getopt.getopt(sys.argv[1:], "a:c:hlo:",
[# script controls:
"columns=", "help", "letters", "output=",
# content components:
"address=", "iconserver=",
"title=", "uplink=", "uptitle="])
except getopt.error, msg:
error(msg)
for opt, val in opts:
if opt in ("-a", "--address"):
val = string.strip(val)
variables["address"] = val and "
<address>
\n%s\n
</address>
\n" % val
elif opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-o", "--output"):
outputfile = val
elif opt in ("-c", "--columns"):
columns = string.atoi(val)
elif opt in ("-l", "--letters"):
letters = 1
elif opt == "--title":
variables["title"] = string.strip(val)
elif opt == "--uplink":
uplink = string.strip(val)
elif opt == "--uptitle":
uptitle = string.strip(val)
elif opt == "--iconserver":
variables["iconserver"] = string.strip(val) or "."
if uplink and uptitle:
variables["uplinkalt"] = "up"
variables["uplinkicon"] = "up"
else:
variables["uplinkalt"] = ""
variables["uplinkicon"] = "blank"
variables["uplink"] = uplink
variables["uptitle"] = uptitle
if not args:
if not args:
args = ["
-
"]
args = ["
-
"]
#
#
...
@@ -138,19 +94,19 @@ def main():
...
@@ -138,19 +94,19 @@ def main():
#
#
num_nodes = len(nodes)
num_nodes = len(nodes)
# Here's the HTML generation:
# Here's the HTML generation:
parts = [
HEAD % variables
,
parts = [
options.get_header()
,
buildindex.process_nodes(nodes,
columns,
letters),
buildindex.process_nodes(nodes,
options.columns, options.
letters),
TAIL % variables
,
options.get_footer()
,
]
]
if has_plat_flag:
if has_plat_flag:
parts.insert(1, PLAT_DISCUSS)
parts.insert(1, PLAT_DISCUSS)
html = string.join(parts, '')
html = string.join(parts, '')
program = os.path.basename(sys.argv[0])
program = os.path.basename(sys.argv[0])
if outputfile == "-":
fp = options.get_output_file()
sys.stdout.write(html)
print >>fp, html.rstrip()
sys.stderr.write("%s: %d index nodes\n" % (program, num_nodes))
if options.outputfile == "
-
":
print >>sys.stderr, "
%
s
:
%
d
index
nodes
" % (program, num_nodes)
else:
else:
open(outputfile, "w").write(html)
print
print
print "
%
s
:
%
d
index
nodes
" % (program, num_nodes)
print "
%
s
:
%
d
index
nodes
" % (program, num_nodes)
...
@@ -161,52 +117,6 @@ platform they are available on.</p>
...
@@ -161,52 +117,6 @@ platform they are available on.</p>
"""
"""
NAVIGATION = '''\
<div
class=
"navigation"
>
<table
width=
"100%%"
cellpadding=
"0"
cellspacing=
"2"
>
<tr>
<td><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
""
src=
"%(iconserver)s/blank.%(imgtype)s"
></td>
<td><a
href=
"%(uplink)s"
title=
"%(uptitle)s"
><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
"%(uplinkalt)s"
src=
"%(iconserver)s/%(uplinkicon)s.%(imgtype)s"
></a></td>
<td><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
""
src=
"%(iconserver)s/blank.%(imgtype)s"
></td>
<td
align=
"center"
width=
"100%%"
>
%(title)s
</td>
<td><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
""
src=
"%(iconserver)s/blank.%(imgtype)s"
></td>
<td><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
""
src=
"%(iconserver)s/blank.%(imgtype)s"
></td>
<td><img
width=
"32"
height=
"32"
align=
"bottom"
border=
"0"
alt=
""
src=
"%(iconserver)s/blank.%(imgtype)s"
></td>
</tr></table>
<b
class=
"navlabel"
>
Up:
</b>
<span
class=
"sectref"
><a
href=
"%(uplink)s"
title=
"%(uptitle)s"
>
%(uptitle)s
</A></span>
<br></div>
'''
HEAD = '''\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
Global Module Index
</title>
<meta
name=
"description"
content=
"%(title)s"
>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=iso-8859-1"
>
<link
rel=
"STYLESHEET"
href=
"lib/lib.css"
>
</head>
<body>
''' + NAVIGATION + '''\
<hr>
<h2>
%(title)s
</h2>
'''
TAIL = "
<hr>
\n" + NAVIGATION + '''\
%(address)s
</body>
</html>
'''
if __name__ == "
__main__
":
if __name__ == "
__main__
":
main()
main()
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