happydoc-checkins Mailing List for HappyDoc (Page 4)
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-26 19:05:27
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv27484/happydoclib/docset/docset_TAL Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:05:18
|
Update of /cvsroot/happydoc/HappyDoc3/TestCases/TAL In directory sc8-pr-cvs1:/tmp/cvs-serv27384/TestCases/TAL Added Files: header.pt testtal.pt Log Message: Test templates for verifying that the TAL module is working properly. --- NEW FILE: header.pt --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head metal:define-macro="html_header" xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal"> <title metal:define-slot="title">Title from header.pt</title> <metal:block metal:define-slot="head_slot"> This is the head_slot part of the header. </metal:block> </head> <body> <p>Contains the html_header macro.</p> </body> </html> --- NEW FILE: testtal.pt --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" > <head metal:use-macro="templates/header.pt/macros/html_header"> <title metal:fill-slot="title">Override title</title> </head> <body> <div> <table border="0" cellpadding="5" cellspacing="5"> <tr> <td> <a href="http://my.weather.com/weather/map/30605?name=index_large&day=1" target="_blank"> <img border=0 src="http://image.weather.com/web/radar/us_atl_closeradar_small_usen.jpg"> </a> </td> </tr> <tr> <td> <a href="http://www.weather.com/weather/local/30605" target="_blank"> <img border=1 width=270 height=140 SRC="http://oap.weather.com/fcgi-bin/oap/generate_magnet?loc_id=USGA0027&code=482224"></a> </td> </tr> </table> <h2>Call Me</h2> <div tal:content="python: here.callMe()">It was not called.</div> <div tal:define="foo string:bar"> <span tal:content="foo">Not foo</span> </div> <div tal:define="foo python:'bar as python string'"> <span tal:content="foo">Not foo</span> </div> <ul tal:define="items python:['foo', 'bar', 'blah', 'bletch']"> <li tal:repeat="item items"> <p tal:content="item">Item goes here</p> </li> </ul> <span tal:condition="python: 1">Should see this.</span> <span tal:condition="python: 0">Should not see this.</span> <span tal:condition="nothing">Should not see this.</span> <span tal:condition="not: python: 1">Should not see this.</span> <span tal:condition="not: not: nothing">Should not see this.</span> <h2>Athens, Structure</h2> <div tal:content="structure here/Athens">Athens Weather</div> <h2>Atlanta, Structure</h2> <div tal:content="structure here/Atlanta">Atlanta Weather</div> <h2>Athens, No Structure</h2> <div tal:content="here/Athens">Athens Weather</div> <h2>Atlanta, No Structure</h2> <div tal:content="here/Atlanta">Atlanta Weather</div> <span tal:content="here/name">Should show name.</span> <span tal:content="here/foo">Should say name-foo.</span> <span tal:content="modules/happydoclib.docset.docset_TAL.test_module/GotTest">Did you get it?</span> <span tal:content="modules/happydoclib.docset.docset_TAL.test_module/GotTestFunc">Did you get it?</span> <span tal:content="modules/test_module/GotTestFunc">Did you get it?</span> </div> </body> </html> |
From: Doug H. <dou...@us...> - 2003-01-26 19:04:41
|
Update of /cvsroot/happydoc/HappyDoc3/TestCases/TAL In directory sc8-pr-cvs1:/tmp/cvs-serv26996/TestCases/TAL Log Message: Directory /cvsroot/happydoc/HappyDoc3/TestCases/TAL added to the repository |
From: Doug H. <dou...@us...> - 2003-01-19 22:25:10
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv21618/happydoclib Modified Files: appclass.py Log Message: Clean up docstrings. Update options to support specifying a template name, in anticipation on the TAL docset. Implement feature request #6688613. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** appclass.py 18 Jan 2003 19:56:00 -0000 1.12 --- appclass.py 19 Jan 2003 22:25:06 -0000 1.13 *************** *** 112,115 **** --- 112,120 ---- supported_docset_types = happydoclib.docset.DocSetLoader() + # + # Which template should be used? + # + template_name = None + ## ## Local methods *************** *** 227,230 **** --- 232,238 ---- For example:: + + --mimetype stx=text/x-structured + --mimetype .gif=image/gif """ *************** *** 258,262 **** Defaults to ignore:: ! CVS, dist, build, doc, docs. """ --- 266,271 ---- Defaults to ignore:: ! ^(CVS|dist|build|docs?|.*pyc|.*~|tmp)$ ! trace.txt """ *************** *** 291,295 **** ## return ! def optionHandler_t(self, title): "Specify a title for the documentation set." self.docset_title = title --- 300,304 ---- ## return ! def optionHandler_title(self, title): "Specify a title for the documentation set." self.docset_title = title *************** *** 299,306 **** """Specify the documentation set type. ! Defaults to 'multifile_docset'.""" self.set_docset_type(docset_type) return ## ## Main --- 308,326 ---- """Specify the documentation set type. ! Defaults to 'MultiHTMLFile'.""" self.set_docset_type(docset_type) return + def optionHandler_t(self, template_name): + """The name of the template set. + + The value is expected to correspond to the name of a directory + containing a template set. If the path exists, it will be + used. If it does not exist, HappyDoc will look for a + directory with the same name in 'happydoclib/templates'. + """ + self.template_name = template_name + return + ## ## Main *************** *** 344,347 **** --- 364,369 ---- parsed_args = self.getParameterGroupsFromArguments(args) (args, parser_params, docset_params) = parsed_args + if self.template_name: + docset_params['template_name'] = self.template_name self.parser_params = parser_params *************** *** 365,371 **** normcase = normcase[:-1] input_modules.append(normcase) - # # Create the scanner, and get the package trees. # --- 387,439 ---- normcase = normcase[:-1] input_modules.append(normcase) # + # Dump some basic info about what we are going to do. + # + self.statusMessage(verboseLevel=2) + self.statusMessage('Docset Title: %s' % self.docset_title, + verboseLevel=2) + + self.statusMessage(verboseLevel=2) + self.statusMessage('Inputs:', + verboseLevel=2) + self.statusMessage(verboseLevel=2) + for input_module in input_modules: + if input_module == os.curdir: + input_module = os.getcwd() + self.statusMessage(' %s' % input_module, + verboseLevel=2) + + self.statusMessage(verboseLevel=2) + self.statusMessage('Ignoring:', verboseLevel=2) + self.statusMessage(verboseLevel=2) + for ignore_pattern in self._ignore_dir_patterns: + self.statusMessage(' %s' % ignore_pattern, + verboseLevel=2) + + self.statusMessage(verboseLevel=2) + self.statusMessage('Parameters:', verboseLevel=2) + self.statusMessage(verboseLevel=2) + if self.include_comments: + self.statusMessage(' Including comments', + verboseLevel=2) + if self.include_private_names: + self.statusMessage(' Including private symbol names', + verboseLevel=2) + extra_params = docset_params.items() + extra_params.sort() + for name, value in extra_params: + self.statusMessage(' %s=%s' % (name, value), + verboseLevel=2) + + self.statusMessage(verboseLevel=2) + self.statusMessage('Output Directory:', verboseLevel=2) + self.statusMessage(verboseLevel=2) + self.statusMessage(' %s' % self.output_directory, + verboseLevel=2) + + self.statusMessage(verboseLevel=2) + + # # Create the scanner, and get the package trees. # *************** *** 398,477 **** return - - def old_main(self, *args): - - self.statusMessage('%s version %s' % (self._app_name, - self._app_version)) - - # - # Debug info about where the docsets and formatters come from - # - self.statusMessage('Docstring converters from %s' % \ - happydoclib.docstring.__path__[0], 1) - self.statusMessage('Docsets list from %s' % \ - happydoclib.docset.__path__[0], 1) - self.statusMessage('Formatters from %s' % \ - happydoclib.formatter.__path__[0], 1) - - # - # Get the list of modules to input - # - if not args: - # - # No files specified, print a help message and exit. - # - self.showHelp('Specify input file(s) to be processed.') - raise self.HelpRequested, 'No input file(s) specified.' - else: - input_modules = [] - for input_module_name in args: - input_modules.append(os.path.normcase(input_module_name)) - - # - # Create output directory - # - if not self.output: - od = self.output_directory - self.statusMessage('Output directory is %s' % self.output_directory, 2) - if (od[0] != '/'): - od = happydoclib.path.join( happydoclib.path.cwd(), od ) - self.statusMessage('Setting output directory to %s' % od, 2) - od = happydoclib.path.normpath(od) - self.statusMessage('Creating output directory %s' % od, 2) - happydoclib.path.rmkdir(od) - self.output_directory = od - - # - # Create the docset - # - ## docset_init_params = { - - ## 'formatterFactory':self.formatter_factory, - ## 'parserFunc':self.parser_function, - ## 'defaultParserConfigValues':parser_params, - ## 'inputModuleNames':input_modules, - - ## 'author':self.author_name, - ## 'outputBaseDirectory':self.output_directory, - ## 'descriptionFilename':self.package_description_file, - ## 'formatterParameters':formatter_params, - ## 'ignoreDirFunc':self.ignoreDirectoryTest, - ## 'includeComments':self.include_comments, - ## 'includePrivateNames':self.include_private_names, - ## 'statusMessageFunc':self.statusMessage, - ## 'title':self.docset_title, - ## 'useRecursion':self.recurse_into_subdirs, - - ## } - ## docset_init_params.update(docset_params) - ## parsed_modules = apply( self.docset_factory, (), docset_init_params) - ## # - ## # Tell the docset to output its results - ## # - ## parsed_modules.write() - ## # - ## # Clean up - ## # - ## parsed_modules = None - return - --- 466,467 ---- |
From: Doug H. <dou...@us...> - 2003-01-19 22:04:43
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv13010/happydoclib/docset Modified Files: base.py Log Message: Cleaned up docstring. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** base.py 1 Jan 2003 14:00:40 -0000 1.14 --- base.py 19 Jan 2003 22:04:40 -0000 1.15 *************** *** 144,159 **** 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 includeComments -- Boolean. False means to skip the --- 144,164 ---- class DocSet(DocSetBase): ! # ! # 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 ! # ! """Docset Parameters ! Pass parameters to the docset using the syntax: ! docset_<argument>=value ! Common parameters for all documentation sets includeComments -- Boolean. False means to skip the |
From: Doug H. <dou...@us...> - 2003-01-19 22:04:08
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docstring In directory sc8-pr-cvs1:/tmp/cvs-serv12831/happydoclib/docstring Modified Files: docstring_RawText.py Log Message: Cleaned up docstring. Index: docstring_RawText.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/docstring_RawText.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** docstring_RawText.py 17 Nov 2002 00:26:19 -0000 1.1.1.1 --- docstring_RawText.py 19 Jan 2003 22:04:06 -0000 1.2 *************** *** 29,38 **** This converter does not modify its inputs in any way. - - This is most useful for internal calls in a formatter. For - instance, if a formatter calls self.writeText() and passes text - that it has produced, it can use "RawText" as the 'textFormat' - argument. - """ --- 29,32 ---- *************** *** 84,94 **** """Raw (pass-through) docstring converter. ! This is most useful for internal calls in a formatter. For ! instance, if a formatter calls self.writeText() and passes text ! that it has produced, it can use "RawText" as the 'textFormat' ! argument. ! ! This converter is not recommended for most uses. ! """ --- 78,82 ---- """Raw (pass-through) docstring converter. ! This converter does not modify its inputs in any way. """ |
From: Doug H. <dou...@us...> - 2003-01-19 22:03:48
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docstring In directory sc8-pr-cvs1:/tmp/cvs-serv12631/happydoclib/docstring Modified Files: docstring_ClassicStructuredText.py Log Message: Corrected docstring. Index: docstring_ClassicStructuredText.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/docstring_ClassicStructuredText.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** docstring_ClassicStructuredText.py 17 Nov 2002 15:04:17 -0000 1.2 --- docstring_ClassicStructuredText.py 19 Jan 2003 22:03:44 -0000 1.3 *************** *** 95,99 **** This converter supports translating StructuredText (see ! happydoc/hddocstring/StructuredText/ClassicStructuredText.py) input to HTML output. --- 95,99 ---- This converter supports translating StructuredText (see ! happydoclib/docstring/StructuredText/ClassicStructuredText.py) input to HTML output. |
From: Doug H. <dou...@us...> - 2003-01-18 22:15:37
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parsers In directory sc8-pr-cvs1:/tmp/cvs-serv13502/happydoclib/parsers Modified Files: parsers_text.py Log Message: Set the TEXT_FORMAT. Index: parsers_text.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parsers/parsers_text.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** parsers_text.py 18 Jan 2003 20:01:50 -0000 1.1 --- parsers_text.py 18 Jan 2003 22:15:34 -0000 1.2 *************** *** 69,72 **** --- 69,73 ---- """Plain text file parser. """ + TEXT_FORMAT = 'Plain Text' def entryPoint(): |
From: Doug H. <dou...@us...> - 2003-01-18 22:15:17
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv13331/happydoclib Modified Files: packagetree.py Log Message: Clean up the __repr__ implementation. Add a bogus __len__ method so testing nodes for true will always pass. Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** packagetree.py 18 Jan 2003 20:00:12 -0000 1.6 --- packagetree.py 18 Jan 2003 22:15:12 -0000 1.7 *************** *** 115,120 **** def __repr__(self): ! base_str = UserDict.UserDict.__repr__(self) return '<%s %s: %s>' % (self.__class__.__name__, self.getName(), base_str) # --- 115,126 ---- def __repr__(self): ! #base_str = UserDict.UserDict.__repr__(self) ! base_str = '' return '<%s %s: %s>' % (self.__class__.__name__, self.getName(), base_str) + + def __len__(self): + """Define this to always return 1, so checks like 'if node' work properly. + """ + return 1 # |
From: Doug H. <dou...@us...> - 2003-01-18 22:14:39
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv12919/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Add some trace statements to debug problem with breadcrumbs. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** docset_MultiHTMLFile.py 18 Jan 2003 14:16:29 -0000 1.15 --- docset_MultiHTMLFile.py 18 Jan 2003 22:14:24 -0000 1.16 *************** *** 152,160 **** This method actually handles the recursion. """ if not breadcrumbNode: return # ! # Write the rest of the breadcrumbs # self._writeBreadcrumbs(output, sourceNode, breadcrumbNode.getParent()) --- 152,166 ---- This method actually handles the recursion. """ + trace.into('MultiHTMLFile', '_writeBreadcrumbs', + sourceNode=sourceNode.getName(), + breadcrumbNode=(breadcrumbNode and breadcrumbNode.getName()), + outputLevel=TRACE_LEVEL, + ) if not breadcrumbNode: + trace.outof(outputLevel=TRACE_LEVEL) return # ! # Write the preceding part of the breadcrumbs # self._writeBreadcrumbs(output, sourceNode, breadcrumbNode.getParent()) *************** *** 171,176 **** --- 177,187 ---- ) output.write('/ %s '% ref) + trace.write('/ %s '% ref, + outputLevel=TRACE_LEVEL) #output.write('\n') + else: + trace.write('Skipping __init__.py', outputLevel=TRACE_LEVEL) + trace.outof(outputLevel=TRACE_LEVEL) return |
From: Doug H. <dou...@us...> - 2003-01-18 20:02:23
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv14243 Modified Files: TODO Log Message: Updates. Index: TODO =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TODO 29 Dec 2002 18:38:51 -0000 1.3 --- TODO 18 Jan 2003 20:02:18 -0000 1.4 *************** *** 3,7 **** (listed in no particular order) - 1. Ignore stuff in .cvsignore files. (Is this already done?) 4. Set up a regression test framework for watching output changes. 5. Port remaining docsets from HappyDoc 2.x. --- 3,6 ---- *************** *** 12,15 **** --- 11,17 ---- - Higher level formatting (class list header, etc.) - Content (TOC, functions, classes, etc.) + 8. CSS-based docset + 9. PageTemplate-based docset (same as 8?) + |
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parsers In directory sc8-pr-cvs1:/tmp/cvs-serv14016/happydoclib/parsers Added Files: parsers_text.py parsers_structuredtext.py parsers_python.py parsers_directory.py parsers_default.py base.py __init__.py Log Message: New parsers plugin set for handling files based on mimetypes. The base class defines the API for the plugin, and __call__ is expected to return something that acts like (is a subclass of) a PackageTree. --- NEW FILE: parsers_text.py --- #!/usr/bin/env python # # $Id: parsers_text.py,v 1.1 2003/01/18 20:01:50 doughellmann Exp $ # # Copyright 2003 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. # """Plain text parser. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: parsers_text.py,v $', 'rcs_id' : '$Id: parsers_text.py,v 1.1 2003/01/18 20:01:50 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:28:46 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:50 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # from parsers_structuredtext import StructuredTextFileParser # # Module # class PlainTextFileParser(StructuredTextFileParser): """Plain text file parser. """ def entryPoint(): return { 'mimetype':'text/plain', 'factory':PlainTextFileParser, } --- NEW FILE: parsers_structuredtext.py --- #!/usr/bin/env python # # $Id: parsers_structuredtext.py,v 1.1 2003/01/18 20:01:51 doughellmann Exp $ # # Copyright 2003 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. # """Structured text file parser. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: parsers_structuredtext.py,v $', 'rcs_id' : '$Id: parsers_structuredtext.py,v 1.1 2003/01/18 20:01:51 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:07:52 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:51 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import re # # Import Local modules # from base import ParserBase import happydoclib from happydoclib.packagetree import PackageTree from happydoclib.status import statusMessage from happydoclib.trace import trace from happydoclib.utils import extractSummary # # Module # TRACE_LEVEL = 2 class StructuredTextFile(PackageTree): """Structured text file node. """ TEXT_FORMAT = 'StructuredText' def __init__(self, parent, name): trace.into('StructuredTextFile', '__init__', outputLevel=TRACE_LEVEL) PackageTree.__init__(self, parent, name) # # Derive the filename for this module. # filename = self.getInputFilename() statusMessage('Importing %s file: %s' % (self.TEXT_FORMAT, filename) ) self.readme_text = open(filename, 'rt').read() self.format = self.TEXT_FORMAT self.summary = extractSummary(self.readme_text) trace.outof(outputLevel=TRACE_LEVEL) return def getDocStringAndFormat(self): """Returns a tuple containing the actual documentation string and the format of that docstring as understood by the docstring converters plugins. """ return (self.readme_text, self.format) def getSummaryAndFormat(self): """Returns a tuple containing a one line summary of the documentation for the node and the format of that string as understood by the docstring converter plugins. """ return (self.summary, self.format) class StructuredTextFileParser(ParserBase): def __call__(self, parent, name): return StructuredTextFile(parent, name) def entryPoint(): return { 'mimetype':'text/x-structured', 'factory':StructuredTextFileParser, } --- NEW FILE: parsers_python.py --- #!/usr/bin/env python # # $Id: parsers_python.py,v 1.1 2003/01/18 20:01:51 doughellmann Exp $ # # Copyright 2003 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. # """Python source file parser. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: parsers_python.py,v $', 'rcs_id' : '$Id: parsers_python.py,v 1.1 2003/01/18 20:01:51 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:07:52 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:51 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # from base import ParserBase import happydoclib from happydoclib.packagetree import PackageTree, ClassTree, FunctionTree from happydoclib.status import statusMessage from happydoclib.trace import trace # # Module # TRACE_LEVEL = 2 class PythonModule(PackageTree): def __init__(self, parent, name): trace.into('PythonModule', '__init__', outputLevel=TRACE_LEVEL) PackageTree.__init__(self, parent, name) # # Derive the filename for this module. # statusMessage('Parsing: %s' % name) # # Figure out if there is a parent node for the # documentation suite. # if parent and hasattr(parent, 'module_info'): docs_parent = parent.module_info else: docs_parent = None trace.writeVar(docs_parent=docs_parent, outputLevel=TRACE_LEVEL) docs = happydoclib.parseinfo.getDocs( parent=docs_parent, fileName=name, ) self.module_info = docs # # Add classes to the tree # for class_name in self.module_info.getClassNames(): class_tree = ClassTree(self, class_name) # # Add functions to the tree # for function_name in self.module_info.getFunctionNames(): function_tree = FunctionTree(self, function_name) trace.outof(outputLevel=TRACE_LEVEL) return 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): """Returns a tuple containing the actual documentation string and the format of that docstring as understood by the docstring converters plugins. """ docstring = self.module_info.getDocString() docstring = self._unquoteString(docstring) format = self.module_info.getDocStringFormat() return (docstring, format) def getSummaryAndFormat(self): """Returns a tuple containing a one line summary of the documentation for the node and the format of that string as understood by the docstring converter plugins. """ return self.module_info.getSummaryAndFormat() class PythonModuleParser(ParserBase): def __call__(self, parent, name): return PythonModule(parent, name) def entryPoint(): return { 'mimetype':'text/x-python', 'factory':PythonModuleParser, } --- NEW FILE: parsers_directory.py --- #!/usr/bin/env python # # $Id: parsers_directory.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $ # # Copyright 2003 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. # """Directory "parser". """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: parsers_directory.py,v $', 'rcs_id' : '$Id: parsers_directory.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:03:15 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:52 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # from base import ParserBase from happydoclib.packagetree import PackageTree from happydoclib.trace import trace from happydoclib.utils import extractSummary # # Module # TRACE_LEVEL=3 class Directory(PackageTree): """Directory node for directories and folders. """ DOCSTRING_SOURCES = ('__init__.py', 'README.txt', 'README.stx') def getDocStringAndFormat(self): """Returns a tuple containing the actual documentation string and the format of that docstring as understood by the docstring converters plugins. """ docstring = '' format = 'StructuredText' if hasattr(self, '_docstring'): docstring, format = self._docstring return (docstring, format) for name in self.DOCSTRING_SOURCES: trace.write('looking for %s' % name, outputLevel=TRACE_LEVEL) node = self.get(name) if node is not None: docstring, format = node.getDocStringAndFormat() self._docstring_source = node break self._docstring = (docstring, format) return (docstring, format) def getSummaryAndFormat(self): """Returns a tuple containing a one line summary of the documentation for the node and the format of that string as understood by the docstring converter plugins. """ if hasattr(self, '_docstring_source'): return self._docstring_source.getSummaryAndFormat() elif hasattr(self, '_summary'): return (self._summary, self._docstring[1]) docstring, format = self.getDocStringAndFormat() summary = extractSummary(docstring) self._summary = summary return (summary, format) class DirectoryParser(ParserBase): """Parser for directories. """ def __call__(self, parent, name): return Directory(parent, name) def entryPoint(): return { 'mimetype':'application/x-directory', 'factory':DirectoryParser, } --- NEW FILE: parsers_default.py --- #!/usr/bin/env python # # $Id: parsers_default.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $ # # Copyright 2003 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. # """Null parser. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: parsers_default.py,v $', 'rcs_id' : '$Id: parsers_default.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:03:15 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:52 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # from happydoclib.packagetree import PackageTree from base import ParserBase # # Module # class Null(PackageTree): """Null node for unknown mimetypes. """ def getDocStringAndFormat(self): """Returns a tuple containing the actual documentation string and the format of that docstring as understood by the docstring converters plugins. """ return ('', 'StructuredText') def getSummaryAndFormat(self): """Returns a tuple containing a one line summary of the documentation for the node and the format of that string as understood by the docstring converter plugins. """ return ('', 'StructuredText') class NullParser(ParserBase): """Parser for unknown files. """ def __call__(self, parent, name): return Null(parent, name) def entryPoint(): return { 'mimetype':'application/octet-stream', 'factory':NullParser, } --- NEW FILE: base.py --- #!/usr/bin/env python # # $Id: base.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Base class for parsers. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: base.py,v $', 'rcs_id' : '$Id: base.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 12:03:15 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:52 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # # # Module # class ParserBase: """Base class for parsers. """ def __init__(self): """Initialize the parser. """ return def __call__(self, parent, filename): raise NotImplementedError('%s.__call__' % self.__class__.__name__) --- NEW FILE: __init__.py --- #!/usr/bin/env python # # $Id: __init__.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $ # # Copyright 2003 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. # """Parser plugins. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: __init__.py,v $', 'rcs_id' : '$Id: __init__.py,v 1.1 2003/01/18 20:01:52 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 11:53:33 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 20:01:52 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # import happydoclib # # Module # class ParserLoader(happydoclib.pluginloader.PluginLoader): """Load parsers. """ def __init__(self): happydoclib.pluginloader.PluginLoader.__init__( self, __name__, __path__[0], 'happydoclib', ) return def addEntryPoint(self, infoDict): "Add the information about the parser to our lookup table." factory = infoDict['factory'] mimetype = infoDict['mimetype'] self[mimetype] = factory return |
From: Doug H. <dou...@us...> - 2003-01-18 20:01:05
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv13734/happydoclib Modified Files: scanner.py Log Message: Move defaults for ignore patterns into the Scanner class. Use the parsers module to get a new node for each file scanned, instead of always using PackageTree directly. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** scanner.py 18 Jan 2003 16:52:05 -0000 1.17 --- scanner.py 18 Jan 2003 20:01:02 -0000 1.18 *************** *** 59,62 **** --- 59,63 ---- # import glob + import mimetypes import os import re *************** *** 67,73 **** import happydoclib from happydoclib.packagetree import PackageTree from happydoclib.status import statusMessage from happydoclib.trace import trace ! from happydoclib.utils import * from happydoclib.cvsignore import CVSIgnoreList --- 68,75 ---- import happydoclib from happydoclib.packagetree import PackageTree + from happydoclib.parsers import ParserLoader from happydoclib.status import statusMessage from happydoclib.trace import trace ! from happydoclib.utils import getMimeType from happydoclib.cvsignore import CVSIgnoreList *************** *** 85,91 **** """ def __init__(self, inputDirectories, ! ignorePatterns=[], includeComments=1, ): --- 87,97 ---- """ + DEFAULT_IGNORE_PATTERNS = ['^(CVS|dist|build|docs?|.*pyc|.*~|tmp)$', + 'trace.txt', + ] + def __init__(self, inputDirectories, ! ignorePatterns=DEFAULT_IGNORE_PATTERNS, includeComments=1, ): *************** *** 102,105 **** --- 108,113 ---- self._package_trees = [] + self.parser_loader = ParserLoader() + # # Scan *************** *** 113,121 **** self._package_trees.append(tree) - # - # Parse - # - self.parsePackageTree() - trace.outof(outputLevel=TRACE_LEVEL) return --- 121,124 ---- *************** *** 169,173 **** # Create the node for this name # ! tree = PackageTree(parent, directoryName) # --- 172,183 ---- # Create the node for this name # ! mimetype, encoding = getMimeType(directoryName) ! try: ! parser_factory = self.parser_loader[mimetype] ! except KeyError: ! parser_factory = self.parser_loader['application/octet-stream'] ! ! parser = parser_factory() ! tree = parser(parent, directoryName) # |
From: Doug H. <dou...@us...> - 2003-01-18 20:00:18
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv13437/happydoclib Modified Files: packagetree.py Log Message: Move logic dealing with different mimetypes in special ways into subclasses in the parsers package. Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** packagetree.py 18 Jan 2003 16:52:04 -0000 1.5 --- packagetree.py 18 Jan 2003 20:00:12 -0000 1.6 *************** *** 55,59 **** # Import system modules # - import mimetypes import os import pprint --- 55,58 ---- *************** *** 68,72 **** from happydoclib.status import statusMessage from happydoclib.trace import trace ! from happydoclib.utils import * --- 67,71 ---- from happydoclib.status import statusMessage from happydoclib.trace import trace ! from happydoclib.utils import getMimeType *************** *** 77,81 **** TRACE_LEVEL=2 - mimetypes.types_map['.stx'] = 'text/x-structured' class PackageTree(UserDict.UserDict): --- 76,79 ---- *************** *** 86,95 **** """ - parser_mapping = { - 'text/x-python' : 'parsePythonInput', - 'text/plain' : 'parsePlainTextInput', - 'text/x-structured' : 'parseStructuredTextInput', - } - def __init__(self, parent, name): trace.into('PackageTree', '__init__', --- 84,87 ---- *************** *** 118,122 **** trace.write('self.name=%s' % self.name, outputLevel=TRACE_LEVEL) ! trace.outof(outputLevel=TRACE_LEVEL) return --- 110,114 ---- trace.write('self.name=%s' % self.name, outputLevel=TRACE_LEVEL) ! trace.outof(outputLevel=TRACE_LEVEL) return *************** *** 127,239 **** # - # 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 - - # - # Add classes to the tree - # - for class_name in self.module_info.getClassNames(): - class_tree = ClassTree(self, class_name) - - # - # Add functions to the tree - # - for function_name in self.module_info.getFunctionNames(): - function_tree = FunctionTree(self, function_name) - - - 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 # --- 119,122 ---- *************** *** 248,259 **** 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): --- 131,138 ---- input_filename = self.getInputFilename() ! mimetype, encoding = getMimeType(input_filename) trace.outof(mimetype, outputLevel=TRACE_LEVEL) ! return (mimetype, encoding) def getName(self): *************** *** 296,368 **** 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) --- 175,192 ---- trace.outof(filename, outputLevel=TRACE_LEVEL) return filename def getDocStringAndFormat(self): ! """Returns a tuple containing the actual documentation string ! and the format of that docstring as understood by the ! docstring converters plugins. ! """ ! raise NotImplementedError('getDocStringAndFormat') def getSummaryAndFormat(self): ! """Returns a tuple containing a one line summary of the ! documentation for the node and the format of that ! string as understood by the docstring converter plugins. ! """ ! raise NotImplementedError('getSummaryAndFormat') *************** *** 636,643 **** return self.code_info.getDocStringAndFormat() - def parseInput(self): - "Does nothing." - return - class FunctionTree(CodeObjectTree): --- 460,463 ---- *************** *** 678,687 **** return self.getParent().module_info.getClassInfo(self.name) - def parseInput(self): - """Add methods as sub-nodes. - """ - return - def getRelativeFilename(self): return PackageTree.getRelativeFilename(self) --- 498,504 ---- return self.getParent().module_info.getClassInfo(self.name) def getRelativeFilename(self): + """Classes are written to their own file. + """ return PackageTree.getRelativeFilename(self) |
From: Doug H. <dou...@us...> - 2003-01-18 19:58:53
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv12962/happydoclib/docset Modified Files: test_docset_MultiHTMLFile.py Log Message: Change import statement so these tests can be run by themselves through proctor. Index: test_docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_docset_MultiHTMLFile.py 1 Jan 2003 14:06:05 -0000 1.9 --- test_docset_MultiHTMLFile.py 18 Jan 2003 19:58:50 -0000 1.10 *************** *** 63,67 **** from happydoclib import tests from happydoclib.scanner import Scanner ! from docset_MultiHTMLFile import MultiHTMLFileDocSet # --- 63,67 ---- from happydoclib import tests from happydoclib.scanner import Scanner ! from happydoclib.docset.docset_MultiHTMLFile import MultiHTMLFileDocSet # |
From: Doug H. <dou...@us...> - 2003-01-18 19:58:11
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parsers In directory sc8-pr-cvs1:/tmp/cvs-serv12745/happydoclib/parsers Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/parsers added to the repository |
From: Doug H. <dou...@us...> - 2003-01-18 19:57:38
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv12527/happydoclib Modified Files: utils.py Log Message: Add getMimeType() function which wraps the mimetypes module guess_type() with logic to deal with directories. Add extractSummary() function for pulling one line descriptions out of text blobs. Index: utils.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/utils.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** utils.py 28 Dec 2002 15:57:53 -0000 1.2 --- utils.py 18 Jan 2003 19:57:33 -0000 1.3 *************** *** 55,59 **** --- 55,61 ---- # Import system modules # + import mimetypes import os + import re # *************** *** 65,76 **** # Module # ! def isSomethingThatLooksLikeDirectory(path): """Returns boolean indicating whether or not path looks like a directory. """ return (os.path.isdir(path) or ! os.path.islink(path) or os.path.ismount(path) ) --- 67,117 ---- # Module # + mimetypes.types_map['.stx'] = 'text/x-structured' ! def isSomethingThatLooksLikeDirectory(path, includeLinks=1): """Returns boolean indicating whether or not path looks like a directory. """ return (os.path.isdir(path) or ! (includeLinks and os.path.islink(path)) or os.path.ismount(path) ) + + def getMimeType(path): + """Returns the mimetype and encoding for path. + """ + if isSomethingThatLooksLikeDirectory(path, includeLinks=0): + mimetype = 'application/x-directory' + encoding = None + else: + mimetype, encoding = mimetypes.guess_type(path) + if (mimetype, encoding) == (None, None) and os.path.islink(path): + mimetype = 'application/x-directory' + encoding = None + return (mimetype, encoding) + + def extractSummary(text, + _summary_pattern = re.compile(r'^\s*([^\n]+)\n'), + ): + """Given a block of text, extract a summary from it. + """ + 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 = _summary_pattern.search(text) + if matchObj: + return matchObj.group(0).strip() + else: + return text |
From: Doug H. <dou...@us...> - 2003-01-18 19:56:28
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv12074/happydoclib Modified Files: pluginloader.py Log Message: Trace changes. Index: pluginloader.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/pluginloader.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pluginloader.py 1 Jan 2003 13:47:47 -0000 1.4 --- pluginloader.py 18 Jan 2003 19:56:24 -0000 1.5 *************** *** 70,74 **** # ! TRACE_LEVEL=3 class PluginException(Exception): --- 70,74 ---- # ! TRACE_LEVEL=4 class PluginException(Exception): *************** *** 176,179 **** --- 176,181 ---- ) _module = __import__( _import_name ) + TRACE.write('Done with import', + outputLevel=TRACE_LEVEL) except Exception, msg: if int(os.environ.get('PLUGIN_DEBUG', '0')): |
From: Doug H. <dou...@us...> - 2003-01-18 19:56:03
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv11941/happydoclib Modified Files: appclass.py Log Message: Move the defaults for the directories to ignore into the scanner. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** appclass.py 18 Jan 2003 16:02:49 -0000 1.11 --- appclass.py 18 Jan 2003 19:56:00 -0000 1.12 *************** *** 124,130 **** self.set_docset_type('MultiHTMLFile') ! self._ignore_dir_patterns = [] ! self.addIgnoreDirectoryPattern('^(CVS|dist|build|docs?|.*pyc|.*~|tmp)$') ! self.addIgnoreDirectoryPattern('trace.txt') # --- 124,128 ---- self.set_docset_type('MultiHTMLFile') ! self._ignore_dir_patterns = Scanner.DEFAULT_IGNORE_PATTERNS[:] # |
From: Doug H. <dou...@us...> - 2003-01-18 16:52:10
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv12335/happydoclib Modified Files: packagetree.py scanner.py Log Message: Have each PackageTree node register itself with its parent, so there is no need to perform the registration as a separate step. Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** packagetree.py 18 Jan 2003 16:03:33 -0000 1.4 --- packagetree.py 18 Jan 2003 16:52:04 -0000 1.5 *************** *** 94,108 **** 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) --- 94,121 ---- def __init__(self, parent, name): trace.into('PackageTree', '__init__', name=name, outputLevel=TRACE_LEVEL, ) UserDict.UserDict.__init__(self) ! ! self.name = os.path.basename(name) self.parent = parent ! if self.parent is not None: ! # ! # If we have a parent, tell it about ! # ourself and use the basename of ! # our name as the canonical name. ! # ! self.parent.addSubNode(self) ! self.canonical_name = self.name ! else: ! # ! # We have no parent, so use our full ! # name as the canonical name. ! # ! self.canonical_name = name ! trace.write('self.name=%s' % self.name, outputLevel=TRACE_LEVEL) trace.outof(outputLevel=TRACE_LEVEL) *************** *** 150,156 **** # for class_name in self.module_info.getClassNames(): ! class_tree = self.addSubNode(class_name, ! nodeClass=ClassTree, ! ) # --- 163,167 ---- # for class_name in self.module_info.getClassNames(): ! class_tree = ClassTree(self, class_name) # *************** *** 158,164 **** # for function_name in self.module_info.getFunctionNames(): ! function_tree = self.addSubNode(function_name, ! nodeClass=FunctionTree, ! ) --- 169,173 ---- # for function_name in self.module_info.getFunctionNames(): ! function_tree = FunctionTree(self, function_name) *************** *** 554,558 **** return named_node ! def addSubNode(self, name, nodeClass=None): """Insert a child node under this node. --- 563,567 ---- return named_node ! def addSubNode(self, node): """Insert a child node under this node. *************** *** 560,574 **** and save it as one of our children. """ ! 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) ! return new_node def getSubNodes(self, mimetype=None): --- 569,574 ---- and save it as one of our children. """ ! self[node.getName()] = node ! return node def getSubNodes(self, mimetype=None): *************** *** 670,676 **** for method_name in self.code_info.getMethodNames(): ! method_node = self.addSubNode(method_name, ! nodeClass=MethodTree, ! ) trace.outof(outputLevel=TRACE_LEVEL) return --- 670,675 ---- for method_name in self.code_info.getMethodNames(): ! method_node = MethodTree(self, method_name) ! trace.outof(outputLevel=TRACE_LEVEL) return Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** scanner.py 18 Jan 2003 14:15:29 -0000 1.16 --- scanner.py 18 Jan 2003 16:52:05 -0000 1.17 *************** *** 169,176 **** # Create the node for this name # ! if parent is not None: ! tree = parent.addSubNode(package_tree_name) ! else: ! tree = PackageTree(None, directoryName) # --- 169,173 ---- # Create the node for this name # ! tree = PackageTree(parent, directoryName) # |
From: Doug H. <dou...@us...> - 2003-01-18 16:03:37
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv29413/happydoclib Modified Files: packagetree.py Log Message: Replace the mimetypes module initialization that is also done by the application setup code. This is needed for the tests to work, since not all of the tests execute the application. Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** packagetree.py 18 Jan 2003 14:35:24 -0000 1.3 --- packagetree.py 18 Jan 2003 16:03:33 -0000 1.4 *************** *** 77,80 **** --- 77,82 ---- TRACE_LEVEL=2 + mimetypes.types_map['.stx'] = 'text/x-structured' + class PackageTree(UserDict.UserDict): """Tree of package information. |
From: Doug H. <dou...@us...> - 2003-01-18 16:02:54
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv29226/happydoclib Modified Files: appclass.py Log Message: Do not depend on the user to remember to include (or omit) . in (from) the extension. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** appclass.py 18 Jan 2003 14:35:24 -0000 1.10 --- appclass.py 18 Jan 2003 16:02:49 -0000 1.11 *************** *** 136,140 **** def addMimetype(self, extension, mimetypeSpec): ! mimetypes.types_map['.%s' % extension] = mimetypeSpec return --- 136,145 ---- def addMimetype(self, extension, mimetypeSpec): ! if extension and extension[0] != '.': ! key = '.%s' % extension ! else: ! key = extension ! ! mimetypes.types_map[key] = mimetypeSpec return |
From: Doug H. <dou...@us...> - 2003-01-18 14:35:28
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv15545/happydoclib Modified Files: appclass.py packagetree.py Log Message: Initialize extra mimetypes in the application, instead of the PackageTree module. Add an option so the user can specify a filename extension-to-mimetype mapping. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** appclass.py 28 Dec 2002 16:40:46 -0000 1.9 --- appclass.py 18 Jan 2003 14:35:24 -0000 1.10 *************** *** 54,64 **** # Import system modules # - import os import glob import sys - import types import string - import re import traceback # --- 54,65 ---- # Import system modules # import glob + import mimetypes + import os + import re import sys import string import traceback + import types # *************** *** 127,130 **** --- 128,140 ---- self.addIgnoreDirectoryPattern('trace.txt') + # + # Initialize extensions for mimetypes that we know about but which are + # not standard. + # + self.addMimetype('stx', 'text/x-structured') + return + + def addMimetype(self, extension, mimetypeSpec): + mimetypes.types_map['.%s' % extension] = mimetypeSpec return *************** *** 205,208 **** --- 215,234 ---- ## self.author_name = authorNameAndEmail ## return + + def optionHandler_mimetype(self, extensionAndMimetype): + """Specify a filename extension and mimetype mapping. + + This is useful if input files are named in a way that the + Python mimetypes module cannot determine their mimetype + automatically. + + For example:: + + """ + parts = extensionAndMimetype.split('=') + if len(parts) != 2: + raise ValueError('Could not understand "%s". Use --mimetype "ext=mimetype"' % extensionAndMimetype) + self.addMimetype(parts[0], parts[1]) + return def optionHandler_d(self, outputDirectory): Index: packagetree.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** packagetree.py 1 Jan 2003 13:47:22 -0000 1.2 --- packagetree.py 18 Jan 2003 14:35:24 -0000 1.3 *************** *** 77,86 **** 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. --- 77,80 ---- |
From: Doug H. <dou...@us...> - 2003-01-18 14:16:36
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv8409/happydoclib/docset Modified Files: docset_MultiHTMLFile.py Log Message: Make breadcrumbs smaller, and put them inside the table instead of just above. This lets the table bump up against the top of the browser window, instead of having a top margin. Index: docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** docset_MultiHTMLFile.py 1 Jan 2003 14:05:28 -0000 1.14 --- docset_MultiHTMLFile.py 18 Jan 2003 14:16:29 -0000 1.15 *************** *** 171,175 **** ) output.write('/ %s '% ref) ! output.write('\n') return --- 171,175 ---- ) output.write('/ %s '% ref) ! #output.write('\n') return *************** *** 182,190 **** # output.write('<!-- breadcrumbs -->\n') ! output.write('<p>\n') self._writeBreadcrumbs(output, packageTreeNode, packageTreeNode) ! output.write('</p>\n') output.write('\n<!-- /breadcrumbs -->\n') return --- 182,190 ---- # output.write('<!-- breadcrumbs -->\n') ! output.write('<p><small>\n') self._writeBreadcrumbs(output, packageTreeNode, packageTreeNode) ! output.write('</small></p>\n') output.write('\n<!-- /breadcrumbs -->\n') return *************** *** 197,201 **** bgcolor = self.pageBackgroundColor root = 'need root URL' ! output.write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html40/loose.dtd"> --- 197,204 ---- bgcolor = self.pageBackgroundColor root = 'need root URL' ! ! # ! # HTML header and Body tag. ! # output.write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html40/loose.dtd"> *************** *** 210,216 **** ''' % locals()) ! if packageTreeNode.getParent() is not None: ! self.writeBreadcrumbs(output, packageTreeNode) ! output.write(''' --- 213,219 ---- ''' % locals()) ! # ! # Outline table ! # output.write(''' *************** *** 231,234 **** --- 234,243 ---- <td> ''' % locals()) + + # + # Breadcrumbs + # + if packageTreeNode.getParent() is not None: + self.writeBreadcrumbs(output, packageTreeNode) return |
From: Doug H. <dou...@us...> - 2003-01-18 14:15:32
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv7942/happydoclib Modified Files: scanner.py Added Files: cvsignore.py test_cvsignore.py Log Message: Update the scanner to read .cvsignore files and ignore anything listed in them. Reads both the local .cvsignore (in the current directory) and the one in $HOME (if it exists) to mimic the behavior of cvs. --- NEW FILE: cvsignore.py --- #!/usr/bin/env python # # $Id: cvsignore.py,v 1.1 2003/01/18 14:15:29 doughellmann Exp $ # # Copyright 2003 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. # """Class to encapsulate the .cvsignore logic. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: cvsignore.py,v $', 'rcs_id' : '$Id: cvsignore.py,v 1.1 2003/01/18 14:15:29 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 08:29:30 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 14:15:29 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # from fnmatch import fnmatch import os # # Import Local modules # # # Module # class CVSIgnoreList: def __init__(self, ignoreFileNames): self.patterns = [] self.ignore_filenames = ignoreFileNames for filename in self.ignore_filenames: self.readIgnoreFile(filename) return def readIgnoreFile(self, filename): """Reads a .cvsignore file to include its patterns with the patterns read from other files. """ try: file = open(filename, 'rt') except IOError: return else: lines = file.readlines() file.close() patterns = [ s.strip() for s in lines ] for pattern in patterns: if pattern not in self.patterns: self.patterns.append(pattern) return def shouldIgnoreFile(self, filename): """Returns true if the filename should be ignored. """ basename = os.path.basename(filename) for pattern in self.patterns: if basename == pattern: return 1 elif fnmatch(basename, pattern): return 1 return 0 --- NEW FILE: test_cvsignore.py --- #!/usr/bin/env python # # $Id: test_cvsignore.py,v 1.1 2003/01/18 14:15:29 doughellmann Exp $ # # Copyright 2003 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. # """Test the cvsignore module. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: test_cvsignore.py,v $', 'rcs_id' : '$Id: test_cvsignore.py,v 1.1 2003/01/18 14:15:29 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sat, 18-Jan-2003 08:42:33 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/18 14:15:29 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import unittest # # Import Local modules # from happydoclib.cvsignore import CVSIgnoreList # # Module # class CVSIgnoreTest(unittest.TestCase): def testIgnoreExplicitName(self): ignore_list = CVSIgnoreList([]) ignore_list.patterns.append('foo.txt') if not ignore_list.shouldIgnoreFile('/tmp/foo.txt'): self.fail('Should have ignored foo.txt.') return def testIgnorePatternWithExt(self): ignore_list = CVSIgnoreList([]) ignore_list.patterns.append('*.pyc') if not ignore_list.shouldIgnoreFile('/tmp/foo.pyc'): self.fail('Should have ignored foo.pyc.') return def testNotIgnoreExplicitName(self): ignore_list = CVSIgnoreList([]) if ignore_list.shouldIgnoreFile('/tmp/foo.txt'): self.fail('Should not have ignored foo.txt.') return def testNotIgnorePatternWithExt(self): ignore_list = CVSIgnoreList([]) if ignore_list.shouldIgnoreFile('/tmp/foo.pyc'): self.fail('Should not have ignored foo.pyc.') return Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** scanner.py 1 Jan 2003 13:48:08 -0000 1.15 --- scanner.py 18 Jan 2003 14:15:29 -0000 1.16 *************** *** 70,73 **** --- 70,74 ---- from happydoclib.trace import trace from happydoclib.utils import * + from happydoclib.cvsignore import CVSIgnoreList # *************** *** 185,192 **** --- 186,205 ---- contents = glob.glob(pattern) + local_cvsignore_filename = os.path.join(directoryName, '.cvsignore') + home_cvsignore_filename = os.path.join(os.environ['HOME'], '.cvsignore') + cvsignore_list = CVSIgnoreList( + (local_cvsignore_filename, + home_cvsignore_filename, + ) + ) + # # Recurse # for subnode_name in contents: + if cvsignore_list.shouldIgnoreFile(subnode_name): + trace.write('Skipping %s, found in .cvsignore' % subnode_name, + outputLevel=TRACE_LEVEL) + continue self.buildPackageTree(subnode_name, tree) |