Parsing/inferring signatures from documentation.
This module provides several functions to generate better stubs using docstrings and Sphinx docs (.rst files).
Class | ArgSig |
Signature info for a single argument. |
Class | DocStringParser |
Parse function signatures in documentation. |
Function | build_signature |
Build function signature from lists of positional and optional argument names. |
Function | find_unique_signatures |
Remove names with duplicate found signatures. |
Function | infer_arg_sig_from_anon_docstring |
Convert signature in form of "(self: TestClass, arg0: str='ada')" to List[TypedArgList]. |
Function | infer_prop_type_from_docstring |
Check for Google/Numpy style docstring type annotation for a property. |
Function | infer_ret_type_sig_from_anon_docstring |
Convert signature in form of "(self: TestClass, arg0) -> int" to their return type. |
Function | infer_ret_type_sig_from_docstring |
Convert signature in form of "func(self: TestClass, arg0) -> int" to their return type. |
Function | infer_sig_from_docstring |
Convert function signature to list of TypedFunctionSig |
Function | is_valid_type |
Try to determine whether a string might be a valid type annotation. |
Function | parse_all_signatures |
Parse all signatures in a given reST document. |
Function | parse_signature |
Split function signature into its name, positional an optional arguments. |
Constant | STATE_ARGUMENT_DEFAULT |
Undocumented |
Constant | STATE_ARGUMENT_LIST |
Undocumented |
Constant | STATE_ARGUMENT_TYPE |
Undocumented |
Constant | STATE_FUNCTION_NAME |
Undocumented |
Constant | STATE_INIT |
Undocumented |
Constant | STATE_OPEN_BRACKET |
Undocumented |
Constant | STATE_RETURN_VALUE |
Undocumented |
Variable | FunctionSig |
Undocumented |
Variable | Sig |
Undocumented |
Constant | _ARG_NAME_RE |
Undocumented |
Constant | _TYPE_RE |
Undocumented |
Parameters | |
positional:Sequence[ | Undocumented |
optional:Sequence[ | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
docstr:str | Undocumented |
Returns | |
List[ | Undocumented |
Check for Google/Numpy style docstring type annotation for a property.
The docstring has the format "<type>: <descriptions>". In the type string, we allow the following characters: * dot: because sometimes classes are annotated using full path * brackets: to allow type hints like List[int] * comma/space: things like Tuple[int, int]
Parameters | |
docstr:Optional[ | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
docstr:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
docstr:str | Undocumented |
name:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Convert function signature to list of TypedFunctionSig
Look for function signatures of function in docstring. Signature is a string of the format <function_name>(<signature>) -> <return type> or perhaps without the return type.
Returns empty list, when no signature is found, one signature in typical case, multiple signatures, if docstring specifies multiple signatures for overload functions. Return None if the docstring is empty.
Parameters | |
docstr:Optional[ | Undocumented |
name:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
s:str | Undocumented |
Returns | |
bool | Undocumented |
Split function signature into its name, positional an optional arguments.
The expected format is "func_name(arg, opt_arg=False)". Return the name of function and lists of positional and optional argument names.
Parameters | |
sig:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Undocumented
Value |
|