Home | Trees | Indices | Help |
|
---|
|
Extract API documentation about python objects by parsing their source code.
The function parse_docs(), which provides the main interface of this module, reads and parses the Python source code for a module, and uses it to create an APIDoc object containing the API documentation for the variables and values defined in that modules.
Currently, parse_docs()
extracts documentation from the
following source code constructions:
'='
s
parse_docs()
does not yet support the following source
code constructions:
By default, parse_docs()
will expore the contents of
top-level try
and if
blocks. If desired,
parse_docs()
can also be configured to explore the contents
of while
and for
blocks. (See the configuration
constants, below.)
To Do:
Make it possible to extend the functionality of
parse_docs()
, by replacing process_line with a dispatch
table that can be customized (similarly to
docintrospector.register_introspector()
).
|
|||
ParseError An exception that is used to signify that docparser
encountered syntactically invalid Python code while processing a
Python source file.
|
|
|||
Module parser | |||
---|---|---|---|
ValueDoc |
|
||
|
|||
|
|||
|
|||
Module Lookup | |||
|
|||
|
|||
|
|||
|
|||
File tokenization loop | |||
|
|||
|
|||
|
|||
Shallow parser | |||
|
|||
Line processing | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Parsing | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Variable Manipulation | |||
|
|||
|
|||
Name Lookup | |||
VariableDoc or None
|
|
||
|
|||
|
|||
Docstring Comments | |||
|
|||
Tree tokens | |||
|
|||
|
|||
|
|||
|
|||
Helper Functions | |||
|
|||
|
|||
|
|
|||
dict
|
_moduledoc_cache =
A cache of ModuleDoc s that we've already created.
|
||
Configuration Constants: Control Flow | |||
---|---|---|---|
PARSE_TRY_BLOCKS = True Should the contents of try blocks be examined?
|
|||
PARSE_EXCEPT_BLOCKS = True Should the contents of except blocks be examined?
|
|||
PARSE_FINALLY_BLOCKS = True Should the contents of finally blocks be examined?
|
|||
PARSE_IF_BLOCKS = True Should the contents of if blocks be examined?
|
|||
PARSE_ELSE_BLOCKS = True Should the contents of else and elif blocks
be examined?
|
|||
PARSE_WHILE_BLOCKS = False Should the contents of while blocks be examined?
|
|||
PARSE_FOR_BLOCKS = False Should the contents of for blocks be examined?
|
|||
Configuration Constants: Imports | |||
IMPORT_HANDLING =
What should docparser do when it encounters an import
statement?
|
|||
IMPORT_STAR_HANDLING =
When docparser encounters a 'from m import *' statement, and is unable to parse
m (either because IMPORT_HANDLING='link' , or because
parsing failed), how should it determine the list of identifiers
expored by m ?
|
|||
DEFAULT_DECORATOR_BEHAVIOR =
When DocParse encounters an unknown decorator, what
should it do to the documentation of the decorated function?
|
|||
PUBLIC_DECORATOR_APPENDS_TO_ALL = True If true, then the @public decorator will append the function's name to the module's __all__ variable. |
|||
BASE_HANDLING =
What should docparser do when it encounters a base class
that was imported from another module?
|
|||
Configuration Constants: Comment docstrings | |||
COMMENT_DOCSTRING_MARKER =
The prefix used to mark comments that contain attribute docstrings for variables. |
|||
Configuration Constants: Grouping | |||
START_GROUP_MARKER =
The prefix used to mark a comment that starts a group. |
|||
END_GROUP_MARKER =
The prefix used to mark a comment that ends a group. |
|||
Line processing | |||
CONTROL_FLOW_KEYWORDS =
A list of the control flow keywords. |
|
Generate the API documentation for a specified object by parsing
Python source files, and return it as a ValueDoc. The
object to generate documentation for may be specified using the
|
Return the API documentaiton for the object whose name is
|
Return true if |
Read the given |
Given a flat list of tokens, return a nested tree structure (called a token tree), whose leaves are identical to the original list, but whose structure reflects the structure implied by the grouping tokens (i.e., parenthases, braces, and brackets). If the parenthases, braces, and brackets do not match, or are not balanced, then raise a ParseError. Assign some structure to a sequence of structure (group parens). |
|
Handle a statement of the form: >>> from <src> import * If IMPORT_HANDLING is Otherwise, try to determine the names of the variables exported by
|
Handle a statement of the form: >>> import <name> If IMPORT_HANDLING is Otherwise, add a variable for the imported variable. (More than one
variable may be created for cases like |
Handle a statement of the form: >>> import src as name If IMPORT_HANDLING is Otherwise, create a variables with its |
The line handler for single-line blocks, such as: >>> def f(x): return x*2 This handler calls process_line twice: once for the tokens up to and including the colon, and once for the remaining tokens. The comment docstring is applied to the first line only.
|
The line handler for semicolon-separated statements, such as: >>> x=1; y=2; z=3
This handler calls process_line once for each statement. The comment docstring is not passed on to any of the sub-statements.
|
The line handler for delete statements, such as: >>> del x, y.z This handler calls del_variable for each dotted variable in the variable
list. The variable list may be nested. Complex expressions in the
variable list (such as
|
The line handler for bare string literals. If
|
The line handler for function declaration lines, such as: >>> def f(a, b=22, (c,d)): This handler creates and initializes a new |
The line handler for class declaration lines, such as: >>> class Foo(Bar, Baz): This handler creates and initializes a new |
The line handler for __all__.append() lines; either of: >>> __all__.append('name') >>> __all__ += ['name'] This handler looks up the value of the variable |
Check if a line is an __all__.append line() See Also: process_append_to_all |
If the given token tree element is a name token, then return that name as a string. Otherwise, raise ParseError.
|
Bug: does not handle 'x.(y).z' |
If the given tree token element contains a valid function definition argument (i.e., an identifier token or nested list of identifiers), then return a corresponding string identifier or nested list of string identifiers. Otherwise, raise a ParseError. |
If the given tree token element contains a valid base list (that contains only dotted names), then return a corresponding list of DottedNames. Otherwise, raise a ParseError. Bug: Does not handle either of: - class A( (base.in.parens) ): pass - class B( (lambda:calculated.base)() ): pass |
If the given list of tree token elements contains a comma-separated list of dotted names, then return a corresponding list of DottedName objects. Otherwise, raise ParseError. |
Add var_doc to namespace. If namespace already contains a variable
with the same name, then discard the old variable. If
|
See Also: PEP 263 |
|
|
_moduledoc_cacheA cache of
|
IMPORT_HANDLINGWhat should
|
IMPORT_STAR_HANDLINGWhen
|
DEFAULT_DECORATOR_BEHAVIORWhen
|
BASE_HANDLINGWhat should
|
START_GROUP_MARKERThe prefix used to mark a comment that starts a group. This marker should be followed (on the same line) by the name of the group. Following a start-group comment, all variables defined at the same indentation level will be assigned to this group name, until the parser reaches the end of the file, a matching end-group comment, or another start-group comment at the same indentation level.
|
END_GROUP_MARKERThe prefix used to mark a comment that ends a group. See START_GROUP_MARKER.
|
CONTROL_FLOW_KEYWORDSA list of the control flow keywords. If a line begins with one of
these keywords, then it should be handled by
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jun 13 23:49:54 2008 | http://epydoc.sourceforge.net |