happydoc-checkins Mailing List for HappyDoc (Page 5)
Brought to you by:
doughellmann,
krlosaqp
You can subscribe to this list here.
2002 |
Jan
(3) |
Feb
(40) |
Mar
(1) |
Apr
|
May
(12) |
Jun
(4) |
Jul
|
Aug
(39) |
Sep
|
Oct
(4) |
Nov
(49) |
Dec
(78) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(54) |
Feb
|
Mar
(41) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
From: Doug H. <dou...@us...> - 2003-01-01 14:06:42
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docstring In directory sc8-pr-cvs1:/tmp/cvs-serv29971/happydoclib/docstring Modified Files: docstring_StructuredText.py Log Message: Change trace level for this module. Index: docstring_StructuredText.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/docstring_StructuredText.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** docstring_StructuredText.py 17 Nov 2002 00:26:19 -0000 1.1.1.1 --- docstring_StructuredText.py 1 Jan 2003 14:06:38 -0000 1.2 *************** *** 67,70 **** --- 67,72 ---- # + TRACE_LEVEL=3 + def entryPoint(): "Return information about this module to the dynamic loader." *************** *** 267,270 **** --- 269,273 ---- args=args, namedArgs=namedArgs, + outputLevel=TRACE_LEVEL, ) self._testOutputFormat(outputFormat) *************** *** 274,278 **** namedArgs, ) ! happydoclib.TRACE.write('AFTER QUOTING="%s"' % html_quoted) # # Replace form: ".*": --- 277,282 ---- namedArgs, ) ! happydoclib.TRACE.write('AFTER QUOTING="%s"' % html_quoted, ! outputLevel=TRACE_LEVEL) # # Replace form: ".*": *************** *** 285,293 **** '"\\1":', html_quoted) ! happydoclib.TRACE.write('AFTER FIXUP="%s"' % html_quoted) ! happydoclib.TRACE.outof() return html_quoted ! happydoclib.TRACE.outof() return inputText --- 289,298 ---- '"\\1":', html_quoted) ! happydoclib.TRACE.write('AFTER FIXUP="%s"' % html_quoted, ! outputLevel=TRACE_LEVEL) ! happydoclib.TRACE.outof(outputLevel=TRACE_LEVEL) return html_quoted ! happydoclib.TRACE.outof(outputLevel=TRACE_LEVEL) return inputText |
From: Doug H. <dou...@us...> - 2003-01-01 14:06:25
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv29916/happydoclib/docset Modified Files: tests.py Log Message: API change. Index: tests.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/tests.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tests.py 29 Dec 2002 17:33:31 -0000 1.4 --- tests.py 1 Jan 2003 14:06:21 -0000 1.5 *************** *** 147,151 **** ) try: ! docset.writeFileHeader(None) except NotImplementedError: pass --- 147,151 ---- ) try: ! docset.writeFileHeader(None, None) except NotImplementedError: pass |
From: Doug H. <dou...@us...> - 2003-01-01 14:06:09
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv29836/happydoclib/docset Modified Files: test_docset_MultiHTMLFile.py Log Message: Tests for HREF and output filename calculations. Index: test_docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_docset_MultiHTMLFile.py 28 Dec 2002 16:43:09 -0000 1.8 --- test_docset_MultiHTMLFile.py 1 Jan 2003 14:06:05 -0000 1.9 *************** *** 265,269 **** def setUp(self): - import os cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') --- 265,268 ---- *************** *** 283,290 **** target = self.expected_tree['levelOne']['levelTwo']['two.py'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] ! href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! '.', ) return --- 282,289 ---- target = self.expected_tree['levelOne']['levelTwo']['two.py'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] ! href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! 'two.html', ) return *************** *** 293,300 **** target = self.expected_tree['levelOne'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] ! href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! '..', ) return --- 292,299 ---- target = self.expected_tree['levelOne'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] ! href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! '../../levelOne/index.html', ) return *************** *** 310,313 **** --- 309,403 ---- return + def testClassFromModuleHREF(self): + target = self.expected_tree['levelOne']['one.py']['One'] + start = self.expected_tree['levelOne']['one.py'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + 'one.py/One.html', + ) + return + + def testModuleFromClassHREF(self): + target = self.expected_tree['levelOne']['one.py'] + start = self.expected_tree['levelOne']['one.py']['One'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + '../one.html', + ) + return + + def testParentPackageFromClassHREF(self): + target = self.expected_tree['levelOne'] + start = self.expected_tree['levelOne']['levelTwo']['two.py']['Two'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + '../../../levelOne/index.html', + ) + return + + def testParentModuleFromClassHREF(self): + target = self.expected_tree['levelOne']['one.py'] + start = self.expected_tree['levelOne']['levelTwo']['two.py']['Two'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + '../../one.html', + ) + return + + def testClassSameModuleHREF(self): + target = self.expected_tree['levelOne']['one.py']['One'] + start = self.expected_tree['levelOne']['one.py']['AnotherOne'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + 'One.html', + ) + return + + def testClassSameModuleCLAHREF(self): + cwd = os.getcwd() + input_dir = os.path.join(cwd, 'happydoclib') + scanner = Scanner([input_dir]) + + trees = scanner.getPackageTrees() + expected_tree = trees[0] + + docset = MultiHTMLFileDocSet(scanner, + 'Testing', + '/tmp/foo', + ) + + target = expected_tree['CommandLineApp.py']['CommandLineApp'] + start = expected_tree['CommandLineApp.py']['TestApp'] + + href = docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + 'CommandLineApp.html', + ) + + + target = expected_tree['CommandLineApp.py']['CommandLineApp'] + start = expected_tree['CommandLineApp.py'] + + href = docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + 'CommandLineApp.py/CommandLineApp.html', + ) + return + + def testClassOtherModuleHREF(self): + target = self.expected_tree['levelOne']['one.py']['One'] + start = self.expected_tree['levelOne']['ignoreme.py']['IgnoreThisClass'] + + href = self.docset._computeRelativeHREF(start, target) + self.failUnlessEqual(href, + '../one.py/One.html', + ) + return + def testModuleParentDirHREF(self): target = self.expected_tree['levelOne']['one.py'] *************** *** 326,334 **** href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! '..', ) return if __name__ == '__main__': --- 416,461 ---- href = self.docset._computeRelativeHREF(start, target) self.failUnlessEqual(href, ! '../../levelOne/index.html', ) return + + class GetOutputFilenameTestCase(unittest.TestCase): + def setUp(self): + import os + cwd = os.getcwd() + input_dir = os.path.join(cwd, 'TestCases/testScanner') + scanner = Scanner([input_dir]) + + trees = scanner.getPackageTrees() + expected_tree = trees[0] + self.expected_tree = expected_tree + + self.docset = MultiHTMLFileDocSet(scanner, + 'Testing', + '/tmp/foo', + ) + return + + def testModule(self): + target = self.expected_tree['levelOne']['one.py'] + + filename = self.docset.getOutputFilenameForPackageTreeNode(target) + self.failUnlessEqual( + filename, + os.path.join('/tmp/foo', 'testScanner', 'levelOne', 'one.html'), + ) + return + + def testClass(self): + target = self.expected_tree['levelOne']['one.py']['One'] + + filename = self.docset.getOutputFilenameForPackageTreeNode(target) + self.failUnlessEqual( + filename, + os.path.join('/tmp/foo', 'testScanner', 'levelOne', 'one.py', 'One.html'), + ) + return if __name__ == '__main__': |
From: Doug H. <dou...@us...> - 2003-01-01 14:05:32
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv29704/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Add breadcrumbs to the file header. Add special case for calculating HREF values to classes from their owning module. Fix handling of base class information so that links always point to the right place when we know where the base class is defined. Use the new application/x-class mimetype with PackageTree.getSubNodes() to find classes, instead of poking around inside the module_info part of the node. Document classes to their own file when we walk() to a class node. Do not generate the files when processing the Python file itself. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** docset_MultiHTMLFile.py 29 Dec 2002 17:33:17 -0000 1.13 --- docset_MultiHTMLFile.py 1 Jan 2003 14:05:28 -0000 1.14 *************** *** 76,79 **** --- 76,81 ---- # + TRACE_LEVEL=2 + def entryPoint(): "Return info about this module to the dynamic loader." *************** *** 92,96 **** levelTwoHeadingForegroundColor='#000000' codeForegroundColor='#000088' ! def getOutputFilenameForPackageTreeNode(self, packageTreeNode, includePath=1): """Returns a filename where documentation for packageTreeNode should be written. --- 94,98 ---- levelTwoHeadingForegroundColor='#000000' codeForegroundColor='#000088' ! def getOutputFilenameForPackageTreeNode(self, packageTreeNode, includePath=1): """Returns a filename where documentation for packageTreeNode should be written. *************** *** 108,112 **** results in : /foo/output/input/bar.py """ ! trace.into('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode') filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode( self, --- 110,115 ---- results in : /foo/output/input/bar.py """ ! trace.into('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode', ! outputLevel=TRACE_LEVEL) filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode( self, *************** *** 122,130 **** else: # ! # This is a file. # filename_with_extension = '%s.html' % filename ! trace.outof(filename_with_extension) return filename_with_extension --- 125,133 ---- else: # ! # This is not a directory (file, module, class, etc.). # filename_with_extension = '%s.html' % filename ! trace.outof(filename_with_extension, outputLevel=TRACE_LEVEL) return filename_with_extension *************** *** 144,148 **** return output_name ! def writeFileHeader(self, output, title='', subtitle=''): """Given an open output stream, write a header using the title and subtitle. """ --- 147,194 ---- return output_name ! def _writeBreadcrumbs(self, output, sourceNode, breadcrumbNode): ! """Write breadcrumb links from the root down to packageTreeNode. ! ! This method actually handles the recursion. ! """ ! if not breadcrumbNode: ! return ! ! # ! # Write the rest of the breadcrumbs ! # ! self._writeBreadcrumbs(output, sourceNode, breadcrumbNode.getParent()) ! ! # ! # Write our breadcrumb ! # ! if breadcrumbNode.getName() != '__init__.py': ! if sourceNode == breadcrumbNode: ! ref = breadcrumbNode.getName() ! else: ! ref = self._getAnchorTagForPackageTreeNode(sourceNode, ! breadcrumbNode, ! ) ! output.write('/ %s '% ref) ! output.write('\n') ! ! return ! ! def writeBreadcrumbs(self, output, packageTreeNode): ! """Write breadcrumb links from the root down to packageTreeNode. ! """ ! # ! # Begin breadcrumbs. ! # ! output.write('<!-- breadcrumbs -->\n') ! output.write('<p>\n') ! ! self._writeBreadcrumbs(output, packageTreeNode, packageTreeNode) ! ! output.write('</p>\n') ! output.write('\n<!-- /breadcrumbs -->\n') ! return ! ! def writeFileHeader(self, output, packageTreeNode, title='', subtitle=''): """Given an open output stream, write a header using the title and subtitle. """ *************** *** 162,167 **** <body bgcolor="%(bgcolor)s"> ! <p><i><a href="%(root)s">Table of Contents</a></i></p> <table border="0" cellpadding="5" cellspacing="0" width="100%%"> --- 208,217 ---- <body bgcolor="%(bgcolor)s"> + ''' % locals()) ! if packageTreeNode.getParent() is not None: ! self.writeBreadcrumbs(output, packageTreeNode) ! ! output.write(''' <table border="0" cellpadding="5" cellspacing="0" width="100%%"> *************** *** 186,190 **** """Given an open output stream, write a footer using the title and subtitle. """ - root = 'Need URL for root' date_str = time.ctime(time.time()) app_version = happydoclib.cvsProductVersion() --- 236,239 ---- *************** *** 197,202 **** <hr> - <p><i><a href="%(root)s">Table of Contents</a></i></p> - <font size="-2"><i>This document was automatically generated %(date_str)s by <a --- 246,249 ---- *************** *** 252,258 **** """Compute the HREF to point from the output file of source to destination. """ relative_path = source.getPathToNode(destination) if not relative_path: ! return '.' destination_name = destination.getName() --- 299,336 ---- """Compute the HREF to point from the output file of source to destination. """ + trace.into('MultiHTMLFileDocSet', '_computeRelativeHREF', + source=source.getName(), + destination=destination.getName(), + outputLevel=TRACE_LEVEL, + ) + relative_path = source.getPathToNode(destination) + trace.writeVar(relative_path=relative_path, + outputLevel=TRACE_LEVEL) if not relative_path: ! output_name = self.getOutputFilenameForPackageTreeNode( ! destination, ! includePath=0, ! ) ! trace.outof(output_name, outputLevel=TRACE_LEVEL) ! return output_name ! ! destination_mimetype = destination.getMimeType()[0] ! source_mimetype = source.getMimeType()[0] ! ! # ! # Pointing to a class defined by source module. ! # ! if ( (len(relative_path) == 1) ! and ! (destination_mimetype == 'application/x-class') ! and ! (source_mimetype == 'text/x-python') ! and ! (source.get(destination.getName()) is not None) ! ): ! trace.write('adding source to relative path', ! outputLevel=TRACE_LEVEL) ! relative_path = (source.getName(), relative_path[0]) destination_name = destination.getName() *************** *** 265,268 **** --- 343,351 ---- includePath=0, ) + trace.write('Replacing %s with %s' % (relative_path[-1], + output_name, + ), + outputLevel=TRACE_LEVEL, + ) relative_path = relative_path[:-1] + (output_name,) *************** *** 277,281 **** href = '/'.join(relative_path) ! #print href return href --- 360,364 ---- href = '/'.join(relative_path) ! trace.outof(href, outputLevel=TRACE_LEVEL) return href *************** *** 400,403 **** --- 483,487 ---- trace.into('MultiHTMLFile', 'writeTOCFile', packageTreeNode=packageTreeNode, + outputLevel=TRACE_LEVEL, ) *************** *** 405,408 **** --- 489,493 ---- output = self.openOutput(output_filename, + packageTreeNode, title=self.title, subtitle=packageTreeNode.getRelativeFilename(), *************** *** 468,472 **** self.closeOutput(output) ! trace.outof() return --- 553,557 ---- self.closeOutput(output) ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 827,857 **** return ! def _getBaseClassTree(self, packageTreeNode, className): ! try: ! class_info = packageTreeNode.module_info.getClassInfo(className) ! except KeyError: base_class_names = [] else: ! base_class_names = self._filterNames(class_info.getBaseClassNames()) ! base_class_trees = [] for base_class_name in base_class_names: ! base_class_tree = self._getBaseClassTree(packageTreeNode, ! base_class_name, ! ) base_class_trees.append( base_class_tree ) ! try: ! symbol_info = packageTreeNode.module_info.getClassInfo(className) ! except KeyError: ! ref = className ! else: ! symbol_output_name = self.getOutputFilenameForSymbol( ! packageTreeNode, ! className, ! includePath=0, ) ! ref = '<a href="%s">%s</a>' % (symbol_output_name, className) ! return (ref, base_class_trees) --- 912,966 ---- return ! def _getBaseClassTree(self, linkSource, moduleTreeNode, classTreeNode, className): ! trace.into('MultiHTMLFile', '_getBaseClassTree', ! linkSource=linkSource.getName(), ! moduleTreeNode=moduleTreeNode.getName(), ! classTreeNode=(classTreeNode and classTreeNode.getName()), ! the_className=className, ! outputLevel=TRACE_LEVEL, ! ) ! ! # ! # Find the list of base classes of the current class ! # ! if classTreeNode is None: base_class_names = [] else: ! try: ! class_info = classTreeNode.code_info ! except AttributeError: ! base_class_names = [] ! else: ! base_class_names = self._filterNames(class_info.getBaseClassNames()) ! ! # ! # Build the subtrees from our base classes ! # base_class_trees = [] for base_class_name in base_class_names: ! base_class_node = moduleTreeNode.findNodeFromDottedName( ! base_class_name, ! ) ! base_class_tree = self._getBaseClassTree( ! linkSource, ! moduleTreeNode, ! base_class_node, ! base_class_name, ! ) base_class_trees.append( base_class_tree ) ! # ! # Set up the reference for this node ! # ! if classTreeNode: ! ref = self._getAnchorTagForPackageTreeNode( ! source=linkSource, ! destination=classTreeNode, ! title=className, ) ! else: ! ref = className ! ! trace.outof(outputLevel=TRACE_LEVEL) return (ref, base_class_trees) *************** *** 863,867 **** def writeBaseClassNames(self, output, packageTreeNode, classInfo): ! base_class_tree = self._getBaseClassTree(packageTreeNode, classInfo.getName()) #self.writeList(output, base_class_names) output.write('<p>\n') --- 972,981 ---- def writeBaseClassNames(self, output, packageTreeNode, classInfo): ! base_class_tree = self._getBaseClassTree( ! linkSource=packageTreeNode, ! moduleTreeNode=packageTreeNode.getParent(), ! classTreeNode=packageTreeNode, ! className=classInfo.getName(), ! ) #self.writeList(output, base_class_names) output.write('<p>\n') *************** *** 870,877 **** return ! def writeOneClassToOutput(self, output, packageTreeNode, className): """Writes information about one class to the output stream. """ ! class_info = packageTreeNode.module_info.getClassInfo(className) # --- 984,991 ---- return ! def writeOneClassToOutput(self, output, packageTreeNode): """Writes information about one class to the output stream. """ ! class_info = packageTreeNode.code_info # *************** *** 915,919 **** """Write descriptions of all of the classes to the output stream. """ ! class_names = self._filterNames(packageTreeNode.module_info.getClassNames()) if self.sort_names: --- 1029,1038 ---- """Write descriptions of all of the classes to the output stream. """ ! #class_names = self._filterNames(packageTreeNode.module_info.getClassNames()) ! classes = packageTreeNode.getSubNodes('application/x-class') ! class_map = {} ! for c in classes: ! class_map[c.getName()] = c ! class_names = self._filterNames(class_map.keys()) if self.sort_names: *************** *** 923,932 **** for class_name in class_names: ! symbol_output_name = self.getOutputFilenameForSymbol( ! packageTreeNode, ! class_name, ! includePath=0, ) - ref = '<a href="%s">%s</a>' % (symbol_output_name, class_name) class_info = packageTreeNode.module_info.getClassInfo(class_name) class_info_summary, class_info_format = class_info.getSummaryAndFormat() --- 1042,1060 ---- for class_name in class_names: ! #symbol_output_name = self.getOutputFilenameForSymbol( ! # packageTreeNode, ! # class_name, ! # includePath=0, ! # ) ! class_node = class_map[class_name] ! #symbol_output_name = self.getOutputFilenameForPackageTreeNode( ! # class_node, ! # ) ! #ref = '<a href="%s">%s</a>' % (symbol_output_name, class_name) ! ref = self._getAnchorTagForPackageTreeNode( ! source=packageTreeNode, ! destination=class_node, ! title=class_name, ) class_info = packageTreeNode.module_info.getClassInfo(class_name) class_info_summary, class_info_format = class_info.getSummaryAndFormat() *************** *** 938,947 **** return ! def writeClassesToOutput(self, output, packageTreeNode): ! """Writes information about classes in this module to the output stream. """ ! class_names = self._filterNames(packageTreeNode.module_info.getClassNames()) ! if not class_names: ! return # --- 1066,1075 ---- return ! def writePythonFileInfoToOutput(self, output, packageTreeNode): ! """Writes parts of the Python file information to the output stream. """ ! self.writePythonFileImportsToOutput(output, packageTreeNode) ! self.writeFunctionsToOutput(output, packageTreeNode) ! #self.writeClassesToOutput(output, packageTreeNode) # *************** *** 950,996 **** self.writeClassListForModule(output, packageTreeNode) - # - # Document each class in its own file - # - - for class_name in class_names: - - # - # Open a new output stream for the class. - # - class_output_name = self.getOutputFilenameForSymbol( - packageTreeNode, - class_name, - includePath=1, - ) - - class_output = self.openOutput( - class_output_name, - title=self.title, - subtitle='Class: %s' % class_name, - ) - - # - # Write class documentation - # - self.writeOneClassToOutput( - class_output, - packageTreeNode, - class_name, - ) - - # - # Close the class' output stream - # - self.closeOutput(class_output) - - return - - def writePythonFileInfoToOutput(self, output, packageTreeNode): - """Writes parts of the Python file information to the output stream. - """ - self.writePythonFileImportsToOutput(output, packageTreeNode) - self.writeFunctionsToOutput(output, packageTreeNode) - self.writeClassesToOutput(output, packageTreeNode) return --- 1078,1081 ---- *************** *** 1001,1004 **** --- 1086,1090 ---- trace.into('MultiHTMLFileDocSet', 'processPythonFile', packageTreeNode=packageTreeNode, + outputLevel=TRACE_LEVEL, ) *************** *** 1010,1015 **** # be handled as part of the package. # ! trace.write('skipping __init__.py') ! trace.outof() return --- 1096,1101 ---- # be handled as part of the package. # ! trace.write('skipping __init__.py', outputLevel=TRACE_LEVEL) ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 1024,1027 **** --- 1110,1114 ---- output = self.openOutput(output_filename, + packageTreeNode, title=self.title, subtitle=packageTreeNode.getRelativeFilename(), *************** *** 1040,1043 **** self.closeOutput(output) ! trace.outof() return --- 1127,1168 ---- self.closeOutput(output) ! trace.outof(outputLevel=TRACE_LEVEL) ! return ! ! def processPythonClass(self, packageTreeNode): ! """Writes information about classes in this module to the output stream. ! """ ! #print 'Processing class: %s' % packageTreeNode.getName() ! # ! # Open a new output stream for the class. ! # ! #class_output_name = self.getOutputFilenameForSymbol( ! # packageTreeNode, ! # class_name, ! # includePath=1, ! # ) ! class_output_name = self.getOutputFilenameForPackageTreeNode( ! packageTreeNode, ! ) ! #print ' output file:', class_output_name ! ! class_output = self.openOutput( ! class_output_name, ! packageTreeNode, ! title=self.title, ! subtitle='Class: %s' % packageTreeNode.getName(), ! ) ! ! # ! # Write class documentation ! # ! self.writeOneClassToOutput( ! class_output, ! packageTreeNode, ! ) ! ! # ! # Close the class' output stream ! # ! self.closeOutput(class_output) return |
From: Doug H. <dou...@us...> - 2003-01-01 14:00:44
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv28698/happydoclib/docset Modified Files: base.py Log Message: Always create the directory containing an output file before trying to open the file for writing. Add a default handler for the application/x-class mimetype. Pass the PackageTree instance to openOutput() so it can be used to generate header information. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** base.py 29 Dec 2002 18:35:48 -0000 1.13 --- base.py 1 Jan 2003 14:00:40 -0000 1.14 *************** *** 322,325 **** --- 322,326 ---- """Register a writer for the specified mimetype. """ + #print '%s -> %s' % (mimetype, writerName) self.mimetype_writer_mapping[mimetype] = writerName return *************** *** 353,356 **** --- 354,358 ---- ('application/x-directory' , 'processDirectory'), ('text/x-python' , 'processPythonFile'), + ('application/x-class' , 'processPythonClass'), ('text/plain' , 'processPlainTextFile'), ('text/x-structured' , 'processPlainTextFile'), *************** *** 487,491 **** raise NotImplementedError('writeTOCFile') ! def writeFileHeader(self, output, title='', subtitle=''): """Given an open output stream, write a header using the title and subtitle. --- 489,493 ---- raise NotImplementedError('writeTOCFile') ! def writeFileHeader(self, output, packageTreeNode, title='', subtitle=''): """Given an open output stream, write a header using the title and subtitle. *************** *** 501,505 **** raise NotImplementedError('writeFileFooter') ! def openOutput(self, name, title='', subtitle=''): """Open the output stream from the name. --- 503,507 ---- raise NotImplementedError('writeFileFooter') ! def openOutput(self, name, packageTreeNode, title='', subtitle=''): """Open the output stream from the name. *************** *** 507,512 **** subtitle. Returns the stream. """ f = open(name, 'wt') ! self.writeFileHeader(f, title=title, subtitle=subtitle) return f --- 509,519 ---- subtitle. Returns the stream. """ + + directory, basename = os.path.split(name) + if not os.path.exists(directory): + self.rmkdir(directory) + f = open(name, 'wt') ! self.writeFileHeader(f, packageTreeNode, title=title, subtitle=subtitle) return f *************** *** 609,612 **** --- 616,620 ---- output_file = self.openOutput( output_filename, + packageTreeNode, title=self.title, subtitle=packageTreeNode.getRelativeFilename(), |
From: Doug H. <dou...@us...> - 2003-01-01 13:49:15
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv26604/happydoclib Modified Files: test_scanner.py Log Message: Verify that classes are making it into the package tree. Index: test_scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_scanner.py 29 Dec 2002 18:35:14 -0000 1.10 --- test_scanner.py 1 Jan 2003 13:49:11 -0000 1.11 *************** *** 127,130 **** --- 127,144 ---- # + # Try for class in one.py + # + try: + class_one = module_one['One'] + except KeyError: + self.fail('Could not get One') + else: + # + # Make sure of the mimetype + # + mimetype = class_one.getMimeType() + self.failUnlessEqual(mimetype, ('application/x-class', None)) + + # # Try for README.txt # |
From: Doug H. <dou...@us...> - 2003-01-01 13:48:51
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv26521/happydoclib Modified Files: test_packagetree.py Log Message: Tests for new methods, new tests for existing methods which were broken. Index: test_packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_packagetree.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_packagetree.py 29 Dec 2002 18:35:14 -0000 1.1 --- test_packagetree.py 1 Jan 2003 13:48:47 -0000 1.2 *************** *** 104,107 **** --- 104,155 ---- return + + def testGetRelativeFilename(self): + scanner = Scanner(['TestCases/testScanner']) + + trees = scanner.getPackageTrees() + + expected_tree = trees[0] + + actual = expected_tree.getRelativeFilename() + expected = 'testScanner' + self.failUnlessEqual( + actual, + expected, + ) + + level_one = expected_tree['levelOne'] + actual = level_one.getRelativeFilename() + expected = os.path.join('testScanner', 'levelOne') + self.failUnlessEqual( + actual, + expected, + ) + + module_one = level_one['one.py'] + actual = module_one.getRelativeFilename() + expected = os.path.join('testScanner', 'levelOne', 'one.py') + self.failUnlessEqual( + actual, + expected, + ) + + class_one = module_one['One'] + actual = class_one.getRelativeFilename() + expected = os.path.join('testScanner', 'levelOne', 'one.py', 'One') + self.failUnlessEqual( + actual, + expected, + ) + + level_two = level_one['levelTwo'] + actual = level_two.getRelativeFilename() + expected = os.path.join('testScanner', 'levelOne', 'levelTwo') + self.failUnlessEqual( + actual, + expected, + ) + + return def testPackageTreePath(self): *************** *** 216,219 **** --- 264,364 ---- 'Parents do not match.') return + + class PackageTreeGetSubNodesTestCase(unittest.TestCase): + + def testGetTextSubNodes(self): + scanner = Scanner(['TestCases/testScanner']) + + trees = scanner.getPackageTrees() + + expected_tree = trees[0] + self.failUnlessEqual( + expected_tree.getName(), + 'testScanner', + 'First level tree got %s instead of testScanner' % expected_tree.getName(), + ) + + level_one = expected_tree['levelOne'] + + subnodes = level_one.getSubNodes('text/plain') + actual = len(subnodes) + names = [ subnode.getName() for subnode in subnodes ] + expected = 1 + self.failUnlessEqual( + actual, + expected, + 'Got %s subnodes (%s), expected %s' % (actual, + names, + expected, + ) + ) + + actual = subnodes[0].getName() + expected = 'README.txt' + self.failUnlessEqual(actual, expected) + + return + + def testGetHtmlSubNodes(self): + scanner = Scanner(['TestCases/testScanner']) + + trees = scanner.getPackageTrees() + + expected_tree = trees[0] + self.failUnlessEqual( + expected_tree.getName(), + 'testScanner', + 'First level tree got %s instead of testScanner' % expected_tree.getName(), + ) + + level_one = expected_tree['levelOne'] + + subnodes = level_one.getSubNodes('text/html') + actual = len(subnodes) + names = [ subnode.getName() for subnode in subnodes ] + expected = 1 + self.failUnlessEqual( + actual, + expected, + 'Got %s subnodes (%s), expected %s' % (actual, + names, + expected, + ) + ) + + actual = subnodes[0].getName() + expected = 'Existing.html' + self.failUnlessEqual(actual, expected) + + return + + def testGetPythonSubNodes(self): + scanner = Scanner(['TestCases/testScanner']) + + trees = scanner.getPackageTrees() + + expected_tree = trees[0] + self.failUnlessEqual( + expected_tree.getName(), + 'testScanner', + 'First level tree got %s instead of testScanner' % expected_tree.getName(), + ) + + level_one = expected_tree['levelOne'] + + subnodes = level_one.getSubNodes('text/x-python') + actual = len(subnodes) + names = [ subnode.getName() for subnode in subnodes ] + expected = 3 + self.failUnlessEqual( + actual, + expected, + 'Got %s subnodes (%s), expected %s' % (actual, + names, + expected, + ) + ) + + return *************** *** 247,250 **** --- 392,397 ---- self.failUnlessEqual(relative_path, ('..', + '..', + 'levelOne', ), ) *************** *** 281,284 **** --- 428,433 ---- self.failUnlessEqual(relative_path, ('..', + '..', + 'levelOne', ), ) *************** *** 343,346 **** --- 492,496 ---- input_dir = os.path.join(cwd, 'TestCases/testScanner') scanner = Scanner([input_dir]) + self.scanner = scanner trees = scanner.getPackageTrees() *************** *** 351,358 **** def _testFind(self, name, start, target): found = start.findNodeFromDottedName(name) ! if not found: ! self.fail('Did not find anything') self.failUnlessEqual(found, target) ! return def testFindSelf(self): --- 501,508 ---- def _testFind(self, name, start, target): found = start.findNodeFromDottedName(name) ! if found is None: ! self.fail('Did not find anything for %s' % name) self.failUnlessEqual(found, target) ! return found def testFindSelf(self): *************** *** 370,373 **** --- 520,530 ---- return + def testFindChildClass(self): + self._testFind('One', + self.expected_tree['levelOne']['one.py'], + self.expected_tree['levelOne']['one.py']['One'], + ) + return + def testFindSelfDotChild(self): self._testFind('levelOne.levelTwo', *************** *** 391,394 **** --- 548,558 ---- return + def testFindSiblingClass(self): + self._testFind('AnotherOne', + self.expected_tree['levelOne']['one.py']['One'], + self.expected_tree['levelOne']['one.py']['AnotherOne'], + ) + return + def testFindAunt(self): self._testFind('readme_from_readme', *************** *** 410,417 **** found = start.findNodeFromDottedName(name) ! if found: self.fail('Found something unexpected') return if __name__ == '__main__': unittest.main() --- 574,600 ---- found = start.findNodeFromDottedName(name) ! if found is not None: self.fail('Found something unexpected') return + def testFindModuleNameMatchesClassName(self): + cwd = os.getcwd() + input_dir = cwd + scanner = Scanner([input_dir], ['TestOutput', 'TestCases']) + self.scanner = scanner + + trees = scanner.getPackageTrees() + expected_tree = trees[0] + + hdl_package = expected_tree['happydoclib'] + cla_module = hdl_package['CommandLineApp.py'] + cla_class = cla_module['CommandLineApp'] + + name = 'happydoclib.CommandLineApp.CommandLineApp' + start = expected_tree['happydoclib']['CommandLineApp.py']['TestApp'] + + self._testFind(name, start, cla_class) + return + if __name__ == '__main__': unittest.main() |
From: Doug H. <dou...@us...> - 2003-01-01 13:48:12
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv26393/happydoclib Modified Files: scanner.py Log Message: API name change. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** scanner.py 29 Dec 2002 18:35:14 -0000 1.14 --- scanner.py 1 Jan 2003 13:48:08 -0000 1.15 *************** *** 115,119 **** # Parse # ! self._parsePackageTree() trace.outof(outputLevel=TRACE_LEVEL) --- 115,119 ---- # Parse # ! self.parsePackageTree() trace.outof(outputLevel=TRACE_LEVEL) *************** *** 124,128 **** return ! def _parsePackageTree(self): for package_tree in self.getPackageTrees(): package_tree.walk(self._parseOne) --- 124,128 ---- return ! def parsePackageTree(self): for package_tree in self.getPackageTrees(): package_tree.walk(self._parseOne) |
From: Doug H. <dou...@us...> - 2003-01-01 13:47:51
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv26299/happydoclib Modified Files: pluginloader.py Log Message: Docstring for exception class. Index: pluginloader.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/pluginloader.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pluginloader.py 29 Dec 2002 18:35:33 -0000 1.3 --- pluginloader.py 1 Jan 2003 13:47:47 -0000 1.4 *************** *** 73,76 **** --- 73,78 ---- class PluginException(Exception): + """Exception raised when any error occurs while loading a plugin. + """ def __init__(self, wrappedException, pluginName): |
From: Doug H. <dou...@us...> - 2003-01-01 13:47:27
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv26212/happydoclib Modified Files: packagetree.py Log Message: Add node types for code (classes, functions and methods). Modify the algorithm for getPathToNode() so that it returns something which can more directly be used to build a relative URL. This includes going one level higher than needed when accessing a directory and treating some nodes as special cases. Make the module name '*.py' lookup optional in the dotted name lookup. Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** packagetree.py 29 Dec 2002 18:35:14 -0000 1.1 --- packagetree.py 1 Jan 2003 13:47:22 -0000 1.2 *************** *** 57,60 **** --- 57,61 ---- import mimetypes import os + import pprint import re import UserDict *************** *** 149,152 **** --- 150,170 ---- self.module_info = docs + # + # Add classes to the tree + # + for class_name in self.module_info.getClassNames(): + class_tree = self.addSubNode(class_name, + nodeClass=ClassTree, + ) + + # + # Add functions to the tree + # + for function_name in self.module_info.getFunctionNames(): + function_tree = self.addSubNode(function_name, + nodeClass=FunctionTree, + ) + + trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 397,403 **** --- 415,427 ---- A '..' indicates moving up to the parent one level. """ + trace.into('PackageTree', 'getPathToNode', + otherNode=otherNode.getName(), + outputLevel=TRACE_LEVEL, + ) + my_path = self.getPath() other_path = otherNode.getPath() if my_path == other_path: + trace.outof((), outputLevel=TRACE_LEVEL) return () *************** *** 406,424 **** # while my_path and other_path and my_path[0] == other_path[0]: my_path = my_path[1:] other_path = other_path[1:] ! if self.items(): ! is_file = 0 ! else: ! is_file = 1 ! going_up = ('..',) * (len(my_path) - is_file) relative_path = going_up + other_path ! return relative_path ! def findNodeFromDottedName(self, dottedNodeName, tryParent=1): """Find the node referenced by the dotted name given. --- 430,484 ---- # while my_path and other_path and my_path[0] == other_path[0]: + trace.write('Removing %s from both paths' % my_path[0], + outputLevel=TRACE_LEVEL) my_path = my_path[1:] other_path = other_path[1:] + + trace.writeVar(my_path=my_path, + other_path=other_path, + outputLevel=TRACE_LEVEL, + ) ! if not other_path: ! # ! # Special Case: I am a child of the other node. ! # ! trace.write('source is child of dest', ! outputLevel=TRACE_LEVEL) ! if self.getMimeType()[0] == 'application/x-directory': ! is_dir = 1 ! else: ! is_dir = 0 ! trace.writeVar(is_dir=is_dir, ! outputLevel=TRACE_LEVEL) ! going_up = ('..',) * (len(my_path) + is_dir) ! other_path = (otherNode.getName(),) ! ! else: ! # ! # Either a parent or off in another branch of the ! # tree. ! # ! if self.getMimeType()[0] == 'application/x-directory': ! is_file = 0 ! else: ! is_file = 1 ! ! going_up = ('..',) * (len(my_path) - is_file) + # + # Go up to a common point in the tree, + # and then back down to the other node. + # relative_path = going_up + other_path ! ! trace.outof(relative_path, outputLevel=TRACE_LEVEL) return relative_path ! def findNodeFromDottedName(self, dottedNodeName, ! tryParent=1, ! tryModuleExtensions=1, ! ): """Find the node referenced by the dotted name given. *************** *** 431,434 **** --- 491,495 ---- dottedNodeName=dottedNodeName, outputLevel=trace_level, + start=self.getName(), ) *************** *** 461,465 **** named_node = self.get(name) ! if (named_node is None): trace.write('Checking %s.py as child' % name, outputLevel=trace_level, --- 522,526 ---- named_node = self.get(name) ! if (named_node is None) and tryModuleExtensions: trace.write('Checking %s.py as child' % name, outputLevel=trace_level, *************** *** 497,501 **** return named_node ! def addSubNode(self, name): """Insert a child node under this node. --- 558,562 ---- return named_node ! def addSubNode(self, name, nodeClass=None): """Insert a child node under this node. *************** *** 505,509 **** trace.into('PackageTree', 'addSubNode', name=name, outputLevel=TRACE_LEVEL) ! new_node = PackageTree(self, name) self[name] = new_node trace.outof(outputLevel=TRACE_LEVEL) --- 566,575 ---- trace.into('PackageTree', 'addSubNode', name=name, outputLevel=TRACE_LEVEL) ! ! if nodeClass: ! new_node = nodeClass(self, name) ! else: ! new_node = PackageTree(self, name) ! self[name] = new_node trace.outof(outputLevel=TRACE_LEVEL) *************** *** 522,527 **** self.grouped_children = {} for node in self.values(): ! mimetype, encoding = node.getMimeType() ! group = self.grouped_children.setdefault(mimetype, []) group.append(node) return self.grouped_children.get(mimetype, []) --- 588,593 ---- self.grouped_children = {} for node in self.values(): ! node_mimetype, node_encoding = node.getMimeType() ! group = self.grouped_children.setdefault(node_mimetype, []) group.append(node) return self.grouped_children.get(mimetype, []) *************** *** 534,535 **** --- 600,699 ---- child.walk(callback) return + + + + class CodeObjectTree(PackageTree): + """Represents a code object to be documented. + """ + + MIMETYPE = 'application/x-code' + + def __init__(self, parent, name): + """Construct a CodeObjectTree. + """ + trace.into('CodeObjectTree', '__init__', + name=name, + outputLevel=TRACE_LEVEL, + ) + PackageTree.__init__(self, parent, name) + self.code_info = self._getCodeInfo() + trace.write(self.getMimeType()[0], outputLevel=TRACE_LEVEL) + trace.outof(outputLevel=TRACE_LEVEL) + return + + def getMimeType(self): + return (self.MIMETYPE, None) + + def getInputFilename(self): + """Returns the input filename of the parent node. + """ + return self.getParent().getInputFilename() + + def getRelativeFilename(self): + """Returns the filename of the parent node. + """ + return self.getParent().getRelativeFilename() + + def getDocStringAndFormat(self): + """Returns the docstring of the code object, and the format of that data. + """ + return self.code_info.getDocStringAndFormat() + + def parseInput(self): + "Does nothing." + return + + + class FunctionTree(CodeObjectTree): + """Represents a function in the package tree. + """ + MIMETYPE = 'application/x-function' + + def _getCodeInfo(self): + return self.getParent().module_info.getFunctionInfo(self.name) + + class MethodTree(FunctionTree): + """Represents a method in the package tree. + """ + + def _getCodeInfo(self): + return self.getParent().code_info.getMethodInfo(self.name) + + class ClassTree(CodeObjectTree): + """Represent a class in the package tree. + """ + + MIMETYPE = 'application/x-class' + + def __init__(self, parent, name): + trace.into('ClassTree', '__init__', + name=name, + outputLevel=TRACE_LEVEL, + ) + CodeObjectTree.__init__(self, parent, name) + + for method_name in self.code_info.getMethodNames(): + method_node = self.addSubNode(method_name, + nodeClass=MethodTree, + ) + trace.outof(outputLevel=TRACE_LEVEL) + return + + def _getCodeInfo(self): + return self.getParent().module_info.getClassInfo(self.name) + + def parseInput(self): + """Add methods as sub-nodes. + """ + return + + def getRelativeFilename(self): + return PackageTree.getRelativeFilename(self) + + # def getRelativeFilename(self): + # """Returns the filename of this node. + # """ + # parent_filename = self.getParent().getRelativeFilename() + # parent_filename, ext = os.path.splitext(parent_filename) + # my_filename = os.path.join(parent_filename, self.getName()) + # return my_filename |
From: Doug H. <dou...@us...> - 2003-01-01 13:42:39
|
Update of /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne/levelTwo In directory sc8-pr-cvs1:/tmp/cvs-serv25245/TestCases/testScanner/levelOne/levelTwo Modified Files: two.py Log Message: Add some code for new tests. Index: two.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne/levelTwo/two.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** two.py 17 Nov 2002 14:51:44 -0000 1.1 --- two.py 1 Jan 2003 13:42:36 -0000 1.2 *************** *** 0 **** --- 1,4 ---- + + class Two: + """Class in two.py. + """ |
From: Doug H. <dou...@us...> - 2003-01-01 13:42:39
|
Update of /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne In directory sc8-pr-cvs1:/tmp/cvs-serv25245/TestCases/testScanner/levelOne Modified Files: ignoreme.py one.py Log Message: Add some code for new tests. Index: ignoreme.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne/ignoreme.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ignoreme.py 17 Nov 2002 14:51:44 -0000 1.1 --- ignoreme.py 1 Jan 2003 13:42:35 -0000 1.2 *************** *** 0 **** --- 1,5 ---- + + class IgnoreThisClass: + """This class should usually be ignored. + """ + Index: one.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne/one.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** one.py 17 Nov 2002 14:51:44 -0000 1.1 --- one.py 1 Jan 2003 13:42:35 -0000 1.2 *************** *** 0 **** --- 1,9 ---- + + class One: + """Class in levelOne/one.py. + """ + + class AnotherOne: + """Another class in levelOne/one.py. + """ + |
From: Doug H. <dou...@us...> - 2002-12-30 15:55:18
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv26600 Modified Files: README.txt Added Files: USERS.txt Log Message: Breaking up README.txt, since it is so big. It needs some major rewrites to match the new design, but since the design isn't finished yet, that cannot be done. --- NEW FILE: USERS.txt --- Who else is using HappyDoc? - **Biopython** The "Biopython project":http://www.biopython.org uses HappyDoc to generate the documentation for their "libraries":http://www.biopython.org/wiki/html/BioPython/BiopythonCode.html - **Numerical Python** "Numerical Python":http://numpy.sourceforge.net adds a fast, compact multidimensional array language facility to Python. - **CDAT** "Climate Data Analysis Tool":http://cdat.sourceforge.net is a Python-based, easily extendible system for accessing and analyzing climate data. It contains a generally useful system for scientific graphics. - **NOAA SEC** The NOAA "Space Environment Center":http://www.sec.noaa.gov/sxi group responsible for supporting the effort to forecast solar activity having a direct impact on earth-orbiting satellites and other earth-based systems. - **ZOD** The "Zope Online Documentation":http://demo.iuveno-net.de/iuveno/Products/ZOnlineDocu tools use the HappyDoc parsing engine to extract information about source code. Index: README.txt =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/README.txt,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README.txt 17 Nov 2002 00:26:14 -0000 1.1.1.1 --- README.txt 30 Dec 2002 15:55:13 -0000 1.2 *************** *** 248,285 **** the HappyDoc site. - Who else is using HappyDoc? - - - **Biopython** - - The "Biopython project":http://www.biopython.org uses HappyDoc to - generate the documentation for their - "libraries":http://www.biopython.org/wiki/html/BioPython/BiopythonCode.html - - - **Numerical Python** - - "Numerical Python":http://numpy.sourceforge.net adds a fast, - compact multidimensional array language facility to Python. - - - **CDAT** - - "Climate Data Analysis Tool":http://cdat.sourceforge.net is a - Python-based, easily extendible system for accessing and analyzing - climate data. It contains a generally useful system for scientific - graphics. - - - **NOAA SEC** - - The NOAA "Space Environment Center":http://www.sec.noaa.gov/sxi - group responsible for supporting the effort to forecast solar - activity having a direct impact on earth-orbiting satellites and - other earth-based systems. - - - **ZOD** - - The "Zope Online - Documentation":http://demo.iuveno-net.de/iuveno/Products/ZOnlineDocu - tools use the HappyDoc parsing engine to extract information about - source code. - Bugs --- 248,251 ---- |
From: Doug H. <dou...@us...> - 2002-12-29 18:38:54
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv29823 Modified Files: TODO Log Message: Updates Index: TODO =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TODO 27 Dec 2002 18:33:06 -0000 1.2 --- TODO 29 Dec 2002 18:38:51 -0000 1.3 *************** *** 4,9 **** 1. Ignore stuff in .cvsignore files. (Is this already done?) - 2. Generate docs for Python classes. - 3. Generate docs for Python functions. 4. Set up a regression test framework for watching output changes. 5. Port remaining docsets from HappyDoc 2.x. --- 4,7 ---- *************** *** 14,20 **** - Higher level formatting (class list header, etc.) - Content (TOC, functions, classes, etc.) - 7. generate import statements in module documentation - - still need to work out references in statements like - 'from happydoclib.scanner import Scanner' --- 12,15 ---- |
From: Doug H. <dou...@us...> - 2002-12-29 18:36:24
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo In directory sc8-pr-cvs1:/tmp/cvs-serv29053/happydoclib/parseinfo Modified Files: __init__.py classinfo.py functioninfo.py moduleinfo.py Log Message: Quiet trace statements. Index: __init__.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __init__.py 7 Dec 2002 17:04:01 -0000 1.3 --- __init__.py 29 Dec 2002 18:36:21 -0000 1.4 *************** *** 125,128 **** --- 125,130 ---- # + TRACE_LEVEL=2 + _parser_options = { 'include_comments':1, *************** *** 171,174 **** --- 173,177 ---- parent=parent, fileName=fileName, + outputLevel=TRACE_LEVEL, ) f = open(fileName) *************** *** 208,212 **** else: comment_info = {} ! happydoclib.TRACE.write('Creating ModuleInfo') config_values = {} --- 211,217 ---- else: comment_info = {} ! happydoclib.TRACE.write('Creating ModuleInfo', ! outputLevel=TRACE_LEVEL, ! ) config_values = {} *************** *** 220,224 **** commentInfo=comment_info, defaultConfigValues=config_values) ! happydoclib.TRACE.outof(mod_info) return mod_info --- 225,231 ---- commentInfo=comment_info, defaultConfigValues=config_values) ! happydoclib.TRACE.outof(mod_info, ! outputLevel=TRACE_LEVEL, ! ) return mod_info Index: classinfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/classinfo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** classinfo.py 28 Dec 2002 16:43:32 -0000 1.2 --- classinfo.py 29 Dec 2002 18:36:21 -0000 1.3 *************** *** 68,72 **** # Module # ! class ClassInfo(SuiteInfoBase): --- 68,72 ---- # Module # ! TRACE_LEVEL=2 class ClassInfo(SuiteInfoBase): *************** *** 90,93 **** --- 90,94 ---- #tree=tree, commentInfo=commentInfo, + outputLevel=TRACE_LEVEL, ) SuiteInfoBase.__init__(self, tree[2][1], parent, parent.getFilename(), *************** *** 98,102 **** self._class_member_info = self._extractClassMembers(tree) #print self._class_member_info ! happydoclib.TRACE.outof() return --- 99,103 ---- self._class_member_info = self._extractClassMembers(tree) #print self._class_member_info ! happydoclib.TRACE.outof(outputLevel=TRACE_LEVEL) return Index: functioninfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/functioninfo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** functioninfo.py 28 Dec 2002 16:43:32 -0000 1.2 --- functioninfo.py 29 Dec 2002 18:36:21 -0000 1.3 *************** *** 69,72 **** --- 69,73 ---- # + TRACE_LEVEL=2 class SuiteFuncInfo: *************** *** 100,103 **** --- 101,105 ---- #tree=tree, commentInfo=commentInfo, + outputLevel=TRACE_LEVEL, ) SuiteInfoBase.__init__(self, tree[2][1], parent, parent.getFilename(), *************** *** 110,114 **** # print 'EXCEPTIONS: ', # pprint.pprint(self._exception_info) ! happydoclib.TRACE.outof() return --- 112,116 ---- # print 'EXCEPTIONS: ', # pprint.pprint(self._exception_info) ! happydoclib.TRACE.outof(outputLevel=TRACE_LEVEL) return Index: moduleinfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/moduleinfo.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** moduleinfo.py 27 Dec 2002 15:52:36 -0000 1.3 --- moduleinfo.py 29 Dec 2002 18:36:21 -0000 1.4 *************** *** 77,80 **** --- 77,82 ---- # + TRACE_LEVEL=2 + class ModuleInfo(SuiteInfoBase, SuiteFuncInfo): """Information gatherer for source code modules. *************** *** 112,115 **** --- 114,118 ---- commentInfo=commentInfo, defaultConfigValues=defaultConfigValues, + outputLevel=TRACE_LEVEL, ) self._filename = fileName *************** *** 129,133 **** self._import_info = self._extractImportedModules(tree) ! happydoclib.TRACE.outof() return --- 132,136 ---- self._import_info = self._extractImportedModules(tree) ! happydoclib.TRACE.outof(outputLevel=TRACE_LEVEL) return |
From: Doug H. <dou...@us...> - 2002-12-29 18:35:51
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv28862/happydoclib/docset Modified Files: base.py Log Message: Quiet trace statements. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** base.py 29 Dec 2002 17:31:34 -0000 1.12 --- base.py 29 Dec 2002 18:35:48 -0000 1.13 *************** *** 70,73 **** --- 70,75 ---- # + TRACE_LEVEL=2 + class DocSetBase: """Base class for documentation sets. *************** *** 109,112 **** --- 111,115 ---- statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, + outputLevel=TRACE_LEVEL, ) # *************** *** 122,126 **** self.statusMessage('NEED TO HANDLE extraParameters in DocSetBase') ! trace.outof() return --- 125,129 ---- self.statusMessage('NEED TO HANDLE extraParameters in DocSetBase') ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 218,221 **** --- 221,225 ---- statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, + outputLevel=TRACE_LEVEL, ) DocSetBase.__init__( *************** *** 236,240 **** self._initializeWriters() ! trace.outof() return --- 240,244 ---- self._initializeWriters() ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 295,303 **** trace.into('MultiHTMLFileDocSet', 'writeCB', packageTreeNode=packageTreeNode, ) writer = self.getWriterForNode(packageTreeNode) writer(packageTreeNode) ! trace.outof() return --- 299,308 ---- trace.into('MultiHTMLFileDocSet', 'writeCB', packageTreeNode=packageTreeNode, + outputLevel=TRACE_LEVEL, ) writer = self.getWriterForNode(packageTreeNode) writer(packageTreeNode) ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 377,386 **** packageTreeNode=packageTreeNode, includePath=includePath, ) mimetype, encoding = packageTreeNode.getMimeType() ! trace.writeVar(mimetype=mimetype) settings = self.mimetype_extension_mapping.get(mimetype, {}) ! trace.writeVar(settings=settings) if includePath: --- 382,394 ---- packageTreeNode=packageTreeNode, includePath=includePath, + outputLevel=TRACE_LEVEL, ) mimetype, encoding = packageTreeNode.getMimeType() ! trace.writeVar(mimetype=mimetype, ! outputLevel=TRACE_LEVEL) settings = self.mimetype_extension_mapping.get(mimetype, {}) ! trace.writeVar(settings=settings, ! outputLevel=TRACE_LEVEL) if includePath: *************** *** 408,412 **** normalized_output_filename = os.path.normpath(output_filename) ! trace.outof(normalized_output_filename) return normalized_output_filename --- 416,421 ---- normalized_output_filename = os.path.normpath(output_filename) ! trace.outof(normalized_output_filename, ! outputLevel=TRACE_LEVEL) return normalized_output_filename *************** *** 444,447 **** --- 453,457 ---- trace.into('MultiFileDocSet', 'processDirectory', packageTreeNode=packageTreeNode, + outputLevel=TRACE_LEVEL, ) *************** *** 464,468 **** self.writeTOCFile(packageTreeNode) ! trace.outof() return --- 474,478 ---- self.writeTOCFile(packageTreeNode) ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 573,576 **** --- 583,587 ---- trace.into('MultiFileDocSet', 'processPlainTextFile', packageTreeNode=packageTreeNode, + outputLevel=TRACE_LEVEL, ) *************** *** 605,608 **** self.closeOutput(output_file) ! trace.outof() return --- 616,619 ---- self.closeOutput(output_file) ! trace.outof(outputLevel=TRACE_LEVEL) return |
From: Doug H. <dou...@us...> - 2002-12-29 18:35:36
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv28787/happydoclib Modified Files: pluginloader.py Log Message: Quiet trace statements. Index: pluginloader.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/pluginloader.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pluginloader.py 7 Dec 2002 17:02:12 -0000 1.2 --- pluginloader.py 29 Dec 2002 18:35:33 -0000 1.3 *************** *** 70,73 **** --- 70,75 ---- # + TRACE_LEVEL=3 + class PluginException(Exception): *************** *** 108,112 **** moduleName=moduleName, modulePath=modulePath, ! parentModulePrefix=parentModulePrefix) # # Initialize the base class --- 110,116 ---- moduleName=moduleName, modulePath=modulePath, ! parentModulePrefix=parentModulePrefix, ! outputLevel=TRACE_LEVEL, ! ) # # Initialize the base class *************** *** 140,145 **** for _module_name in _module_list: TRACE.into('PluginLoader', '__init__:Loop', ! _module_name=_module_name, ! ) module_name_parts = _module_name.split(os.sep) module_base_name = module_name_parts[-1] --- 144,150 ---- for _module_name in _module_list: TRACE.into('PluginLoader', '__init__:Loop', ! _module_name=_module_name, ! outputLevel=TRACE_LEVEL, ! ) module_name_parts = _module_name.split(os.sep) module_base_name = module_name_parts[-1] *************** *** 149,153 **** (plugin_set_name, self.plugin_set_name) parent_package_name = module_name_parts[-3] ! TRACE.writeVar(parent_package_name=parent_package_name) _module_name = os.path.basename(_module_name) --- 154,160 ---- (plugin_set_name, self.plugin_set_name) parent_package_name = module_name_parts[-3] ! TRACE.writeVar(parent_package_name=parent_package_name, ! outputLevel=TRACE_LEVEL, ! ) _module_name = os.path.basename(_module_name) *************** *** 158,165 **** else: _import_name = '%s.%s' % (plugin_set_name, module_base_name) ! TRACE.writeVar(_import_name=_import_name) try: ! TRACE.write('Importing %s' % _import_name) _module = __import__( _import_name ) except Exception, msg: --- 165,176 ---- else: _import_name = '%s.%s' % (plugin_set_name, module_base_name) ! TRACE.writeVar(_import_name=_import_name, ! outputLevel=TRACE_LEVEL, ! ) try: ! TRACE.write('Importing %s' % _import_name, ! outputLevel=TRACE_LEVEL, ! ) _module = __import__( _import_name ) except Exception, msg: *************** *** 169,180 **** traceback.print_exc(file=buffer) TRACE.into('PluginLoader' 'Plugin module error', ! _import_name=_import_name) ! TRACE.write(buffer.getvalue()) ! TRACE.outof() buffer.write('---------------------------\n\n') ! TRACE.outof() raise PluginException( buffer.getvalue(), _import_name ) elif int(os.environ.get('PLUGIN_SILENT_ERRORS', '0')): ! TRACE.outof() continue else: --- 180,195 ---- traceback.print_exc(file=buffer) TRACE.into('PluginLoader' 'Plugin module error', ! _import_name=_import_name, ! outputLevel=TRACE_LEVEL, ! ) ! TRACE.write(buffer.getvalue(), ! outputLevel=TRACE_LEVEL, ! ) ! TRACE.outof(outputLevel=TRACE_LEVEL) buffer.write('---------------------------\n\n') ! TRACE.outof(outputLevel=TRACE_LEVEL) raise PluginException( buffer.getvalue(), _import_name ) elif int(os.environ.get('PLUGIN_SILENT_ERRORS', '0')): ! TRACE.outof(outputLevel=TRACE_LEVEL) continue else: *************** *** 182,186 **** traceback.print_exc() sys.stderr.write('---------------------------\n\n') ! TRACE.outof() continue --- 197,201 ---- traceback.print_exc() sys.stderr.write('---------------------------\n\n') ! TRACE.outof(outputLevel=TRACE_LEVEL) continue *************** *** 203,209 **** self.addEntryPoint(info) ! TRACE.outof() ! TRACE.outof() return --- 218,224 ---- self.addEntryPoint(info) ! TRACE.outof(outputLevel=TRACE_LEVEL) ! TRACE.outof(outputLevel=TRACE_LEVEL) return |
From: Doug H. <dou...@us...> - 2002-12-29 18:35:17
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv28702/happydoclib Modified Files: scanner.py test_scanner.py Added Files: packagetree.py test_packagetree.py Log Message: Move PackageTree to its own file. --- NEW FILE: packagetree.py --- #!/usr/bin/env python # # $Id: packagetree.py,v 1.1 2002/12/29 18:35:14 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. # """Tree representing the input data. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: packagetree.py,v $', 'rcs_id' : '$Id: packagetree.py,v 1.1 2002/12/29 18:35:14 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 29-Dec-2002 12:37:53 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/12/29 18:35:14 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import mimetypes import os import re import UserDict # # Import Local modules # import happydoclib from happydoclib.status import statusMessage from happydoclib.trace import trace from happydoclib.utils import * # # Module # TRACE_LEVEL=2 # # Initialize extensions for mimetypes that we know about but which are # not standard. # mimetypes.types_map['.stx'] = 'text/x-structured' class PackageTree(UserDict.UserDict): """Tree of package information. Access each child node using the standard mapping de-reference syntax ([], .get(), etc.). """ parser_mapping = { 'text/x-python' : 'parsePythonInput', 'text/plain' : 'parsePlainTextInput', 'text/x-structured' : 'parseStructuredTextInput', } def __init__(self, parent, name): trace.into('PackageTree', '__init__', parent=parent, name=name, outputLevel=TRACE_LEVEL, ) UserDict.UserDict.__init__(self) self.parent = parent self.name = os.path.basename(name) trace.write('self.name=%s' % self.name, outputLevel=TRACE_LEVEL) self.canonical_name = name trace.outof(outputLevel=TRACE_LEVEL) return def __repr__(self): base_str = UserDict.UserDict.__repr__(self) return '<%s %s: %s>' % (self.__class__.__name__, self.getName(), base_str) # # Parsing methods # def parsePythonInput(self): trace.into('PackageTree', 'parsePythonInput', outputLevel=TRACE_LEVEL) # # Derive the filename for this module. # filename = self.getInputFilename() statusMessage('Parsing: %s' % filename) # # Figure out if there is a parent node for the # documentation suite. # package_parent = self.getParent() if package_parent and hasattr(package_parent, 'module_info'): docs_parent = package_parent.module_info else: docs_parent = None trace.writeVar(docs_parent=docs_parent, outputLevel=TRACE_LEVEL) docs = happydoclib.parseinfo.getDocs( parent=docs_parent, fileName=filename, ) self.module_info = docs trace.outof(outputLevel=TRACE_LEVEL) return def parsePlainTextInput(self): trace.into('PackageTree', 'parsePlainTextInput', outputLevel=TRACE_LEVEL, ) # # Derive the filename for this module. # filename = self.getInputFilename() trace.writeVar(filename=filename, outputLevel=TRACE_LEVEL) statusMessage('Importing preformatted file: %s' % filename) #f = open(filename, 'rt') #body = f.read() #f.close() #packageTreeNode.preformatted_text = body trace.outof(outputLevel=TRACE_LEVEL) return def parseStructuredTextInput(self): trace.into('PackageTree', 'parseStructuredTextInput', outputLevel=TRACE_LEVEL) self.parsePlainTextInput() trace.outof(outputLevel=TRACE_LEVEL) return def parseInput(self): """Get whatever information is appropriate from the input file. """ trace.into('PackageTree', 'parseInput', outputLevel=TRACE_LEVEL) if os.path.isdir(self.getInputFilename()): trace.write('directory', outputLevel=TRACE_LEVEL) trace.outof(outputLevel=TRACE_LEVEL) return mimetype, encoding = self.getMimeType() try: parse_method_name = self.parser_mapping[mimetype] except KeyError: # # Don't know what to do with this file. # statusMessage('Not parsing input %s with mimetype %s' % ( self.getInputFilename(), mimetype, ), 2) else: # # Call the parse method # parse_method = getattr(self, parse_method_name) parse_method() trace.outof(outputLevel=TRACE_LEVEL) return # # Data retrieval methods # def getMimeType(self): """Returns the (mimetype, encoding) setting for this node. """ trace.into('PackageTreeNode', 'getMimeType', name=self.name, outputLevel=TRACE_LEVEL, ) input_filename = self.getInputFilename() mimetype = mimetypes.guess_type(input_filename) if mimetype == (None, None): if isSomethingThatLooksLikeDirectory(input_filename): mimetype = ('application/x-directory', None) trace.outof(mimetype, outputLevel=TRACE_LEVEL) return mimetype def getName(self): """Returns the name of this tree node. """ return self.name def getCanonicalName(self): """Returns the canonical, full, name of the this tree node. """ return self.canonical_name def getInputFilename(self): """Returns the original input filename that created the node. """ trace.into('PackageTree', 'getInputFilename', outputLevel=TRACE_LEVEL) node_path = self.getPath(1) trace.writeVar(node_path=node_path, outputLevel=TRACE_LEVEL) filename = apply(os.path.join, node_path) trace.writeVar(filename=filename, outputLevel=TRACE_LEVEL) trace.outof(filename, outputLevel=TRACE_LEVEL) return filename def getRelativeFilename(self): """Returns the filename relative to the root of the input area. """ trace.into('PackageTree', 'getRelativeFilename', outputLevel=TRACE_LEVEL) node_path = self.getPath() trace.writeVar(node_path=node_path, outputLevel=TRACE_LEVEL) filename = apply(os.path.join, node_path) trace.writeVar(filename=filename, outputLevel=TRACE_LEVEL) trace.outof(filename, outputLevel=TRACE_LEVEL) return filename def _unquoteString(self, str): "Remove surrounding quotes from a string." str = str.strip() while ( str and (str[0] == str[-1]) and str[0] in ('"', "'") ): str = str[1:-1] return str def getDocStringAndFormat(self): # # Are we a python module? # if hasattr(self, 'module_info'): docstring = self.module_info.getDocString() docstring = self._unquoteString(docstring) format = self.module_info.getDocStringFormat() return (docstring, format) # # Are we a text file? # mimetype, encoding = self.getMimeType() if mimetype in ('text/plain', 'text/x-structured'): input_filename = self.getInputFilename() readme_text = open(input_filename, 'rt').read() format = 'StructuredText' return (readme_text, format) # # Look inside sub-nodes # for name in ('__init__.py', 'README.txt', 'README.stx'): trace.write('looking for %s' % name, outputLevel=TRACE_LEVEL) node = self.get(name) if node is not None: return node.getDocStringAndFormat() return ('', 'StructuredText') _summary_pattern = re.compile(r'^\s*([^\n]+)\n') def getSummaryAndFormat(self): if hasattr(self, 'module_info'): return self.module_info.getSummaryAndFormat() else: text, format = self.getDocStringAndFormat() text = text.strip() # # Remove surrounding quotes, if present. # while text and (text[0] in ('"', "'")): text = text[1:] while text and (text[-1] in ('"', "'")): text = text[:-1] # # Pull out the first line, and return it if # we can find it. Otherwise, return the whole # string since that means that the whole thing # is just one line. # matchObj = self._summary_pattern.search(text) if matchObj: return (matchObj.group(0).strip(), format) else: return (text, format) # # Tree methods # def getParent(self): """Returns the parent node for this tree. If there is no parent (root of the tree), returns None. """ return self.parent def getPath(self, useCanonicalName=0): """Return the path from the root to this node. Returns a tuple of node names, beginning with the root node and ending with this node. """ trace.into('PackageTree', 'getPath', useCanonicalName=useCanonicalName, outputLevel=TRACE_LEVEL+1, ) parent = self.getParent() trace.writeVar(parent=parent, outputLevel=TRACE_LEVEL+1, ) if parent: parent_path = parent.getPath(useCanonicalName=useCanonicalName) else: parent_path = () trace.writeVar(parent_path=parent_path, outputLevel=TRACE_LEVEL+1, ) if useCanonicalName: name = self.getCanonicalName() else: name = self.getName() path = parent_path + (name,) trace.outof(path, outputLevel=TRACE_LEVEL+1, ) return path def getPathToNode(self, otherNode): """Returns a sequence of nodes to be traversed to reach the otherNode. The sequence assumes that traversal begins at the current node. A '..' indicates moving up to the parent one level. """ my_path = self.getPath() other_path = otherNode.getPath() if my_path == other_path: return () # # Strip the top parts of the paths which match. # while my_path and other_path and my_path[0] == other_path[0]: my_path = my_path[1:] other_path = other_path[1:] if self.items(): is_file = 0 else: is_file = 1 going_up = ('..',) * (len(my_path) - is_file) relative_path = going_up + other_path return relative_path def findNodeFromDottedName(self, dottedNodeName, tryParent=1): """Find the node referenced by the dotted name given. The dottedNodeName 'happydoclib.scanner' retuns the node for this module. If the named node cannot be found, the return value is None. """ trace_level=TRACE_LEVEL trace.into('PackageTree', 'findNodeFromDottedName', dottedNodeName=dottedNodeName, outputLevel=trace_level, ) name_parts = dottedNodeName.split('.') name = name_parts[0] trace.write('name=%s' % name, outputLevel=trace_level, ) trace.writeVar(name=name, outputLevel=trace_level, ) named_node = None # # Is someone looking for us? # if (named_node is None): if (name == self.getName()): trace.write('Matched ourself', outputLevel=trace_level, ) named_node = self if (named_node is None): trace.write('Checking %s as child' % name, outputLevel=trace_level, ) named_node = self.get(name) if (named_node is None): trace.write('Checking %s.py as child' % name, outputLevel=trace_level, ) named_node = self.get('%s.py' % name) if (named_node is None) and tryParent: # # Try the parent with the whole name # parent = self.getParent() if parent: trace.write('Checking for %s in parent' % name, outputLevel=trace_level, ) named_node = parent.findNodeFromDottedName(dottedNodeName) # # Do we need to process the remainder of the original name? # if named_node and (len(name_parts) > 1): remainder = '.'.join(name_parts[1:]) trace.write('Handling remainder (%s)' % remainder, outputLevel=trace_level, ) named_node = named_node.findNodeFromDottedName(remainder, tryParent=0) if named_node is not None: trace.outof(named_node.getName(), outputLevel=trace_level, ) else: trace.outof(outputLevel=trace_level) return named_node def addSubNode(self, name): """Insert a child node under this node. Create a new PackageTree node, set its parent to be ourself, and save it as one of our children. """ trace.into('PackageTree', 'addSubNode', name=name, outputLevel=TRACE_LEVEL) new_node = PackageTree(self, name) self[name] = new_node trace.outof(outputLevel=TRACE_LEVEL) return new_node def getSubNodes(self, mimetype=None): """Returns the children of this node. If mimetype is not none, returns only the children with that mimetype. """ if mimetype is None: return self.values() else: if not hasattr(self, 'grouped_children'): self.grouped_children = {} for node in self.values(): mimetype, encoding = node.getMimeType() group = self.grouped_children.setdefault(mimetype, []) group.append(node) return self.grouped_children.get(mimetype, []) def walk(self, callback): """Walk the PackageTree, calling the callback at each node. """ callback(self) for child in self.values(): child.walk(callback) return --- NEW FILE: test_packagetree.py --- #!/usr/bin/env python # # $Id: test_packagetree.py,v 1.1 2002/12/29 18:35:14 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. # """Tests for packagetree module. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: test_packagetree.py,v $', 'rcs_id' : '$Id: test_packagetree.py,v 1.1 2002/12/29 18:35:14 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 29-Dec-2002 12:41:21 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/12/29 18:35:14 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import os import unittest # # Import Local modules # from happydoclib.scanner import Scanner from happydoclib.packagetree import PackageTree # # Module # class PackageTreeTestCase(unittest.TestCase): def testGetInputFilename(self): scanner = Scanner(['TestCases/testScanner']) trees = scanner.getPackageTrees() expected_tree = trees[0] self.failUnlessEqual( expected_tree.getName(), 'testScanner', 'First level tree got %s instead of testScanner' % expected_tree.getName(), ) level_one = expected_tree['levelOne'] self.failUnlessEqual( level_one.getName(), 'levelOne', 'First sub-level tree got %s instead of levelOne' % level_one.getName(), ) self.failUnlessEqual(level_one.getInputFilename(), 'TestCases/testScanner/levelOne', ) level_two = level_one['levelTwo'] self.failUnlessEqual( level_two.getName(), 'levelTwo', 'First sub-level tree got %s instead of levelTwo' % level_two.getName(), ) self.failUnlessEqual(level_two.getInputFilename(), 'TestCases/testScanner/levelOne/levelTwo', ) return def testPackageTreePath(self): scanner = Scanner(['TestCases/testScanner']) trees = scanner.getPackageTrees() expected_tree = trees[0] dir_one = expected_tree['levelOne'] dir_one_path = dir_one.getPath() self.failUnlessEqual(dir_one_path, ('testScanner', 'levelOne', )) dir_two = expected_tree['levelOne']['levelTwo'] dir_two_path = dir_two.getPath() self.failUnlessEqual(dir_two_path, ('testScanner', 'levelOne', 'levelTwo', )) module_two = expected_tree['levelOne']['levelTwo']['two.py'] module_two_path = module_two.getPath() self.failUnlessEqual(module_two_path, ('testScanner', 'levelOne', 'levelTwo', 'two.py', ), ) return def testPackageTreePath(self): cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') scanner = Scanner([input_dir]) trees = scanner.getPackageTrees() expected_tree = trees[0] module_two = expected_tree['levelOne']['levelTwo']['two.py'] module_two_path = module_two.getPath(1) self.failUnlessEqual(module_two_path, (input_dir, 'levelOne', 'levelTwo', 'two.py', ), ) return def testPackageTreeIgnore(self): scanner = Scanner(['TestCases/testScanner'], ['ignoreme.py']) trees = scanner.getPackageTrees() level_one = trees[0]['levelOne'] try: ignoring = level_one['ignoreme.py'] except KeyError: pass else: self.fail('Still have ignoreme.py') return def testPackageTreeIgnoreTestFiles(self): scanner = Scanner(['happydoclib'], ['^tests.py$', '^test_.*py$', ]) trees = scanner.getPackageTrees() level_one = trees[0] for name in ('tests.py', 'test_scanner.py', ): try: ignoring = level_one[name] except KeyError: pass else: self.fail('Still have %s' % name) return def testPackageTreeName(self): tree = PackageTree(None, 'tree1') self.failUnlessEqual('tree1', tree.getName(), 'Names do not match.') return def testPackageTreeNameNotCanonical(self): tree = PackageTree(None, '/full/path/to/tree1') self.failUnlessEqual('tree1', tree.getName(), 'Names do not match.') return def testPackageTreeNameCanonical(self): tree = PackageTree(None, '/full/path/to/tree1') self.failUnlessEqual('/full/path/to/tree1', tree.getCanonicalName(), 'Names do not match.') return def testPackageTreeParent(self): tree = PackageTree(None, 'tree1') self.failUnlessEqual(None, tree.getParent(), 'Parents do not match.') return class PackageTreeRelativePathTestCase(unittest.TestCase): def setUp(self): cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') scanner = Scanner([input_dir]) trees = scanner.getPackageTrees() expected_tree = trees[0] self.expected_tree = expected_tree return def testSelf(self): target = self.expected_tree['levelOne']['levelTwo']['two.py'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] relative_path = start.getPathToNode(target) self.failUnlessEqual(relative_path, (), ) return def testParentDirOfModuleDir(self): target = self.expected_tree['levelOne'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] relative_path = start.getPathToNode(target) self.failUnlessEqual(relative_path, ('..', ), ) return def testModuleSameDir(self): target = self.expected_tree['levelOne']['one.py'] start = self.expected_tree['levelOne']['ignoreme.py'] relative_path = start.getPathToNode(target) self.failUnlessEqual(relative_path, ('one.py', ), ) return def testModuleParentDir(self): target = self.expected_tree['levelOne']['one.py'] start = self.expected_tree['levelOne']['levelTwo']['two.py'] relative_path = start.getPathToNode(target) self.failUnlessEqual(relative_path, ('..', 'one.py', ), ) return def testParentDirOfDir(self): target = self.expected_tree['levelOne'] start = self.expected_tree['levelOne']['levelTwo'] relative_path = start.getPathToNode(target) self.failUnlessEqual(relative_path, ('..', ), ) return class PackageTreeSummaryAndDocStringTests(unittest.TestCase): def setUp(self): input_dir = os.path.join('TestCases', 'testScanner') output_dir = '/tmp/foo' scanner = Scanner([input_dir]) self.scanner = scanner return def tearDown(self): del self.scanner return def testGetReadmeTextForDirectoryInit(self): trees = self.scanner.getPackageTrees() expected_tree = trees[0]['readme_from_init'] actual, format = expected_tree.getDocStringAndFormat() expected_format = 'StructuredText' expected = 'This is the __init__.py file for readme_from_init.' self.failUnlessEqual(actual, expected) return def testGetReadmeTextForDirectoryDotTxt(self): trees = self.scanner.getPackageTrees() expected_tree = trees[0]['readme_from_readme'] actual, format = expected_tree.getDocStringAndFormat() expected_format = 'StructuredText' expected = 'This is the README.txt file for readme_from_readme.\n' self.failUnlessEqual(actual, expected) return def testGetReadmeTextForDirectoryDotStx(self): trees = self.scanner.getPackageTrees() expected_tree = trees[0]['readme_from_stx'] actual, format = expected_tree.getDocStringAndFormat() expected_format = 'StructuredText' expected = 'This is the README.stx file for readme_from_stx.\n' self.failUnlessEqual(actual, expected) return class PackageTreeFindNodeTestCase(unittest.TestCase): def setUp(self): cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') scanner = Scanner([input_dir]) trees = scanner.getPackageTrees() expected_tree = trees[0] self.expected_tree = expected_tree return def _testFind(self, name, start, target): found = start.findNodeFromDottedName(name) if not found: self.fail('Did not find anything') self.failUnlessEqual(found, target) return def testFindSelf(self): self._testFind('levelOne', self.expected_tree['levelOne'], self.expected_tree['levelOne'], ) return def testFindChild(self): self._testFind('levelTwo', self.expected_tree['levelOne'], self.expected_tree['levelOne']['levelTwo'], ) return def testFindSelfDotChild(self): self._testFind('levelOne.levelTwo', self.expected_tree['levelOne'], self.expected_tree['levelOne']['levelTwo'], ) return def testFindParent(self): self._testFind('levelOne', self.expected_tree['levelOne']['levelTwo'], self.expected_tree['levelOne'], ) return def testFindSibling(self): self._testFind('readme_from_readme', self.expected_tree['levelOne'], self.expected_tree['readme_from_readme'], ) return def testFindAunt(self): self._testFind('readme_from_readme', self.expected_tree['levelOne']['levelTwo'], self.expected_tree['readme_from_readme'], ) return def testFindNeice(self): self._testFind('levelOne.levelTwo', self.expected_tree['readme_from_readme'], self.expected_tree['levelOne']['levelTwo'], ) return def testFindNotThere(self): name = 'levelOne.levelTwo.notThereAtAll' start = self.expected_tree['readme_from_readme'] found = start.findNodeFromDottedName(name) if found: self.fail('Found something unexpected') return if __name__ == '__main__': unittest.main() Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** scanner.py 29 Dec 2002 17:30:58 -0000 1.13 --- scanner.py 29 Dec 2002 18:35:14 -0000 1.14 *************** *** 59,66 **** # import glob - import mimetypes import os import re - import UserDict # --- 59,64 ---- *************** *** 68,71 **** --- 66,70 ---- # import happydoclib + from happydoclib.packagetree import PackageTree from happydoclib.status import statusMessage from happydoclib.trace import trace *************** *** 76,527 **** # ! # ! # Initialize extensions for mimetypes that we know about but which are ! # not standard. ! # ! mimetypes.types_map['.stx'] = 'text/x-structured' ! ! class PackageTree(UserDict.UserDict): ! """Tree of package information. ! ! Access each child node using the standard mapping de-reference ! syntax ([], .get(), etc.). ! """ ! ! parser_mapping = { ! 'text/x-python' : 'parsePythonInput', ! 'text/plain' : 'parsePlainTextInput', ! 'text/x-structured' : 'parseStructuredTextInput', ! } ! ! def __init__(self, parent, name): ! trace.into('PackageTree', '__init__', ! parent=parent, ! name=name, ! ) ! UserDict.UserDict.__init__(self) ! ! self.parent = parent ! ! self.name = os.path.basename(name) ! trace.write('self.name=%s' % self.name) ! self.canonical_name = name ! ! trace.outof() ! return ! ! def __repr__(self): ! base_str = UserDict.UserDict.__repr__(self) ! return '<%s %s: %s>' % (self.__class__.__name__, self.getName(), base_str) ! ! # ! # Parsing methods ! # ! ! def parsePythonInput(self): ! trace.into('PackageTree', 'parsePythonInput') ! # ! # Derive the filename for this module. ! # ! filename = self.getInputFilename() ! statusMessage('Parsing: %s' % filename) ! ! # ! # Figure out if there is a parent node for the ! # documentation suite. ! # ! package_parent = self.getParent() ! if package_parent and hasattr(package_parent, 'module_info'): ! docs_parent = package_parent.module_info ! else: ! docs_parent = None ! ! trace.writeVar(docs_parent=docs_parent) ! ! docs = happydoclib.parseinfo.getDocs( ! parent=docs_parent, ! fileName=filename, ! ) ! ! self.module_info = docs ! ! trace.outof() ! return ! ! def parsePlainTextInput(self): ! trace.into('PackageTree', 'parsePlainTextInput', ! ) ! # ! # Derive the filename for this module. ! # ! filename = self.getInputFilename() ! trace.writeVar(filename=filename) ! ! statusMessage('Importing preformatted file: %s' % filename) ! ! #f = open(filename, 'rt') ! #body = f.read() ! #f.close() ! ! #packageTreeNode.preformatted_text = body ! ! trace.outof() ! return ! ! def parseStructuredTextInput(self): ! trace.into('PackageTree', 'parseStructuredTextInput') ! self.parsePlainTextInput() ! trace.outof() ! return ! ! def parseInput(self): ! """Get whatever information is appropriate from the input file. ! """ ! trace.into('PackageTree', 'parseInput') ! ! if os.path.isdir(self.getInputFilename()): ! trace.write('directory') ! trace.outof() ! return ! ! mimetype, encoding = self.getMimeType() ! try: ! parse_method_name = self.parser_mapping[mimetype] ! except KeyError: ! # ! # Don't know what to do with this file. ! # ! statusMessage('Not parsing input %s with mimetype %s' % ( ! self.getInputFilename(), ! mimetype, ! ), 2) ! else: ! # ! # Call the parse method ! # ! parse_method = getattr(self, parse_method_name) ! parse_method() ! ! trace.outof() ! return ! ! # ! # Data retrieval methods ! # ! ! def getMimeType(self): ! """Returns the (mimetype, encoding) setting for this node. ! """ ! trace.into('PackageTreeNode', 'getMimeType', ! name=self.name, ! ) ! ! input_filename = self.getInputFilename() ! mimetype = mimetypes.guess_type(input_filename) ! ! if mimetype == (None, None): ! if isSomethingThatLooksLikeDirectory(input_filename): ! mimetype = ('application/x-directory', None) ! ! trace.outof(mimetype) ! return mimetype ! ! def getName(self): ! """Returns the name of this tree node. ! """ ! return self.name ! ! def getCanonicalName(self): ! """Returns the canonical, full, name of the this tree node. ! """ ! return self.canonical_name ! ! def getInputFilename(self): ! """Returns the original input filename that created the node. ! """ ! trace.into('PackageTree', 'getInputFilename') ! ! node_path = self.getPath(1) ! trace.writeVar(node_path=node_path) ! filename = apply(os.path.join, node_path) ! trace.writeVar(filename=filename) ! ! trace.outof(filename) ! return filename ! ! def getRelativeFilename(self): ! """Returns the filename relative to the root of the input area. ! """ ! trace.into('PackageTree', 'getRelativeFilename') ! ! node_path = self.getPath() ! trace.writeVar(node_path=node_path) ! filename = apply(os.path.join, node_path) ! trace.writeVar(filename=filename) ! ! trace.outof(filename) ! return filename ! ! def _unquoteString(self, str): ! "Remove surrounding quotes from a string." ! str = str.strip() ! while ( str ! and ! (str[0] == str[-1]) ! and ! str[0] in ('"', "'") ! ): ! str = str[1:-1] ! return str ! ! def getDocStringAndFormat(self): ! # ! # Are we a python module? ! # ! if hasattr(self, 'module_info'): ! docstring = self.module_info.getDocString() ! docstring = self._unquoteString(docstring) ! format = self.module_info.getDocStringFormat() ! return (docstring, format) ! ! # ! # Are we a text file? ! # ! mimetype, encoding = self.getMimeType() ! if mimetype in ('text/plain', 'text/x-structured'): ! input_filename = self.getInputFilename() ! readme_text = open(input_filename, 'rt').read() ! format = 'StructuredText' ! return (readme_text, format) ! ! # ! # Look inside sub-nodes ! # ! for name in ('__init__.py', 'README.txt', 'README.stx'): ! trace.write('looking for %s' % name) ! node = self.get(name) ! if node is not None: ! return node.getDocStringAndFormat() ! ! return ('', 'StructuredText') ! ! _summary_pattern = re.compile(r'^\s*([^\n]+)\n') ! def getSummaryAndFormat(self): ! if hasattr(self, 'module_info'): ! return self.module_info.getSummaryAndFormat() ! else: ! text, format = self.getDocStringAndFormat() ! text = text.strip() ! # ! # Remove surrounding quotes, if present. ! # ! while text and (text[0] in ('"', "'")): ! text = text[1:] ! while text and (text[-1] in ('"', "'")): ! text = text[:-1] ! # ! # Pull out the first line, and return it if ! # we can find it. Otherwise, return the whole ! # string since that means that the whole thing ! # is just one line. ! # ! matchObj = self._summary_pattern.search(text) ! if matchObj: ! return (matchObj.group(0).strip(), format) ! else: ! return (text, format) ! ! ! # ! # Tree methods ! # ! ! def getParent(self): ! """Returns the parent node for this tree. ! ! If there is no parent (root of the tree), returns None. ! """ ! return self.parent ! ! def getPath(self, useCanonicalName=0): ! """Return the path from the root to this node. ! ! Returns a tuple of node names, beginning with the root node ! and ending with this node. ! """ ! trace.into('PackageTree', 'getPath', ! useCanonicalName=useCanonicalName, ! outputLevel=2, ! ) ! ! parent = self.getParent() ! trace.writeVar(parent=parent, ! outputLevel=2, ! ) ! if parent: ! parent_path = parent.getPath(useCanonicalName=useCanonicalName) ! else: ! parent_path = () ! ! trace.writeVar(parent_path=parent_path, ! outputLevel=2, ! ) ! ! if useCanonicalName: ! name = self.getCanonicalName() ! else: ! name = self.getName() ! ! path = parent_path + (name,) ! ! trace.outof(path, ! outputLevel=2, ! ) ! return path ! ! def getPathToNode(self, otherNode): ! """Returns a sequence of nodes to be traversed to reach the otherNode. ! ! The sequence assumes that traversal begins at the current node. ! A '..' indicates moving up to the parent one level. ! """ ! my_path = self.getPath() ! other_path = otherNode.getPath() ! if my_path == other_path: ! return () ! ! # ! # Strip the top parts of the paths which match. ! # ! while my_path and other_path and my_path[0] == other_path[0]: ! my_path = my_path[1:] ! other_path = other_path[1:] ! ! if self.items(): ! is_file = 0 ! else: ! is_file = 1 ! ! going_up = ('..',) * (len(my_path) - is_file) ! ! relative_path = going_up + other_path ! ! return relative_path ! ! def findNodeFromDottedName(self, dottedNodeName, tryParent=1): ! """Find the node referenced by the dotted name given. ! ! The dottedNodeName 'happydoclib.scanner' retuns the node for ! this module. If the named node cannot be found, the return ! value is None. ! """ ! trace_level=1 ! trace.into('PackageTree', 'findNodeFromDottedName', ! dottedNodeName=dottedNodeName, ! outputLevel=trace_level, ! ) ! ! name_parts = dottedNodeName.split('.') ! name = name_parts[0] ! ! trace.write('name=%s' % name, ! outputLevel=trace_level, ! ) ! trace.writeVar(name=name, ! outputLevel=trace_level, ! ) ! ! named_node = None ! ! # ! # Is someone looking for us? ! # ! if (named_node is None): ! if (name == self.getName()): ! trace.write('Matched ourself', ! outputLevel=trace_level, ! ) ! named_node = self ! ! if (named_node is None): ! trace.write('Checking %s as child' % name, ! outputLevel=trace_level, ! ) ! named_node = self.get(name) ! ! if (named_node is None): ! trace.write('Checking %s.py as child' % name, ! outputLevel=trace_level, ! ) ! named_node = self.get('%s.py' % name) ! ! if (named_node is None) and tryParent: ! # ! # Try the parent with the whole name ! # ! parent = self.getParent() ! if parent: ! trace.write('Checking for %s in parent' % name, ! outputLevel=trace_level, ! ) ! named_node = parent.findNodeFromDottedName(dottedNodeName) ! ! # ! # Do we need to process the remainder of the original name? ! # ! if named_node and (len(name_parts) > 1): ! remainder = '.'.join(name_parts[1:]) ! trace.write('Handling remainder (%s)' % remainder, ! outputLevel=trace_level, ! ) ! named_node = named_node.findNodeFromDottedName(remainder, ! tryParent=0) ! ! if named_node is not None: ! trace.outof(named_node.getName(), ! outputLevel=trace_level, ! ) ! else: ! trace.outof(outputLevel=trace_level) ! return named_node ! ! def addSubNode(self, name): ! """Insert a child node under this node. ! ! Create a new PackageTree node, set its parent to be ourself, ! and save it as one of our children. ! """ ! trace.into('PackageTree', 'addSubNode', name=name) ! new_node = PackageTree(self, name) ! self[name] = new_node ! trace.outof() ! return new_node ! ! def getSubNodes(self, mimetype=None): ! """Returns the children of this node. ! ! If mimetype is not none, returns only the children with that ! mimetype. ! """ ! if mimetype is None: ! return self.values() ! else: ! if not hasattr(self, 'grouped_children'): ! self.grouped_children = {} ! for node in self.values(): ! mimetype, encoding = node.getMimeType() ! group = self.grouped_children.setdefault(mimetype, []) ! group.append(node) ! return self.grouped_children.get(mimetype, []) ! ! def walk(self, callback): ! """Walk the PackageTree, calling the callback at each node. ! """ ! callback(self) ! for child in self.values(): ! child.walk(callback) ! return ! ! class Scanner: --- 75,79 ---- # ! TRACE_LEVEL=2 class Scanner: *************** *** 541,544 **** --- 93,97 ---- ignorePatterns=ignorePatterns, includeComments=includeComments, + outputLevel=TRACE_LEVEL, ) *************** *** 564,568 **** self._parsePackageTree() ! trace.outof() return --- 117,121 ---- self._parsePackageTree() ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 586,591 **** trace.into('Scanner', 'buildPackageTree', directoryName=directoryName, ! parent=parent, ) package_tree_name = os.path.basename(directoryName) --- 139,152 ---- trace.into('Scanner', 'buildPackageTree', directoryName=directoryName, ! #parent=parent, ! outputLevel=TRACE_LEVEL, ) + + if parent is not None: + trace.writeVar(parent=parent.getName(), + outputLevel=TRACE_LEVEL) + else: + trace.writeVar(parent=parent, + outputLevel=TRACE_LEVEL) package_tree_name = os.path.basename(directoryName) *************** *** 598,604 **** if ignore_re.search(package_tree_name): trace.write('Ignoring because "%s" matched %s' % (package_tree_name, ! ignore_re.pattern) ) ! trace.outof() return None --- 159,166 ---- if ignore_re.search(package_tree_name): trace.write('Ignoring because "%s" matched %s' % (package_tree_name, ! ignore_re.pattern), ! outputLevel=TRACE_LEVEL, ) ! trace.outof(outputLevel=TRACE_LEVEL) return None *************** *** 618,622 **** # Get directory contents # ! trace.write('Scanning %s' % directoryName) pattern = os.path.join(directoryName, '*') contents = glob.glob(pattern) --- 180,185 ---- # Get directory contents # ! trace.write('Scanning %s' % directoryName, ! outputLevel=TRACE_LEVEL) pattern = os.path.join(directoryName, '*') contents = glob.glob(pattern) *************** *** 628,632 **** self.buildPackageTree(subnode_name, tree) ! trace.outof() return tree --- 191,195 ---- self.buildPackageTree(subnode_name, tree) ! trace.outof(outputLevel=TRACE_LEVEL) return tree Index: test_scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_scanner.py 28 Dec 2002 16:41:31 -0000 1.9 --- test_scanner.py 29 Dec 2002 18:35:14 -0000 1.10 *************** *** 61,65 **** # Import Local modules # ! from happydoclib.scanner import Scanner, PackageTree --- 61,65 ---- # Import Local modules # ! from happydoclib.scanner import Scanner *************** *** 195,540 **** self.failUnlessEqual(mimetype, ('text/x-structured', None)) - return - - def testGetInputFilename(self): - scanner = Scanner(['TestCases/testScanner']) - - trees = scanner.getPackageTrees() - - expected_tree = trees[0] - self.failUnlessEqual( - expected_tree.getName(), - 'testScanner', - 'First level tree got %s instead of testScanner' % expected_tree.getName(), - ) - - level_one = expected_tree['levelOne'] - self.failUnlessEqual( - level_one.getName(), - 'levelOne', - 'First sub-level tree got %s instead of levelOne' % level_one.getName(), - ) - self.failUnlessEqual(level_one.getInputFilename(), - 'TestCases/testScanner/levelOne', - ) - - level_two = level_one['levelTwo'] - self.failUnlessEqual( - level_two.getName(), - 'levelTwo', - 'First sub-level tree got %s instead of levelTwo' % level_two.getName(), - ) - self.failUnlessEqual(level_two.getInputFilename(), - 'TestCases/testScanner/levelOne/levelTwo', - ) - - return - - def testPackageTreePath(self): - scanner = Scanner(['TestCases/testScanner']) - - trees = scanner.getPackageTrees() - expected_tree = trees[0] - - dir_one = expected_tree['levelOne'] - dir_one_path = dir_one.getPath() - self.failUnlessEqual(dir_one_path, - ('testScanner', - 'levelOne', - )) - - dir_two = expected_tree['levelOne']['levelTwo'] - dir_two_path = dir_two.getPath() - self.failUnlessEqual(dir_two_path, - ('testScanner', - 'levelOne', - 'levelTwo', - )) - - module_two = expected_tree['levelOne']['levelTwo']['two.py'] - - module_two_path = module_two.getPath() - self.failUnlessEqual(module_two_path, - ('testScanner', - 'levelOne', - 'levelTwo', - 'two.py', - ), - ) - return - - def testPackageTreePath(self): - cwd = os.getcwd() - input_dir = os.path.join(cwd, 'TestCases/testScanner') - scanner = Scanner([input_dir]) - - trees = scanner.getPackageTrees() - expected_tree = trees[0] - - module_two = expected_tree['levelOne']['levelTwo']['two.py'] - - module_two_path = module_two.getPath(1) - self.failUnlessEqual(module_two_path, - (input_dir, - 'levelOne', - 'levelTwo', - 'two.py', - ), - ) - return - - def testPackageTreeIgnore(self): - scanner = Scanner(['TestCases/testScanner'], ['ignoreme.py']) - - trees = scanner.getPackageTrees() - level_one = trees[0]['levelOne'] - - try: - ignoring = level_one['ignoreme.py'] - except KeyError: - pass - else: - self.fail('Still have ignoreme.py') - - return - - def testPackageTreeIgnoreTestFiles(self): - scanner = Scanner(['happydoclib'], ['^tests.py$', - '^test_.*py$', - ]) - - trees = scanner.getPackageTrees() - level_one = trees[0] - - for name in ('tests.py', - 'test_scanner.py', - ): - try: - ignoring = level_one[name] - except KeyError: - pass - else: - self.fail('Still have %s' % name) - - return - - def testPackageTreeName(self): - tree = PackageTree(None, 'tree1') - self.failUnlessEqual('tree1', tree.getName(), - 'Names do not match.') - return - - def testPackageTreeNameNotCanonical(self): - tree = PackageTree(None, '/full/path/to/tree1') - self.failUnlessEqual('tree1', tree.getName(), - 'Names do not match.') - return - - def testPackageTreeNameCanonical(self): - tree = PackageTree(None, '/full/path/to/tree1') - self.failUnlessEqual('/full/path/to/tree1', tree.getCanonicalName(), - 'Names do not match.') - return - - def testPackageTreeParent(self): - tree = PackageTree(None, 'tree1') - self.failUnlessEqual(None, tree.getParent(), - 'Parents do not match.') - return - - class ScannerRelativePathTestCase(unittest.TestCase): - - def setUp(self): - cwd = os.getcwd() - input_dir = os.path.join(cwd, 'TestCases/testScanner') - scanner = Scanner([input_dir]) - - trees = scanner.getPackageTrees() - expected_tree = trees[0] - self.expected_tree = expected_tree - return - - def testSelf(self): - target = self.expected_tree['levelOne']['levelTwo']['two.py'] - start = self.expected_tree['levelOne']['levelTwo']['two.py'] - - relative_path = start.getPathToNode(target) - self.failUnlessEqual(relative_path, - (), - ) - return - - def testParentDirOfModuleDir(self): - target = self.expected_tree['levelOne'] - start = self.expected_tree['levelOne']['levelTwo']['two.py'] - - relative_path = start.getPathToNode(target) - self.failUnlessEqual(relative_path, - ('..', - ), - ) - return - - def testModuleSameDir(self): - target = self.expected_tree['levelOne']['one.py'] - start = self.expected_tree['levelOne']['ignoreme.py'] - - relative_path = start.getPathToNode(target) - self.failUnlessEqual(relative_path, - ('one.py', - ), - ) - return - - def testModuleParentDir(self): - target = self.expected_tree['levelOne']['one.py'] - start = self.expected_tree['levelOne']['levelTwo']['two.py'] - - relative_path = start.getPathToNode(target) - self.failUnlessEqual(relative_path, - ('..', - 'one.py', - ), - ) - return - - def testParentDirOfDir(self): - target = self.expected_tree['levelOne'] - start = self.expected_tree['levelOne']['levelTwo'] - - relative_path = start.getPathToNode(target) - self.failUnlessEqual(relative_path, - ('..', - ), - ) - return - - - class ScannerSummaryAndDocStringTests(unittest.TestCase): - - def setUp(self): - input_dir = os.path.join('TestCases', 'testScanner') - output_dir = '/tmp/foo' - - scanner = Scanner([input_dir]) - - self.scanner = scanner - return - - def tearDown(self): - del self.scanner - return - - def testGetReadmeTextForDirectoryInit(self): - trees = self.scanner.getPackageTrees() - expected_tree = trees[0]['readme_from_init'] - - actual, format = expected_tree.getDocStringAndFormat() - - expected_format = 'StructuredText' - expected = 'This is the __init__.py file for readme_from_init.' - - self.failUnlessEqual(actual, expected) - return - - def testGetReadmeTextForDirectoryDotTxt(self): - trees = self.scanner.getPackageTrees() - expected_tree = trees[0]['readme_from_readme'] - - actual, format = expected_tree.getDocStringAndFormat() - - expected_format = 'StructuredText' - expected = 'This is the README.txt file for readme_from_readme.\n' - - self.failUnlessEqual(actual, expected) - return - - def testGetReadmeTextForDirectoryDotStx(self): - trees = self.scanner.getPackageTrees() - expected_tree = trees[0]['readme_from_stx'] - - actual, format = expected_tree.getDocStringAndFormat() - - expected_format = 'StructuredText' - expected = 'This is the README.stx file for readme_from_stx.\n' - - self.failUnlessEqual(actual, expected) - return - - class ScannerFindNodeTestCase(unittest.TestCase): - - def setUp(self): - cwd = os.getcwd() - input_dir = os.path.join(cwd, 'TestCases/testScanner') - scanner = Scanner([input_dir]) - - trees = scanner.getPackageTrees() - expected_tree = trees[0] - self.expected_tree = expected_tree - return - - def _testFind(self, name, start, target): - found = start.findNodeFromDottedName(name) - if not found: - self.fail('Did not find anything') - self.failUnlessEqual(found, target) - return - - def testFindSelf(self): - self._testFind('levelOne', - self.expected_tree['levelOne'], - self.expected_tree['levelOne'], - ) - return - - def testFindChild(self): - self._testFind('levelTwo', - self.expected_tree['levelOne'], - self.expected_tree['levelOne']['levelTwo'], - ) - return - - def testFindSelfDotChild(self): - self._testFind('levelOne.levelTwo', - self.expected_tree['levelOne'], - self.expected_tree['levelOne']['levelTwo'], - ) - return - - def testFindParent(self): - self._testFind('levelOne', - self.expected_tree['levelOne']['levelTwo'], - self.expected_tree['levelOne'], - ) - return - - def testFindSibling(self): - self._testFind('readme_from_readme', - self.expected_tree['levelOne'], - self.expected_tree['readme_from_readme'], - ) - return - - def testFindAunt(self): - self._testFind('readme_from_readme', - self.expected_tree['levelOne']['levelTwo'], - self.expected_tree['readme_from_readme'], - ) - return - - def testFindNeice(self): - self._testFind('levelOne.levelTwo', - self.expected_tree['readme_from_readme'], - self.expected_tree['levelOne']['levelTwo'], - ) - return - - def testFindNotThere(self): - name = 'levelOne.levelTwo.notThereAtAll' - start = self.expected_tree['readme_from_readme'] - found = start.findNodeFromDottedName(name) - - if found: - self.fail('Found somethi... [truncated message content] |
From: Doug H. <dou...@us...> - 2002-12-29 17:33:33
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv9445/happydoclib/docset Modified Files: tests.py Log Message: API change from writeX to processX for mimetype writers. Index: tests.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/tests.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tests.py 28 Dec 2002 16:00:13 -0000 1.3 --- tests.py 29 Dec 2002 17:33:31 -0000 1.4 *************** *** 168,172 **** return ! def testRequiresWritePythonFile(self): docset = base.MultiFileDocSet( scanner=None, --- 168,172 ---- return ! def testRequiresProcessPythonFile(self): docset = base.MultiFileDocSet( scanner=None, *************** *** 175,179 **** ) try: ! docset.writePythonFile(None) except NotImplementedError: pass --- 175,179 ---- ) try: ! docset.processPythonFile(None) except NotImplementedError: pass |
From: Doug H. <dou...@us...> - 2002-12-29 17:33:20
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv9352/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Let the PackageTree deal with finding subnodes by mimetype. API cleanup to remove _ prefix from several methods which are part of the API to override. API change from writeX to processX for mimetype writers. Add methods to document classes. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** docset_MultiHTMLFile.py 28 Dec 2002 15:59:51 -0000 1.12 --- docset_MultiHTMLFile.py 29 Dec 2002 17:33:17 -0000 1.13 *************** *** 56,59 **** --- 56,60 ---- # import os + import pprint try: from cStringIO import StringIO *************** *** 114,118 **** ) ! if packageTreeNode.values(): # # This is a directory. --- 115,119 ---- ) ! if packageTreeNode.getMimeType() == ('application/x-directory', None): # # This is a directory. *************** *** 128,131 **** --- 129,147 ---- return filename_with_extension + def getOutputFilenameForSymbol(self, packageTreeNode, symbolName, includePath=1): + """Returns a filename where documentation for symbolName 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. + """ + package_output_name = self.getOutputFilenameForPackageTreeNode( + packageTreeNode, + includePath=includePath, + ) + name, ext = os.path.splitext(package_output_name) + output_name = '%s_%s.html' % (name, symbolName) + return output_name + def writeFileHeader(self, output, title='', subtitle=''): """Given an open output stream, write a header using the title and subtitle. *************** *** 193,197 **** return ! def _writeDescriptiveList(self, output, descriptiveList): """Write a list including descriptions. --- 209,213 ---- return ! def writeDescriptiveList(self, output, descriptiveList): """Write a list including descriptions. *************** *** 205,209 **** """ ! output.write('<!-- _writeDescriptiveList -->\n') output.write('<table border="0" cellpadding="3" cellspacing="0">\n') --- 221,225 ---- """ ! output.write('<!-- writeDescriptiveList -->\n') output.write('<table border="0" cellpadding="3" cellspacing="0">\n') *************** *** 225,228 **** --- 241,246 ---- def writeList(self, output, listElements): + """Write a formatted list of values to the output. + """ output.write('<p>\n') for list_element in listElements: *************** *** 262,266 **** return href ! def _getAnchorTagForPackageTreeNode(self, source, destination, title=None): """Return a anchor tag to be included in the documentation of source that points to the destination. --- 280,288 ---- return href ! def _getAnchorTagForPackageTreeNode(self, ! source, ! destination, ! title=None, ! internalTarget=None): """Return a anchor tag to be included in the documentation of source that points to the destination. *************** *** 269,275 **** --- 291,301 ---- title = destination.getName() href = self._computeRelativeHREF(source, destination) + if internalTarget: + href='%s#%s' % (href, internalTarget) return '<a href="%s">%s</a>' % (href, title) def writeSectionTitle(self, output, title, subtitle, anchor=None): + """Generate the text and styles to begin a new section. + """ bgcolor = self.levelTwoHeadingBackgroundColor fgcolor = self.levelTwoHeadingForegroundColor *************** *** 301,305 **** def pushSectionLevel(self, output, title, subtitle='', anchor=''): ! """Generate the text and styles to begin a new section one deeper than the previous level. """ output.write( --- 327,334 ---- def pushSectionLevel(self, output, title, subtitle='', anchor=''): ! """Increase the section level. ! ! Generate the text and styles to begin a new section one ! deeper than the previous level. """ output.write( *************** *** 314,326 **** def writeSectionFooter(self, output): output.write('</td></tr>\n') return def popSectionLevel(self, output): self.writeSectionFooter(output) output.write('</table>') return ! def _writeTOCReferencesSection(self, output, packageTreeNode, --- 343,362 ---- def writeSectionFooter(self, output): + """Generate the text and styles to close the current section. + """ output.write('</td></tr>\n') return def popSectionLevel(self, output): + """Decrease the section level. + + Generate the text and styles to close the current section + and change the section level to the next higher level. + """ self.writeSectionFooter(output) output.write('</table>') return ! def writeTOCReferencesSection(self, output, packageTreeNode, *************** *** 344,353 **** """ descriptive_list = [(self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat() ! for name, node in moduleList ] if descriptive_list: self.pushSectionLevel(output, title) descriptive_list.sort() ! self._writeDescriptiveList(output, descriptive_list) if descriptive_list: --- 380,390 ---- """ descriptive_list = [(self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat() ! for node in moduleList ! ] if descriptive_list: self.pushSectionLevel(output, title) descriptive_list.sort() ! self.writeDescriptiveList(output, descriptive_list) if descriptive_list: *************** *** 386,406 **** pass else: ! self._writePythonFileInfoToOutput(output, init_node) ! ! # ! # Group contained modules by mimetype ! # ! contained_modules = packageTreeNode.items() ! contained_modules_map = {} ! ! for name, node in contained_modules: ! mimetype, encoding = node.getMimeType() ! set = contained_modules_map.setdefault(mimetype, []) ! set.append( (name, node) ) ! ! #output.write('Summary\n') ! #descriptive_list = [ (name, str(len(set)), 'StructuredText') for name, set in contained_modules_map.items() ] ! #descriptive_list.sort() ! #self._writeDescriptiveList(output, descriptive_list) # --- 423,427 ---- pass else: ! self.writePythonFileInfoToOutput(output, init_node) # *************** *** 408,416 **** # converted. # ! plain_text_files = contained_modules_map.get('text/plain', []) ! structured_text_files = contained_modules_map.get('text/x-structured', []) ! html_files = contained_modules_map.get('text/html', []) text_files = plain_text_files + structured_text_files + html_files ! self._writeTOCReferencesSection( output, packageTreeNode, --- 429,437 ---- # converted. # ! plain_text_files = packageTreeNode.getSubNodes('text/plain') ! structured_text_files = packageTreeNode.getSubNodes('text/x-structured') ! html_files = packageTreeNode.getSubNodes('text/html') text_files = plain_text_files + structured_text_files + html_files ! self.writeTOCReferencesSection( output, packageTreeNode, *************** *** 422,431 **** # Write out references to Python files we parsed. # ! self._writeTOCReferencesSection( output, packageTreeNode, 'Python files', ! [ cm for cm in contained_modules_map.get('text/x-python', []) ! if cm[1].getName() != '__init__.py' ], ) --- 443,452 ---- # Write out references to Python files we parsed. # ! self.writeTOCReferencesSection( output, packageTreeNode, 'Python files', ! [ node for node in packageTreeNode.getSubNodes('text/x-python') ! if node.getName() != '__init__.py' ], ) *************** *** 434,442 **** # Write out references to subdirectories # ! directories = contained_modules_map.get('application/x-directory', []) #directories = [ d for d in directories # if d[1].items() # ] ! self._writeTOCReferencesSection( output, packageTreeNode, --- 455,463 ---- # Write out references to subdirectories # ! directories = packageTreeNode.getSubNodes('application/x-directory') #directories = [ d for d in directories # if d[1].items() # ] ! self.writeTOCReferencesSection( output, packageTreeNode, *************** *** 450,454 **** return ! def _writeImportWithFrom(self, output, pacakgeTreeNode, moduleReference, symbolReferences): output.write('from %s import %s<br>' % (moduleReference, ', '.join(symbolReferences), --- 471,477 ---- return ! def writeImportWithFrom(self, output, pacakgeTreeNode, moduleReference, symbolReferences): ! """Write an import statement: 'from X import Y' ! """ output.write('from %s import %s<br>' % (moduleReference, ', '.join(symbolReferences), *************** *** 457,465 **** return ! def _writeImport(self, output, packageTreeNode, moduleReference): output.write('import %s<br>' % moduleReference) return ! def _writeImportForPythonSystemModule(self, output, packageTreeNode, --- 480,490 ---- return ! def writeImport(self, output, packageTreeNode, moduleReference): ! """Write an import statement: 'import X' ! """ output.write('import %s<br>' % moduleReference) return ! def writeImportForPythonSystemModule(self, output, packageTreeNode, *************** *** 468,474 **** url, ): ref = '<a href="%s">%s</a>' % (url, name) if symbols: ! self._writeImportWithFrom(output, packageTreeNode, ref, --- 493,505 ---- url, ): + """Write an import statement for a Python system module. + + Handles either 'from X import Y' or 'import X'. The module + name is a link to the Python documentation on + http://www.python.org. + """ ref = '<a href="%s">%s</a>' % (url, name) if symbols: ! self.writeImportWithFrom(output, packageTreeNode, ref, *************** *** 476,480 **** ) else: ! self._writeImport(output, packageTreeNode, ref, --- 507,511 ---- ) else: ! self.writeImport(output, packageTreeNode, ref, *************** *** 483,487 **** ! def _writeImportForKnownModule(self, output, packageTreeNode, --- 514,518 ---- ! def writeImportForKnownModule(self, output, packageTreeNode, *************** *** 490,493 **** --- 521,530 ---- symbols, ): + """Write an import statement for a module known to HappyDoc. + + Handles either 'from X import Y' or 'import X'. The module + name is a link to the documentation for that module within the + HappyDoc-generated output. + """ # # Compute the href from here to there. *************** *** 515,519 **** symbol_refs.append( symbol_ref ) ! self._writeImportWithFrom(output, packageTreeNode, ref, --- 552,556 ---- symbol_refs.append( symbol_ref ) ! self.writeImportWithFrom(output, packageTreeNode, ref, *************** *** 521,525 **** ) else: ! self._writeImport(output, packageTreeNode, ref, --- 558,562 ---- ) else: ! self.writeImport(output, packageTreeNode, ref, *************** *** 528,532 **** ! def _writePythonFileImportsToOutput(self, output, packageTreeNode): """Writes the list of imported modules for the packageTreeNode. """ --- 565,569 ---- ! def writePythonFileImportsToOutput(self, output, packageTreeNode): """Writes the list of imported modules for the packageTreeNode. """ *************** *** 545,549 **** url = getPythonSystemModuleURL(name) if url: ! self._writeImportForPythonSystemModule(output, packageTreeNode, name, --- 582,586 ---- url = getPythonSystemModuleURL(name) if url: ! self.writeImportForPythonSystemModule(output, packageTreeNode, name, *************** *** 558,562 **** referenced_module = packageTreeNode.findNodeFromDottedName(name) if referenced_module is not None: ! self._writeImportForKnownModule(output, packageTreeNode, name, --- 595,599 ---- referenced_module = packageTreeNode.findNodeFromDottedName(name) if referenced_module is not None: ! self.writeImportForKnownModule(output, packageTreeNode, name, *************** *** 570,574 **** # if symbols: ! self._writeImportWithFrom(output, packageTreeNode, name, --- 607,611 ---- # if symbols: ! self.writeImportWithFrom(output, packageTreeNode, name, *************** *** 576,580 **** ) else: ! self._writeImport(output, packageTreeNode, name, --- 613,617 ---- ) else: ! self.writeImport(output, packageTreeNode, name, *************** *** 587,591 **** return ! def _writePreformatted(self, output, text): """Write text as a preformatted section. """ --- 624,628 ---- return ! def writePreformatted(self, output, text): """Write text as a preformatted section. """ *************** *** 597,601 **** return ! def _writeFunctionParameter(self, output, name, info): '''Write a function parameter to the output. --- 634,638 ---- return ! def writeFunctionParameter(self, output, name, info): '''Write a function parameter to the output. *************** *** 636,640 **** return ! def _writeFunctionSignature(self, output, packageTreeNode, --- 673,677 ---- return ! def writeFunctionSignature(self, output, packageTreeNode, *************** *** 661,665 **** param_info = function.getParameterInfo(param) signature_buffer.write(' ') ! self._writeFunctionParameter(signature_buffer, param, param_info, --- 698,702 ---- param_info = function.getParameterInfo(param) signature_buffer.write(' ') ! self.writeFunctionParameter(signature_buffer, param, param_info, *************** *** 674,678 **** signature_buffer.write(' ' * indent) param_info = function.getParameterInfo(param) ! self._writeFunctionParameter(signature_buffer, param, param_info, --- 711,715 ---- signature_buffer.write(' ' * indent) param_info = function.getParameterInfo(param) ! self.writeFunctionParameter(signature_buffer, param, param_info, *************** *** 682,689 **** signature_buffer.write(')\n') ! self._writePreformatted(output, signature_buffer.getvalue()) return ! def _writeExceptionListForFunction(self, output, function): """Write the list of exceptions raised by a function. --- 719,726 ---- signature_buffer.write(')\n') ! self.writePreformatted(output, signature_buffer.getvalue()) return ! def writeExceptionListForFunction(self, output, function): """Write the list of exceptions raised by a function. *************** *** 711,714 **** --- 748,753 ---- if exception_class: + # FIXME - Need a way to get a reference to a class in the + # scanned input! ref = formatter.getReference( exception_class, #output_reduced_name, *************** *** 727,735 **** return ! def _writeOneFunctionToOutput(self, output, packageTreeNode, functionInfo, ): self.pushSectionLevel(output, title='', --- 766,776 ---- return ! def writeOneFunctionToOutput(self, output, packageTreeNode, functionInfo, ): + """Write all of the information for one function to the output stream. + """ self.pushSectionLevel(output, title='', *************** *** 740,744 **** # Signature # ! self._writeFunctionSignature(output, packageTreeNode, functionInfo) # --- 781,785 ---- # Signature # ! self.writeFunctionSignature(output, packageTreeNode, functionInfo) # *************** *** 752,761 **** # Exceptions # ! self._writeExceptionListForFunction(output, functionInfo) self.popSectionLevel(output) return ! def _writeFunctionsToOutput(self, output, packageTreeNode): """Writes information about functions in this module to the output stream. """ --- 793,802 ---- # Exceptions # ! self.writeExceptionListForFunction(output, functionInfo) self.popSectionLevel(output) return ! def writeFunctionsToOutput(self, output, packageTreeNode): """Writes information about functions in this module to the output stream. """ *************** *** 777,781 **** for function_name in function_names: ! self._writeOneFunctionToOutput( output, packageTreeNode, --- 818,822 ---- for function_name in function_names: ! self.writeOneFunctionToOutput( output, packageTreeNode, *************** *** 786,802 **** return ! def _writePythonFileInfoToOutput(self, output, packageTreeNode): """Writes parts of the Python file information to the output stream. """ ! self._writePythonFileImportsToOutput(output, packageTreeNode) ! self._writeFunctionsToOutput(output, packageTreeNode) ! # Classes return ! def writePythonFile(self, packageTreeNode): """Handler for text/x-python nodes. """ ! trace.into('MultiHTMLFileDocSet', 'writePythonFile', packageTreeNode=packageTreeNode, ) --- 827,1003 ---- return ! def _getBaseClassTree(self, packageTreeNode, className): ! try: ! class_info = packageTreeNode.module_info.getClassInfo(className) ! except KeyError: ! base_class_names = [] ! else: ! base_class_names = self._filterNames(class_info.getBaseClassNames()) ! ! base_class_trees = [] ! for base_class_name in base_class_names: ! base_class_tree = self._getBaseClassTree(packageTreeNode, ! base_class_name, ! ) ! base_class_trees.append( base_class_tree ) ! ! try: ! symbol_info = packageTreeNode.module_info.getClassInfo(className) ! except KeyError: ! ref = className ! else: ! symbol_output_name = self.getOutputFilenameForSymbol( ! packageTreeNode, ! className, ! includePath=0, ! ) ! ref = '<a href="%s">%s</a>' % (symbol_output_name, className) ! ! return (ref, base_class_trees) ! ! def writeTree(self, output, treeRoot, indent=0): ! output.write('%s%s<br>' % (' ' * indent, treeRoot[0])) ! for subtree in treeRoot[1]: ! self.writeTree(output, subtree, indent+1) ! return ! ! def writeBaseClassNames(self, output, packageTreeNode, classInfo): ! base_class_tree = self._getBaseClassTree(packageTreeNode, classInfo.getName()) ! #self.writeList(output, base_class_names) ! output.write('<p>\n') ! self.writeTree(output, base_class_tree) ! output.write('</p>\n') ! return ! ! def writeOneClassToOutput(self, output, packageTreeNode, className): ! """Writes information about one class to the output stream. ! """ ! class_info = packageTreeNode.module_info.getClassInfo(className) ! ! # ! # Description ! # ! docstring_text = class_info.getDocString() ! docstring_format = class_info.getDocStringFormat() ! self.writeText(output, docstring_text, docstring_format) ! ! # ! # Base classes ! # ! base_class_names = self._filterNames(class_info.getBaseClassNames()) ! if base_class_names: ! self.pushSectionLevel(output, 'Base Classes') ! self.writeBaseClassNames(output, packageTreeNode, class_info) ! self.popSectionLevel(output) ! ! # ! # Methods ! # ! method_names = self._filterNames(class_info.getMethodNames()) ! if method_names: ! if self.sort_names: ! method_names.sort() ! self.pushSectionLevel(output, 'Methods') ! ! for method_name in method_names: ! method_info = class_info.getMethodInfo(method_name) ! self.writeOneFunctionToOutput( ! output, ! packageTreeNode, ! method_info, ! ) ! ! self.popSectionLevel(output) ! ! return ! ! def writeClassListForModule(self, output, packageTreeNode): ! """Write descriptions of all of the classes to the output stream. ! """ ! class_names = self._filterNames(packageTreeNode.module_info.getClassNames()) ! ! if self.sort_names: ! class_names.sort() ! ! descriptive_list = [] ! ! for class_name in class_names: ! symbol_output_name = self.getOutputFilenameForSymbol( ! packageTreeNode, ! class_name, ! includePath=0, ! ) ! ref = '<a href="%s">%s</a>' % (symbol_output_name, class_name) ! class_info = packageTreeNode.module_info.getClassInfo(class_name) ! class_info_summary, class_info_format = class_info.getSummaryAndFormat() ! descriptive_list.append( (ref, class_info_summary, class_info_format) ) ! ! self.pushSectionLevel(output, 'Classes') ! self.writeDescriptiveList(output, descriptive_list) ! self.popSectionLevel(output) ! return ! ! def writeClassesToOutput(self, output, packageTreeNode): ! """Writes information about classes in this module to the output stream. ! """ ! class_names = self._filterNames(packageTreeNode.module_info.getClassNames()) ! if not class_names: ! return ! ! # ! # Write a list of the classes to the current output file ! # ! self.writeClassListForModule(output, packageTreeNode) ! ! # ! # Document each class in its own file ! # ! ! for class_name in class_names: ! ! # ! # Open a new output stream for the class. ! # ! class_output_name = self.getOutputFilenameForSymbol( ! packageTreeNode, ! class_name, ! includePath=1, ! ) ! ! class_output = self.openOutput( ! class_output_name, ! title=self.title, ! subtitle='Class: %s' % class_name, ! ) ! ! # ! # Write class documentation ! # ! self.writeOneClassToOutput( ! class_output, ! packageTreeNode, ! class_name, ! ) ! ! # ! # Close the class' output stream ! # ! self.closeOutput(class_output) ! ! return ! ! def writePythonFileInfoToOutput(self, output, packageTreeNode): """Writes parts of the Python file information to the output stream. """ ! self.writePythonFileImportsToOutput(output, packageTreeNode) ! self.writeFunctionsToOutput(output, packageTreeNode) ! self.writeClassesToOutput(output, packageTreeNode) return ! def processPythonFile(self, packageTreeNode): """Handler for text/x-python nodes. """ ! trace.into('MultiHTMLFileDocSet', 'processPythonFile', packageTreeNode=packageTreeNode, ) *************** *** 804,807 **** --- 1005,1009 ---- node_name = packageTreeNode.getName() if node_name == '__init__.py': + # # Skip the __init__.py file, since it will *************** *** 834,838 **** self.writeText(output, readme_text, text_format) ! self._writePythonFileInfoToOutput(output, packageTreeNode) self.closeOutput(output) --- 1036,1040 ---- self.writeText(output, readme_text, text_format) ! self.writePythonFileInfoToOutput(output, packageTreeNode) self.closeOutput(output) |
From: Doug H. <dou...@us...> - 2002-12-29 17:31:37
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv8758/happydoclib/docset Modified Files: base.py Log Message: API change from writeX to processX for mimetype writers. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** base.py 28 Dec 2002 15:58:29 -0000 1.11 --- base.py 29 Dec 2002 17:31:34 -0000 1.12 *************** *** 346,353 **** mimetype_writers = [ ! ('application/x-directory' , 'writeDirectory'), ! ('text/x-python' , 'writePythonFile'), ! ('text/plain' , 'writePlainTextFile'), ! ('text/x-structured' , 'writePlainTextFile'), ('text/html' , 'copyInputFileToOutput'), ('image/gif' , 'copyInputFileToOutput'), --- 346,353 ---- mimetype_writers = [ ! ('application/x-directory' , 'processDirectory'), ! ('text/x-python' , 'processPythonFile'), ! ('text/plain' , 'processPlainTextFile'), ! ('text/x-structured' , 'processPlainTextFile'), ('text/html' , 'copyInputFileToOutput'), ('image/gif' , 'copyInputFileToOutput'), *************** *** 436,440 **** return ! def writeDirectory(self, packageTreeNode): """Handler for application/x-directory nodes. --- 436,440 ---- return ! def processDirectory(self, packageTreeNode): """Handler for application/x-directory nodes. *************** *** 442,446 **** file. """ ! trace.into('MultiFileDocSet', 'writeDirectory', packageTreeNode=packageTreeNode, ) --- 442,446 ---- file. """ ! trace.into('MultiFileDocSet', 'processDirectory', packageTreeNode=packageTreeNode, ) *************** *** 559,568 **** return ! def writePythonFile(self, packageTreeNode): """Handler for text/x-python nodes. """ ! raise NotImplementedError('writePythonFile') ! def writePlainTextFile(self, packageTreeNode): """Handler for text/x-structured and text/plain nodes. --- 559,568 ---- return ! def processPythonFile(self, packageTreeNode): """Handler for text/x-python nodes. """ ! raise NotImplementedError('processPythonFile') ! def processPlainTextFile(self, packageTreeNode): """Handler for text/x-structured and text/plain nodes. *************** *** 571,575 **** already exist. """ ! trace.into('MultiFileDocSet', 'writePlainTextFile', packageTreeNode=packageTreeNode, ) --- 571,575 ---- already exist. """ ! trace.into('MultiFileDocSet', 'processPlainTextFile', packageTreeNode=packageTreeNode, ) |
From: Doug H. <dou...@us...> - 2002-12-29 17:31:01
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv8618/happydoclib Modified Files: scanner.py Log Message: Let a PackageTree node know how to find its children by their mimetype. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** scanner.py 28 Dec 2002 16:41:16 -0000 1.12 --- scanner.py 29 Dec 2002 17:30:58 -0000 1.13 *************** *** 498,501 **** --- 498,518 ---- return new_node + def getSubNodes(self, mimetype=None): + """Returns the children of this node. + + If mimetype is not none, returns only the children with that + mimetype. + """ + if mimetype is None: + return self.values() + else: + if not hasattr(self, 'grouped_children'): + self.grouped_children = {} + for node in self.values(): + mimetype, encoding = node.getMimeType() + group = self.grouped_children.setdefault(mimetype, []) + group.append(node) + return self.grouped_children.get(mimetype, []) + def walk(self, callback): """Walk the PackageTree, calling the callback at each node. |
From: Doug H. <dou...@us...> - 2002-12-28 16:43:34
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo In directory sc8-pr-cvs1:/tmp/cvs-serv29560/happydoclib/parseinfo Modified Files: classinfo.py functioninfo.py Log Message: Do not print the parse tree when tracing into the constructor. Index: classinfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/classinfo.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** classinfo.py 17 Nov 2002 15:05:43 -0000 1.1 --- classinfo.py 28 Dec 2002 16:43:32 -0000 1.2 *************** *** 88,92 **** happydoclib.TRACE.into('ClassInfo', '__init__', parent=parent, ! tree=tree, commentInfo=commentInfo, ) --- 88,92 ---- happydoclib.TRACE.into('ClassInfo', '__init__', parent=parent, ! #tree=tree, commentInfo=commentInfo, ) Index: functioninfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/functioninfo.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functioninfo.py 17 Nov 2002 15:05:43 -0000 1.1 --- functioninfo.py 28 Dec 2002 16:43:32 -0000 1.2 *************** *** 98,102 **** happydoclib.TRACE.into('FunctionInfo', '__init__', parent=parent, ! tree=tree, commentInfo=commentInfo, ) --- 98,102 ---- happydoclib.TRACE.into('FunctionInfo', '__init__', parent=parent, ! #tree=tree, commentInfo=commentInfo, ) |
From: Doug H. <dou...@us...> - 2002-12-28 16:43:12
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv29486/happydoclib/docset Modified Files: test_docset_MultiHTMLFile.py Log Message: Ignore test files when documenting HappyDoc. Index: test_docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_docset_MultiHTMLFile.py 15 Dec 2002 17:02:48 -0000 1.7 --- test_docset_MultiHTMLFile.py 28 Dec 2002 16:43:09 -0000 1.8 *************** *** 102,118 **** self.runHappyDoc( '-i', 'TestCases', '-i', 'TestOutput', os.getcwd(), ) scanner = Scanner([self.getOutputDirectory()]) ! root = os.path.join( self.getOutputDirectory(), 'testScanner' ) expected_dirs = [ ('HappyDoc3', 'levelOne',), ('HappyDoc3', 'levelOne', 'levelTwo'), ] ! expected_dirs = [ apply(os.path.join, (root,) + ed) for ed in expected_dirs ] for dirname in expected_dirs: if os.path.isdir(dirname): self.fail('%s should have been ignored' % dirname) return class MultiHTMLFileDocSetTestCase(unittest.TestCase): --- 102,148 ---- self.runHappyDoc( '-i', 'TestCases', '-i', 'TestOutput', + '-i', '^tests.py$', + '-i', '^test_.*.py$', os.getcwd(), ) scanner = Scanner([self.getOutputDirectory()]) ! root = self.getOutputDirectory() ! ! # ! # Directories to ignore ! # expected_dirs = [ ('HappyDoc3', 'levelOne',), ('HappyDoc3', 'levelOne', 'levelTwo'), ] ! expected_dirs = [ apply(os.path.join, (root,) + ed) ! for ed in expected_dirs ! ] for dirname in expected_dirs: if os.path.isdir(dirname): self.fail('%s should have been ignored' % dirname) + + # + # Directories to document + # + expected_dirs = [ ('HappyDoc3', 'happydoclib',), + ('HappyDoc3', 'happydoclib', 'docset'), + ('HappyDoc3', 'happydoclib', 'docstring'), + ('HappyDoc3', 'happydoclib', 'parseinfo'), + ] + expected_dirs = [ apply(os.path.join, (root,) + ed) + for ed in expected_dirs + ] + for dirname in expected_dirs: + if not os.path.isdir(dirname): + self.fail('%s should not have been ignored' % dirname) return + + # def testImportStatements(self): + # self.runHappyDoc( os.path.join( 'TestCases', + # 'parseinfo', + # 'test_import_statements.py') + # ) + # return class MultiHTMLFileDocSetTestCase(unittest.TestCase): |
From: Doug H. <dou...@us...> - 2002-12-28 16:41:34
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv29126/happydoclib Modified Files: test_scanner.py Log Message: Test the ignore pattern feature. Index: test_scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_scanner.py 27 Dec 2002 18:35:10 -0000 1.8 --- test_scanner.py 28 Dec 2002 16:41:31 -0000 1.9 *************** *** 299,302 **** --- 299,322 ---- return + def testPackageTreeIgnoreTestFiles(self): + scanner = Scanner(['happydoclib'], ['^tests.py$', + '^test_.*py$', + ]) + + trees = scanner.getPackageTrees() + level_one = trees[0] + + for name in ('tests.py', + 'test_scanner.py', + ): + try: + ignoring = level_one[name] + except KeyError: + pass + else: + self.fail('Still have %s' % name) + + return + def testPackageTreeName(self): tree = PackageTree(None, 'tree1') |