stubber.rst.output_dict ======================= .. py:module:: stubber.rst.output_dict .. autoapi-nested-parse:: ModuleSourceDict represents a source file with the following components - docstr - version - comment - typing - Optional: list of constants - optional: ClassSourcedicts - optional: FunctionSourcedicts - optional: individual lines of code ClassSourceDict represents a source file with the following components - comment - class - docstr - Optional: list of constants - __init__ : class signature - optional: FunctionSourcedicts - optional: individual lines of code FunctionSourceDict represents a source file with the following components - # comments - todo - optional: decorator - def - function definition - docstr - constants - body - ... - optional: individual lines of code SourceDict is the 'base class' Classes ------- .. autoapisummary:: stubber.rst.output_dict.SourceDict stubber.rst.output_dict.ModuleSourceDict stubber.rst.output_dict.ClassSourceDict stubber.rst.output_dict.FunctionSourceDict Module Contents --------------- .. py:class:: SourceDict(base: List, indent: int = 0, body: int = 0, lf: str = '\n', name='') Bases: :py:obj:`OrderedDict` (abstract) dict to store source components respecting parent child dependencies and proper definition order .. py:attribute:: lf :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ """ .. raw:: html
.. py:attribute:: indent :value: 0 .. py:attribute:: _body :value: 0 .. py:attribute:: _nr :value: 0 .. py:attribute:: name :value: '' .. py:method:: __str__() -> str convert the OD into a string ( the to be generated source code ) .. py:method:: __add__(other: SourceDict) Aallows instances of the SourceDict class to be added together using the + operator or the += operator. .. py:method:: add_docstr(docstr: Union[str, List[str]], extra: int = 0) .. py:method:: add_comment(line: Union[str, List[str]]) Add a comment, or list of comments, to this block. .. py:method:: add_constant(line: str, autoindent: bool = True) add constant to the constant scope of this block .. py:method:: add_constant_smart(name: str, type: str = '', docstr: Optional[List[str]] = None, autoindent: bool = True) add literal / constant to the constant scope of this block, or a class in this block .. py:method:: find(name: str) -> Union[str, None] :abstractmethod: .. py:method:: add_line(line: str, autoindent: bool = True) .. py:method:: index(key: str) .. py:class:: ModuleSourceDict(name: str, indent=0, lf: str = '\n') Bases: :py:obj:`SourceDict` (abstract) dict to store source components respecting parent child dependencies and proper definition order .. py:method:: sort() make sure all classdefs are in order .. py:method:: __str__() sort in the correct parent-child order, then convert to string (the code) .. py:method:: find(name: str) -> Union[str, None] find a classnode based on the name with or without the superclass .. py:method:: classes() get a list of the class names in parent-child order .. py:method:: add_import(imports: Union[str, List[str]]) add a [list of] imports this module .. py:class:: ClassSourceDict(name: str, *, docstr: Optional[List[str]] = None, init: str = '', indent: int = 0, lf='\n') Bases: :py:obj:`SourceDict` (abstract) dict to store source components respecting parent child dependencies and proper definition order .. py:class:: FunctionSourceDict(name: str, *, definition: Optional[List[str]] = None, docstr: Optional[List[str]] = None, indent: int = 0, decorators: Optional[List[str]] = None, lf='\n', is_async: bool = False) Bases: :py:obj:`SourceDict` (abstract) dict to store source components respecting parent child dependencies and proper definition order