Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b07216b

Browse files
committed
Added support for --favicon.
Fix support for the Aesop Meta Type.
1 parent 56c8c27 commit b07216b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

Doc/tools/support.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
import getopt
11+
import os.path
1112
import sys
1213

1314

@@ -18,14 +19,15 @@ class Options:
1819
"columns=", "help", "output=",
1920

2021
# content components
21-
"address=", "iconserver=",
22+
"address=", "iconserver=", "favicon=",
2223
"title=", "uplink=", "uptitle="]
2324

2425
outputfile = "-"
2526
columns = 1
2627
letters = 0
2728
uplink = "index.html"
2829
uptitle = "Python Documentation Index"
30+
favicon = None
2931

3032
# The "Aesop Meta Tag" is poorly described, and may only be used
3133
# by the Aesop search engine (www.aesop.com), but doesn't hurt.
@@ -89,6 +91,8 @@ def parse(self, args):
8991
self.uptitle = val.strip()
9092
elif opt == "--iconserver":
9193
self.variables["iconserver"] = val.strip() or "."
94+
elif opt == "--favicon":
95+
self.favicon = val.strip()
9296
else:
9397
self.handle_option(opt, val)
9498
if self.uplink and self.uptitle:
@@ -114,11 +118,20 @@ def get_header(self):
114118
repl = " %s\n</head>" % link
115119
s = s.replace("</head>", repl, 1)
116120
if self.aesop_type:
117-
meta = '\n <meta name="aesop" content="%s">'
121+
meta = '<meta name="aesop" content="%s">\n ' % self.aesop_type
118122
# Insert this in the middle of the head that's been
119123
# generated so far, keeping <meta> and <link> elements in
120124
# neat groups:
121125
s = s.replace("<link ", meta + "<link ", 1)
126+
if self.favicon:
127+
ext = os.path.splitext(self.favicon)[1]
128+
if ext in (".gif", ".png"):
129+
type = ' type="image/%s"' % ext[1:]
130+
else:
131+
type = ''
132+
link = ('<link rel="SHORTCUT ICON" href="%s"%s>\n '
133+
% (self.favicon, type))
134+
s = s.replace("<link ", link + "<link ", 1)
122135
return s
123136

124137
def get_footer(self):

0 commit comments

Comments
 (0)