Table of Contents

Class: FunctionInfo HappyDoc-r0_7_1/parseinfo.py

Gather information about a function or method definition.

Base Classes   
SuiteInfoBase
SuiteFuncInfo
Methods   
__init__
_constructParameterInfo
_extractFunctionParameters
_extractThrownExceptions
_reconstructValueFromAtom
getExceptionInfo
getExceptionNames
getParameterInfo
getParameterNames
  __init__ 
__init__ (
        self,
        parent=None,
        tree=None,
        commentInfo={},
        )

Initialize the info extractor.

Parameters:

parent

parent object for this object (e.g. Module or Function)

tree

parse tree from which to extract information

commentInfo

comments extracted from the source file holding this module

  _constructParameterInfo 
_constructParameterInfo ( self,  parameterData )

Construct storable parameter data from a parameter list.

Given the sequence of tuples extracted as a parameter list, store the names (in order) in self._parameter_names and the information about the parameter in self._parameter_info where the keys are the parameter name and the info is a tuple containing:

(default_specified, default_value, default_value_type)

Where:

default_specified

boolean indicating whether a default value was specified

default_value

the default value given, if any

default_value_type

the type of the default value (token.STRING, token.NAME, None). A type of None means unknown.

  _extractFunctionParameters 
_extractFunctionParameters ( self,  tree )

Extract information about a function's parameters.

print print self._name pprint.pprint(parameters) No parameters: def func()

Move down the parse tree and process the argument list

pprint.pprint(parameters)

Exceptions   
'Unrecognized parse result %s in %s'
ValueError( 'Unrecognized parameter value type.', parameter )

  _extractThrownExceptions 
_extractThrownExceptions ( self,  tree )

Return a dictionary of exception->exception_type values.

print 'found raise: ', parseTreeToString(tree) print parsing...

  _reconstructValueFromAtom 
_reconstructValueFromAtom (
        self,
        atom,
        trailer=[],
        )

Convert an atom portion of a parse tree into the value.

If the atom represents a string, number or name

  getExceptionInfo 
getExceptionInfo ( self,  exceptionName )

Returns a type value for an exception.

The return value will be one of (token.NAME, token.STRING) indicating whether the exception was thrown as a string or a named object.

  getExceptionNames 
getExceptionNames ( self )

Return a list of the names of any exceptions raised by the function.

  getParameterInfo 
getParameterInfo ( self,  paramName )

Returns the info record for a parameter.

The returned tuple consists of:

(default_specified, default_value, default_value_type)

Where:

default_specified

boolean indicating whether a default value was specified

default_value

the default value given, if any

default_value_type

the type of the default value (token.STRING, token.NAME, None). A type of None means unknown.

  getParameterNames 
getParameterNames ( self )

Returns a list of the names of all parameters to the function, in order.


Table of Contents

This document was automatically generated on Sat Sep 9 20:27:32 2000 by HappyDoc version r0_7_1