enum_tools.documentation
Core Functionality
Decorators to add docstrings to enum members from comments.
Classes:
|
An enum where docstrings are automatically added to members from comments starting with |
Functions:
|
Document all members of an enum by parsing a docstring from the Python source.. |
|
Document a member of an enum by adding a comment to the end of the line that starts with |
-
enum
DocumentedEnum
(value)[source] Bases:
enum.Enum
An enum where docstrings are automatically added to members from comments starting with
doc:
.Note
This class does not (yet) support the other docstring formats
@document_enum
does.
-
@
document_enum
(an_enum)[source] Document all members of an enum by parsing a docstring from the Python source..
The docstring can be added in several ways:
If more than one docstring format is found for an enum member a
MultipleDocstringsWarning
is emitted.- Parameters
- Returns
The same object passed as
an_enum
. This allows this function to be used as a decorator.- Return type
Changed in version 0.8.0: Added support for other docstring formats and multiline docstrings.
Utilities
Exceptions:
|
Warning emitted when multiple docstrings are found for a single Enum member. |
Functions:
|
Determine the base level of indentation (i.e. |
|
Returns the line without indentation, and the amount of indentation. |
|
Returns a list ot tokens generated from the given Python code. |
|
Parse the tokens representing a line of code to identify Enum members and |
-
get_base_indent
(base_indent, all_tokens, indent)[source] Determine the base level of indentation (i.e. one level of indentation in from the
c
ofclass
).
-
get_dedented_line
(line)[source] Returns the line without indentation, and the amount of indentation.
Warnings
-
exception
MultipleDocstringsWarning
(member, docstrings=())[source] Bases:
UserWarning
Warning emitted when multiple docstrings are found for a single Enum member.
New in version 0.8.0.
- Parameters