g_docformatter.parse¶
Module to parse out docstrings from a Python file.
- g_docformatter.parse.get_docstrings(file_handle: TextIOBase) tuple[list[tuple[int, TokenInfo]], list[TokenInfo]]¶
Get all docstrings from a Python file.
- Parameters:
file_handle – The file handle of the Python file.
- Returns:
A list of docstrings and token_index tuple and a list of tokens from the file.
- class g_docformatter.parse.DocstringToken(type: str, text: str, start: int, line: int)¶
Bases:
NamedTupleA
typing.NamedTuplerepresenting a token in a docstring.- type: str¶
The type of the token.
- text: str¶
The text of the token.
- start: int¶
The starting index of the token in the docstring.
- line: int¶
The line of the token in the docstring.
- g_docformatter.parse.tokenize_docstring(docstring: str, token_enums: Iterable[type[tokens.BaseTokenEnum]]) Generator[DocstringToken, None, None]¶
Tokenize a docstring.
- Parameters:
docstring – The docstring to tokenize.
token_enums – The token enums to use for tokenizing.
- Yields:
The next token in the docstring.