Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
texi2html.HTMLHelp Class Reference

List of all members.

Public Member Functions

def __init__
def addnode
def menuitem
def addimage
def index
def beginmenu
def endmenu
def finalize
def dumpfiles
def dumpnodes
def dumpnode
def dumpmenu
def getnode
def dumpindex
def codeexpand

Public Attributes

 helpbase
 dirname
 projectfile
 contentfile
 indexfile
 nodelist
 nodenames
 nodeindex
 filenames
 indexlist
 current
 menudict
 dumped
 topnode

Static Public Attributes

tuple codeprog = re.compile('@code{(.*?)}')

Detailed Description

This class encapsulates support for HTML Help. Node names,
file names, menu items, index items, and image file names are
accumulated until a call to finalize(). At that time, three
output files are created in the current directory:

    `helpbase`.hhp  is a HTML Help Workshop project file.
                    It contains various information, some of
                    which I do not understand; I just copied
                    the default project info from a fresh
                    installation.
    `helpbase`.hhc  is the Contents file for the project.
    `helpbase`.hhk  is the Index file for the project.

When these files are used as input to HTML Help Workshop,
the resulting file will be named:

    `helpbase`.chm

If none of the defaults in `helpbase`.hhp are changed,
the .CHM file will have Contents, Index, Search, and
Favorites tabs.

Definition at line 1682 of file texi2html.py.


Constructor & Destructor Documentation

def texi2html.HTMLHelp.__init__ (   self,
  helpbase,
  dirname 
)

Definition at line 1709 of file texi2html.py.

01709 
01710     def __init__(self,helpbase,dirname):
01711         self.helpbase    = helpbase
01712         self.dirname     = dirname
01713         self.projectfile = None
01714         self.contentfile = None
01715         self.indexfile   = None
01716         self.nodelist    = []
01717         self.nodenames   = {}         # nodename : index
01718         self.nodeindex   = {}
01719         self.filenames   = {}         # filename : filename
01720         self.indexlist   = []         # (args,nodename) == (key,location)
01721         self.current     = ''
01722         self.menudict    = {}
01723         self.dumped      = {}
01724 


Member Function Documentation

def texi2html.HTMLHelp.addimage (   self,
  imagename 
)

Definition at line 1742 of file texi2html.py.

01742 
01743     def addimage(self,imagename):
01744         self.filenames[imagename] = imagename

def texi2html.HTMLHelp.addnode (   self,
  name,
  next,
  prev,
  up,
  filename 
)

Definition at line 1725 of file texi2html.py.

01725 
01726     def addnode(self,name,next,prev,up,filename):
01727         node = (name,next,prev,up,filename)
01728         # add this file to dict
01729         # retrieve list with self.filenames.values()
01730         self.filenames[filename] = filename
01731         # add this node to nodelist
01732         self.nodeindex[name] = len(self.nodelist)
01733         self.nodelist.append(node)
01734         # set 'current' for menu items
01735         self.current = name
01736         self.menudict[self.current] = []

Definition at line 1748 of file texi2html.py.

01748 
01749     def beginmenu(self):
01750         pass

def texi2html.HTMLHelp.codeexpand (   self,
  line 
)

Definition at line 1925 of file texi2html.py.

01925 
01926     def codeexpand(self, line):
01927         co = self.codeprog.match(line)
01928         if not co:
01929             return line
01930         bgn, end = co.span(0)
01931         a, b = co.span(1)
01932         line = line[:bgn] + line[a:b] + line[end:]
01933         return line
01934 
01935 
# Put @var{} around alphabetic substrings

Here is the caller graph for this function:

def texi2html.HTMLHelp.dumpfiles (   self,
  outfile = sys.stdout 
)

Definition at line 1849 of file texi2html.py.

01849 
01850     def dumpfiles(self, outfile=sys.stdout):
01851         filelist = sorted(self.filenames.values())
01852         for filename in filelist:
01853             print(filename, file=outfile)

Here is the call graph for this function:

def texi2html.HTMLHelp.dumpindex (   self,
  outfile = sys.stdout 
)

Definition at line 1913 of file texi2html.py.

01913 
01914     def dumpindex(self, outfile=sys.stdout):
01915         print('<UL>', file=outfile)
01916         for (key,location) in self.indexlist:
01917             key = self.codeexpand(key)
01918             location = makefile(location)
01919             location = self.dirname + '/' + location
01920             print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
01921             print('<param name="Name" value="' + key + '">', end=' ', file=outfile)
01922             print('<param name="Local" value="' + location + '">', end=' ', file=outfile)
01923             print('</OBJECT>', file=outfile)
01924         print('</UL>', file=outfile)

