backend.help
Handles all ops for assembling and pretty printing help info
#
find_attribute_idxdef find_attribute_idx(newline_split_docs)
Finds the possible split between the header and Attribute annotations
Arguments:
newline_split_docs
- new line split text
Returns:
idx
- -1 if none or the idx of Attributes
#
split_docsdef split_docs(obj)
Possibly splits head class doc string from attribute docstrings
Attempts to find the first contiguous line within the Google style docstring to use as the class docstring. Splits the docs base on the Attributes tag if present.
Arguments:
obj
- class object to rip info from
Returns:
class_doc
- class docstring if present or blank strattr_doc
- list of attribute doc strings
#
match_attribute_docsdef match_attribute_docs(attr_name, attr_docs, attr_type_str, attr_default=NOTHING)
Matches class attributes with attribute docstrings via regex
Arguments:
attr_name
- attribute nameattr_docs
- list of attribute docstringsattr_type_str
- str representation of the attribute typeattr_default
- str representation of a possible default value
Returns:
dictionary of packed attribute information
#
handle_attributes_printdef handle_attributes_print(info_dict, max_indent: int)
Prints attribute information in an argparser style format
Arguments:
info_dict
- packed attribute info dictionary to printmax_indent
- max indent for pretty print of help
#
get_type_stringdef get_type_string(val, nested_others)
Gets the type of the attr val as a string
Arguments:
val
- current attr being processednested_others
- list of nested others to deal with that might have module path info in the string
Returns:
type_string
- type of the attr as a str
#
get_from_sys_modulesdef get_from_sys_modules(cls_name)
Gets the class from a dot notation name
Arguments:
cls_name
- dot notation enum name
Returns:
module
- enum class
#
handle_help_maindef handle_help_main(input_classes: list, module_name: str, extract_fnc: Callable, max_indent: int)
Handles the print of the main class types
Arguments:
input_classes
- current set of input classesmodule_name
- module name to matchextract_fnc
- function that gets the nested lists within classesmax_indent
- max indent for pretty print of help
Returns:
other_list
- extended list of other classes/enums to process
#
handle_help_enumsdef handle_help_enums(other_list: list, module_name: str, extract_fnc: Callable, max_indent: int)
Handles any extra enums from non main args
Arguments:
other_list
- extended list of other classes/enums to processmodule_name
- module name to matchextract_fnc
- function that gets the nested lists within classesmax_indent
- max indent for pretty print of help
Returns:
None
#
attrs_helpdef attrs_help(input_classes: Union[list, tuple], module_name: str, extract_fnc: Callable, max_indent: int) -> None
Handles walking through a list classes to get help info
For each class this function will search doc and attempt to pull out help information for both the class itself and each attribute within the class. If it finds a repeated class in a iterable object it will recursively call self to handle information
Arguments:
input_classes
- list of attr classesmodule_name
- name of module to matchextract_fnc
- function that gets the nested lists within classesmax_indent
- max indent for pretty print of help
Returns:
None