[Python-checkins] python/dist/src/Doc/tools prechm.py,1.10,1.11

tim_one@sourceforge.net tim_one@sourceforge.net
Sat, 20 Apr 2002 13:26:29 -0700


Update of /cvsroot/python/python/dist/src/Doc/tools
In directory usw-pr-cvs1:/tmp/cvs-serv4632

Modified Files:
	prechm.py 
Log Message:
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.


Index: prechm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/prechm.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** prechm.py	20 Apr 2002 08:36:42 -0000	1.10
--- prechm.py	20 Apr 2002 20:26:26 -0000	1.11
***************
*** 20,25 ****
  from formatter import NullWriter, AbstractFormatter
  from htmllib import HTMLParser
- import string
  import getopt
  
  usage_mode = '''
--- 20,25 ----
  from formatter import NullWriter, AbstractFormatter
  from htmllib import HTMLParser
  import getopt
+ import cgi
  
  usage_mode = '''
***************
*** 57,61 ****
  '''
  
! contents_header = '''
  <OBJECT type="text/site properties">
  	<param name="Window Styles" value="0x801227">
--- 57,67 ----
  '''
  
! contents_header = '''\
! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
! <HTML>
! <HEAD>
! <meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
! <!-- Sitemap 1.0 -->
! </HEAD><BODY>
  <OBJECT type="text/site properties">
  	<param name="Window Styles" value="0x801227">
***************
*** 63,85 ****
  </OBJECT>
  <UL>
! <LI> <OBJECT type="text/sitemap">
! 	<param name="Name" value="Python %s Docs">
! 	<param name="Local" value="./index.html">
! 	</OBJECT>
  <UL>
  '''
  
! contents_footer = '''
! </UL></UL>
  '''
  
! object_sitemap = '''
!     <LI> <OBJECT type="text/sitemap">
!         <param name="Local" value="%s">
!         <param name="Name" value="%s">
!         </OBJECT>
  '''
  
- 
  # List of words the full text search facility shouldn't index.  This
  # becomes file ARCH.stp.  Note that this list must be pretty small!
--- 69,90 ----
  </OBJECT>
  <UL>
! <LI><OBJECT type="text/sitemap">
!        <param name="Name" value="Python %s Docs">
!        <param name="Local" value="./index.html">
!     </OBJECT>
  <UL>
  '''
  
! contents_footer = '''\
! </UL></UL></BODY></HTML>
  '''
  
! object_sitemap = '''\
! <OBJECT type="text/sitemap">
!     <param name="Name" value="%s">
!     <param name="Local" value="%s">
! </OBJECT>
  '''
  
  # List of words the full text search facility shouldn't index.  This
  # becomes file ARCH.stp.  Note that this list must be pretty small!
***************
*** 229,232 ****
--- 234,240 ----
          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 <http://www.python.org/sf/546579>.
+         self.hrefstack = [] # stack of hrefs from anchor begins
  
      def begin_group(self):
***************
*** 242,253 ****
          if self.proc:
              self.saved_clear()
!             self.write('<OBJECT type="text/sitemap">\n')
!             self.tab('\t<param name="Local" value="%s/%s">\n' %
!                      (self.path, href))
  
      def anchor_end(self):
          if self.proc:
!             self.tab('\t<param name="Name" value="%s">\n' % self.saved_get())
!             self.tab('\t</OBJECT>\n')
  
      def start_dl(self, atr_val):
--- 250,265 ----
          if self.proc:
              self.saved_clear()
!             self.hrefstack.append(href)
  
      def anchor_end(self):
          if self.proc:
!             title = cgi.escape(self.saved_get(), True)
!             path = self.path + '/' + self.hrefstack.pop()
!             # XXX See SF bug <http://www.python.org/sf/546579>.
!             # XXX index.html for the 2.2 language reference manual contains
!             # XXX nested <a></a> 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):
***************
*** 333,338 ****
      for book in library:
          print '\t', book.title, '-', book.firstpage
!         output.write(object_sitemap % (book.directory + "/" + book.firstpage,
!                                        book.title))
          if book.contentpage:
              content(book.directory, book.contentpage, output)
--- 345,351 ----
      for book in library:
          print '\t', book.title, '-', book.firstpage
!         path = book.directory + "/" + book.firstpage
!         output.write('<LI>')
!         output.write(object_sitemap % (book.title, path))
          if book.contentpage:
              content(book.directory, book.contentpage, output)