Modules | Files | Inheritance Tree | Inheritance Graph | Name Index | Config
File: Synopsis/Formatter/HTML/InheritanceTree.py
    1| # $Id: InheritanceTree.py,v 1.10 2002/07/04 06:43:18 chalky Exp $
    2| #
    3| # This file is a part of Synopsis.
    4| # Copyright (C) 2000, 2001 Stephen Davies
    5| # Copyright (C) 2000, 2001 Stefan Seefeld
    6| #
    7| # Synopsis is free software; you can redistribute it and/or modify it
    8| # under the terms of the GNU General Public License as published by
    9| # the Free Software Foundation; either version 2 of the License, or
   10| # (at your option) any later version.
   11| #
   12| # This program is distributed in the hope that it will be useful,
   13| # but WITHOUT ANY WARRANTY; without even the implied warranty of
   14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15| # General Public License for more details.
   16| #
   17| # You should have received a copy of the GNU General Public License
   18| # along with this program; if not, write to the Free Software
   19| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   20| # 02111-1307, USA.
   21| #
   22| # $Log: InheritanceTree.py,v $
   23| # Revision 1.10  2002/07/04 06:43:18  chalky
   24| # Improved support for absolute references - pages known their full path.
   25| #
   26| # Revision 1.9  2001/07/05 05:39:58  stefan
   27| # advanced a lot in the refactoring of the HTML module.
   28| # Page now is a truely polymorphic (abstract) class. Some derived classes
   29| # implement the 'filename()' method as a constant, some return a variable
   30| # dependent on what the current scope is...
   31| #
   32| # Revision 1.8  2001/07/05 02:08:35  uid20151
   33| # Changed the registration of pages to be part of a two-phase construction
   34| #
   35| # Revision 1.7  2001/06/28 07:22:18  stefan
   36| # more refactoring/cleanup in the HTML formatter
   37| #
   38| # Revision 1.6  2001/06/26 04:32:16  stefan
   39| # A whole slew of changes mostly to fix the HTML formatter's output generation,
   40| # i.e. to make the output more robust towards changes in the layout of files.
   41| #
   42| # the rpm script now works, i.e. it generates source and binary packages.
   43| #
   44| # Revision 1.5  2001/02/06 05:13:05  chalky
   45| # Fixes
   46| #
   47| # Revision 1.4  2001/02/05 05:26:24  chalky
   48| # Graphs are separated. Misc changes
   49| #
   50| # Revision 1.3  2001/02/01 18:36:55  chalky
   51| # Moved TOC out to Formatter/TOC.py
   52| #
   53| # Revision 1.2  2001/02/01 15:23:24  chalky
   54| # Copywritten brown paper bag edition.
   55| #
   56| #
   57| 
   58| import os
   59| from Synopsis.Core import Util
   60| 
   61| import core, Page
   62| from core import config
   63| from Tags import *
   64| 
   65| class InheritanceTree(Page.Page):
   66|     def __init__(self, manager):
   67|         Page.Page.__init__(self, manager)
   68| 
   69|     def filename(self): return config.files.nameOfSpecial('InheritanceTree')
   70|     def title(self): return 'Synopsis - Class Hierarchy'
   71| 
   72|     def register(self):
   73|         self.manager.addRootPage(self.filename(), 'Inheritance Tree', 'main', 1)
   74|  
   75|     def process(self, start):
   76|         """Creates a file with the inheritance tree"""
   77|         roots = config.classTree.roots()
   78|         self.start_file()
   79|         self.write(self.manager.formatHeader(self.filename()))
   80|         self.write(entity('h1', "Inheritance Tree"))
   81|         self.write('<ul>')
   82|         map(self.processClassInheritance, map(lambda a,b=start.name():(a,b), roots))
   83|         self.write('</ul>')
   84|         self.end_file()   
   85| 
   86|     def processClassInheritance(self, args):
   87|         name, rel_name = args
   88|         self.write('<li>')
   89|         self.write(self.reference(name, rel_name))
   90|         parents = config.classTree.superclasses(name)
   91|         if parents:
   92|             self.write(' <i>(%s)</i>'%string.join(map(Util.ccolonName, parents), ", "))
   93|         subs = config.classTree.subclasses(name)
   94|         if subs:
   95|             self.write('<ul>')
   96|             map(self.processClassInheritance, map(lambda a,b=name:(a,b), subs))
   97|             self.write('</ul>\n')
   98|         self.write('</li>')
   99| 
  100| htmlPageClass = InheritanceTree