stubber.rst.output_dict

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’

Module Contents

Classes

SourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

ModuleSourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

ClassSourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

FunctionSourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

class stubber.rst.output_dict.SourceDict(base: List, indent: int = 0, body: int = 0, lf: str = '\n')

Bases: OrderedDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

Parameters
  • base (List) –

  • indent (int) –

  • body (int) –

  • lf (str) –

__str__() str

convert the OD into a string

Return type

str

__add__(dict: SourceDict)
Parameters

dict (SourceDict) –

add_docstr(docstr: Union[str, List[str]], extra: int = 0)
Parameters
  • docstr (Union[str, List[str]]) –

  • extra (int) –

add_comment(line: Union[str, List[str]])

Add a comment, or list of comments, to this block.

Parameters

line (Union[str, List[str]]) –

add_constant(line: str, autoindent: bool = True)

add constant to the constant scope of this block

Parameters
  • line (str) –

  • autoindent (bool) –

add_constant_smart(name: str, type: str = 'Any', docstr: List[str] = [], autoindent: bool = True)

add literal / constant to the constant scope of this block, or a class in this block

Parameters
  • name (str) –

  • type (str) –

  • docstr (List[str]) –

  • autoindent (bool) –

abstract find(name: str) Union[str, None]
Parameters

name (str) –

Return type

Union[str, None]

add_line(line: str, autoindent: bool = True)
Parameters
  • line (str) –

  • autoindent (bool) –

index(key: str)
Parameters

key (str) –

class stubber.rst.output_dict.ModuleSourceDict(name: str, indent=0, lf: str = '\n')

Bases: SourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

Parameters
sort()

make sure all classdefs are in order

__str__()

convert the OD into a string

find(name: str) Union[str, None]

find a classnode based on the name with or without the superclass

Parameters

name (str) –

Return type

Union[str, None]

classes()

get a list of the class names in parent-child order

add_import(imports: Union[str, List[str]])

add a [list of] imports this module

Parameters

imports (Union[str, List[str]]) –

class stubber.rst.output_dict.ClassSourceDict(name: str, *, docstr: List[str] = ['""" """'], init: str = '', indent: int = 0, lf='\n')

Bases: SourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

Parameters
  • name (str) –

  • docstr (List[str]) –

  • init (str) –

  • indent (int) –

class stubber.rst.output_dict.FunctionSourceDict(name: str, *, definition: List[str] = [], docstr: List[str] = ['""" """'], indent: int = 0, decorators: List[str] = [], lf='\n')

Bases: SourceDict

(abstract) dict to store source components respecting parent child dependencies and proper definition order

Parameters
  • name (str) –

  • definition (List[str]) –

  • docstr (List[str]) –

  • indent (int) –

  • decorators (List[str]) –