[Happydoc-checkins] CVS: HappyDoc3/happydoclib/docset base.py,NONE,1.1
Brought to you by:
doughellmann,
krlosaqp
From: Doug H. <dou...@pr...> - 2002-11-18 13:43:40
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv7098/happydoclib/docset Added Files: base.py Log Message: Base classes for docsets. --- NEW FILE: base.py --- #!/usr/bin/env python # # $Id: base.py,v 1.1 2002/11/18 13:43:37 doughellmann Exp $ # # Copyright 2002 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Base class for documentation sets. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: base.py,v $', 'rcs_id' : '$Id: base.py,v 1.1 2002/11/18 13:43:37 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 17-Nov-2002 13:17:17 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/11/18 13:43:37 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import os # # Import Local modules # import happydoclib from happydoclib.trace import trace # # Module # class DocSet: """Basic Documentation Set. Parameters includeComments -- Boolean. False means to skip the comment parsing step in the parser. Default is True. includePrivateNames -- Boolean. False means to ignore names beginning with _. Default is True. """ def __init__(self, scanner, title, outputDirectory, includeComments=1, includePrivateNames=1, statusMessageFunc=None, extraParameters={}, ): """Basic Documentation Set Parameters scanner -- A directory tree scanner. title -- the title of the documentation set outputDirectory -- The base directory for writing the output files. includeComments -- Boolean. False means to skip the comment parsing step in the parser. Default is True. includePrivateNames -- Boolean. False means to ignore names beginning with _. Default is True. statusMessageFunc -- function which will print a status message for the user extraParameters -- Dictionary containing parameters specified on the command line by the user. """ trace.into('DocSet', '__init__', scanner=scanner, title=title, outputDirectory=outputDirectory, includeComments=includeComments, includePrivateNames=includePrivateNames, ## formatter=formatter, statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, ) # # Store parameters # self.scanner = scanner self.title = title self.output_directory = outputDirectory self.include_comments = includeComments self.include_private_names = includePrivateNames ## self.formatter = formatter self.status_message_func = statusMessageFunc self.statusMessage('Initializing documentation set %s' % title) self.statusMessage('NEED TO HANDLE extraParameters in DocSet') trace.outof() return def statusMessage(self, message='', verboseLevel=1): "Print a status message for the user." if self.status_message_func: self.status_message_func(message, verboseLevel) return def writeCB(self, packageTreeNode): raise NotImplementedError('No writeCB defined for %s' % self.__class__.__name__) def write(self): package_trees = self.scanner.getPackageTrees() for package_tree in package_trees: package_tree.walk(self.writeCB) return class MultiFileDocSet(DocSet): """Base class for documentation sets which write to multiple files. """ def getOutputFilenameForPackageTreeNode(self, packageTreeNode): """Returns a filename where documentation for packageTreeNode should be written. The filename will be in the output directory, possibly in a subdirectory based on the path from the input root to the input file. For example:: input_directory : /foo/input containing : /foo/input/bar.py output_directory : /foo/output results in : /foo/output/input/bar.py """ # # Get the path to the node from the root of the scanned # tree. # node_path = packageTreeNode.getPath() # # Get the input filename, relative to the root of the input. # filename = apply(os.path.join, node_path) # # Add the output directory to the front of the input # filename. # output_filename = os.path.join(self.output_directory, filename) # # Normalize the path, in case it includes /./ and the like. # normalized_output_filename = os.path.normpath(output_filename) return normalized_output_filename |