SPRAAK
Data Structures | Functions
spr_pydoc_filter Namespace Reference

Data Structures

class  ClassInfo
 Represents a parsed class. More...
 
class  FunctionInfo
 Represents a parsed function. More...
 
class  ModuleInfo
 Represents a parsed python file. More...
 
class  ParamInfo
 Represents a function parameter. More...
 

Functions

def match_tree (pat, tree)
 Utility function to find specific sub-trees of the parse tree. More...
 
def search_tree (symb, tree)
 Utility function to find all subtrees starting with a specific node name. More...
 
def conv (ast)
 Utility function that converts token and symbol id numbers to readable strings. More...
 
def pprint_ast (ast)
 Utility function to dump a parse tree to stdout. More...
 
def split_comment (comment)
 Looks for an optional spr_* tag at the start of a comment. More...
 
def is_empty_line (line)
 
def ws_len (ws)
 
def parse_endlist_line (line)
 
def parse_itemlist_line (line)
 
def convert_comment_lists (comment)
 
def tag_from_name (name)
 Matches access level tags to functions based on naming convention. More...
 
def ast_to_tok (ast, tok=None)
 Walks a parse tree and returns a list of all encountered token nodes. More...
 
def convert (fname, stdout=None, tag_mask=None)
 Convert python source code. More...
 
def main ()
 Main function. More...
 

Function Documentation

§ match_tree()

def spr_pydoc_filter.match_tree (   pat,
  tree 
)

Utility function to find specific sub-trees of the parse tree.

Parameters
patList of symbol and token ids that should be matched.
treeThe parse tree to search in.

§ search_tree()

def spr_pydoc_filter.search_tree (   symb,
  tree 
)

Utility function to find all subtrees starting with a specific node name.

Parameters
symbSymbol or token id to search for.
treeThe parse tree to search in.

§ conv()

def spr_pydoc_filter.conv (   ast)

Utility function that converts token and symbol id numbers to readable strings.

Used mainly for debuging.

Returns
A parse tree with strings.
Parameters
astThe parse tree with ids.

§ pprint_ast()

def spr_pydoc_filter.pprint_ast (   ast)

Utility function to dump a parse tree to stdout.

Parameters
astThe parse tree to be dumped.

§ split_comment()

def spr_pydoc_filter.split_comment (   comment)

Looks for an optional spr_* tag at the start of a comment.

Returns
A tuple with the tag (or None) and the comment without the tag.
Parameters
commentThe comment that needs splitting.

§ is_empty_line()

def spr_pydoc_filter.is_empty_line (   line)

§ ws_len()

def spr_pydoc_filter.ws_len (   ws)

§ parse_endlist_line()

def spr_pydoc_filter.parse_endlist_line (   line)

§ parse_itemlist_line()

def spr_pydoc_filter.parse_itemlist_line (   line)

§ convert_comment_lists()

def spr_pydoc_filter.convert_comment_lists (   comment)

§ tag_from_name()

def spr_pydoc_filter.tag_from_name (   name)

Matches access level tags to functions based on naming convention.

  • Names starting with a single underscore are tagged private. (Unless they start and end with a double underscore)
  • All other names are tagged as public.
Returns
The access level for the given function or method.
Parameters
nameA name of a function or method.

§ ast_to_tok()

def spr_pydoc_filter.ast_to_tok (   ast,
  tok = None 
)

Walks a parse tree and returns a list of all encountered token nodes.

Returns
A list of token nodes.
Parameters
astA parse tree.
tokAn optional list in which the token nodes will be collected.

§ convert()

def spr_pydoc_filter.convert (   fname,
  stdout = None,
  tag_mask = None 
)

Convert python source code.

Convert python source code to a format supported by doxygen.

Parameters
fnameThe file name holding the source code.
stdoutThe file object to which the converted code should be written. Defaults to stdout.
tag_maskA list of access level tags used to filter what should be documented. Defaults to all.

§ main()

def spr_pydoc_filter.main ( )

Main function.

Expects one command-line argument, the input python file.