From: Tim Peters Date: Sat, 20 Apr 2002 20:26:26 +0000 (+0000) Subject: Stopped all warnings from the HTML Help Compiler, by generating proper X-Git-Tag: v2.3c1~5861 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=454540774618c35374ecd0042ab689692040c425;p=python Stopped all warnings from the HTML Help Compiler, by generating proper HTML (or, at least, proper in its view). The TOC file is now identical to what the HTML compiler itself generates, except for whitespace and a glitch identified below. The pretty-printing done by prechm.py is pretty much destroyed for now; if you need it pretty-printed, just make the Help Compiler save the files (it's got its own idea of pretty- printing anyway). Glitch: The title of Ref Man "2.1.6 Blank lines" shows up as a blank for now. This is because the relevant entry in ref/index.html contains nested anchors, and pychm really has no idea what to do with that. I hacked it for now to avoid any error messages or worse insanity, and filed a bug report against the docs. --- diff --git a/Doc/tools/prechm.py b/Doc/tools/prechm.py index 675e40062b..59a2d2101d 100644 --- a/Doc/tools/prechm.py +++ b/Doc/tools/prechm.py @@ -19,8 +19,8 @@ import sys import os from formatter import NullWriter, AbstractFormatter from htmllib import HTMLParser -import string import getopt +import cgi usage_mode = ''' Usage: make_chm.py [-c] [-k] [-p] [-v 1.5[.x]] filename @@ -56,31 +56,36 @@ Title=Python %(version)s Documentation [FILES] ''' -contents_header = ''' +contents_header = '''\ + + + + + + +contents_footer = '''\ + ''' -object_sitemap = ''' -
  • - - - +object_sitemap = '''\ + + + + ''' - # List of words the full text search facility shouldn't index. This # becomes file ARCH.stp. Note that this list must be pretty small! # Different versions of the MS docs claim the file has a maximum size of @@ -228,6 +233,9 @@ class HelpHtmlParser(HTMLParser): self.indent = 0 # number of tabs for pretty printing of files self.proc = False # True when actively processing, else False # (headers, footers, etc) + # XXX This shouldn't need to be a stack -- anchors shouldn't nest. + # XXX See SF bug . + self.hrefstack = [] # stack of hrefs from anchor begins def begin_group(self): self.indent += 1 @@ -241,14 +249,18 @@ class HelpHtmlParser(HTMLParser): def anchor_bgn(self, href, name, type): if self.proc: self.saved_clear() - self.write('\n') - self.tab('\t\n' % - (self.path, href)) + self.hrefstack.append(href) def anchor_end(self): if self.proc: - self.tab('\t\n' % self.saved_get()) - self.tab('\t\n') + title = cgi.escape(self.saved_get(), True) + path = self.path + '/' + self.hrefstack.pop() + # XXX See SF bug . + # XXX index.html for the 2.2 language reference manual contains + # XXX nested tags in the entry for the section on blank + # XXX lines. We want to ignore the nested part completely. + if len(self.hrefstack) == 0: + self.tab(object_sitemap % (title, path)) def start_dl(self, atr_val): self.begin_group() @@ -332,8 +344,9 @@ def do_content(library, version, output): output.write(contents_header % version) for book in library: print '\t', book.title, '-', book.firstpage - output.write(object_sitemap % (book.directory + "/" + book.firstpage, - book.title)) + path = book.directory + "/" + book.firstpage + output.write('
  • ') + output.write(object_sitemap % (book.title, path)) if book.contentpage: content(book.directory, book.contentpage, output) output.write(contents_footer)