Here is the call graph for this function:

def texi2html.HTMLHelp.dumpmenu (   self,
  menu,
  indent = 0,
  outfile = sys.stdout 
)

Definition at line 1890 of file texi2html.py.

01890 
01891     def dumpmenu(self, menu, indent=0, outfile=sys.stdout):
01892         if menu:
01893             currentnode = self.current
01894             if currentnode != self.topnode:    # XXX this is a hack
01895                 print(' '*indent + '<UL>', file=outfile)
01896                 indent += 2
01897             for item in menu:
01898                 menunode = self.getnode(item)
01899                 self.dumpnode(menunode,indent,outfile)
01900             if currentnode != self.topnode:    # XXX this is a hack
01901                 print(' '*indent + '</UL>', file=outfile)
01902                 indent -= 2

Here is the call graph for this function:

Here is the caller graph for this function:

def texi2html.HTMLHelp.dumpnode (   self,
  node,
  indent = 0,
  outfile = sys.stdout 
)

Definition at line 1865 of file texi2html.py.

01865 
01866     def dumpnode(self, node, indent=0, outfile=sys.stdout):
01867         if node:
01868             # Retrieve info for this node
01869             (nodename,next,prev,up,filename) = node
01870             self.current = nodename
01871 
01872             # Have we been dumped already?
01873             if nodename in self.dumped:
01874                 return
01875             self.dumped[nodename] = 1
01876 
01877             # Print info for this node
01878             print(' '*indent, end=' ', file=outfile)
01879             print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
01880             print('<param name="Name" value="' + nodename +'">', end=' ', file=outfile)
01881             print('<param name="Local" value="'+ filename +'">', end=' ', file=outfile)
01882             print('</OBJECT>', file=outfile)
01883 
01884             # Does this node have menu items?
01885             try:
01886                 menu = self.menudict[nodename]
01887                 self.dumpmenu(menu,indent+2,outfile)
01888             except KeyError:
01889                 pass

Here is the call graph for this function:

Here is the caller graph for this function:

def texi2html.HTMLHelp.dumpnodes (   self,
  outfile = sys.stdout 
)

Definition at line 1854 of file texi2html.py.

01854 
01855     def dumpnodes(self, outfile=sys.stdout):
01856         self.dumped = {}
01857         if self.nodelist:
01858             nodename, dummy, dummy, dummy, dummy = self.nodelist[0]
01859             self.topnode = nodename
01860 
01861         print('<UL>', file=outfile)
01862         for node in self.nodelist:
01863             self.dumpnode(node,0,outfile)
01864         print('</UL>', file=outfile)

Definition at line 1751 of file texi2html.py.

01751 
01752     def endmenu(self):
01753         pass

Definition at line 1754 of file texi2html.py.

