Fix three problems in HTML help index generation.

Patch from Hirokazu Yamamoto (see bugs.python.org/4252), fixes #44.
This commit is contained in:
Georg Brandl 2008-11-22 15:28:09 +01:00
parent c8e08821fd
commit e8cfdda7a2
2 changed files with 17 additions and 5 deletions

View File

@ -161,6 +161,8 @@ New features added
Bugs fixed Bugs fixed
---------- ----------
* Fix small problems in HTML help index generation.
* Fix "illegal unit" error when using pixel image widths/heights. * Fix "illegal unit" error when using pixel image widths/heights.
* Support table captions in LaTeX output. * Support table captions in LaTeX output.

View File

@ -55,6 +55,7 @@ from sphinx import addnodes
project_template = '''\ project_template = '''\
[OPTIONS] [OPTIONS]
Binary TOC=Yes Binary TOC=Yes
Binary Index=No
Compiled file=%(outname)s.chm Compiled file=%(outname)s.chm
Contents file=%(outname)s.hhc Contents file=%(outname)s.hhc
Default Window=%(outname)s Default Window=%(outname)s
@ -191,12 +192,21 @@ def build_hhx(builder, outdir, outname):
try: try:
f.write('<UL>\n') f.write('<UL>\n')
def write_index(title, refs, subitems): def write_index(title, refs, subitems):
if refs: def write_param(name, value):
f.write('<LI> ') item = ' <param name="%s" value="%s">\n' % (name, value)
item = object_sitemap % (cgi.escape(title), refs[0])
f.write(item.encode('ascii', 'xmlcharrefreplace')) f.write(item.encode('ascii', 'xmlcharrefreplace'))
for ref in refs[1:]: title = cgi.escape(title)
f.write(object_sitemap % ('[Link]', ref)) f.write('<LI> <OBJECT type="text/sitemap">\n')
write_param('Keyword', title)
if len(refs) == 0:
write_param('See Also', title)
elif len(refs) == 1:
write_param('Local', refs[0])
else:
for i, ref in enumerate(refs):
write_param('Name', '[%d] %s' % (i, ref)) # XXX: better title?
write_param('Local', ref)
f.write('</OBJECT>\n')
if subitems: if subitems:
f.write('<UL> ') f.write('<UL> ')
for subitem in subitems: for subitem in subitems: