/ HappyDoc3-r3_1 / happydoclib / parseinfo
Extract information from a Python code parse tree.
This module is based on the Demos/parser/example.py module
distributed with the Python source distribution.
File-specific Parser Configuration Values
Parameters to the HappyDoc Parser can also be embedded within the
first comment block of the module. The parameter values
recognized and their meanings are listed below.
To provide file-specific parser configuration settings, any Python
code can be embedded in the comments of the file. For example:
#!/usr/bin/env python
#
# HappyDoc:# These variables should be discovered.
# HappyDoc:TestInt=1
# HappyDoc:TestString="String"
# HappyDoc:TestStringModule=string.strip(' this has spaces in front and back ')
# HappyDoc:url=urlencode({'a':'A', 'b':'B'})
# HappyDoc:docStringFormat='StructuredText'
All lines beginning with the pattern "'# HappyDoc:'" will be
concatenated (separated by newlines) and execed . The local
namespace resulting from the execution of the code will be
examined for variables of interest to the parser. The incoming
global namespace for the configuration code will have a few
pre-populated names for convenience.
Pre-defined Globals
Name
|
Description
|
string
|
The string module.
|
urlquote
|
Same as urllib.quote function.
|
urlencode
|
Same as urllib.urlencode function.
|
Recognized Parser Configuration Variables
Parameter
|
Description
|
docStringFormat
|
The name of the format for the __doc__
strings in the module. This value is used
to determine the docstring converter which
will know how to translate the docstrings in
the module.
|
Functions
|
|
|
getDocsFromCache
|
getDocsFromCache ( parent, fileName )
|
|
setOption
|
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.
|
|
getDocsFromFile
|
getDocsFromFile ( parent, fileName )
Retrieve information from the parse tree of a source file.
Parameters
- fileName
- Name of the file to read Python source code from.
|
|
getDocs
|
getDocs ( parent, fileName )
|
|
getOption
|
getOption ( name )
Get options which control the parser behavior.
Options
- name
- The name of the option whose value should be retrieved.
|
|
|