typedargs.doc_parser module¶
Experimental module for better google docstring parsing.
Summary¶
Classes:
BlankLine |
|
ContinuationLine |
|
Line |
|
ListItem |
|
ParsedDocstring |
A parser for google docstrings. |
SectionHeader |
Functions:
parse_param |
Parse a single typed parameter statement. |
parse_return |
Parse a single return statement declaration. |
Reference¶
-
class
typedargs.doc_parser.
ContinuationLine
(contents)¶ Bases:
tuple
-
contents
¶ Alias for field number 0
-
-
class
typedargs.doc_parser.
ListItem
(marker, contents)¶ Bases:
tuple
-
contents
¶ Alias for field number 1
-
marker
¶ Alias for field number 0
-
-
class
typedargs.doc_parser.
ParsedDocstring
(doc)[source]¶ Bases:
object
A parser for google docstrings.
The parser will collect all of the sections and parse them into paragraphs that are separated by blank lines or indented sections depending on what kind of section it is.
-
MAIN_SECTION
= 0¶
-
ARGS_SECTION
= 1¶
-
RETURN_SECTION
= 2¶
-
short_desc
¶ One line description of this parsed docstring.
Returns: str
-
wrap_and_format
(width=None, include_params=False, include_return=False, excluded_params=None)[source]¶ Wrap, format and print this docstring for a specific width.
Parameters: - width (int) – The number of characters per line. If set to None this will be inferred from the terminal width and default to 80 if not passed or if passed as None and the terminal width cannot be determined.
- include_return (bool) – Include the return information section in the output.
- include_params (bool) – Include a parameter information section in the output.
- excluded_params (list) – An optional list of parameter names to exclude. Options for excluding things are, for example, ‘self’ or ‘cls’.
-
-
typedargs.doc_parser.
parse_param
(param, include_desc=False, validate_type=True)[source]¶ Parse a single typed parameter statement.
-
typedargs.doc_parser.
parse_return
(return_line, include_desc=False, validate_type=True)[source]¶ Parse a single return statement declaration.
The valid types of return declaration are a Returns: section heading followed a line that looks like: type [format-as formatter]: description
OR
type [show-as (context | string | formatter)]: description sentence