happydoc-checkins Mailing List for HappyDoc (Page 8)
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-07 15:35:02
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv32585/happydoclib/docset
Modified Files:
docset_MultiHTMLFile.py
Log Message:
Add writeFileHeader and writeFileFooter methods, some class attributes
as placeholders for color values.
Index: docset_MultiHTMLFile.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** docset_MultiHTMLFile.py 1 Dec 2002 22:37:17 -0000 1.2
--- docset_MultiHTMLFile.py 7 Dec 2002 15:34:59 -0000 1.3
***************
*** 56,63 ****
--- 56,65 ----
#
import os
+ import time
#
# Import Local modules
#
+ import happydoclib
from happydoclib.docset import base
from happydoclib.trace import trace
***************
*** 77,80 ****
--- 79,89 ----
"""
+ pageBackgroundColor='#ffffff'
+ levelOneHeadingBackgroundColor='#88bbee'
+ levelOneHeadingForegroundColor='#000000'
+ levelTwoHeadingBackgroundColor='#99ccff'
+ levelTwoHeadingForegroundColor='#000000'
+ codeForegroundColor='#000088'
+
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode')
***************
*** 98,101 ****
--- 107,173 ----
return filename_with_extension
+ def writeFileHeader(self, output, title='', subtitle=''):
+
+ title_bg = self.levelOneHeadingBackgroundColor
+ title_fg = self.levelOneHeadingForegroundColor
+ 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">
+
+ <html>
+
+ <head>
+ <title>%(title)s</title>
+ </head>
+
+ <body bgcolor="%(bgcolor)s">
+
+ <p><i><a href="%(root)s">Table of Contents</a></i></p>
+
+ <table border="0" cellpadding="5" cellspacing="0" width="100%%">
+ <tr>
+ <th rowspan="2"
+ valign="top"
+ align="left"
+ width="10%%"
+ bgcolor="%(title_bg)s"><font color="%(title_fg)s">%(title)s</font>
+ </th>
+ <th bgcolor="%(title_bg)s"
+ width="90%%"
+ align="right"><font color="%(title_fg)s">%(subtitle)s</font>
+ </th>
+ </tr>
+ <tr>
+ <td>
+ ''' % locals())
+ return
+
+ def writeFileFooter(self, output):
+
+ root = 'Need URL for root'
+ date_str = time.ctime(time.time())
+ app_version = happydoclib.cvsProductVersion()
+
+ output.write('''
+ </td>
+ </tr>
+ </table>
+
+ <hr>
+
+ <p><i><a href="%(root)s">Table of Contents</a></i></p>
+
+ <font size="-2"><i>This document was automatically generated
+ %(date_str)s by <a
+ href="http://happydoc.sourceforge.net">HappyDoc</a> version
+ %(app_version)s</i></font>
+
+ </body>
+ </html>
+ ''' % locals())
+ return
+
def writePythonFile(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writePythonFile',
***************
*** 121,141 ****
output_filename,
))
-
- trace.outof()
- return
! def writePlainTextFile(self, packageTreeNode):
! trace.into('MultiHTMLFileDocSet', 'writePlainTextFile',
! packageTreeNode=packageTreeNode,
! )
!
! canonical_path = packageTreeNode.getPath(1)
! canonical_filename = apply(os.path.join, canonical_path)
! output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
!
! self.statusMessage('Translating: "%s"\n to: "%s"' % (
! canonical_filename,
! output_filename,
! ))
trace.outof()
--- 193,200 ----
output_filename,
))
! output_file = self.openOutput(output_filename)
! output_file.write('\n')
! self.closeOutput(output_file)
trace.outof()
|
|
From: Doug H. <dou...@us...> - 2002-12-07 15:34:36
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv32473/happydoclib/docset
Modified Files:
base.py
Log Message:
Add writeFileHeader and writeFileFooter methods to base class.
Index: base.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** base.py 7 Dec 2002 15:33:27 -0000 1.4
--- base.py 7 Dec 2002 15:34:32 -0000 1.5
***************
*** 339,342 ****
--- 339,348 ----
return
+ def writeFileHeader(self, output, title=None, subtitle=None):
+ raise NotImplemented('writeFileHeader')
+
+ def writeFileFooter(self, output):
+ raise NotImplemented('writeFileFooter')
+
def openOutput(self, name, title=None, subtitle=None):
f = open(name, 'wt')
|
|
From: Doug H. <dou...@us...> - 2002-12-07 15:33:30
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv32225/happydoclib/docset
Modified Files:
base.py
Log Message:
Use openOutput and closeOutput for TOC file.
Index: base.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** base.py 7 Dec 2002 15:31:45 -0000 1.3
--- base.py 7 Dec 2002 15:33:27 -0000 1.4
***************
*** 332,338 ****
output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
! file = open(output_filename, 'wt')
! file.write('\n')
! file.close()
trace.outof()
--- 332,338 ----
output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
! file = self.openOutput(output_filename)
! file.write('TOC goes here')
! self.closeOutput(file)
trace.outof()
|
|
From: Doug H. <dou...@us...> - 2002-12-07 15:31:48
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv31740/happydoclib/docset
Modified Files:
base.py
Log Message:
Add mappings to handle images by copying them.
Add openOutput() and closeOutput().
Add writePlainTextFile().
Index: base.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** base.py 1 Dec 2002 22:36:53 -0000 1.2
--- base.py 7 Dec 2002 15:31:45 -0000 1.3
***************
*** 62,65 ****
--- 62,66 ----
import happydoclib
from happydoclib.trace import trace
+ from happydoclib.docstring import getConverterFactoryForFile, getConverterFactory
#
***************
*** 173,187 ****
mimetype_writer_mapping = {
! 'text/x-python': 'writePythonFile',
! 'text/x-text': 'writePlainTextFile',
! 'text/x-structured': 'writePlainTextFile',
! 'text/html': 'copyInputFileToOutput',
}
mimetype_extension_mapping = {
! 'text/x-python': { 'remove_existing':1,},
! 'text/plain': { 'remove_existing':1,},
! 'text/x-structured': { 'remove_existing':1,},
! 'text/html': { 'remove_existing':1,},
}
--- 174,191 ----
mimetype_writer_mapping = {
! '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 = {
! 'text/x-python' : { 'remove_existing':1,},
! 'text/plain' : { 'remove_existing':1,},
! 'text/x-structured' : { 'remove_existing':1,},
! 'text/html' : { 'remove_existing':1,},
}
***************
*** 332,335 ****
--- 336,381 ----
file.close()
+ trace.outof()
+ return
+
+ def openOutput(self, name, title=None, subtitle=None):
+ f = open(name, 'wt')
+ self.writeFileHeader(f, title=title, subtitle=subtitle)
+ return f
+
+ def closeOutput(self, output):
+ self.writeFileFooter(output)
+ output.close()
+ return
+
+ def writePlainTextFile(self, packageTreeNode):
+ trace.into('MultiFileDocSet', 'writePlainTextFile',
+ packageTreeNode=packageTreeNode,
+ )
+
+ canonical_path = packageTreeNode.getPath(1)
+ canonical_filename = apply(os.path.join, canonical_path)
+ output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
+
+ self.statusMessage('Translating: "%s"\n to: "%s"' % (
+ canonical_filename,
+ output_filename,
+ ))
+
+ converter_factory = getConverterFactoryForFile(canonical_filename)
+ converter = converter_factory()
+
+ input_file = converter.getExternalDocumentationFile(canonical_filename)
+
+ raw_body = str(input_file)
+
+ cooked_body = converter.convert(raw_body, 'html', level=3)
+
+ output_file = self.openOutput(output_filename)
+
+ output_file.write(cooked_body)
+
+ self.closeOutput(output_file)
+
trace.outof()
return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:39:03
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo
In directory sc8-pr-cvs1:/tmp/cvs-serv28795/happydoclib/parseinfo
Modified Files:
suite.py
Log Message:
Add a method to retrieve the comment text for a given object.
Index: suite.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/suite.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** suite.py 17 Nov 2002 15:05:43 -0000 1.1
--- suite.py 1 Dec 2002 22:38:59 -0000 1.2
***************
*** 237,240 ****
--- 237,244 ----
## DocStrings
##
+
+ def getComment(self):
+ "Return any comments for the object."
+ return self._comments
def getDocString(self):
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:38:42
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo
In directory sc8-pr-cvs1:/tmp/cvs-serv28607/happydoclib/parseinfo
Modified Files:
__init__.py
Log Message:
Use module-level options controlled by the application instead of
passing lots of arguments around to different objects.
Index: __init__.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/__init__.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** __init__.py 17 Nov 2002 15:05:43 -0000 1.1
--- __init__.py 1 Dec 2002 22:38:38 -0000 1.2
***************
*** 125,129 ****
#
! def getDocs(parent, fileName, includeComments=1, defaultConfigValues={}):
"""Retrieve information from the parse tree of a source file.
--- 125,162 ----
#
! _parser_options = {
! 'include_comments':1,
! }
!
! def setOption(**kwargs):
! """Set options to control the parser behavior.
!
! Options
!
! include_comments -- Boolean (default true) controlling whether
! text should be taken from comments in
! addition to docstrings.
!
! """
! global _parser_options
! #print 'Before %s' % str(_parser_options)
! #print 'Updating with %s' % str(kwargs)
! _parser_options.update(kwargs)
! #print 'After %s' % str(_parser_options)
! return
!
! def getOption(name):
! """Get options which control the parser behavior.
!
! Options
!
! name -- The name of the option whose value should be retrieved.
!
! """
! global _parser_options
! return _parser_options[name]
!
!
! def getDocs(parent, fileName):
"""Retrieve information from the parse tree of a source file.
***************
*** 133,146 ****
Name of the file to read Python source code from.
- includeComments=1 --
- Flag to indicate whether comments should be parsed for
- cases where __doc__ strings are not available.
-
"""
happydoclib.TRACE.into('parseinfo', 'getDocs',
parent=parent,
fileName=fileName,
- includeComments=includeComments,
- defaultConfigValues=defaultConfigValues,
)
f = open(fileName)
--- 166,173 ----
***************
*** 173,181 ****
tup = parser.ast2tuple(ast)
! if includeComments:
comment_info = parsecomments.extractComments(source)
else:
comment_info = {}
happydoclib.TRACE.write('Creating ModuleInfo')
mod_info = ModuleInfo(parent=parent,
tree=tup,
--- 200,216 ----
tup = parser.ast2tuple(ast)
!
! include_comments = getOption('include_comments')
!
! if include_comments:
comment_info = parsecomments.extractComments(source)
else:
comment_info = {}
happydoclib.TRACE.write('Creating ModuleInfo')
+
+ config_values = {}
+ global _parser_options
+ config_values.update(_parser_options)
+
mod_info = ModuleInfo(parent=parent,
tree=tup,
***************
*** 183,187 ****
fileName=fileName,
commentInfo=comment_info,
! defaultConfigValues=defaultConfigValues)
happydoclib.TRACE.outof(mod_info)
return mod_info
--- 218,222 ----
fileName=fileName,
commentInfo=comment_info,
! defaultConfigValues=config_values)
happydoclib.TRACE.outof(mod_info)
return mod_info
***************
*** 208,221 ****
'testNestedFunctions':'TestCases/parseinfo/test_nested_structures.py',
}
- include_comments = {
- 'testIgnoreComments':0,
- }
def setUp(self):
name = self._TestCase__testMethodName
filename = self.filename_map.get(name, self.default_filename)
- comments_flag = self.include_comments.get(name, 1)
self.filename = filename
! self.parsed_module = getDocs(None, filename, includeComments=comments_flag)
return
--- 243,253 ----
'testNestedFunctions':'TestCases/parseinfo/test_nested_structures.py',
}
def setUp(self):
name = self._TestCase__testMethodName
filename = self.filename_map.get(name, self.default_filename)
self.filename = filename
! setOption(include_comments=1)
! self.parsed_module = getDocs(None, filename)
return
***************
*** 317,328 ****
return
! # def testExtractVariablesFromModule(self):
! # expected_values = {
! # 'TestInt':1,
! # 'TestString':"String",
! # 'TestStringModule':"this has spaces in front and back",
! # 'url': 'b=B&a=A',
! # }
! # module_values = self.parsed_module.getConfigurationValues()
# if self.verboseLevel.get() > 1:
--- 349,367 ----
return
! def testExtractVariablesFromModule(self):
! expected_values = {
! 'include_comments':1,
! 'TestInt':1,
! 'TestString':"String",
! 'TestStringModule':"this has spaces in front and back",
! 'url': 'a=A&b=B',
! }
! module_values = self.parsed_module.getConfigurationValues()
!
! #for name, value in module_values.items():
! # self.failUnlessEqual(
! # value, expected_values[name],
! # 'Got %s for %s instead of %s' % (value, name, expected_values[name])
! # )
# if self.verboseLevel.get() > 1:
***************
*** 331,340 ****
# pprint.pprint(module_values)
! # assert (module_values == expected_values), 'Did not find expected variables'
! # return
def testExtractVariablesFromModuleWithException(self):
module_values = self.parsed_module.getConfigurationValues()
! assert not module_values, 'Did not find expected exception'
return
--- 370,383 ----
# pprint.pprint(module_values)
! self.failUnlessEqual(module_values, expected_values)
! return
def testExtractVariablesFromModuleWithException(self):
+ expected_values = {
+ 'include_comments':1,
+ }
module_values = self.parsed_module.getConfigurationValues()
! self.failUnlessEqual(module_values, expected_values)
! #assert not module_values, 'Did not find expected exception'
return
***************
*** 371,394 ****
return
def testIgnoreComments(self):
! assert not self.parsed_module._comments, \
'Did not ignore module comments %s' % self.filename
! assert self.parsed_module._docstring, \
'Did not find docstring for module %s' % self.filename
! c = self.parsed_module['WithComments']
! assert not c._comments, \
! 'Did not ignore comments in class WithComments'
assert not c._docstring, \
'Found unexepcted docstring for class WithComments'
method = c['__init__']
! assert not method._comments, \
'Did not ignore comments in method WithComments.__init__'
assert not method._docstring, \
'Found unexpected docstring for method WithComments.__init__'
! c = self.parsed_module['WithoutComments']
! assert not c._comments, \
'Found unexepected comments for class WithoutComments'
assert c._docstring, \
--- 414,453 ----
return
+ def testIgnoreCommentsSetting(self):
+ setOption(include_comments=0)
+ include_comments = getOption('include_comments')
+ if include_comments:
+ self.fail('include_comments option not turned off (%s)' % include_comments)
+ return
+
+ def testIncludeCommentsSetting(self):
+ setOption(include_comments=1)
+ include_comments = getOption('include_comments')
+ if not include_comments:
+ self.fail('include_comments option not turned off')
+ return
+
def testIgnoreComments(self):
! setOption(include_comments=0)
! parsed_module = getDocs(None, self.filename)
! assert not parsed_module._comments, \
'Did not ignore module comments %s' % self.filename
! assert parsed_module._docstring, \
'Did not find docstring for module %s' % self.filename
! c = parsed_module['WithComments']
! assert not c.getComment(), \
! 'Did not ignore comments in class WithComments (%s)' % c.getComment()
assert not c._docstring, \
'Found unexepcted docstring for class WithComments'
method = c['__init__']
! assert not method.getComment(), \
'Did not ignore comments in method WithComments.__init__'
assert not method._docstring, \
'Found unexpected docstring for method WithComments.__init__'
! c = parsed_module['WithoutComments']
! assert not c.getComment(), \
'Found unexepected comments for class WithoutComments'
assert c._docstring, \
***************
*** 396,400 ****
method = c['__init__']
! assert not method._comments, \
'Found unexpected comments for method WithoutComments.__init__'
assert method._docstring, \
--- 455,459 ----
method = c['__init__']
! assert not method.getComment(), \
'Found unexpected comments for method WithoutComments.__init__'
assert method._docstring, \
***************
*** 580,583 ****
--- 639,675 ----
'Docstring for InnerFunction2 does not match.'
+ return
+
+ def testIncludeCommentsOptionTrue(self):
+ happydoclib.parseinfo.setOption(include_comments=1)
+
+ input_filename = os.path.join( 'TestCases',
+ 'parseinfo',
+ 'test_decorated_comments.py'
+ )
+ module_info = happydoclib.parseinfo.getDocs(None, input_filename)
+
+ func_names = module_info.getFunctionNames()
+ for func_name in func_names:
+ func_info = module_info.getFunctionInfo(func_name)
+ comments = func_info.getComment()
+ self.failUnless(comments, 'Did not get any comments for %s.' % func_name)
+ return
+
+ def testIncludeCommentsOptionFalse(self):
+ happydoclib.parseinfo.setOption(include_comments=0)
+
+ input_filename = os.path.join( 'TestCases',
+ 'parseinfo',
+ 'test_decorated_comments.py'
+ )
+ module_info = happydoclib.parseinfo.getDocs(None, input_filename)
+
+ func_names = module_info.getFunctionNames()
+ for func_name in func_names:
+ func_info = module_info.getFunctionInfo(func_name)
+ comments = func_info.getComment()
+ if comments:
+ self.fail('Got comments for %s.' % func_name)
return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:38:13
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv28336/happydoclib/docset
Modified Files:
test_docset_MultiHTMLFile.py
Log Message:
Add a test for the output name of a plain text file.
Add a test to run the app and validate the output using this docset.
This test still does not pass.
Index: test_docset_MultiHTMLFile.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_docset_MultiHTMLFile.py 18 Nov 2002 13:45:58 -0000 1.1
--- test_docset_MultiHTMLFile.py 1 Dec 2002 22:38:06 -0000 1.2
***************
*** 61,64 ****
--- 61,65 ----
# Import Local modules
#
+ import happydoclib
from happydoclib.scanner import Scanner
from docset_MultiHTMLFile import MultiHTMLFileDocSet
***************
*** 68,71 ****
--- 69,112 ----
#
+ 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 = ( '-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') )
+ scanner = Scanner([self.getOutputDirectory()])
+ root = os.path.join( self.getOutputDirectory(), 'testScanner' )
+ expected_dirs = [ ('levelOne',),
+ ('levelOne', 'levelTwo'),
+ ]
+ expected_dirs = [ apply(os.path.join, (root,) + ed) for ed in expected_dirs ]
+ for dirname in expected_dirs:
+ self.failUnless(os.path.isdir(dirname),
+ '%s is not a directory' % dirname,
+ )
+
+ expected_files = [ ('levelOne', 'index.html'),
+ ('levelOne', 'Existing.html'),
+ ('levelOne', 'README.txt.html'),
+ ('levelOne', 'one.py.html'),
+ ('levelOne', 'levelTwo'),
+ ]
+ expected_files = [ apply(os.path.join, (root,) + ef) for ef in expected_files ]
+ for filename in expected_files:
+ self.failUnless(os.path.exists(filename),
+ '%s does not exist' % filename,
+ )
+ return
+
class MultiHTMLFileDocSetTestCase(unittest.TestCase):
***************
*** 95,99 ****
'levelOne',
'levelTwo',
! 'two.py.html',
)
--- 136,140 ----
'levelOne',
'levelTwo',
! 'two.html',
)
***************
*** 110,114 ****
'levelOne',
'levelTwo',
! 'two.py.html',
)
--- 151,155 ----
'levelOne',
'levelTwo',
! 'two.html',
)
***************
*** 126,130 ****
'levelOne',
'levelTwo',
! 'two.py.html',
)
--- 167,171 ----
'levelOne',
'levelTwo',
! 'two.html',
)
***************
*** 134,135 ****
--- 175,205 ----
)
return
+
+ def testPlainTextFile(self):
+
+ input_dir = os.path.join('TestCases', 'testScanner')
+ output_dir = '/tmp/foo'
+
+ scanner = Scanner([input_dir])
+
+ trees = scanner.getPackageTrees()
+ expected_tree = trees[0]
+
+ readme = expected_tree['levelOne']['README.txt']
+
+ docset = MultiHTMLFileDocSet(scanner,
+ 'Testing',
+ output_dir,
+ )
+
+ actual = docset.getOutputFilenameForPackageTreeNode(readme)
+
+ expected = os.path.join(output_dir, 'testScanner', 'levelOne', 'README.html')
+
+ self.failUnlessEqual(actual, expected)
+ return
+
+
+ if __name__ == '__main__':
+ unittest.main()
+
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:37:20
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv27926/happydoclib/docset
Modified Files:
docset_MultiHTMLFile.py
Log Message:
Refactor some of this code into the base class.
Index: docset_MultiHTMLFile.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** docset_MultiHTMLFile.py 18 Nov 2002 13:45:58 -0000 1.1
--- docset_MultiHTMLFile.py 1 Dec 2002 22:37:17 -0000 1.2
***************
*** 78,82 ****
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
! filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode(self, packageTreeNode)
if packageTreeNode.values():
--- 78,86 ----
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
! trace.into('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode')
! filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode(
! self,
! packageTreeNode,
! )
if packageTreeNode.values():
***************
*** 90,112 ****
#
filename_with_extension = '%s.html' % filename
-
- return filename_with_extension
! def writeDirectory(self, packageTreeNode):
! trace.into('MultiHTMLFileDocSet', 'writeDirectory',
! packageTreeNode=packageTreeNode,
! )
!
! canonical_path = packageTreeNode.getPath(1)
! canonical_filename = apply(os.path.join, canonical_path)
! output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
!
! self.statusMessage('Directory : "%s"\n to: "%s"' % (
! canonical_filename,
! output_filename,
! ))
!
! trace.outof()
! return
def writePythonFile(self, packageTreeNode):
--- 94,100 ----
#
filename_with_extension = '%s.html' % filename
! trace.outof(filename_with_extension)
! return filename_with_extension
def writePythonFile(self, packageTreeNode):
***************
*** 114,117 ****
--- 102,115 ----
packageTreeNode=packageTreeNode,
)
+
+ node_name = packageTreeNode.getName()
+ if node_name == '__init__.py':
+ #
+ # Skip the __init__.py file, since it will
+ # be handled as part of the package.
+ #
+ trace.write('skipping __init__.py')
+ trace.outof()
+ return
canonical_path = packageTreeNode.getPath(1)
***************
*** 143,197 ****
trace.outof()
return
-
- def writeCB(self, packageTreeNode):
- trace.into('MultiHTMLFileDocSet', 'writeCB',
- packageTreeNode=packageTreeNode,
- )
- node_name = packageTreeNode.getName()
-
- extension = os.path.splitext(node_name)[1]
-
- if packageTreeNode.values():
- #
- # Directory node
- #
- self.writeDirectory(packageTreeNode)
-
- elif node_name == '__init__.py':
- #
- # Skip the __init__.py file, since it will
- # be handled as part of the package.
- #
- trace.write('skipping __init__.py')
- pass
-
- else:
- #
- # Anything past here looks like a file.
- #
-
- if extension == '.py':
- #
- # Filename ends in .py, so it is a Python file.
- #
- self.writePythonFile(packageTreeNode)
-
- elif extension in ('.txt', '.stx'):
- #
- # Filename ends in .txt or .stx so it is
- # a text file.
- #
- self.writePlainTextFile(packageTreeNode)
-
- else:
- #
- # Unrecognized file, skipped.
- #
- node_path = packageTreeNode.getPath()
- filename = apply(os.path.join, node_path)
- self.statusMessage('Skiping unrecognized file %s' % filename,
- 2)
-
- trace.outof()
- return
-
--- 141,142 ----
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:36:56
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv27748/happydoclib/docset
Modified Files:
base.py
Log Message:
Start working on mimetype-driven output code. This version creates
output directories and empty index.html files.
Index: base.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** base.py 18 Nov 2002 13:43:37 -0000 1.1
--- base.py 1 Dec 2002 22:36:53 -0000 1.2
***************
*** 67,70 ****
--- 67,78 ----
#
+ def isSomethingThatLooksLikeDirectory(path):
+ return (os.path.isdir(path)
+ or
+ os.path.islink(path)
+ or
+ os.path.ismount(path)
+ )
+
class DocSet:
"""Basic Documentation Set.
***************
*** 155,163 ****
def write(self):
! package_trees = self.scanner.getPackageTrees()
!
! for package_tree in package_trees:
! package_tree.walk(self.writeCB)
!
return
--- 163,167 ----
def write(self):
! self.scanner.walk(self.writeCB)
return
***************
*** 168,171 ****
--- 172,188 ----
"""
+ mimetype_writer_mapping = {
+ 'text/x-python': 'writePythonFile',
+ 'text/x-text': 'writePlainTextFile',
+ 'text/x-structured': 'writePlainTextFile',
+ 'text/html': 'copyInputFileToOutput',
+ }
+
+ mimetype_extension_mapping = {
+ 'text/x-python': { 'remove_existing':1,},
+ 'text/plain': { 'remove_existing':1,},
+ 'text/x-structured': { 'remove_existing':1,},
+ 'text/html': { 'remove_existing':1,},
+ }
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
***************
*** 184,205 ****
results in : /foo/output/input/bar.py
"""
! #
! # Get the path to the node from the root of the scanned
! # tree.
! #
! node_path = packageTreeNode.getPath()
#
# Get the input filename, relative to the root of the input.
#
! filename = apply(os.path.join, node_path)
#
# Add the output directory to the front of the input
# filename.
#
! output_filename = os.path.join(self.output_directory, filename)
#
# Normalize the path, in case it includes /./ and the like.
#
normalized_output_filename = os.path.normpath(output_filename)
return normalized_output_filename
--- 201,335 ----
results in : /foo/output/input/bar.py
"""
! trace.into('MultiFileDocSet', 'getOutputFilenameForPackageTreeNode',
! packageTreeNode=packageTreeNode,
! )
!
! mimetype, encoding = packageTreeNode.getMimeType()
! trace.writeVar(mimetype=mimetype)
! settings = self.mimetype_extension_mapping.get(mimetype, {})
! trace.writeVar(settings=settings)
!
#
# Get the input filename, relative to the root of the input.
#
! #input_filename = packageTreeNode.getInputFilename()
! input_filename = packageTreeNode.getRelativeFilename()
!
#
# Add the output directory to the front of the input
# filename.
#
! output_filename = os.path.join(self.output_directory, input_filename)
!
! if settings.get('remove_existing'):
! output_filename, ignore = os.path.splitext(output_filename)
!
#
# Normalize the path, in case it includes /./ and the like.
#
normalized_output_filename = os.path.normpath(output_filename)
+ trace.outof(normalized_output_filename)
return normalized_output_filename
+
+ def copyInputFileToOutput(self, packageTreeNode):
+ input_filename = packageTreeNode.getInputFilename()
+ output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
+ self.statusMessage('Copying: %s\n To: %s' % (
+ 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,
+ )
+
+ 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()
+ return
+ def rmkdir(self, path):
+ "Create a directory and all of its children."
+ if not path:
+ return
+ parts = os.path.split(path)
+ if len(parts) > 1:
+ parent, child = parts
+ if not isSomethingThatLooksLikeDirectory(parent):
+ self.rmkdir(parent)
+ if not isSomethingThatLooksLikeDirectory(path):
+ os.mkdir(path)
+ return
+
+ def writeDirectory(self, packageTreeNode):
+ trace.into('MultiFileDocSet', 'writeDirectory',
+ packageTreeNode=packageTreeNode,
+ )
+
+ canonical_path = packageTreeNode.getPath(1)
+ canonical_filename = apply(os.path.join, canonical_path)
+ output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
+ output_dirname = os.path.dirname(output_filename)
+
+ self.statusMessage('Directory : "%s"\n to: "%s"' % (
+ canonical_filename,
+ output_filename,
+ ))
+
+ if os.path.isdir(output_dirname):
+ self.statusMessage('\tExists')
+ else:
+ self.rmkdir(output_dirname)
+ self.statusMessage('\tCreated')
+
+ self.writeTOCFile(packageTreeNode)
+
+ trace.outof()
+ return
+
+ def writeTOCFile(self, packageTreeNode):
+ trace.into('MultiFileDocSet', 'writeDirectory',
+ packageTreeNode=packageTreeNode,
+ )
+
+ output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
+
+ file = open(output_filename, 'wt')
+ file.write('\n')
+ file.close()
+
+ trace.outof()
+ return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:36:17
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv27588/happydoclib
Modified Files:
test_scanner.py
Log Message:
Update tests to include mimetype checks.
Index: test_scanner.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/test_scanner.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_scanner.py 17 Nov 2002 16:19:59 -0000 1.3
--- test_scanner.py 1 Dec 2002 22:36:14 -0000 1.4
***************
*** 99,106 ****
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']
--- 99,107 ----
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']
***************
*** 118,121 ****
--- 119,156 ----
except KeyError:
self.fail('Could not get one.py')
+ else:
+ #
+ # Make sure of the mimetype
+ #
+ mimetype = module_one.getMimeType()
+ self.failUnlessEqual(mimetype, ('text/x-python', None))
+
+ #
+ # Try for README.txt
+ #
+ try:
+ readme = level_one['README.txt']
+ except KeyError:
+ self.fail('Could not get README.txt')
+ else:
+ #
+ # Make sure of the mimetype
+ #
+ mimetype = readme.getMimeType()
+ self.failUnlessEqual(mimetype, ('text/plain', None))
+
+ #
+ # Try for Existing.html
+ #
+ try:
+ readme = level_one['Existing.html']
+ except KeyError:
+ self.fail('Could not get Existing.html')
+ else:
+ #
+ # Make sure of the mimetype
+ #
+ mimetype = readme.getMimeType()
+ self.failUnlessEqual(mimetype, ('text/html', None))
#
***************
*** 145,148 ****
--- 180,197 ----
self.fail('Could not get two.py')
+
+ #
+ # Try for README.txt
+ #
+ try:
+ readme = level_two['README.stx']
+ except KeyError:
+ self.fail('Could not get README.stx')
+ else:
+ #
+ # Make sure of the mimetype
+ #
+ mimetype = readme.getMimeType()
+ self.failUnlessEqual(mimetype, ('text/x-structured', None))
return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:35:56
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv27493/happydoclib
Added Files:
status.py
Log Message:
Module-level status message handling, so every class does not need to
know that it is participating in a CommandLineApp program.
--- NEW FILE: status.py ---
#
# $Id: status.py,v 1.1 2002/12/01 22:35:53 doughellmann Exp $
#
# Copyright 2002 Racemi, Inc.
#
"""Module interface for providing status messages to the user.
"""
#
# Import system modules
#
#
# Import Local modules
#
#
# Module
#
_status_message_func = None
def statusMessage(msg, verboseLevel=1, error=None):
"""Print a status message to output.
Arguments
msg='' -- The status message string to be printed.
verboseLevel=1 -- The verbose level to use. The message
will only be printed if the current verbose
level is >= this number.
error=None -- If true, the message is considered an error and
printed as such.
"""
global _status_message_func
if _status_message_func:
_status_message_func(msg, verboseLevel, error)
return
def registerStatusMessageFunc(function):
"""Register the function to be called by statusMessage().
"""
global _status_message_func
_status_message_func = function
return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:35:23
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv27320/happydoclib
Modified Files:
scanner.py
Log Message:
Make the parsing code driven by mimetype, and move it here from the
main application class.
Index: scanner.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** scanner.py 17 Nov 2002 16:19:59 -0000 1.4
--- scanner.py 1 Dec 2002 22:35:19 -0000 1.5
***************
*** 59,62 ****
--- 59,63 ----
#
import glob
+ import mimetypes
import os
import re
***************
*** 66,69 ****
--- 67,72 ----
# Import Local modules
#
+ import happydoclib
+ from happydoclib.status import statusMessage
from happydoclib.trace import trace
***************
*** 72,75 ****
--- 75,84 ----
#
+ #
+ # 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.
***************
*** 79,82 ****
--- 88,97 ----
"""
+ parser_mapping = {
+ 'text/x-python' : 'parsePythonInput',
+ 'text/plain' : 'parsePlainTextInput',
+ 'text/x-structured' : 'parseStructuredTextInput',
+ }
+
def __init__(self, parent, name):
trace.into('PackageTree', '__init__',
***************
*** 85,91 ****
--- 100,112 ----
)
UserDict.UserDict.__init__(self)
+
self.parent = parent
+
self.name = os.path.basename(name)
+ trace.write('self.name=%s' % self.name)
self.canonical_name = name
+
+ self.mimetype = mimetypes.guess_type(name)
+
trace.outof()
return
***************
*** 93,97 ****
def __repr__(self):
base_str = UserDict.UserDict.__repr__(self)
! return '<Scanner %s: %s>' % (self.getName(), base_str)
def getParent(self):
--- 114,210 ----
def __repr__(self):
base_str = UserDict.UserDict.__repr__(self)
! return '<%s %s: %s>' % (self.__class__.__name__, self.getName(), base_str)
!
! def parsePythonInput(self):
! trace.into('PackageTree', 'parsePythonInput')
! #
! # Derive the filename for this module.
! #
! filename = self.getInputFilename()
! statusMessage('Parsing: %s' % filename)
!
! #
! # Figure out if there is a parent node for the
! # documentation suite.
! #
! package_parent = self.getParent()
! if package_parent and hasattr(package_parent, 'module_info'):
! docs_parent = package_parent.module_info
! else:
! docs_parent = None
!
! trace.writeVar(docs_parent=docs_parent)
!
! docs = happydoclib.parseinfo.getDocs(
! parent=docs_parent,
! fileName=filename,
! )
!
! self.module_info = docs
!
! trace.outof()
! return
!
! def parsePlainTextInput(self):
! trace.into('PackageTree', 'parsePlainTextInput',
! )
! #
! # Derive the filename for this module.
! #
! filename = self.getInputFilename()
! trace.writeVar(filename=filename)
!
! statusMessage('Importing preformatted file: %s' % filename)
!
! #f = open(filename, 'rt')
! #body = f.read()
! #f.close()
!
! #packageTreeNode.preformatted_text = body
!
! trace.outof()
! return
!
! def parseStructuredTextInput(self):
! trace.into('PackageTree', 'parseStructuredTextInput')
! self.parsePlainTextInput()
! trace.outof()
! return
!
! def getMimeType(self):
! """Returns the mimetype setting for this node.
! """
! return self.mimetype
!
! def parseInput(self):
! """Get whatever information is appropriate from the input file.
! """
! trace.into('PackageTree', 'parseInput')
!
! if os.path.isdir(self.getInputFilename()):
! trace.write('directory')
! trace.outof()
! return
!
! mimetype, encoding = self.getMimeType()
! try:
! parse_method_name = self.parser_mapping[mimetype]
! except KeyError:
! #
! # Don't know what to do with this file.
! #
! statusMessage('Not parsing input %s with mimetype %s' % (
! self.getInputFilename(),
! mimetype,
! ))
! else:
! #
! # Call the parse method
! #
! parse_method = getattr(self, parse_method_name)
! parse_method()
!
! trace.outof()
! return
def getParent(self):
***************
*** 118,122 ****
--- 231,238 ----
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)
***************
*** 124,134 ****
--- 240,282 ----
parent_path = ()
+ trace.writeVar(parent_path=parent_path)
+
if useCanonicalName:
name = self.getCanonicalName()
else:
name = self.getName()
+
path = parent_path + (name,)
+
+ trace.outof(path)
return path
+ def getInputFilename(self):
+ """Returns the original input filename that created the node.
+ """
+ trace.into('PackageTree', 'getInputFilename')
+
+ node_path = self.getPath(1)
+ trace.writeVar(node_path=node_path)
+ filename = apply(os.path.join, node_path)
+ trace.writeVar(filename=filename)
+
+ trace.outof(filename)
+ return filename
+
+ def getRelativeFilename(self):
+ """Returns the filename relative to the root of the input area.
+ """
+ trace.into('PackageTree', 'getRelativeFilename')
+
+ node_path = self.getPath()
+ trace.writeVar(node_path=node_path)
+ filename = apply(os.path.join, node_path)
+ trace.writeVar(filename=filename)
+
+ trace.outof(filename)
+ return filename
+
+
def addSubNode(self, name):
"""Insert a child node under this node.
***************
*** 159,168 ****
"""
! def __init__(self, inputDirectories, ignorePatterns=[]):
self._ignore_patterns = ignorePatterns
self._ignore_res = [ re.compile(ip) for ip in ignorePatterns ]
self._package_trees = []
!
for dir_name in inputDirectories:
if not os.path.exists(dir_name):
--- 307,324 ----
"""
! def __init__(self,
! inputDirectories,
! ignorePatterns=[],
! includeComments=1,
! ):
self._ignore_patterns = ignorePatterns
self._ignore_res = [ re.compile(ip) for ip in ignorePatterns ]
+ self._include_comments = includeComments
self._package_trees = []
!
! #
! # Scan
! #
for dir_name in inputDirectories:
if not os.path.exists(dir_name):
***************
*** 172,176 ****
if tree:
self._package_trees.append(tree)
!
return
--- 328,345 ----
if tree:
self._package_trees.append(tree)
!
! #
! # Parse
! #
! self._parsePackageTree()
! return
!
! def _parseOne(self, packageTreeNode):
! packageTreeNode.parseInput()
! return
!
! def _parsePackageTree(self):
! for package_tree in self.getPackageTrees():
! package_tree.walk(self._parseOne)
return
***************
*** 205,209 ****
tree = parent.addSubNode(package_tree_name)
else:
! tree = PackageTree(parent, directoryName)
#
--- 374,378 ----
tree = parent.addSubNode(package_tree_name)
else:
! tree = PackageTree(None, directoryName)
#
***************
*** 232,233 ****
--- 401,411 ----
"""
return self._package_trees
+
+ def walk(self, callback):
+ """Walk the PackageTree, calling the callback at each node.
+ """
+ trees = self.getPackageTrees()
+ for tree in trees:
+ tree.walk(callback)
+ return
+
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:34:52
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv27141/happydoclib
Modified Files:
appclass.py
Log Message:
Comment out some option handlers that might be useful but which aren't
supported right now.
Move parsing code into scanner module.
Index: appclass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** appclass.py 18 Nov 2002 13:41:12 -0000 1.6
--- appclass.py 1 Dec 2002 22:34:49 -0000 1.7
***************
*** 67,70 ****
--- 67,71 ----
import happydoclib
from happydoclib.scanner import Scanner
+ from happydoclib import status
from happydoclib.trace import trace
***************
*** 96,100 ****
app_home = 'http://HappyDoc.sourceforge.net/'
package_description_file = 'README.txt'
- recurse_into_subdirs=True
docset_type = None
--- 97,100 ----
***************
*** 116,119 ****
--- 116,121 ----
def appInit(self):
+ status.registerStatusMessageFunc(self.statusMessage)
+
self._app_name = self.__class__.__name__
self._app_version = happydoclib.cvsProductVersion()
***************
*** 196,205 ****
##
! def optionHandler_author(self, authorNameAndEmail):
! """Specify the author identification to be inserted for
! references.
! """
! self.author_name = authorNameAndEmail
! return
def optionHandler_d(self, outputDirectory):
--- 198,207 ----
##
! ## def optionHandler_author(self, authorNameAndEmail):
! ## """Specify the author identification to be inserted for
! ## references.
! ## """
! ## self.author_name = authorNameAndEmail
! ## return
def optionHandler_d(self, outputDirectory):
***************
*** 210,219 ****
return
! def optionHandler_dia(self):
! """Generate UML diagram in Gnome dia format.
! """
! self.set_docset_type("Dia")
! self.set_format("Dia")
! return
def optionHandler_i(self, ignoreDirectory):
--- 212,221 ----
return
! ## def optionHandler_dia(self):
! ## """Generate UML diagram in Gnome dia format.
! ## """
! ## self.set_docset_type("Dia")
! ## self.set_format("Dia")
! ## return
def optionHandler_i(self, ignoreDirectory):
***************
*** 238,242 ****
a __doc__ string.
"""
! self.include_comments = False
return
--- 240,244 ----
a __doc__ string.
"""
! happydoclib.parseinfo.setOption(include_comments=0)
return
***************
*** 246,267 ****
return
! def optionHandler_o(self):
! "Specify that output should go to stdout."
! self.set_docset_type('StdOut')
! return
! def optionHandler_p(self, packageDescriptionFile):
! """Specify a file with a description of the package.
! The default packageDescriptionFile is README.txt.
! """
! self.package_description_file = packageDescriptionFile
! return
- def optionHandler_r(self):
- "Disable recursion into subdirectories."
- self.recurse_into_subdirs = False
- return
-
def optionHandler_t(self, title):
"Specify a title for the documentation set."
--- 248,264 ----
return
! ## def optionHandler_o(self):
! ## "Specify that output should go to stdout."
! ## self.set_docset_type('StdOut')
! ## return
! ## def optionHandler_p(self, packageDescriptionFile):
! ## """Specify a file with a description of the package.
! ## The default packageDescriptionFile is README.txt.
! ## """
! ## self.package_description_file = packageDescriptionFile
! ## return
def optionHandler_t(self, title):
"Specify a title for the documentation set."
***************
*** 280,392 ****
##
- def scanForInput(self, inputModules):
- scanner = Scanner(inputModules, self._ignore_dir_patterns)
- return scanner
-
- def parsePythonInput(self, packageTreeNode):
- trace.into('HappyDoc', 'parsePythonInput',
- packageTreeNode=packageTreeNode,
- )
- #
- # Derive the filename for this module.
- #
- node_path = packageTreeNode.getPath(1)
- filename = apply(os.path.join, node_path)
- trace.writeVar(filename=filename)
-
- self.statusMessage('Parsing: %s' % filename)
-
- #
- # Figure out if there is a parent node for the
- # documentation suite.
- #
- package_parent = packageTreeNode.getParent()
- if package_parent and hasattr(package_parent, 'module_info'):
- docs_parent = package_parent.module_info
- else:
- docs_parent = None
-
- trace.writeVar(docs_parent=docs_parent)
-
- docs = happydoclib.parseinfo.getDocs(
- parent=docs_parent,
- fileName=filename,
- includeComments=self.include_comments,
- defaultConfigValues=self.parser_params,
- )
-
- packageTreeNode.module_info = docs
-
- trace.outof()
- return
-
- def parsePlainTextInput(self, packageTreeNode):
- trace.into('HappyDoc', 'parsePlainTextInput',
- packageTreeNode=packageTreeNode,
- )
- #
- # Derive the filename for this module.
- #
- node_path = packageTreeNode.getPath(1)
- filename = apply(os.path.join, node_path)
- trace.writeVar(filename=filename)
-
- self.statusMessage('Importing preformatted file: %s' % filename)
-
- #f = open(filename, 'rt')
- #body = f.read()
- #f.close()
-
- #packageTreeNode.preformatted_text = body
-
- trace.outof()
- return
-
- def parseInputCB(self, packageTreeNode):
- trace.into('HappyDoc', 'parseInputCB',
- packageTreeNode=packageTreeNode,
- )
-
- node_name = packageTreeNode.getName()
-
- extension = os.path.splitext(node_name)[1]
-
- if extension == '.py':
- #
- # Filename ends in .py, so it is a Python file.
- #
- self.parsePythonInput(packageTreeNode)
-
- elif extension in ('.txt', '.stx'):
- #
- # Filename ends in .txt or .stx so it is
- # a text file.
- #
- self.parsePlainTextInput(packageTreeNode)
-
- elif packageTreeNode.values():
- #
- # Directory node.
- #
- pass
-
- elif not packageTreeNode.values():
- #
- # Leaf node we are skipping.
- #
- node_path = packageTreeNode.getPath()
- filename = apply(os.path.join, node_path)
- self.statusMessage('Skipping: %s' % filename)
-
- trace.outof()
- return
-
- def parseInputs(self, scanner):
- package_trees = scanner.getPackageTrees()
-
- for package_tree in package_trees:
- package_tree.walk(self.parseInputCB)
-
- return
def getParameterGroupsFromArguments(self, args):
--- 277,280 ----
***************
*** 452,461 ****
# Create the scanner, and get the package trees.
#
! scanner = self.scanForInput(input_modules)
!
! #
! # Parse the input files
! #
! self.parseInputs(scanner)
#
--- 340,349 ----
# Create the scanner, and get the package trees.
#
! self.statusMessage('Scanning...')
! scanner = Scanner(inputDirectories=input_modules,
! ignorePatterns=self._ignore_dir_patterns,
! includeComments=self.include_comments,
! )
! self.statusMessage('Done')
#
***************
*** 464,468 ****
docset = self.docset_factory(
scanner=scanner,
! title='Title',
outputDirectory=self.output_directory,
includeComments=self.include_comments,
--- 352,356 ----
docset = self.docset_factory(
scanner=scanner,
! title=self.docset_title,
outputDirectory=self.output_directory,
includeComments=self.include_comments,
***************
*** 475,479 ****
--- 363,369 ----
# Generate some output
#
+ self.statusMessage('Writing...')
docset.write()
+ self.statusMessage('Done')
return
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:34:14
|
Update of /cvsroot/happydoc/HappyDoc3/TestCases/testScanner/levelOne
In directory sc8-pr-cvs1:/tmp/cvs-serv26956/TestCases/testScanner/levelOne
Added Files:
Existing.html
Log Message:
Add a regular HTML file to the test input so we can verify that it is
copied to the output properly.
--- NEW FILE: Existing.html ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Existing HTML file.</title>
</head>
<body>
<h1>Existing HTML file.</h1>
<p>Sample of processing for an existing HTML file.</p>
<hr>
<address><a href="mailto:do...@he...">Doug Hellmann</a></address>
<!-- Created: Sun Dec 1 11:04:13 EST 2002 -->
<!-- hhmts start -->
Last modified: Sun Dec 1 11:04:29 EST 2002
<!-- hhmts end -->
</body>
</html>
|
|
From: Doug H. <dou...@us...> - 2002-12-01 22:33:43
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv26792 Modified Files: .cvsignore Log Message: Ignore test output directory. Index: .cvsignore =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 17 Nov 2002 14:51:01 -0000 1.1 --- .cvsignore 1 Dec 2002 22:33:39 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- .coverage + TestOutput trace.txt |
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:46:01
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv9383
Added Files:
docset_MultiHTMLFile.py test_docset_MultiHTMLFile.py tests.py
Log Message:
Initial checkin
--- NEW FILE: docset_MultiHTMLFile.py ---
#!/usr/bin/env python
#
# $Id: docset_MultiHTMLFile.py,v 1.1 2002/11/18 13:45:58 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.
#
"""Documentation set which writes output to multiple files.
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name' : '$RCSfile: docset_MultiHTMLFile.py,v $',
'rcs_id' : '$Id: docset_MultiHTMLFile.py,v 1.1 2002/11/18 13:45:58 doughellmann Exp $',
'creator' : 'Doug Hellmann <do...@he...>',
'project' : 'HappyDoc',
'created' : 'Sun, 17-Nov-2002 13:32:00 EST',
#
# Current Information
#
'author' : '$Author: doughellmann $',
'version' : '$Revision: 1.1 $',
'date' : '$Date: 2002/11/18 13:45:58 $',
}
try:
__version__ = __rcs_info__['version'].split(' ')[1]
except:
__version__ = '0.0'
#
# Import system modules
#
import os
#
# Import Local modules
#
from happydoclib.docset import base
from happydoclib.trace import trace
#
# Module
#
def entryPoint():
"Return info about this module to the dynamic loader."
return { 'name':'MultiHTMLFile',
'factory':MultiHTMLFileDocSet,
}
class MultiHTMLFileDocSet(base.MultiFileDocSet):
"""Documentation set written to multiple HTML files.
"""
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode(self, packageTreeNode)
if packageTreeNode.values():
#
# This is a directory.
#
filename_with_extension = os.path.join(filename, 'index.html')
else:
#
# This is a file.
#
filename_with_extension = '%s.html' % filename
return filename_with_extension
def writeDirectory(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writeDirectory',
packageTreeNode=packageTreeNode,
)
canonical_path = packageTreeNode.getPath(1)
canonical_filename = apply(os.path.join, canonical_path)
output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
self.statusMessage('Directory : "%s"\n to: "%s"' % (
canonical_filename,
output_filename,
))
trace.outof()
return
def writePythonFile(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writePythonFile',
packageTreeNode=packageTreeNode,
)
canonical_path = packageTreeNode.getPath(1)
canonical_filename = apply(os.path.join, canonical_path)
output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
self.statusMessage('Documenting: "%s"\n to: "%s"' % (
canonical_filename,
output_filename,
))
trace.outof()
return
def writePlainTextFile(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writePlainTextFile',
packageTreeNode=packageTreeNode,
)
canonical_path = packageTreeNode.getPath(1)
canonical_filename = apply(os.path.join, canonical_path)
output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
self.statusMessage('Translating: "%s"\n to: "%s"' % (
canonical_filename,
output_filename,
))
trace.outof()
return
def writeCB(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writeCB',
packageTreeNode=packageTreeNode,
)
node_name = packageTreeNode.getName()
extension = os.path.splitext(node_name)[1]
if packageTreeNode.values():
#
# Directory node
#
self.writeDirectory(packageTreeNode)
elif node_name == '__init__.py':
#
# Skip the __init__.py file, since it will
# be handled as part of the package.
#
trace.write('skipping __init__.py')
pass
else:
#
# Anything past here looks like a file.
#
if extension == '.py':
#
# Filename ends in .py, so it is a Python file.
#
self.writePythonFile(packageTreeNode)
elif extension in ('.txt', '.stx'):
#
# Filename ends in .txt or .stx so it is
# a text file.
#
self.writePlainTextFile(packageTreeNode)
else:
#
# Unrecognized file, skipped.
#
node_path = packageTreeNode.getPath()
filename = apply(os.path.join, node_path)
self.statusMessage('Skiping unrecognized file %s' % filename,
2)
trace.outof()
return
--- NEW FILE: test_docset_MultiHTMLFile.py ---
#!/usr/bin/env python
#
# $Id: test_docset_MultiHTMLFile.py,v 1.1 2002/11/18 13:45:58 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 the MultiHTMLFile docset.
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name' : '$RCSfile: test_docset_MultiHTMLFile.py,v $',
'rcs_id' : '$Id: test_docset_MultiHTMLFile.py,v 1.1 2002/11/18 13:45:58 doughellmann Exp $',
'creator' : 'Doug Hellmann <do...@he...>',
'project' : 'HappyDoc',
'created' : 'Sun, 17-Nov-2002 17:31:33 EST',
#
# Current Information
#
'author' : '$Author: doughellmann $',
'version' : '$Revision: 1.1 $',
'date' : '$Date: 2002/11/18 13:45:58 $',
}
try:
__version__ = __rcs_info__['version'].split(' ')[1]
except:
__version__ = '0.0'
#
# Import system modules
#
import os
import unittest
#
# Import Local modules
#
from happydoclib.scanner import Scanner
from docset_MultiHTMLFile import MultiHTMLFileDocSet
#
# Module
#
class MultiHTMLFileDocSetTestCase(unittest.TestCase):
def _test(self, inputDir, outputDir, expected):
scanner = Scanner([inputDir])
trees = scanner.getPackageTrees()
expected_tree = trees[0]
module_two = expected_tree['levelOne']['levelTwo']['two.py']
docset = MultiHTMLFileDocSet(scanner,
'Testing',
outputDir,
)
actual = docset.getOutputFilenameForPackageTreeNode(module_two)
self.failUnlessEqual(actual, expected)
return
def testScanningFromCurrentDirectory(self):
output_directory = '/foo/bar'
expected = os.path.join( output_directory,
'testScanner',
'levelOne',
'levelTwo',
'two.py.html',
)
self._test(inputDir='TestCases/testScanner',
outputDir=output_directory,
expected=expected,
)
return
def testScanningFromRoot(self):
output_directory = '/foo/bar'
expected = os.path.join( output_directory,
'testScanner',
'levelOne',
'levelTwo',
'two.py.html',
)
self._test(inputDir=os.path.join( os.getcwd(),
'TestCases/testScanner'),
outputDir=output_directory,
expected=expected,
)
return
def testScanningRelativePath(self):
output_directory = '/foo/bar'
expected = os.path.join( output_directory,
'testScanner',
'levelOne',
'levelTwo',
'two.py.html',
)
self._test(inputDir='../HappyDoc3/TestCases/testScanner',
outputDir=output_directory,
expected=expected,
)
return
--- NEW FILE: tests.py ---
#!/usr/bin/env python
#
# $Id: tests.py,v 1.1 2002/11/18 13:45:58 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 docsets.
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name' : '$RCSfile: tests.py,v $',
'rcs_id' : '$Id: tests.py,v 1.1 2002/11/18 13:45:58 doughellmann Exp $',
'creator' : 'Doug Hellmann <do...@he...>',
'project' : 'HappyDoc',
'created' : 'Sun, 17-Nov-2002 14:09:33 EST',
#
# Current Information
#
'author' : '$Author: doughellmann $',
'version' : '$Revision: 1.1 $',
'date' : '$Date: 2002/11/18 13:45:58 $',
}
try:
__version__ = __rcs_info__['version'].split(' ')[1]
except:
__version__ = '0.0'
#
# Import system modules
#
#
# Import Local modules
#
#
# Module
#
|
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:43:40
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv7098/happydoclib/docset
Added Files:
base.py
Log Message:
Base classes for docsets.
--- NEW FILE: base.py ---
#!/usr/bin/env python
#
# $Id: base.py,v 1.1 2002/11/18 13:43:37 doughellmann Exp $
#
# Copyright 2002 Doug Hellmann.
#
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that both that copyright notice and this permission
# notice appear in supporting documentation, and that the name of Doug
# Hellmann not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.
#
# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
# NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
"""Base class for documentation sets.
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name' : '$RCSfile: base.py,v $',
'rcs_id' : '$Id: base.py,v 1.1 2002/11/18 13:43:37 doughellmann Exp $',
'creator' : 'Doug Hellmann <do...@he...>',
'project' : 'HappyDoc',
'created' : 'Sun, 17-Nov-2002 13:17:17 EST',
#
# Current Information
#
'author' : '$Author: doughellmann $',
'version' : '$Revision: 1.1 $',
'date' : '$Date: 2002/11/18 13:43:37 $',
}
try:
__version__ = __rcs_info__['version'].split(' ')[1]
except:
__version__ = '0.0'
#
# Import system modules
#
import os
#
# Import Local modules
#
import happydoclib
from happydoclib.trace import trace
#
# Module
#
class DocSet:
"""Basic Documentation Set.
Parameters
includeComments -- Boolean. False means to skip the
comment parsing step in the parser.
Default is True.
includePrivateNames -- Boolean. False means to ignore
names beginning with _. Default
is True.
"""
def __init__(self, scanner,
title,
outputDirectory,
includeComments=1,
includePrivateNames=1,
statusMessageFunc=None,
extraParameters={},
):
"""Basic Documentation Set
Parameters
scanner -- A directory tree scanner.
title -- the title of the documentation set
outputDirectory -- The base directory for writing the
output files.
includeComments -- Boolean. False means to skip the
comment parsing step in the parser.
Default is True.
includePrivateNames -- Boolean. False means to ignore
names beginning with _. Default
is True.
statusMessageFunc -- function which will print a status
message for the user
extraParameters -- Dictionary containing parameters
specified on the command line by
the user.
"""
trace.into('DocSet', '__init__',
scanner=scanner,
title=title,
outputDirectory=outputDirectory,
includeComments=includeComments,
includePrivateNames=includePrivateNames,
## formatter=formatter,
statusMessageFunc=statusMessageFunc,
extraParameters=extraParameters,
)
#
# Store parameters
#
self.scanner = scanner
self.title = title
self.output_directory = outputDirectory
self.include_comments = includeComments
self.include_private_names = includePrivateNames
## self.formatter = formatter
self.status_message_func = statusMessageFunc
self.statusMessage('Initializing documentation set %s' % title)
self.statusMessage('NEED TO HANDLE extraParameters in DocSet')
trace.outof()
return
def statusMessage(self, message='', verboseLevel=1):
"Print a status message for the user."
if self.status_message_func:
self.status_message_func(message, verboseLevel)
return
def writeCB(self, packageTreeNode):
raise NotImplementedError('No writeCB defined for %s' % self.__class__.__name__)
def write(self):
package_trees = self.scanner.getPackageTrees()
for package_tree in package_trees:
package_tree.walk(self.writeCB)
return
class MultiFileDocSet(DocSet):
"""Base class for documentation sets which write to multiple files.
"""
def getOutputFilenameForPackageTreeNode(self, packageTreeNode):
"""Returns a filename where documentation for packageTreeNode should be written.
The filename will be in the output directory, possibly in a
subdirectory based on the path from the input root to the
input file.
For example::
input_directory : /foo/input
containing : /foo/input/bar.py
output_directory : /foo/output
results in : /foo/output/input/bar.py
"""
#
# Get the path to the node from the root of the scanned
# tree.
#
node_path = packageTreeNode.getPath()
#
# Get the input filename, relative to the root of the input.
#
filename = apply(os.path.join, node_path)
#
# Add the output directory to the front of the input
# filename.
#
output_filename = os.path.join(self.output_directory, filename)
#
# Normalize the path, in case it includes /./ and the like.
#
normalized_output_filename = os.path.normpath(output_filename)
return normalized_output_filename
|
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:42:41
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv6438/happydoclib/docset
Added Files:
__init__.py
Log Message:
Plugin loader for docset package.
--- NEW FILE: __init__.py ---
#!/usr/bin/env python
#
# Time-stamp: <01/12/08 08:13:37 dhellmann>
#
# COPYRIGHT
#
# 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.
#
# DISCLAIMER
#
# 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.
#
"""Documentation Sets
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name':'$RCSfile: __init__.py,v $',
'creator':'Doug Hellmann <do...@he...>',
'project':'HappyDoc',
'created':'Sat, 03-Jun-2000 19:06:39 EDT',
#
# Current Information
#
'author':'$Author: doughellmann $',
'version':'$Revision: 1.1 $',
'date':'$Date: 2002/11/18 13:42:38 $',
}
try:
__version__ = __rcs_info__['version'].split(' ')[1]
except:
__version__ = '0.0'
#
# Import system modules
#
import os
import sys
import glob
#
# Import Local modules
#
import happydoclib
#
# Module
#
class DocSetLoader(happydoclib.pluginloader.PluginLoader):
"Load pluggable docset types."
def __init__(self):
happydoclib.pluginloader.PluginLoader.__init__(self, __name__, __path__[0],
'happydoclib')
return
def addEntryPoint(self, infoDict):
"Add the information about a docset to our lookup table."
name = infoDict['name']
factory = infoDict['factory']
self[name] = factory
return
|
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:42:04
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv5888/happydoclib/docset Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset added to the repository |
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:41:16
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv5317/happydoclib
Modified Files:
appclass.py
Log Message:
Eliminating formatter modules, they will be combined with the docset
now.
Moving the writing logic down into the docset base class.
Index: appclass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** appclass.py 17 Nov 2002 16:26:49 -0000 1.5
--- appclass.py 18 Nov 2002 13:41:12 -0000 1.6
***************
*** 107,118 ****
#
- # Define the output formats supported
- #
- ## supported_formats = happydoclib.formatter.FormatterLoader()
-
- #
# Define the documentation set types supported
#
! ## supported_docset_types = happydoclib.docset.DocSetLoader()
##
--- 107,113 ----
#
# Define the documentation set types supported
#
! supported_docset_types = happydoclib.docset.DocSetLoader()
##
***************
*** 124,129 ****
self._app_version = happydoclib.cvsProductVersion()
! ## self.set_docset_type('MultiFile')
! ## self.set_format('HTMLTable')
self._ignore_dir_patterns = []
--- 119,123 ----
self._app_version = happydoclib.cvsProductVersion()
! self.set_docset_type('MultiHTMLFile')
self._ignore_dir_patterns = []
***************
*** 140,154 ****
return
- def set_format(self, format):
- "Set the formatter to be used."
- self.format = format
- try:
- self.formatter_factory = self.supported_formats[format]
- except KeyError:
- raise ValueError('format must be one of %s' \
- % self.supported_formats.keys(),
- format)
- return
-
def set_docset_type(self, docset_type):
"Set the docset to be used."
--- 134,137 ----
***************
*** 177,181 ****
def showVerboseSyntaxHelp(self):
! "Overloaded to show supported docset and format types."
happydoclib.CommandLineApp.CommandLineApp.showVerboseSyntaxHelp(self)
--- 160,164 ----
def showVerboseSyntaxHelp(self):
! "Overloaded to show supported docset types."
happydoclib.CommandLineApp.CommandLineApp.showVerboseSyntaxHelp(self)
***************
*** 183,194 ****
self._showOptionItemsDescription('SYNTAX TYPE', self.docstring_syntaxes.items())
- print
- print 'SUPPORTED FORMATS for -F Option:\n'
- self._showOptionItemsDescription(
- 'FORMATTER TYPE', self.supported_formats.items())
-
print 'SUPPORTED DOCSET TYPES for -T Option:'
print
! print ' %s' % happydoclib.happydocset.DocSet.__doc__
print
self._showOptionItemsDescription(
--- 166,172 ----
self._showOptionItemsDescription('SYNTAX TYPE', self.docstring_syntaxes.items())
print 'SUPPORTED DOCSET TYPES for -T Option:'
print
! print ' %s' % happydoclib.docset.base.DocSet.__doc__
print
self._showOptionItemsDescription(
***************
*** 239,249 ****
return
- def optionHandler_F(self, format):
- """Specify the output format.
-
- Defaults to 'HTMLTable'."""
- self.set_format(format)
- return
-
def optionHandler_i(self, ignoreDirectory):
"""Specify a directory basename to be ignored.
--- 217,220 ----
***************
*** 363,371 ****
self.statusMessage('Importing preformatted file: %s' % filename)
! f = open(filename, 'rt')
! body = f.read()
! f.close()
! packageTreeNode.preformatted_text = body
trace.outof()
--- 334,342 ----
self.statusMessage('Importing preformatted file: %s' % filename)
! #f = open(filename, 'rt')
! #body = f.read()
! #f.close()
! #packageTreeNode.preformatted_text = body
trace.outof()
***************
*** 419,476 ****
return
- def writeOutputsCB(self, packageTreeNode):
- trace.into('HappyDoc', 'writeOutputsCB',
- packageTreeNode=packageTreeNode,
- )
- node_name = packageTreeNode.getName()
- node_path = packageTreeNode.getPath()
- canonical_path = packageTreeNode.getPath(1)
- filename = apply(os.path.join, node_path)
- canonical_filename = apply(os.path.join, canonical_path)
-
- extension = os.path.splitext(node_name)[1]
-
- if extension == '.py':
- #
- # Filename ends in .py, so it is a Python file.
- #
- self.statusMessage('Documenting: "%s"\n to: "%s"' % (
- canonical_filename,
- 'unknown',
- ))
-
- elif extension in ('.txt', '.stx'):
- #
- # Filename ends in .txt or .stx so it is
- # a text file.
- #
- self.statusMessage('Translating: "%s"\n to: "%s"' % (
- canonical_filename,
- 'unknown',
- ))
-
- elif packageTreeNode.values():
- #
- # Directory node.
- #
- pass
-
- elif not packageTreeNode.values():
- #
- # Leaf node we are skipping.
- #
- pass
-
- trace.outof()
- return
-
- def writeOutputs(self, scanner):
- package_trees = scanner.getPackageTrees()
-
- for package_tree in package_trees:
- package_tree.walk(self.writeOutputsCB)
-
- return
-
def getParameterGroupsFromArguments(self, args):
#
--- 390,393 ----
***************
*** 500,513 ****
self.statusMessage('DEBUG: \t%s:%s' % (p,v), 4)
! #
! # Find Formatter parameters
! #
! self.statusMessage('Looking for formatter parameters', 2)
! args, formatter_params = happydoclib.optiontools.getParameters('formatter', args)
! self.statusMessage('DEBUG: Formatter parameters:', 4)
! for p, v in formatter_params.items():
! self.statusMessage('DEBUG: \t%s:%s' % (p,v), 4)
!
! return (args, parser_params, docset_params, formatter_params)
def main(self, *args):
--- 417,421 ----
self.statusMessage('DEBUG: \t%s:%s' % (p,v), 4)
! return (args, parser_params, docset_params)
def main(self, *args):
***************
*** 517,521 ****
parsed_args = self.getParameterGroupsFromArguments(args)
! (args, parser_params, docset_params, formatter_params) = parsed_args
self.parser_params = parser_params
--- 425,429 ----
parsed_args = self.getParameterGroupsFromArguments(args)
! (args, parser_params, docset_params) = parsed_args
self.parser_params = parser_params
***************
*** 552,559 ****
#
# Generate some output
#
! self.writeOutputs(scanner)
!
return
--- 460,480 ----
#
+ # Create the docset
+ #
+ docset = self.docset_factory(
+ scanner=scanner,
+ title='Title',
+ outputDirectory=self.output_directory,
+ includeComments=self.include_comments,
+ includePrivateNames=self.include_private_names,
+ statusMessageFunc=self.statusMessage,
+ extraParameters=docset_params,
+ )
+
+ #
# Generate some output
#
! docset.write()
!
return
|
|
From: Doug H. <dou...@pr...> - 2002-11-18 13:39:29
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv3965/happydoclib Modified Files: __init__.py Log Message: Eliminating formatter modules, they will be combined with the docset now. Also eliminating some module imports that are rarely used. Index: __init__.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 17 Nov 2002 14:58:37 -0000 1.2 --- __init__.py 18 Nov 2002 13:39:25 -0000 1.3 *************** *** 66,75 **** import happydoclib.CommandLineApp from happydoclib.cvsversion import cvsProductVersion - #import happydoclib.happydom - #import happydoclib.path import happydoclib.optiontools import happydoclib.parseinfo import happydoclib.pluginloader - #import happydoclib.prettyast import happydoclib.trace --- 66,72 ---- *************** *** 77,88 **** # Import Plugins # ! #import happydoclib.happydocset ! #import happydoclib.docset import happydoclib.happydocstring import happydoclib.docstring - - #import happydoclib.happyformatter - #import happydoclib.formatter --- 74,81 ---- # Import Plugins # ! import happydoclib.docset import happydoclib.happydocstring import happydoclib.docstring |
|
From: Doug H. <dou...@us...> - 2002-11-17 16:41:01
|
Update of /cvsroot/happydoc/HappyDoc3
In directory usw-pr-cvs1:/tmp/cvs-serv21085
Added Files:
.proctor
Log Message:
Proctor control file.
--- NEW FILE: .proctor ---
#
# Local variables:
# mode: python
# end:
#
# $Id: .proctor,v 1.1 2002/11/17 16:40:57 doughellmann Exp $
#
"""Proctor instruction file.
"""
ignore = [
'TestCases',
'tmp',
]
|
|
From: Doug H. <dou...@us...> - 2002-11-17 16:26:52
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory usw-pr-cvs1:/tmp/cvs-serv1656/happydoclib
Modified Files:
appclass.py
Log Message:
Use the attribute 'module_info' instead of docs for managing the stuff
that comes back from parseinfo.
Index: appclass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** appclass.py 17 Nov 2002 16:21:31 -0000 1.4
--- appclass.py 17 Nov 2002 16:26:49 -0000 1.5
***************
*** 331,336 ****
#
package_parent = packageTreeNode.getParent()
! if package_parent and hasattr(package_parent, 'docs'):
! docs_parent = package_parent.docs
else:
docs_parent = None
--- 331,336 ----
#
package_parent = packageTreeNode.getParent()
! if package_parent and hasattr(package_parent, 'module_info'):
! docs_parent = package_parent.module_info
else:
docs_parent = None
***************
*** 345,349 ****
)
! packageTreeNode.docs = docs
trace.outof()
--- 345,349 ----
)
! packageTreeNode.module_info = docs
trace.outof()
|
|
From: Doug H. <dou...@us...> - 2002-11-17 16:21:33
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory usw-pr-cvs1:/tmp/cvs-serv27019/happydoclib
Modified Files:
appclass.py
Log Message:
Different parsing routines based on the file extension.
Simple, simulated, output writer that really just prints filenames.
Index: appclass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** appclass.py 17 Nov 2002 15:15:26 -0000 1.3
--- appclass.py 17 Nov 2002 16:21:31 -0000 1.4
***************
*** 67,70 ****
--- 67,71 ----
import happydoclib
from happydoclib.scanner import Scanner
+ from happydoclib.trace import trace
#
***************
*** 129,133 ****
self.addIgnoreDirectoryPattern('(CVS|dist|build|docs?|.*pyc|.*~)')
- ## self.parser_function = happydoclib.parseinfo.getDocs
return
--- 130,133 ----
***************
*** 313,379 ****
return scanner
! def parseInputs(self, scanner):
! package_trees = scanner.getPackageTrees()
!
! for package_tree in package_trees:
! pass
!
! return
!
! def main(self, *args):
! self.statusMessage('%s version %s' % (self._app_name,
! self._app_version))
#
! # 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 the scanner, and get the package trees.
#
! scanner = self.scanForInput(input_modules)
! self.showPackageTree(scanner)
return
! def showPackageTree(self, scanner):
package_trees = scanner.getPackageTrees()
for package_tree in package_trees:
! package_tree.walk(self.showPackageTreeCB)
! return
- def showPackageTreeCB(self, packageTreeNode):
- path = packageTreeNode.getPath()
- indent = ' ' * len(path)
- self.statusMessage('%s%s' % (indent, packageTreeNode.getName()))
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)
#
# Set default parser params
--- 313,477 ----
return scanner
! def parsePythonInput(self, packageTreeNode):
! trace.into('HappyDoc', 'parsePythonInput',
! packageTreeNode=packageTreeNode,
! )
! #
! # Derive the filename for this module.
! #
! node_path = packageTreeNode.getPath(1)
! filename = apply(os.path.join, node_path)
! trace.writeVar(filename=filename)
! self.statusMessage('Parsing: %s' % filename)
#
! # Figure out if there is a parent node for the
! # documentation suite.
#
! package_parent = packageTreeNode.getParent()
! if package_parent and hasattr(package_parent, 'docs'):
! docs_parent = package_parent.docs
else:
! docs_parent = None
+ trace.writeVar(docs_parent=docs_parent)
+
+ docs = happydoclib.parseinfo.getDocs(
+ parent=docs_parent,
+ fileName=filename,
+ includeComments=self.include_comments,
+ defaultConfigValues=self.parser_params,
+ )
+
+ packageTreeNode.docs = docs
+
+ trace.outof()
+ return
+
+ def parsePlainTextInput(self, packageTreeNode):
+ trace.into('HappyDoc', 'parsePlainTextInput',
+ packageTreeNode=packageTreeNode,
+ )
#
! # Derive the filename for this module.
#
! node_path = packageTreeNode.getPath(1)
! filename = apply(os.path.join, node_path)
! trace.writeVar(filename=filename)
+ self.statusMessage('Importing preformatted file: %s' % filename)
+
+ f = open(filename, 'rt')
+ body = f.read()
+ f.close()
+
+ packageTreeNode.preformatted_text = body
+
+ trace.outof()
return
! def parseInputCB(self, packageTreeNode):
! trace.into('HappyDoc', 'parseInputCB',
! packageTreeNode=packageTreeNode,
! )
!
! node_name = packageTreeNode.getName()
!
! extension = os.path.splitext(node_name)[1]
!
! if extension == '.py':
! #
! # Filename ends in .py, so it is a Python file.
! #
! self.parsePythonInput(packageTreeNode)
!
! elif extension in ('.txt', '.stx'):
! #
! # Filename ends in .txt or .stx so it is
! # a text file.
! #
! self.parsePlainTextInput(packageTreeNode)
!
! elif packageTreeNode.values():
! #
! # Directory node.
! #
! pass
!
! elif not packageTreeNode.values():
! #
! # Leaf node we are skipping.
! #
! node_path = packageTreeNode.getPath()
! filename = apply(os.path.join, node_path)
! self.statusMessage('Skipping: %s' % filename)
!
! trace.outof()
! return
!
! def parseInputs(self, scanner):
package_trees = scanner.getPackageTrees()
for package_tree in package_trees:
! package_tree.walk(self.parseInputCB)
return
!
! def writeOutputsCB(self, packageTreeNode):
! trace.into('HappyDoc', 'writeOutputsCB',
! packageTreeNode=packageTreeNode,
! )
! node_name = packageTreeNode.getName()
! node_path = packageTreeNode.getPath()
! canonical_path = packageTreeNode.getPath(1)
! filename = apply(os.path.join, node_path)
! canonical_filename = apply(os.path.join, canonical_path)
!
! extension = os.path.splitext(node_name)[1]
! if extension == '.py':
! #
! # Filename ends in .py, so it is a Python file.
! #
! self.statusMessage('Documenting: "%s"\n to: "%s"' % (
! canonical_filename,
! 'unknown',
! ))
!
! elif extension in ('.txt', '.stx'):
! #
! # Filename ends in .txt or .stx so it is
! # a text file.
! #
! self.statusMessage('Translating: "%s"\n to: "%s"' % (
! canonical_filename,
! 'unknown',
! ))
!
! elif packageTreeNode.values():
! #
! # Directory node.
! #
! pass
!
! elif not packageTreeNode.values():
! #
! # Leaf node we are skipping.
! #
! pass
! trace.outof()
! return
+ def writeOutputs(self, scanner):
+ package_trees = scanner.getPackageTrees()
+
+ for package_tree in package_trees:
+ package_tree.walk(self.writeOutputsCB)
+
+ return
+
+ def getParameterGroupsFromArguments(self, args):
#
# Set default parser params
***************
*** 410,413 ****
--- 508,575 ----
for p, v in formatter_params.items():
self.statusMessage('DEBUG: \t%s:%s' % (p,v), 4)
+
+ return (args, parser_params, docset_params, formatter_params)
+
+ def main(self, *args):
+
+ self.statusMessage('%s version %s' % (self._app_name,
+ self._app_version))
+
+ parsed_args = self.getParameterGroupsFromArguments(args)
+ (args, parser_params, docset_params, formatter_params) = parsed_args
+
+ self.parser_params = parser_params
+
+ #
+ # 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:
+ normcase = os.path.normcase(input_module_name)
+ if not normcase:
+ continue
+ while normcase[-1] == os.sep:
+ normcase = normcase[:-1]
+ input_modules.append(normcase)
+
+
+ #
+ # Create the scanner, and get the package trees.
+ #
+ scanner = self.scanForInput(input_modules)
+
+ #
+ # Parse the input files
+ #
+ self.parseInputs(scanner)
+
+ #
+ # Generate some output
+ #
+ self.writeOutputs(scanner)
+
+ 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)
#
|
|
From: Doug H. <dou...@us...> - 2002-11-17 16:20:44
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo
In directory usw-pr-cvs1:/tmp/cvs-serv25928/happydoclib/parseinfo
Modified Files:
moduleinfo.py
Log Message:
Do not include the tree in each module info trace statement.
Index: moduleinfo.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/moduleinfo.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** moduleinfo.py 17 Nov 2002 15:05:43 -0000 1.1
--- moduleinfo.py 17 Nov 2002 16:20:41 -0000 1.2
***************
*** 106,110 ****
happydoclib.TRACE.into('ModuleInfo', '__init__',
parent=parent,
! tree=tree,
name=name,
fileName=fileName,
--- 106,110 ----
happydoclib.TRACE.into('ModuleInfo', '__init__',
parent=parent,
! #tree=tree,
name=name,
fileName=fileName,
|