happydoc-checkins Mailing List for HappyDoc (Page 6)
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...> - 2002-12-28 16:41:19
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv29069/happydoclib Modified Files: scanner.py Log Message: Trace statement changes to aid in debugging. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** scanner.py 28 Dec 2002 15:57:40 -0000 1.11 --- scanner.py 28 Dec 2002 16:41:16 -0000 1.12 *************** *** 350,357 **** and ending with this node. """ ! trace.into('PackageTree', 'getPath', useCanonicalName=useCanonicalName) parent = self.getParent() ! trace.writeVar(parent=parent) if parent: parent_path = parent.getPath(useCanonicalName=useCanonicalName) --- 350,362 ---- 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) *************** *** 359,363 **** parent_path = () ! trace.writeVar(parent_path=parent_path) if useCanonicalName: --- 364,370 ---- parent_path = () ! trace.writeVar(parent_path=parent_path, ! outputLevel=2, ! ) if useCanonicalName: *************** *** 368,372 **** path = parent_path + (name,) ! trace.outof(path) return path --- 375,381 ---- path = parent_path + (name,) ! trace.outof(path, ! outputLevel=2, ! ) return path *************** *** 511,514 **** --- 520,528 ---- includeComments=1, ): + trace.into('Scanner', '__init__', + inputDirectories=inputDirectories, + ignorePatterns=ignorePatterns, + includeComments=includeComments, + ) self._ignore_patterns = ignorePatterns *************** *** 532,535 **** --- 546,551 ---- # self._parsePackageTree() + + trace.outof() return *************** *** 563,567 **** #if package_tree_name in self._ignore_names: for ignore_re in self._ignore_res: ! if ignore_re.match(package_tree_name): trace.outof() return None --- 579,586 ---- #if package_tree_name in self._ignore_names: for ignore_re in self._ignore_res: ! if ignore_re.search(package_tree_name): ! trace.write('Ignoring because "%s" matched %s' % (package_tree_name, ! ignore_re.pattern) ! ) trace.outof() return None |
From: Doug H. <dou...@us...> - 2002-12-28 16:40:49
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv28931/happydoclib Modified Files: appclass.py Log Message: Tighten up the ignore patterns so that 'docset' and 'docstring' do not match the pattern 'docs'. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** appclass.py 15 Dec 2002 16:59:10 -0000 1.8 --- appclass.py 28 Dec 2002 16:40:46 -0000 1.9 *************** *** 124,128 **** self._ignore_dir_patterns = [] ! self.addIgnoreDirectoryPattern('(CVS|dist|build|docs?|.*pyc|.*~)') self.addIgnoreDirectoryPattern('trace.txt') --- 124,128 ---- self._ignore_dir_patterns = [] ! self.addIgnoreDirectoryPattern('^(CVS|dist|build|docs?|.*pyc|.*~|tmp)$') self.addIgnoreDirectoryPattern('trace.txt') |
From: Doug H. <dou...@us...> - 2002-12-28 16:00:16
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv16433/happydoclib/docset Modified Files: tests.py Log Message: Tests for name filtering function. Index: tests.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/tests.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tests.py 27 Dec 2002 18:37:25 -0000 1.2 --- tests.py 28 Dec 2002 16:00:13 -0000 1.3 *************** *** 82,85 **** --- 82,126 ---- return + class TestDocSet(unittest.TestCase): + + def testFilterNames(self): + docset = base.DocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + includePrivateNames=0, + ) + + name_list = [ 'foo', + '_bar', + '__blah', + '__foobar__', + ] + expected = [ 'foo', + '__blah', + '__foobar__', + ] + actual = docset._filterNames(name_list) + self.failUnlessEqual(actual, expected) + return + + def testNoFilterNames(self): + docset = base.DocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + includePrivateNames=1, + ) + + name_list = [ 'foo', + '_bar', + '__blah', + '__foobar__', + ] + expected = name_list + actual = docset._filterNames(name_list) + self.failUnlessEqual(actual, expected) + return + class TestMultiFileDocSet(unittest.TestCase): |
From: Doug H. <dou...@us...> - 2002-12-28 15:59:54
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv16183/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Switch section headers/footers to use table formatting like HappyDoc 2.0. A new docset will be written to use CSS later, but for now this makes it easier to see whether the basic work is correct. Add function information to the module output. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** docset_MultiHTMLFile.py 28 Dec 2002 14:27:32 -0000 1.11 --- docset_MultiHTMLFile.py 28 Dec 2002 15:59:51 -0000 1.12 *************** *** 56,60 **** --- 56,65 ---- # import os + try: + from cStringIO import StringIO + except: + from StringIO import StringIO import time + import token # *************** *** 207,212 **** output.write(''' <tr> ! <td>%(name)s</td> ! <td>''' % locals()) self.writeText(output, text, text_format) --- 212,217 ---- output.write(''' <tr> ! <td valign="top"><p>%(name)s</p></td> ! <td valign="top">''' % locals()) self.writeText(output, text, text_format) *************** *** 219,222 **** --- 224,234 ---- return + def writeList(self, output, listElements): + output.write('<p>\n') + for list_element in listElements: + output.write('%s<br>\n' % list_element) + output.write('</p>\n') + return + def _computeRelativeHREF(self, source, destination): """Compute the HREF to point from the output file of source to destination. *************** *** 259,263 **** return '<a href="%s">%s</a>' % (href, title) ! def _writeTOCReferencesSection(self, output, packageTreeNode, title, moduleList): """Write a list of references in the table of contents. --- 271,331 ---- return '<a href="%s">%s</a>' % (href, title) ! def writeSectionTitle(self, output, title, subtitle, anchor=None): ! bgcolor = self.levelTwoHeadingBackgroundColor ! fgcolor = self.levelTwoHeadingForegroundColor ! output.write(''' ! <tr> ! <th bgcolor="%(bgcolor)s" ! rowspan="2" ! valign="top" ! align="left" ! width="20%%" ! > ! <font color="%(fgcolor)s"> ! <a name="%(anchor)s">%(title)s</a> ! </font> ! </th> ! <th bgcolor="%(bgcolor)s" ! valign="top" ! align="left" ! width="80%%" ! > ! <font color="%(fgcolor)s">%(subtitle)s </font> ! </th> ! </tr> ! <tr> ! <td> ! ''' % locals()) ! #output.write('<h%s>%s</h%s>\n' % (level, title, level)) ! return ! ! 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( ! '<table border="0" cellpadding="5" cellspacing="0" width="100%">\n' ! ) ! self.writeSectionTitle(output, ! title=title, ! subtitle=subtitle, ! anchor=anchor, ! ) ! return ! ! 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, ! title, ! moduleList, ! ): """Write a list of references in the table of contents. *************** *** 278,284 **** for name, node in moduleList ] if descriptive_list: ! output.write('<h4>%s</h4>\n' % title) descriptive_list.sort() self._writeDescriptiveList(output, descriptive_list) return --- 346,356 ---- for name, node in moduleList ] if descriptive_list: ! self.pushSectionLevel(output, title) ! descriptive_list.sort() self._writeDescriptiveList(output, descriptive_list) + + if descriptive_list: + self.popSectionLevel(output) return *************** *** 461,465 **** import_data = packageTreeNode.module_info.getImportData() if import_data: ! output.write('<h4>Imported Modules</h4>\n') output.write('<p>\n') --- 533,538 ---- import_data = packageTreeNode.module_info.getImportData() if import_data: ! self.pushSectionLevel(output, 'Imported Modules') ! output.write('<p>\n') *************** *** 509,512 **** --- 582,787 ---- output.write('</p>\n') + + self.popSectionLevel(output) + + return + + def _writePreformatted(self, output, text): + """Write text as a preformatted section. + """ + output.write('<pre>\n') + output.write(text) + if text and text[-1] != '\n': + output.write('\n') + output.write('</pre>\n') + return + + def _writeFunctionParameter(self, output, name, info): + '''Write a function parameter to the output. + + No indenting or formatting is performed. The output + looks like:: + + name + + or + + name=default + + Parameters: + + name -- name of the parameter + + info -- tuple of (default_specified, default_value, + default_value_type) + concerning the default value of the parameter + + output -- destination for written output + + ''' + output.write(name) + default_specified, default_value, default_value_type = info + if default_specified: + output.write('=') + if default_value_type == token.STRING: + output.write(`default_value`) + elif default_value_type == token.NUMBER: + output.write(str(default_value)) + else: + #print 'FUNCTION DEFAULT VALUE (%s, %s): "%s"' % ( + # type(default_value), + # default_value_type or 'Unknown', + # default_value) + output.write(str(default_value)) + return + + def _writeFunctionSignature(self, + output, + packageTreeNode, + function, + ): + """Write the function signature for 'function' to 'output'. + + Parameters + + output -- Where to write. + + pacakgeTreeNode -- The part of the input we are processing. + + function -- Instance of FunctionInfo from parseinfo module. + + """ + function_name = function.getName() + signature_buffer = StringIO() + signature_buffer.write('%s (' % function_name) + parameter_names = function.getParameterNames() + if parameter_names: + if len(parameter_names) <= 2: + for param in parameter_names: + param_info = function.getParameterInfo(param) + signature_buffer.write(' ') + self._writeFunctionParameter(signature_buffer, + param, + param_info, + ) + if param != parameter_names[-1]: + signature_buffer.write(',') + signature_buffer.write(' ') + else: + signature_buffer.write('\n') + indent = 8 #len(name) + 3 + for param in parameter_names: + signature_buffer.write(' ' * indent) + param_info = function.getParameterInfo(param) + self._writeFunctionParameter(signature_buffer, + param, + param_info, + ) + signature_buffer.write(',\n') + signature_buffer.write('%s' % (' ' * indent)) + 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. + + Parameters + + output -- Where to write. + + function -- FunctionInfo from parseinfo module. + + listHeader -- Header for list being generated. + + """ + exception_names = function.getExceptionNames() + if not exception_names: + return + + if self.sort_names: + exception_names.sort() + + exception_list = [] + + for name in exception_names: + #exception_class = self.getClassInfo(name) + exception_class = None + + if exception_class: + ref = formatter.getReference( exception_class, + #output_reduced_name, + output.name, + ) + else: + #ref = formatter.getPythonReference( name ) + ref = name + + exception_list.append(ref) + + self.pushSectionLevel(output, 'Exceptions') + self.writeList(output, exception_list) + self.popSectionLevel(output) + + return + + def _writeOneFunctionToOutput(self, + output, + packageTreeNode, + functionInfo, + ): + self.pushSectionLevel(output, + title='', + subtitle=functionInfo.getName(), + anchor=functionInfo.getName(), + ) + # + # Signature + # + self._writeFunctionSignature(output, packageTreeNode, functionInfo) + + # + # Description + # + docstring_text = functionInfo.getDocString() + docstring_format = functionInfo.getDocStringFormat() + self.writeText(output, docstring_text, docstring_format) + + # + # 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. + """ + function_names = self._filterNames(packageTreeNode.module_info.getFunctionNames()) + if not function_names: + return + + if self.sort_names: + function_names.sort() + + # + # Section header + # + self.pushSectionLevel(output, 'Functions') + + # + # Functions + # + + for function_name in function_names: + self._writeOneFunctionToOutput( + output, + packageTreeNode, + packageTreeNode.module_info.getFunctionInfo(function_name), + ) + + self.popSectionLevel(output) return *************** *** 515,519 **** """ self._writePythonFileImportsToOutput(output, packageTreeNode) ! # Functions # Classes return --- 790,794 ---- """ self._writePythonFileImportsToOutput(output, packageTreeNode) ! self._writeFunctionsToOutput(output, packageTreeNode) # Classes return |
From: Doug H. <dou...@us...> - 2002-12-28 15:58:34
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv15827/happydoclib/docset Modified Files: base.py Log Message: Add option to control whether names are sorted. Add method to filter names to enforce the includePrivateNames option. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** base.py 27 Dec 2002 18:35:55 -0000 1.10 --- base.py 28 Dec 2002 15:58:29 -0000 1.11 *************** *** 175,178 **** --- 175,179 ---- includeComments=1, includePrivateNames=1, + sortNames=0, statusMessageFunc=None, extraParameters={}, *************** *** 197,200 **** --- 198,204 ---- is True. + sortNames=0 -- Boolean. True means to sort names before + generating output. Default is False. + statusMessageFunc -- function which will print a status message for the user *************** *** 205,209 **** """ ! trace.into('DocSetBase', '__init__', scanner=scanner, title=title, --- 209,213 ---- """ ! trace.into('DocSet', '__init__', scanner=scanner, title=title, *************** *** 211,214 **** --- 215,219 ---- includeComments=includeComments, includePrivateNames=includePrivateNames, + sortNames=0, statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, *************** *** 227,230 **** --- 232,236 ---- self.include_comments = includeComments self.include_private_names = includePrivateNames + self.sort_names = sortNames self._initializeWriters() *************** *** 233,236 **** --- 239,264 ---- return + def _filterNames(self, nameList): + """Remove names which should be ignored. + + Parameters + + nameList -- List of strings representing names of methods, + classes, functions, etc. + + This method returns a list based on the contents of nameList. + If private names are being ignored, they are removed before + the list is returned. + + """ + if not self.include_private_names: + #nameList = filter(lambda x: ( (x[0] != '_') or (x[:2] == '__') ), + # nameList) + nameList = [ name + for name in nameList + if name and ((name[0] != '_') or (name[:2] == '__')) + ] + return nameList + def _skipInputFile(self, packageTreeNode): """False writer method used to notify the user that a node is being *************** *** 527,531 **** # Convert and write the text. # ! html = converter.convert(text, 'html', level=3) output.write(html) return --- 555,559 ---- # Convert and write the text. # ! html = converter.convert(text, 'html', level=4) output.write(html) return |
From: Doug H. <dou...@us...> - 2002-12-28 15:57:55
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv15652/happydoclib Modified Files: utils.py Log Message: Add docstrings. Index: utils.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/utils.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** utils.py 15 Dec 2002 17:00:44 -0000 1.1 --- utils.py 28 Dec 2002 15:57:53 -0000 1.2 *************** *** 26,30 **** # ! """ """ --- 26,30 ---- # ! """Utility functions which do not seem to fit elsewhere. """ *************** *** 67,70 **** --- 67,72 ---- def isSomethingThatLooksLikeDirectory(path): + """Returns boolean indicating whether or not path looks like a directory. + """ return (os.path.isdir(path) or |
From: Doug H. <dou...@us...> - 2002-12-28 15:57:43
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv15594/happydoclib Modified Files: scanner.py Log Message: Look at mimetype instead of filename to determine whether the node is a text file when trying to get the docstring summary. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** scanner.py 28 Dec 2002 14:26:29 -0000 1.10 --- scanner.py 28 Dec 2002 15:57:40 -0000 1.11 *************** *** 288,292 **** # Are we a text file? # ! if self.getName() in ('README.txt', 'README.stx'): input_filename = self.getInputFilename() readme_text = open(input_filename, 'rt').read() --- 288,293 ---- # 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() *************** *** 297,305 **** # Look inside sub-nodes # ! node = self.get('__init__.py') ! if node is not None: ! return node.getDocStringAndFormat() ! ! for name in ('README.txt', 'README.stx'): trace.write('looking for %s' % name) node = self.get(name) --- 298,302 ---- # Look inside sub-nodes # ! for name in ('__init__.py', 'README.txt', 'README.stx'): trace.write('looking for %s' % name) node = self.get(name) *************** *** 418,431 **** name_parts = dottedNodeName.split('.') name = name_parts[0] - remainder = '.'.join(name_parts[1:]) trace.write('name=%s' % name, outputLevel=trace_level, ) - trace.write('remainder=%s' % remainder, - outputLevel=trace_level, - ) trace.writeVar(name=name, - remainder=remainder, outputLevel=trace_level, ) --- 415,423 ---- *************** *** 469,474 **** # Do we need to process the remainder of the original name? # ! if named_node and remainder: ! trace.write('Handling remainder', outputLevel=trace_level, ) --- 461,467 ---- # 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, ) |
From: Doug H. <dou...@us...> - 2002-12-28 14:27:35
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv26126/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Use the dotted name of the module as the title of the anchor tag when generating a link to a known module. Check 'is not null' when examining the result of the dotted name search. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** docset_MultiHTMLFile.py 27 Dec 2002 18:37:05 -0000 1.10 --- docset_MultiHTMLFile.py 28 Dec 2002 14:27:32 -0000 1.11 *************** *** 389,393 **** return ! def _writeImportForPythonSystemModule(self, output, packageTreeNode, name, symbols, url): ref = '<a href="%s">%s</a>' % (url, name) if symbols: --- 389,399 ---- return ! def _writeImportForPythonSystemModule(self, ! output, ! packageTreeNode, ! name, ! symbols, ! url, ! ): ref = '<a href="%s">%s</a>' % (url, name) if symbols: *************** *** 405,409 **** ! def _writeImportForKnownModule(self, output, packageTreeNode, referencedModule, symbols): # # Compute the href from here to there. --- 411,421 ---- ! def _writeImportForKnownModule(self, ! output, ! packageTreeNode, ! name, ! referencedModule, ! symbols, ! ): # # Compute the href from here to there. *************** *** 412,415 **** --- 424,428 ---- packageTreeNode, referencedModule, + title=name, ) *************** *** 466,477 **** ) continue ! # # Check to see if the name is another module we know about. # referenced_module = packageTreeNode.findNodeFromDottedName(name) ! if referenced_module: self._writeImportForKnownModule(output, packageTreeNode, referenced_module, symbols, --- 479,491 ---- ) continue ! # # Check to see if the name is another module we know about. # referenced_module = packageTreeNode.findNodeFromDottedName(name) ! if referenced_module is not None: self._writeImportForKnownModule(output, packageTreeNode, + name, referenced_module, symbols, |
From: Doug H. <dou...@us...> - 2002-12-28 14:26:35
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv25928/happydoclib Modified Files: scanner.py Log Message: Fixup trace statements so that it is easier to debug the find function. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scanner.py 27 Dec 2002 18:33:53 -0000 1.9 --- scanner.py 28 Dec 2002 14:26:29 -0000 1.10 *************** *** 410,415 **** --- 410,417 ---- value is None. """ + trace_level=1 trace.into('PackageTree', 'findNodeFromDottedName', dottedNodeName=dottedNodeName, + outputLevel=trace_level, ) *************** *** 418,423 **** --- 420,432 ---- remainder = '.'.join(name_parts[1:]) + trace.write('name=%s' % name, + outputLevel=trace_level, + ) + trace.write('remainder=%s' % remainder, + outputLevel=trace_level, + ) trace.writeVar(name=name, remainder=remainder, + outputLevel=trace_level, ) *************** *** 429,441 **** if (named_node is None): if (name == self.getName()): ! trace.write('Matched ourself') named_node = self if (named_node is None): ! trace.write('Checking child') named_node = self.get(name) if (named_node is None): ! trace.write('Checking child.py') named_node = self.get('%s.py' % name) --- 438,456 ---- 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) *************** *** 446,450 **** parent = self.getParent() if parent: ! trace.write('Checking parent') named_node = parent.findNodeFromDottedName(dottedNodeName) --- 461,467 ---- parent = self.getParent() if parent: ! trace.write('Checking for %s in parent' % name, ! outputLevel=trace_level, ! ) named_node = parent.findNodeFromDottedName(dottedNodeName) *************** *** 453,461 **** # if named_node and remainder: ! trace.write('Recursing') named_node = named_node.findNodeFromDottedName(remainder, tryParent=0) ! trace.outof(named_node) return named_node --- 470,485 ---- # if named_node and remainder: ! trace.write('Handling 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 |
From: Doug H. <dou...@us...> - 2002-12-27 18:37:29
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv19760/happydoclib/docset Modified Files: tests.py Log Message: Test API changes in docset base classes. Index: tests.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/tests.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tests.py 18 Nov 2002 13:45:58 -0000 1.1 --- tests.py 27 Dec 2002 18:37:25 -0000 1.2 *************** *** 55,66 **** # Import system modules # ! # # Import Local modules # ! # # Module # --- 55,146 ---- # Import system modules # ! import unittest # # Import Local modules # ! from happydoclib.docset import base # # Module # + + class TestDocSetBase(unittest.TestCase): + + def testRequiresWrite(self): + docset = base.DocSetBase( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + ) + try: + docset.write() + except NotImplementedError: + pass + else: + self.fail('Did not raise NotImplementedError') + return + + + class TestMultiFileDocSet(unittest.TestCase): + + def testRequiresWriteTOCFile(self): + docset = base.MultiFileDocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + ) + try: + docset.writeTOCFile(None) + except NotImplementedError: + pass + else: + self.fail('Did not raise NotImplementedError') + return + + def testRequiresWriteFileHeader(self): + docset = base.MultiFileDocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + ) + try: + docset.writeFileHeader(None) + except NotImplementedError: + pass + else: + self.fail('Did not raise NotImplementedError') + return + + def testRequiresWriteFileFooter(self): + docset = base.MultiFileDocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + ) + try: + docset.writeFileFooter(None) + except NotImplementedError: + pass + else: + self.fail('Did not raise NotImplementedError') + return + + def testRequiresWritePythonFile(self): + docset = base.MultiFileDocSet( + scanner=None, + title=self.__class__.__name__, + outputDirectory='/tmp', + ) + try: + docset.writePythonFile(None) + except NotImplementedError: + pass + else: + self.fail('Did not raise NotImplementedError') + return + + + if __name__ == '__main__': + unittest.main() + |
From: Doug H. <dou...@us...> - 2002-12-27 18:37:09
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv19632/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Added docstrings to a few existing methods. Added first draft of code to generate the import statements when documenting a module. There are still places where hrefs can be inserted instead of just the name of the object, and the formatting needs to be fixed up when all of that is done. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** docset_MultiHTMLFile.py 15 Dec 2002 17:02:26 -0000 1.9 --- docset_MultiHTMLFile.py 27 Dec 2002 18:37:05 -0000 1.10 *************** *** 63,66 **** --- 63,67 ---- import happydoclib from happydoclib.docset import base + from happydoclib.sysmodules import getPythonSystemModuleURL from happydoclib.trace import trace *************** *** 87,90 **** --- 88,105 ---- def getOutputFilenameForPackageTreeNode(self, packageTreeNode, includePath=1): + """Returns a filename where documentation for packageTreeNode should be written. + + The filename will be in the output directory, possibly in a + subdirectory based on the path from the input root to the + input file. + + For example:: + + input_directory : /foo/input + containing : /foo/input/bar.py + output_directory : /foo/output + + results in : /foo/output/input/bar.py + """ trace.into('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode') filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode( *************** *** 109,113 **** def writeFileHeader(self, output, title='', subtitle=''): ! title_bg = self.levelOneHeadingBackgroundColor title_fg = self.levelOneHeadingForegroundColor --- 124,129 ---- def writeFileHeader(self, output, title='', subtitle=''): ! """Given an open output stream, write a header using the title and subtitle. ! """ title_bg = self.levelOneHeadingBackgroundColor title_fg = self.levelOneHeadingForegroundColor *************** *** 147,151 **** def writeFileFooter(self, output): ! root = 'Need URL for root' date_str = time.ctime(time.time()) --- 163,168 ---- def writeFileFooter(self, output): ! """Given an open output stream, write a footer using the title and subtitle. ! """ root = 'Need URL for root' date_str = time.ctime(time.time()) *************** *** 172,175 **** --- 189,203 ---- def _writeDescriptiveList(self, output, descriptiveList): + """Write a list including descriptions. + + Arguments + + output -- Open output stream. + + descriptiveList -- Sequence of (name, description, + description_format) values to be included in the output + list. + + """ output.write('<!-- _writeDescriptiveList -->\n') output.write('<table border="0" cellpadding="3" cellspacing="0">\n') *************** *** 192,195 **** --- 220,225 ---- def _computeRelativeHREF(self, source, destination): + """Compute the HREF to point from the output file of source to destination. + """ relative_path = source.getPathToNode(destination) if not relative_path: *************** *** 207,219 **** relative_path = relative_path[:-1] + (output_name,) href = '/'.join(relative_path) return href ! def _getAnchorTagForPackageTreeNode(self, source, destination): href = self._computeRelativeHREF(source, destination) ! return '<a href="%s">%s</a>' % (href, destination.getName()) def _writeTOCReferencesSection(self, output, packageTreeNode, title, moduleList): ! descriptive_list = [ (self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat() for name, node in moduleList ] if descriptive_list: --- 237,279 ---- relative_path = relative_path[:-1] + (output_name,) + # + # If the destination is a directory, add 'index.html' to the end. + # + #print destination.getName(), destination.getMimeType() + #if destination.getMimeType() == ('application/x-directory', None): + # print 'adding index.html' + # relative_path += ('index.html',) + # print relative_path + href = '/'.join(relative_path) + #print href 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. ! """ ! if title is None: ! title = destination.getName() href = self._computeRelativeHREF(source, destination) ! return '<a href="%s">%s</a>' % (href, title) def _writeTOCReferencesSection(self, output, packageTreeNode, title, moduleList): ! """Write a list of references in the table of contents. ! ! Arguments ! ! output -- Open output stream on which to write. ! ! packageTreeNode -- The node for which the section is being ! written. ! ! title -- Title of the reference section. ! ! moduleList -- A list of nodes to be included in the ! reference section. ! ! """ ! descriptive_list = [(self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat() for name, node in moduleList ] if descriptive_list: *************** *** 224,227 **** --- 284,292 ---- def writeTOCFile(self, packageTreeNode): + """Write the table of contents for a directory. + + The packageTreeNode is a directory, and the table of contents + for that directory should be written as appropriate. + """ trace.into('MultiHTMLFile', 'writeTOCFile', packageTreeNode=packageTreeNode, *************** *** 313,334 **** return ! def _writePythonFileInfoToOutput(self, output, packageTreeNode): ! """Writes part of the Python file information to the output stream. ! """ ! # ! # Imports ! # # ! # Functions # ! # # Classes - # return def writePythonFile(self, packageTreeNode): trace.into('MultiHTMLFileDocSet', 'writePythonFile', packageTreeNode=packageTreeNode, --- 378,512 ---- return ! def _writeImportWithFrom(self, output, pacakgeTreeNode, moduleReference, symbolReferences): ! output.write('from %s import %s<br>' % (moduleReference, ! ', '.join(symbolReferences), ! ) ! ) ! return ! ! def _writeImport(self, output, packageTreeNode, moduleReference): ! output.write('import %s<br>' % moduleReference) ! return ! ! def _writeImportForPythonSystemModule(self, output, packageTreeNode, name, symbols, url): ! ref = '<a href="%s">%s</a>' % (url, name) ! if symbols: ! self._writeImportWithFrom(output, ! packageTreeNode, ! ref, ! symbols, ! ) ! else: ! self._writeImport(output, ! packageTreeNode, ! ref, ! ) ! return + + def _writeImportForKnownModule(self, output, packageTreeNode, referencedModule, symbols): # ! # Compute the href from here to there. # + ref = self._getAnchorTagForPackageTreeNode( + packageTreeNode, + referencedModule, + ) ! if symbols: ! symbol_refs = [] ! ! for symbol in symbols: ! symbol_module = referencedModule.findNodeFromDottedName(symbol) ! if symbol_module is not None: ! symbol_ref = self._getAnchorTagForPackageTreeNode( ! packageTreeNode, ! symbol_module, ! title=symbol, ! ) ! else: ! symbol_ref = symbol ! ! symbol_refs.append( symbol_ref ) ! ! self._writeImportWithFrom(output, ! packageTreeNode, ! ref, ! symbol_refs, ! ) ! else: ! self._writeImport(output, ! packageTreeNode, ! ref, ! ) ! return ! ! ! def _writePythonFileImportsToOutput(self, output, packageTreeNode): ! """Writes the list of imported modules for the packageTreeNode. ! """ ! import_data = packageTreeNode.module_info.getImportData() ! if import_data: ! output.write('<h4>Imported Modules</h4>\n') ! output.write('<p>\n') ! ! for name, symbols in import_data: ! ref = None ! ! # ! # Check if the name is a Python system module. ! # ! url = getPythonSystemModuleURL(name) ! if url: ! self._writeImportForPythonSystemModule(output, ! packageTreeNode, ! name, ! symbols, ! url, ! ) ! continue ! ! # ! # Check to see if the name is another module we know about. ! # ! referenced_module = packageTreeNode.findNodeFromDottedName(name) ! if referenced_module: ! self._writeImportForKnownModule(output, ! packageTreeNode, ! referenced_module, ! symbols, ! ) ! continue ! ! # ! # Default to the module name for the reference. ! # ! if symbols: ! self._writeImportWithFrom(output, ! packageTreeNode, ! name, ! symbols, ! ) ! else: ! self._writeImport(output, ! packageTreeNode, ! name, ! ) ! ! output.write('</p>\n') ! return ! ! def _writePythonFileInfoToOutput(self, output, packageTreeNode): ! """Writes parts of the Python file information to the output stream. ! """ ! self._writePythonFileImportsToOutput(output, packageTreeNode) ! # Functions # Classes return def writePythonFile(self, packageTreeNode): + """Handler for text/x-python nodes. + """ trace.into('MultiHTMLFileDocSet', 'writePythonFile', packageTreeNode=packageTreeNode, |
From: Doug H. <dou...@us...> - 2002-12-27 18:35:59
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv19277/happydoclib/docset Modified Files: base.py Log Message: Refactoring and docstrings to make the various API levels a bit more clear. Work may still need to be done on this. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** base.py 15 Dec 2002 17:02:14 -0000 1.9 --- base.py 27 Dec 2002 18:35:55 -0000 1.10 *************** *** 26,30 **** # ! """Base class for documentation sets. """ --- 26,30 ---- # ! """Base classes for documentation sets. """ *************** *** 56,59 **** --- 56,60 ---- # import os + import shutil # *************** *** 69,76 **** # ! class DocSet: """Basic Documentation Set. Parameters --- 70,155 ---- # + class DocSetBase: + """Base class for documentation sets. ! This is the base class for all documentation set classes. The ! methods defined here are required of all docset classes. Only the ! 'write' method is actually used by the main application. ! """ ! ! def __init__(self, scanner, ! title, ! outputDirectory, ! statusMessageFunc=None, ! extraParameters={}, ! ): ! """Basic Documentation Set ! ! Parameters ! ! scanner -- A directory tree scanner. ! ! title -- the title of the documentation set ! ! outputDirectory -- The base directory for writing the ! output files. ! ! statusMessageFunc -- function which will print a status ! message for the user ! ! extraParameters -- Dictionary containing parameters ! specified on the command line by ! the user. ! ! """ ! trace.into('DocSetBase', '__init__', ! scanner=scanner, ! title=title, ! outputDirectory=outputDirectory, ! statusMessageFunc=statusMessageFunc, ! extraParameters=extraParameters, ! ) ! # ! # Store parameters ! # ! self.scanner = scanner ! self.title = title ! self.output_directory = outputDirectory ! self.status_message_func = statusMessageFunc ! ! self.statusMessage('Initializing documentation set %s' % title) ! ! self.statusMessage('NEED TO HANDLE extraParameters in DocSetBase') ! ! trace.outof() ! return ! ! def statusMessage(self, message='', verboseLevel=1): ! "Print a status message for the user." ! if self.status_message_func: ! self.status_message_func(message, verboseLevel) ! return ! ! def write(self): ! """Called by the application to cause the docset to be written. ! """ ! raise NotImplementedError('%s.write' % self.__class__.__name__) ! ! ! ! ! ! class DocSet(DocSetBase): """Basic Documentation Set. + This class extends the DocSetBase with a few more convenience + methods. Most docsets will actually subclass from DocSet or one + of its descendants rather than from DocSet directly. + + The basic extension is that this class provides a 'write' method + which walks the scanner tree, determines the appropriate writer + method for each node, and calls the writer. Subclasses need only + provide writers and + Parameters *************** *** 84,87 **** --- 163,173 ---- """ + # + # Override this with a mapping from mime-type to the + # method name to be called to handle writing a node + # of that type. + # + mimetype_writer_mapping = {} + def __init__(self, scanner, title, *************** *** 119,123 **** """ ! trace.into('DocSet', '__init__', scanner=scanner, title=title, --- 205,209 ---- """ ! trace.into('DocSetBase', '__init__', scanner=scanner, title=title, *************** *** 125,180 **** includeComments=includeComments, includePrivateNames=includePrivateNames, - ## formatter=formatter, statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, ) # # Store parameters # - self.scanner = scanner - self.title = title - self.output_directory = outputDirectory self.include_comments = includeComments self.include_private_names = includePrivateNames - ## self.formatter = formatter - self.status_message_func = statusMessageFunc - - self.statusMessage('Initializing documentation set %s' % title) - - self.statusMessage('NEED TO HANDLE extraParameters in DocSet') trace.outof() return ! def statusMessage(self, message='', verboseLevel=1): ! "Print a status message for the user." ! if self.status_message_func: ! self.status_message_func(message, verboseLevel) return - def writeCB(self, packageTreeNode): ! raise NotImplementedError('No writeCB defined for %s' % self.__class__.__name__) def write(self): self.scanner.walk(self.writeCB) return class MultiFileDocSet(DocSet): """Base class for documentation sets which write to multiple files. - """ ! mimetype_writer_mapping = { ! 'application/x-directory' : 'writeDirectory', ! 'text/x-python' : 'writePythonFile', ! 'text/plain' : 'writePlainTextFile', ! 'text/x-structured' : 'writePlainTextFile', ! 'text/html' : 'copyInputFileToOutput', ! 'image/gif' : 'copyInputFileToOutput', ! 'image/jpeg' : 'copyInputFileToOutput', ! 'image/png' : 'copyInputFileToOutput', ! } mimetype_extension_mapping = { --- 211,305 ---- includeComments=includeComments, includePrivateNames=includePrivateNames, statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, ) + DocSetBase.__init__( + self, + scanner=scanner, + title=title, + outputDirectory=outputDirectory, + statusMessageFunc=statusMessageFunc, + extraParameters=extraParameters, + ) # # Store parameters # self.include_comments = includeComments self.include_private_names = includePrivateNames + self._initializeWriters() + trace.outof() return ! def _skipInputFile(self, packageTreeNode): ! """False writer method used to notify the user that a node is being ! skipped because the real writer is unknown. ! """ ! mimetype, encoding = packageTreeNode.getMimeType() ! filename = packageTreeNode.getInputFilename() ! self.statusMessage('Skiping unrecognized file %s with mimetype %s' % ( ! filename, ! mimetype, ! )) return + def getWriterForNode(self, packageTreeNode): + """Returns the writer to be used for the node. + """ + mimetype, encoding = packageTreeNode.getMimeType() + + writer_name = self.mimetype_writer_mapping.get(mimetype) + if writer_name: + writer = getattr(self, writer_name) + + else: + # + # Unrecognized file. + # + writer = self._skipInputFile + + return writer + def writeCB(self, packageTreeNode): ! """Callback used when walking the scanned package tree. ! """ ! trace.into('MultiHTMLFileDocSet', 'writeCB', ! packageTreeNode=packageTreeNode, ! ) ! ! writer = self.getWriterForNode(packageTreeNode) ! writer(packageTreeNode) ! trace.outof() ! return def write(self): + """Called by the application to cause the docset to be written. + """ self.scanner.walk(self.writeCB) return + def _initializeWriters(self): + """Hook to allow subclasses to register writers without having to + override __init__ with all of its arguments. + """ + return + + def registerWriter(self, mimetype, writerName): + """Register a writer for the specified mimetype. + """ + self.mimetype_writer_mapping[mimetype] = writerName + return + class MultiFileDocSet(DocSet): """Base class for documentation sets which write to multiple files. ! This class further extends the DocSet class by adding several ! convenience methods for handling files, as well as a few basic ! handlers. ! ! """ mimetype_extension_mapping = { *************** *** 185,188 **** --- 310,334 ---- } + def _initializeWriters(self): + """Hook to allow subclasses to register writers without having to + override __init__ with all of its arguments. + """ + + DocSet._initializeWriters(self) + + mimetype_writers = [ + ('application/x-directory' , 'writeDirectory'), + ('text/x-python' , 'writePythonFile'), + ('text/plain' , 'writePlainTextFile'), + ('text/x-structured' , 'writePlainTextFile'), + ('text/html' , 'copyInputFileToOutput'), + ('image/gif' , 'copyInputFileToOutput'), + ('image/jpeg' , 'copyInputFileToOutput'), + ('image/png' , 'copyInputFileToOutput'), + ] + for mimetype, writer_name in mimetype_writers: + self.registerWriter(mimetype, writer_name) + return + def getOutputFilenameForPackageTreeNode(self, packageTreeNode, includePath=1): """Returns a filename where documentation for packageTreeNode should be written. *************** *** 238,241 **** --- 384,389 ---- def copyInputFileToOutput(self, packageTreeNode): + """Copy the input file to the appropriate place in the output. + """ input_filename = packageTreeNode.getInputFilename() output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode) *************** *** 243,278 **** input_filename, output_filename, ! )) ! input_file = open(input_filename, 'rb') ! output_file = open(output_filename, 'wb') ! output_file.write(input_file.read()) ! input_file.close() ! output_file.close() ! return ! ! def writeCB(self, packageTreeNode): ! trace.into('MultiHTMLFileDocSet', 'writeCB', ! packageTreeNode=packageTreeNode, ! ) ! ! mimetype, encoding = packageTreeNode.getMimeType() ! ! writer_name = self.mimetype_writer_mapping.get(mimetype) ! if writer_name: ! writer = getattr(self, writer_name) ! writer(packageTreeNode) ! ! else: ! # ! # Unrecognized file, skipped. ! # ! node_path = packageTreeNode.getPath() ! filename = apply(os.path.join, node_path) ! self.statusMessage('Skiping unrecognized file %s with mimetype %s' % ( ! filename, ! mimetype, ! )) ! ! trace.outof() return --- 391,396 ---- input_filename, output_filename, ! )) ! shutil.copyfile(input_filename, output_filename) return *************** *** 291,294 **** --- 409,417 ---- def writeDirectory(self, packageTreeNode): + """Handler for application/x-directory nodes. + + Creates the output directory and writes the table of contents + file. + """ trace.into('MultiFileDocSet', 'writeDirectory', packageTreeNode=packageTreeNode, *************** *** 317,329 **** def writeTOCFile(self, packageTreeNode): ! raise NotImplemented('writeTOCFile') def writeFileHeader(self, output, title='', subtitle=''): ! raise NotImplemented('writeFileHeader') def writeFileFooter(self, output): ! raise NotImplemented('writeFileFooter') def openOutput(self, name, title='', subtitle=''): f = open(name, 'wt') self.writeFileHeader(f, title=title, subtitle=subtitle) --- 440,472 ---- def writeTOCFile(self, packageTreeNode): ! """Write the table of contents for a directory. ! ! Subclasses must implement this method. ! ! The packageTreeNode is a directory, and the table of contents ! for that directory should be written as appropriate. ! """ ! raise NotImplementedError('writeTOCFile') def writeFileHeader(self, output, title='', subtitle=''): ! """Given an open output stream, write a header using the title and subtitle. ! ! Subclasses must implement this method. ! """ ! raise NotImplementedError('writeFileHeader') def writeFileFooter(self, output): ! """Given an open output stream, write a footer using the title and subtitle. ! ! Subclasses must implement this method. ! """ ! raise NotImplementedError('writeFileFooter') def openOutput(self, name, title='', subtitle=''): + """Open the output stream from the name. + + Opens the output stream and writes a header using title and + subtitle. Returns the stream. + """ f = open(name, 'wt') self.writeFileHeader(f, title=title, subtitle=subtitle) *************** *** 331,334 **** --- 474,481 ---- def closeOutput(self, output): + """Close the output stream. + + Writes a footer to the output stream and then closes it. + """ self.writeFileFooter(output) output.close() *************** *** 383,389 **** output.write(html) return ! def writePlainTextFile(self, packageTreeNode): trace.into('MultiFileDocSet', 'writePlainTextFile', packageTreeNode=packageTreeNode, --- 530,546 ---- output.write(html) 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. + + Converts the input file to the output file format and + generates the output. The output directory is assumed to + already exist. + """ trace.into('MultiFileDocSet', 'writePlainTextFile', packageTreeNode=packageTreeNode, *************** *** 406,409 **** --- 563,569 ---- raw_body = str(input_file) + # + # FIXME - This needs to be handled more abstractly! + # cooked_body = converter.convert(raw_body, 'html', level=3) |
From: Doug H. <dou...@us...> - 2002-12-27 18:35:12
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv19077/happydoclib Modified Files: test_scanner.py Log Message: Added tests for findNodeFromDottedName(). Index: test_scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_scanner.py 15 Dec 2002 17:00:25 -0000 1.7 --- test_scanner.py 27 Dec 2002 18:35:10 -0000 1.8 *************** *** 265,269 **** def testPackageTreePath(self): - import os cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') --- 265,268 ---- *************** *** 327,331 **** def setUp(self): - import os cwd = os.getcwd() input_dir = os.path.join(cwd, 'TestCases/testScanner') --- 326,329 ---- *************** *** 442,445 **** --- 440,520 ---- 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 something unexpected') return |
From: Doug H. <dou...@us...> - 2002-12-27 18:34:39
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv18858/happydoclib Added Files: sysmodules.py Log Message: New module to hold the magic code that figures out if a module is a 'system' module or not, and generates URLs pointing to the online docs when asked. --- NEW FILE: sysmodules.py --- #!/usr/bin/env python # # $Id: sysmodules.py,v 1.1 2002/12/27 18:34:36 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. # """Utilities for working with Python system modules. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: sysmodules.py,v $', 'rcs_id' : '$Id: sysmodules.py,v 1.1 2002/12/27 18:34:36 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Fri, 27-Dec-2002 11:19:36 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/12/27 18:34:36 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import glob import os import string import sys # # Import Local modules # # # Module # # # Find a list of system modules for creating reference # links to them. # _sysdirs = [] version_dir='python%d.%d' % (sys.version_info[0], sys.version_info[1]) for path in sys.path: path_parts = string.split(path, os.sep) if (version_dir in path_parts) and ('site-packages' not in path_parts): # system directory _sysdirs.append(path) _sys_modules = [] for path in _sysdirs: module_list = glob.glob( os.path.join( path, '*.py' ) ) module_file_names = map(os.path.basename, module_list) for name in module_file_names: name = name[:-3] if name: #print 'System module %s/%s.py' % (path, name) _sys_modules.append(name) shared_lib_list = glob.glob( os.path.join( path, '*.so' ) ) shared_lib_file_names = map(os.path.basename, shared_lib_list) for name in shared_lib_file_names: #print 'Shared library %s/%s' % (path, name) name = name[:-3] #print ' name="%s"' % name if name: _sys_modules.append(name) _well_known_names = ( 'regex', 'sys', 'thread', 'threading', 'new' ) for _name in _well_known_names: _sys_modules.append(_name) #print _sys_modules #sys.exit(1) PYTHON_LIB_DOC_ROOT = 'http://www.python.org/doc/current/lib' def getPythonSystemModuleURL(moduleName, root=PYTHON_LIB_DOC_ROOT): """Returns a URL pointing to the documentation for the named module. """ global _sys_modules if moduleName in _sys_modules: href = '%s/module-%s.html' % (root, moduleName) else: href = None return href |
From: Doug H. <dou...@us...> - 2002-12-27 18:33:56
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv18590/happydoclib Modified Files: scanner.py Log Message: Added findNodeFromDottedName() method to PackageTree so that one module can find another. This is especially useful when setting up xrefs between imported modules. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** scanner.py 15 Dec 2002 16:59:52 -0000 1.8 --- scanner.py 27 Dec 2002 18:33:53 -0000 1.9 *************** *** 211,215 **** def getMimeType(self): ! """Returns the mimetype setting for this node. """ trace.into('PackageTreeNode', 'getMimeType', --- 211,215 ---- def getMimeType(self): ! """Returns the (mimetype, encoding) setting for this node. """ trace.into('PackageTreeNode', 'getMimeType', *************** *** 402,405 **** --- 402,462 ---- 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.into('PackageTree', 'findNodeFromDottedName', + dottedNodeName=dottedNodeName, + ) + + name_parts = dottedNodeName.split('.') + name = name_parts[0] + remainder = '.'.join(name_parts[1:]) + + trace.writeVar(name=name, + remainder=remainder, + ) + + named_node = None + + # + # Is someone looking for us? + # + if (named_node is None): + if (name == self.getName()): + trace.write('Matched ourself') + named_node = self + + if (named_node is None): + trace.write('Checking child') + named_node = self.get(name) + + if (named_node is None): + trace.write('Checking child.py') + 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 parent') + named_node = parent.findNodeFromDottedName(dottedNodeName) + + # + # Do we need to process the remainder of the original name? + # + if named_node and remainder: + trace.write('Recursing') + named_node = named_node.findNodeFromDottedName(remainder, + tryParent=0) + + trace.outof(named_node) + return named_node def addSubNode(self, name): |
From: Doug H. <dou...@us...> - 2002-12-27 18:33:10
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv18317 Modified Files: TODO Log Message: Updates with notes to myself. Index: TODO =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TODO,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TODO 15 Dec 2002 17:06:36 -0000 1.1 --- TODO 27 Dec 2002 18:33:06 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- To Do List + (listed in no particular order) + 1. Ignore stuff in .cvsignore files. (Is this already done?) 2. Generate docs for Python classes. *************** *** 6,7 **** --- 8,23 ---- 4. Set up a regression test framework for watching output changes. 5. Port remaining docsets from HappyDoc 2.x. + 6. Break up docset API into mixins to define the interfaces at + different levels. + - I/O (open, close, etc.) + - Low level formatting (headers, lists, etc.) + - 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' + + + Local variables: + mode: text + End: |
From: Doug H. <dou...@us...> - 2002-12-27 15:52:40
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo In directory sc8-pr-cvs1:/tmp/cvs-serv29214/happydoclib/parseinfo Modified Files: moduleinfo.py Log Message: Use the status module and statusFunction to report exceptions when interpreting options embedded in the comments of a module. This ensures that the error messages go the same place as other messages. It also lets our tests run more quietly. Index: moduleinfo.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/moduleinfo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** moduleinfo.py 17 Nov 2002 16:20:41 -0000 1.2 --- moduleinfo.py 27 Dec 2002 15:52:36 -0000 1.3 *************** *** 66,69 **** --- 66,70 ---- # import happydoclib + from happydoclib.status import statusMessage from happydoclib.parseinfo.classinfo import ClassInfo from happydoclib.parseinfo.functioninfo import SuiteFuncInfo, FunctionInfo *************** *** 177,183 **** exec config_statement in global_namespace, local_namespace except: ! sys.stderr.write('\n--- Parser Config Value Extraction Error ---\n') ! traceback.print_exc() ! sys.stderr.write('--------------------------------------------\n\n') else: self._configuration_values.update(local_namespace) --- 178,190 ---- exec config_statement in global_namespace, local_namespace except: ! statusMessage('--- Parser Config Value Extraction Error ---') ! ! #traceback.print_exc() ! etype, value, tb = sys.exc_info() ! lines = traceback.format_exception(etype, value, tb) ! for line in lines: ! statusMessage(line) ! ! statusMessage('--------------------------------------------') else: self._configuration_values.update(local_namespace) |
From: Doug H. <dou...@us...> - 2002-12-15 17:06:40
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv2550 Added Files: TODO Log Message: To do list. --- NEW FILE: TODO --- To Do List 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. |
From: Doug H. <dou...@us...> - 2002-12-15 17:02:50
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv1587/happydoclib/docset Modified Files: test_docset_MultiHTMLFile.py Log Message: Add a test for documenting HappyDoc. Index: test_docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_docset_MultiHTMLFile.py 8 Dec 2002 17:19:05 -0000 1.6 --- test_docset_MultiHTMLFile.py 15 Dec 2002 17:02:48 -0000 1.7 *************** *** 59,65 **** # - # Import Local modules # import happydoclib from happydoclib.scanner import Scanner from docset_MultiHTMLFile import MultiHTMLFileDocSet --- 59,65 ---- # # import happydoclib + from happydoclib import tests from happydoclib.scanner import Scanner from docset_MultiHTMLFile import MultiHTMLFileDocSet *************** *** 69,86 **** # ! class MultiHTMLFileDocSetRunTest(unittest.TestCase): TEST_OUTPUT_DIRECTORY_BASE = 'TestOutput' - def getOutputDirectory(self): - return os.path.join(self.TEST_OUTPUT_DIRECTORY_BASE, self._TestCase__testMethodName) - - def runHappyDoc(self, *args): - default_args = ( '-q', '-d', self.getOutputDirectory(), ) - all_args = default_args + args - happydoc = happydoclib.HappyDoc(all_args) - happydoc.run() - return - def testAllExpectedFilesCreated(self): self.runHappyDoc( os.path.join('TestCases', 'testScanner') ) --- 69,76 ---- # ! class MultiHTMLFileDocSetRunTest(tests.HappyDocRunTest): TEST_OUTPUT_DIRECTORY_BASE = 'TestOutput' def testAllExpectedFilesCreated(self): self.runHappyDoc( os.path.join('TestCases', 'testScanner') ) *************** *** 107,110 **** --- 97,117 ---- '%s does not exist' % filename, ) + return + + def testSelfDoc(self): + 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 |
From: Doug H. <dou...@us...> - 2002-12-15 17:02:29
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv1506/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Include the title and subtitle in output files. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** docset_MultiHTMLFile.py 8 Dec 2002 17:19:05 -0000 1.8 --- docset_MultiHTMLFile.py 15 Dec 2002 17:02:26 -0000 1.9 *************** *** 230,234 **** output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode) ! output = self.openOutput(output_filename) # --- 230,237 ---- output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode) ! output = self.openOutput(output_filename, ! title=self.title, ! subtitle=packageTreeNode.getRelativeFilename(), ! ) # *************** *** 294,302 **** # Write out references to subdirectories # self._writeTOCReferencesSection( output, packageTreeNode, 'Subdirectories', ! contained_modules_map.get(None, []), ) --- 297,309 ---- # 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, 'Subdirectories', ! directories, ) *************** *** 347,351 **** )) ! output = self.openOutput(output_filename) # --- 354,361 ---- )) ! output = self.openOutput(output_filename, ! title=self.title, ! subtitle=packageTreeNode.getRelativeFilename(), ! ) # |
From: Doug H. <dou...@us...> - 2002-12-15 17:02:17
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv1437/happydoclib/docset Modified Files: base.py Log Message: Use a pseudo-mimetype for dealing with directories. This prevents us from assuming that anything with an unknown mimetype is a directory. Include the title and subtitle in output files. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** base.py 8 Dec 2002 17:02:37 -0000 1.8 --- base.py 15 Dec 2002 17:02:14 -0000 1.9 *************** *** 61,64 **** --- 61,65 ---- # import happydoclib + from happydoclib.utils import * from happydoclib.trace import trace from happydoclib.docstring import getConverterFactoryForFile, getConverterFactory *************** *** 68,78 **** # - def isSomethingThatLooksLikeDirectory(path): - return (os.path.isdir(path) - or - os.path.islink(path) - or - os.path.ismount(path) - ) class DocSet: --- 69,72 ---- *************** *** 174,177 **** --- 168,172 ---- mimetype_writer_mapping = { + 'application/x-directory' : 'writeDirectory', 'text/x-python' : 'writePythonFile', 'text/plain' : 'writePlainTextFile', *************** *** 261,291 **** ) ! if packageTreeNode.values(): ! # ! # Directory node ! # ! self.writeDirectory(packageTreeNode) else: # ! # Anything past here looks like a file. # ! mimetype, encoding = packageTreeNode.getMimeType() ! ! writer_name = self.mimetype_writer_mapping.get(mimetype) ! if writer_name: ! writer = getattr(self, writer_name) ! writer(packageTreeNode) ! ! else: ! # ! # Unrecognized file, skipped. ! # ! node_path = packageTreeNode.getPath() ! filename = apply(os.path.join, node_path) ! self.statusMessage('Skiping unrecognized file %s with mimetype %s' % ( ! filename, ! mimetype, ! )) trace.outof() --- 256,276 ---- ) ! mimetype, encoding = packageTreeNode.getMimeType() ! ! writer_name = self.mimetype_writer_mapping.get(mimetype) ! if writer_name: ! writer = getattr(self, writer_name) ! writer(packageTreeNode) else: # ! # Unrecognized file, skipped. # ! node_path = packageTreeNode.getPath() ! filename = apply(os.path.join, node_path) ! self.statusMessage('Skiping unrecognized file %s with mimetype %s' % ( ! filename, ! mimetype, ! )) trace.outof() *************** *** 314,318 **** output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode) output_dirname = os.path.dirname(output_filename) ! self.statusMessage('Directory : "%s"\n to: "%s"' % ( canonical_filename, --- 299,303 ---- output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode) output_dirname = os.path.dirname(output_filename) ! self.statusMessage('Directory : "%s"\n to: "%s"' % ( canonical_filename, *************** *** 423,427 **** cooked_body = converter.convert(raw_body, 'html', level=3) ! output_file = self.openOutput(output_filename) output_file.write(cooked_body) --- 408,416 ---- cooked_body = converter.convert(raw_body, 'html', level=3) ! output_file = self.openOutput( ! output_filename, ! title=self.title, ! subtitle=packageTreeNode.getRelativeFilename(), ! ) output_file.write(cooked_body) |
From: Doug H. <dou...@us...> - 2002-12-15 17:01:15
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv1174/happydoclib Added Files: tests.py Log Message: Base class for tests which run HappyDoc with arguments as though it was being executed from the command line. --- NEW FILE: tests.py --- #!/usr/bin/env python # # $Id: tests.py,v 1.1 2002/12/15 17:01:11 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 HappyDoc. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: tests.py,v $', 'rcs_id' : '$Id: tests.py,v 1.1 2002/12/15 17:01:11 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'UNSPECIFIED', 'created' : 'Sun, 15-Dec-2002 09:39:20 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/12/15 17:01:11 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import os import unittest # # Import Local modules # import happydoclib # # Module # class HappyDocRunTest(unittest.TestCase): TEST_OUTPUT_DIRECTORY_BASE = 'TestOutput' def getTestName(self): return self._TestCase__testMethodName def getOutputDirectory(self): return os.path.join(self.TEST_OUTPUT_DIRECTORY_BASE, self.getTestName(), ) def runHappyDoc(self, *args): default_args = ( '-q', '-d', self.getOutputDirectory(), '-t', self.getTestName(), ) #default_args = ( '-d', self.getOutputDirectory(), ) all_args = default_args + args happydoc = happydoclib.HappyDoc(all_args) happydoc.run() return |
From: Doug H. <dou...@us...> - 2002-12-15 17:00:47
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv990/happydoclib Added Files: utils.py Log Message: General utility functions. --- NEW FILE: utils.py --- #!/usr/bin/env python # # $Id: utils.py,v 1.1 2002/12/15 17:00:44 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. # """ """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: utils.py,v $', 'rcs_id' : '$Id: utils.py,v 1.1 2002/12/15 17:00:44 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'UNSPECIFIED', 'created' : 'Sun, 15-Dec-2002 10:12:56 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2002/12/15 17:00:44 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import os # # Import Local modules # # # Module # def isSomethingThatLooksLikeDirectory(path): return (os.path.isdir(path) or os.path.islink(path) or os.path.ismount(path) ) |
From: Doug H. <dou...@us...> - 2002-12-15 17:00:30
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv904/happydoclib Modified Files: test_scanner.py Log Message: Add a test for getInputFilename(). Add sub-tests for individual nodes in the path. Index: test_scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_scanner.py 8 Dec 2002 17:18:31 -0000 1.6 --- test_scanner.py 15 Dec 2002 17:00:25 -0000 1.7 *************** *** 197,200 **** --- 197,234 ---- 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']) *************** *** 202,205 **** --- 236,254 ---- 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'] |
From: Doug H. <dou...@us...> - 2002-12-15 16:59:55
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv632/happydoclib Modified Files: scanner.py Log Message: Delay evaluation of mimetype until it is needed, and then use a pseudo value for directories. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** scanner.py 8 Dec 2002 17:01:29 -0000 1.7 --- scanner.py 15 Dec 2002 16:59:52 -0000 1.8 *************** *** 70,73 **** --- 70,74 ---- from happydoclib.status import statusMessage from happydoclib.trace import trace + from happydoclib.utils import * # *************** *** 106,111 **** trace.write('self.name=%s' % self.name) self.canonical_name = name - - self.mimetype = mimetypes.guess_type(name) trace.outof() --- 107,110 ---- *************** *** 196,200 **** self.getInputFilename(), mimetype, ! )) else: # --- 195,199 ---- self.getInputFilename(), mimetype, ! ), 2) else: # *************** *** 214,218 **** """Returns the mimetype setting for this node. """ ! return self.mimetype def getName(self): --- 213,229 ---- """Returns the mimetype 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): |