Commits

Georg Brandl  committed 970452b

Fix three problems in HTML help index generation.

Patch from Hirokazu Yamamoto (see bugs.python.org/4252), fixes #44.

  • Participants
  • Parent commits ec19e87

Comments (0)

Files changed (2)

 Bugs fixed
 ----------
 
+* Fix small problems in HTML help index generation.
+
 * Fix "illegal unit" error when using pixel image widths/heights.
 
 * Support table captions in LaTeX output.

File sphinx/htmlhelp.py

 project_template = '''\
 [OPTIONS]
 Binary TOC=Yes
+Binary Index=No
 Compiled file=%(outname)s.chm
 Contents file=%(outname)s.hhc
 Default Window=%(outname)s
     try:
         f.write('<UL>\n')
         def write_index(title, refs, subitems):
-            if refs:
-                f.write('<LI> ')
-                item = object_sitemap % (cgi.escape(title), refs[0])
+            def write_param(name, value):
+                item = '    <param name="%s" value="%s">\n' % (name, value)
                 f.write(item.encode('ascii', 'xmlcharrefreplace'))
-                for ref in refs[1:]:
-                    f.write(object_sitemap % ('[Link]', ref))
+            title = cgi.escape(title)
+            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:
                 f.write('<UL> ')
                 for subitem in subitems: