stubber.codemod.merge_docstub
¶
Merge documentation and type information from from the docstubs into a board stub
Module Contents¶
Classes¶
A libcst transformer that merges the type-rich information from a doc-stub into |
Attributes¶
- stubber.codemod.merge_docstub.empty_module¶
- class stubber.codemod.merge_docstub.MergeCommand(context: libcst.codemod.CodemodContext, docstub_file: pathlib.Path | str)¶
Bases:
libcst.codemod.VisitorBasedCodemodCommand
A libcst transformer that merges the type-rich information from a doc-stub into a firmware stub. The resulting file will contain information from both sources.
module docstring - from source
function parameters and types - from docstubs
function return types - from docstubs
function docstrings - from source
- Parameters:
context (libcst.codemod.CodemodContext) –
docstub_file (Union[pathlib.Path, str]) –
- static add_args(arg_parser: argparse.ArgumentParser) None ¶
Add command-line args that a user can specify for running this codemod.
- Parameters:
arg_parser (argparse.ArgumentParser) –
- Return type:
None
- leave_Module(original_node: libcst.Module, updated_node: libcst.Module) libcst.Module ¶
This method is responsible for updating the module node after processing it in the codemod. It performs the following tasks: 1. Adds any needed imports from the doc-stub. 2. Adds from module import * from the doc-stub. 3. Updates the module docstring. 4. Updates the comments in the module.
- Parameters:
original_node (libcst.Module) – The original module node.
updated_node (libcst.Module) – The updated module node after processing.
- Returns:
The updated module node.
- Return type:
libcst.Module
- visit_ClassDef(node: libcst.ClassDef) bool | None ¶
keep track of the the (class, method) names to the stack
- Parameters:
node (libcst.ClassDef) –
- Return type:
Optional[bool]
- leave_ClassDef(original_node: libcst.ClassDef, updated_node: libcst.ClassDef) libcst.ClassDef ¶
- Parameters:
original_node (libcst.ClassDef) –
updated_node (libcst.ClassDef) –
- Return type:
libcst.ClassDef
- visit_FunctionDef(node: libcst.FunctionDef) bool | None ¶
- Parameters:
node (libcst.FunctionDef) –
- Return type:
Optional[bool]
- leave_FunctionDef(original_node: libcst.FunctionDef, updated_node: libcst.FunctionDef) libcst.FunctionDef | libcst.ClassDef ¶
Update the function Parameters and return type, decorators and docstring
- Parameters:
original_node (libcst.FunctionDef) –
updated_node (libcst.FunctionDef) –
- Return type:
Union[libcst.FunctionDef, libcst.ClassDef]