annotate Doc/tools/support.py @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents d7da080d7763
children ab6b108a8cec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15026
b368e06a3b62 Better add at least a short docstring to the module!
Fred Drake <fdrake@acm.org>
parents: 15020
diff changeset
1 """Miscellaneous support code shared by some of the tool scripts.
b368e06a3b62 Better add at least a short docstring to the module!
Fred Drake <fdrake@acm.org>
parents: 15020
diff changeset
2
b368e06a3b62 Better add at least a short docstring to the module!
Fred Drake <fdrake@acm.org>
parents: 15020
diff changeset
3 This includes option parsing code, HTML formatting code, and a couple of
b368e06a3b62 Better add at least a short docstring to the module!
Fred Drake <fdrake@acm.org>
parents: 15020
diff changeset
4 useful helpers.
b368e06a3b62 Better add at least a short docstring to the module!
Fred Drake <fdrake@acm.org>
parents: 15020
diff changeset
5
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 """
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 __version__ = '$Revision$'
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 import getopt
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
11 import os.path
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 import sys
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 class Options:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16 __short_args = "a:c:ho:"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 __long_args = [
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 # script controls
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 "columns=", "help", "output=",
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 # content components
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
22 "address=", "iconserver=", "favicon=",
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 "title=", "uplink=", "uptitle="]
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 outputfile = "-"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 columns = 1
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 letters = 0
21871
5043b738b072 When linking to an index page, explicitly name index.html instead of
Fred Drake <fdrake@acm.org>
parents: 20609
diff changeset
28 uplink = "index.html"
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 uptitle = "Python Documentation Index"
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
30 favicon = None
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31
22849
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
32 # The "Aesop Meta Tag" is poorly described, and may only be used
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
33 # by the Aesop search engine (www.aesop.com), but doesn't hurt.
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
34 #
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
35 # There are a number of values this may take to roughly categorize
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
36 # a page. A page should be marked according to its primary
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
37 # category. Known values are:
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
38 # 'personal' -- personal-info
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
39 # 'information' -- information
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
40 # 'interactive' -- interactive media
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
41 # 'multimedia' -- multimedia presenetation (non-sales)
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
42 # 'sales' -- sales material
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
43 # 'links' -- links to other information pages
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
44 #
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
45 # Setting the aesop_type value to one of these strings will cause
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
46 # get_header() to add the appropriate <meta> tag to the <head>.
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
47 #
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
48 aesop_type = None
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
49
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 def __init__(self):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51 self.args = []
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 self.variables = {"address": "",
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53 "iconserver": "icons",
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
54 "imgtype": "gif",
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
55 "title": "Global Module Index",
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
56 }
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
57
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
58 def add_args(self, short=None, long=None):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
59 if short:
16570
8657384dcc4a Jon Nelson <jnelson@users.sourceforge.net>:
Fred Drake <fdrake@acm.org>
parents: 15026
diff changeset
60 self.__short_args = self.__short_args + short
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
61 if long:
16570
8657384dcc4a Jon Nelson <jnelson@users.sourceforge.net>:
Fred Drake <fdrake@acm.org>
parents: 15026
diff changeset
62 self.__long_args = self.__long_args + long
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
63
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
64 def parse(self, args):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
65 try:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
66 opts, args = getopt.getopt(args, self.__short_args,
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
67 self.__long_args)
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
68 except getopt.error:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
69 sys.stdout = sys.stderr
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
70 self.usage()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
71 sys.exit(2)
16570
8657384dcc4a Jon Nelson <jnelson@users.sourceforge.net>:
Fred Drake <fdrake@acm.org>
parents: 15026
diff changeset
72 self.args = self.args + args
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
73 for opt, val in opts:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
74 if opt in ("-a", "--address"):
25800
bc81d531c629 Use string methods.
Fred Drake <fdrake@acm.org>
parents: 22849
diff changeset
75 val = val.strip()
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
76 if val:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
77 val = "<address>\n%s\n</address>\n" % val
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
78 self.variables["address"] = val
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
79 elif opt in ("-h", "--help"):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
80 self.usage()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
81 sys.exit()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
82 elif opt in ("-o", "--output"):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
83 self.outputfile = val
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
84 elif opt in ("-c", "--columns"):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
85 self.columns = int(val)
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
86 elif opt == "--title":
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
87 self.variables["title"] = val.strip()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
88 elif opt == "--uplink":
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
89 self.uplink = val.strip()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
90 elif opt == "--uptitle":
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
91 self.uptitle = val.strip()
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
92 elif opt == "--iconserver":
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
93 self.variables["iconserver"] = val.strip() or "."
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
94 elif opt == "--favicon":
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
95 self.favicon = val.strip()
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
96 else:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
97 self.handle_option(opt, val)
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
98 if self.uplink and self.uptitle:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
99 self.variables["uplinkalt"] = "up"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
100 self.variables["uplinkicon"] = "up"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
101 else:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
102 self.variables["uplinkalt"] = ""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
103 self.variables["uplinkicon"] = "blank"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
104 self.variables["uplink"] = self.uplink
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
105 self.variables["uptitle"] = self.uptitle
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
106
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
107 def handle_option(self, opt, val):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
108 raise getopt.error("option %s not recognized" % opt)
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
109
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
110 def get_header(self):
20609
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
111 s = HEAD % self.variables
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
112 if self.uplink:
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
113 if self.uptitle:
25969
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
114 link = ('<link rel="up" href="%s" title="%s">\n '
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
115 '<link rel="start" href="%s" title="%s">'
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
116 % (self.uplink, self.uptitle,
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
117 self.uplink, self.uptitle))
20609
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
118 else:
25969
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
119 link = ('<link rel="up" href="%s">\n '
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
120 '<link rel="start" href="%s">'
d7da080d7763 More <link> support for generated pages.
Fred Drake <fdrake@acm.org>
parents: 25961
diff changeset
121 % (self.uplink, self.uplink))
20609
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
122 repl = " %s\n</head>" % link
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
123 s = s.replace("</head>", repl, 1)
22849
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
124 if self.aesop_type:
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
125 meta = '<meta name="aesop" content="%s">\n ' % self.aesop_type
22849
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
126 # Insert this in the middle of the head that's been
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
127 # generated so far, keeping <meta> and <link> elements in
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
128 # neat groups:
d6d64239aa05 Add support for the "Aesop Meta Tag". Not widely used, but not a bad idea,
Fred Drake <fdrake@acm.org>
parents: 21871
diff changeset
129 s = s.replace("<link ", meta + "<link ", 1)
25961
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
130 if self.favicon:
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
131 ext = os.path.splitext(self.favicon)[1]
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
132 if ext in (".gif", ".png"):
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
133 type = ' type="image/%s"' % ext[1:]
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
134 else:
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
135 type = ''
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
136 link = ('<link rel="SHORTCUT ICON" href="%s"%s>\n '
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
137 % (self.favicon, type))
91d3d4452c48 Added support for --favicon.
Fred Drake <fdrake@acm.org>
parents: 25800
diff changeset
138 s = s.replace("<link ", link + "<link ", 1)
20609
828cb0c2c480 Do a little bit more to try and add <link> elements to the header, not that
Fred Drake <fdrake@acm.org>
parents: 16570
diff changeset
139 return s
15020
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
140
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
141 def get_footer(self):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
142 return TAIL % self.variables
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
143
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
144 def get_output_file(self, filename=None):
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 if filename is None:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
146 filename = self.outputfile
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
147 if filename == "-":
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
148 return sys.stdout
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
149 else:
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
150 return open(filename, "w")
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
151
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
152
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
153 NAVIGATION = '''\
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
154 <div class="navigation">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
155 <table width="100%%" cellpadding="0" cellspacing="2">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
156 <tr>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
157 <td><img width="32" height="32" align="bottom" border="0" alt=""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
158 src="%(iconserver)s/blank.%(imgtype)s"></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
159 <td><a href="%(uplink)s"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
160 title="%(uptitle)s"><img width="32" height="32" align="bottom" border="0"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
161 alt="%(uplinkalt)s"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
162 src="%(iconserver)s/%(uplinkicon)s.%(imgtype)s"></a></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
163 <td><img width="32" height="32" align="bottom" border="0" alt=""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
164 src="%(iconserver)s/blank.%(imgtype)s"></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
165 <td align="center" width="100%%">%(title)s</td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
166 <td><img width="32" height="32" align="bottom" border="0" alt=""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
167 src="%(iconserver)s/blank.%(imgtype)s"></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
168 <td><img width="32" height="32" align="bottom" border="0" alt=""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
169 src="%(iconserver)s/blank.%(imgtype)s"></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
170 <td><img width="32" height="32" align="bottom" border="0" alt=""
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
171 src="%(iconserver)s/blank.%(imgtype)s"></td>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
172 </tr></table>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
173 <b class="navlabel">Up:</b> <span class="sectref"><a href="%(uplink)s"
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
174 title="%(uptitle)s">%(uptitle)s</A></span>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
175 <br></div>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
176 '''
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
177
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
178 HEAD = '''\
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
179 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
180 <html>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
181 <head>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
182 <title>%(title)s</title>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
183 <meta name="description" content="%(title)s">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
184 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
185 <link rel="STYLESHEET" href="lib/lib.css">
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
186 </head>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
187 <body>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
188 ''' + NAVIGATION + '''\
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
189 <hr>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
190
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
191 <h2>%(title)s</h2>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
192
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
193 '''
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
194
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
195 TAIL = "<hr>\n" + NAVIGATION + '''\
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
196 %(address)s</body>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
197 </html>
405ad0a7f7a6 Factor out some of the presentation and shared code from mkmodindex and
Fred Drake <fdrake@acm.org>
parents:
diff changeset
198 '''