Package peppy :: Package pype :: Module exparse
[frames] | no frames]

Module exparse

Simple code to extract class & function docstrings from a module.

This code is used as an example in the library reference manual in the section on using the parser module. Refer to the manual for a thorough discussion of the operation of this code.

The code has been extended by Stephen Davies for the Synopsis project. It now also recognises parameter names and values, and baseclasses. Names are now returned in order also.

July 25, 2006 Adapted from Synopsis package, assumed GPL-compatible or at least PSF licensed, given the content of the Synopsis README.quick.

Classes
  SuiteInfoBase
  FunctionInfo
  ClassInfo
  ModuleInfo
Functions
 
format(tree, depth=-1)
Format the given tree up to the given depth.
 
stringify(tree)
Convert the given tree to a string
 
get_docs(source)
 
parse(content)
 
match(pattern, data, vars=None)
Match `data' to `pattern', with variable extraction.
 
dmatch(pattern, data, vars=None)
Debugging match
Variables
  line_end = ((4, ''), (5, ''), (6, ''))
  COMPOUND_STMT_PATTERN = (266, (291, ['compound']))
  DOCSTRING_STMT_PATTERN = (266, (267, (268, (269, (326, (303, (...
  TEST_NAME_PATTERN = (303, (305, (306, (307, (309, (310, (311, ...
  IMPORT_STMT_PATTERN = (266, (267, (268, ['import_spec']), (4, ...
Function Details

format(tree, depth=-1)

 

Format the given tree up to the given depth. Numbers are replaced with their symbol or token names.

match(pattern, data, vars=None)

 
Match `data' to `pattern', with variable extraction.

pattern
    Pattern to match against, possibly containing variables.

data
    Data to be checked and against which variables are extracted.

vars
    Dictionary of variables which have already been found.  If not
    provided, an empty dictionary is created.

The `pattern' value may contain variables of the form ['varname'] which
are allowed to match anything.  The value that is matched is returned as
part of a dictionary which maps 'varname' to the matched value.  'varname'
is not required to be a string object, but using strings makes patterns
and the code which uses them more readable.

This function returns two values: a boolean indicating whether a match
was found and a dictionary mapping variable names to their associated
values.


Variables Details

DOCSTRING_STMT_PATTERN

Value:
(266,
 (267,
  (268,
   (269,
    (326,
     (303,
      (305,
       (306, (307, (309, (310, (311, (312, (313, (314, (315, (316, (31\
...

TEST_NAME_PATTERN

Value:
(303,
 (305,
  (306,
   (307, (309, (310, (311, (312, (313, (314, (315, ['power']))))))))))\
)

IMPORT_STMT_PATTERN

Value:
(266, (267, (268, ['import_spec']), (4, '')))