01754 
01755     def finalize(self):
01756         if not self.helpbase:
01757             return
01758 
01759         # generate interesting filenames
01760         resultfile   = self.helpbase + '.chm'
01761         projectfile  = self.helpbase + '.hhp'
01762         contentfile  = self.helpbase + '.hhc'
01763         indexfile    = self.helpbase + '.hhk'
01764 
01765         # generate a reasonable title
01766         title        = self.helpbase
01767 
01768         # get the default topic file
01769         (topname,topnext,topprev,topup,topfile) = self.nodelist[0]
01770         defaulttopic = topfile
01771 
01772         # PROJECT FILE
01773         try:
01774             fp = open(projectfile,'w')
01775             print('[OPTIONS]', file=fp)
01776             print('Auto Index=Yes', file=fp)
01777             print('Binary TOC=No', file=fp)
01778             print('Binary Index=Yes', file=fp)
01779             print('Compatibility=1.1', file=fp)
01780             print('Compiled file=' + resultfile + '', file=fp)
01781             print('Contents file=' + contentfile + '', file=fp)
01782             print('Default topic=' + defaulttopic + '', file=fp)
01783             print('Error log file=ErrorLog.log', file=fp)
01784             print('Index file=' + indexfile + '', file=fp)
01785             print('Title=' + title + '', file=fp)
01786             print('Display compile progress=Yes', file=fp)
01787             print('Full-text search=Yes', file=fp)
01788             print('Default window=main', file=fp)
01789             print('', file=fp)
01790             print('[WINDOWS]', file=fp)
01791             print('main=,"' + contentfile + '","' + indexfile
01792                         + '","","",,,,,0x23520,222,0x1046,[10,10,780,560],'
01793                         '0xB0000,,,,,,0', file=fp)
01794             print('', file=fp)
01795             print('[FILES]', file=fp)
01796             print('', file=fp)
01797             self.dumpfiles(fp)
01798             fp.close()
01799         except IOError as msg:
01800             print(projectfile, ':', msg)
01801             sys.exit(1)
01802 
01803         # CONTENT FILE
01804         try:
01805             fp = open(contentfile,'w')
01806             print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
01807             print('<!-- This file defines the table of contents -->', file=fp)
01808             print('<HTML>', file=fp)
01809             print('<HEAD>', file=fp)
01810             print('<meta name="GENERATOR"'
01811                         'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
01812             print('<!-- Sitemap 1.0 -->', file=fp)
01813             print('</HEAD>', file=fp)
01814             print('<BODY>', file=fp)
01815             print('   <OBJECT type="text/site properties">', file=fp)
01816             print('     <param name="Window Styles" value="0x800025">', file=fp)
01817             print('     <param name="comment" value="title:">', file=fp)
01818             print('     <param name="comment" value="base:">', file=fp)
01819             print('   </OBJECT>', file=fp)
01820             self.dumpnodes(fp)
01821             print('</BODY>', file=fp)
01822             print('</HTML>', file=fp)
01823             fp.close()
01824         except IOError as msg:
01825             print(contentfile, ':', msg)
01826             sys.exit(1)
01827 
01828         # INDEX FILE
01829         try:
01830             fp = open(indexfile  ,'w')
01831             print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
01832             print('<!-- This file defines the index -->', file=fp)
01833             print('<HTML>', file=fp)
01834             print('<HEAD>', file=fp)
01835             print('<meta name="GENERATOR"'
01836                         'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
01837             print('<!-- Sitemap 1.0 -->', file=fp)
01838             print('</HEAD>', file=fp)
01839             print('<BODY>', file=fp)
01840             print('<OBJECT type="text/site properties">', file=fp)
01841             print('</OBJECT>', file=fp)
01842             self.dumpindex(fp)
01843             print('</BODY>', file=fp)
01844             print('</HTML>', file=fp)
01845             fp.close()
01846         except IOError as msg:
01847             print(indexfile  , ':', msg)
01848             sys.exit(1)

Here is the call graph for this function:

def texi2html.HTMLHelp.getnode (   self,
  nodename 
)

Definition at line 1903 of file texi2html.py.

01903 
01904     def getnode(self, nodename):
01905         try:
01906             index = self.nodeindex[nodename]
01907             return self.nodelist[index]
01908         except KeyError:
01909             return None
01910         except IndexError:
01911             return None

Here is the caller graph for this function:

def texi2html.HTMLHelp.index (   self,
  args,
  nodename 
)

Definition at line 1745 of file texi2html.py.

01745 
01746     def index(self, args, nodename):
01747         self.indexlist.append((args,nodename))

Here is the caller graph for this function:

def texi2html.HTMLHelp.menuitem (   self,
  nodename 
)

Definition at line 1737 of file texi2html.py.

01737 
01738     def menuitem(self,nodename):
01739         menu = self.menudict[self.current]
01740         menu.append(nodename)
01741 


Member Data Documentation

tuple texi2html.HTMLHelp.codeprog = re.compile('@code{(.*?)}') [static]

Definition at line 1707 of file texi2html.py.

Definition at line 1713 of file texi2html.py.

Definition at line 1720 of file texi2html.py.

Definition at line 1711 of file texi2html.py.

Definition at line 1722 of file texi2html.py.

Definition at line 1718 of file texi2html.py.

Definition at line 1710 of file texi2html.py.

Definition at line 1714 of file texi2html.py.

Definition at line 1719 of file texi2html.py.

Definition at line 1721 of file texi2html.py.

Definition at line 1717 of file texi2html.py.

Definition at line 1715 of file texi2html.py.

Definition at line 1716 of file texi2html.py.

Definition at line 1712 of file texi2html.py.

Definition at line 1858 of file texi2html.py.


The documentation for this class was generated from the following file: