module documentation

Convert ASTs into pydoctor.model.Documentable instances.
Class ​ASTBuilder Undocumented
Class ​Module​Vistor No class docstring; 0/5 instance variable, 7/29 methods documented
Function attrib​_args Get the arguments passed to an attr.ib definition. @return: The arguments, or None if expr does not look like an attr.ib definition or the arguments passed to it are invalid.
Function extract​_final​_subscript Extract the "str" part from annotations like "Final[str]".
Function find​Module​Level​Assign Find module level Assign. Yields tuples containing the assigment name and the Assign node.
Function is​_attrib Does this expression return an attr.ib?
Function is​_attribute​_overridden Detect if the optional new_value expression override the one already stored in the Attribute.value attribute.
Function is​_constant Detect if the given assignment is a constant.
Function is​_using​_typing​_final Detect if obj's Attribute.annotation is using typing.Final.
Function node2fullname Undocumented
Function parse​All Find and attempt to parse into a list of names the __all__ variable of a module's AST and set Module.all accordingly.
Function parse​Docformat Find __docformat__ variable of this module's AST and set Module.docformat accordingly.
Function parse​File Parse the contents of a Python source file.
Constant MODULE​_VARIABLES​_META​_PARSERS Undocumented
Variable ​Documentable​T Undocumented
Class _​Annotation​String​Parser Implementation of ModuleVistor._unstring_annotation().
Class _​Value​Formatter Class to encapsulate a python value and translate it to HTML when calling repr() on the _ValueFormatter. Used for presenting default values of parameters.
Function ​_annotation​_for​_elements Undocumented
Function ​_annotation​_for​_value Undocumented
Function ​_extract​_annotation​_subscript Extract the "str, bytes" part from annotations like "Union[str, bytes]".
Function _handle​Aliasing If the given expression is a name assigned to a target that is not yet in use, create an alias. @return: True iff an alias was created.
Function ​_infer​_type Infer an expression's type. @param expr: The expression's AST. @return: A type annotation, or None if the expression has no obvious type.
Function _maybe​Attribute Check whether a name is a potential attribute of the given class. This is used to prevent an assignment that wraps a method from creating an attribute that would overwrite or shadow that method.
Function ​_uses​_auto​_attribs No summary
Variable ​_attrib​_signature Signature of the attr.ib function for defining class attributes.
Variable ​_attrs​_decorator​_signature Signature of the attr.s class decorator.
Variable ​_parse Undocumented
def attrib_args(expr, ctx):
Get the arguments passed to an attr.ib definition.
Parameters
expr:ast.exprUndocumented
ctx:model.DocumentableUndocumented
Returns
Optional[BoundArguments]The arguments, or None if expr does not look like an attr.ib definition or the arguments passed to it are invalid.
def extract_final_subscript(annotation):
Extract the "str" part from annotations like "Final[str]".
Parameters
annotation:ast.SubscriptUndocumented
Returns
ast.exprUndocumented
Raises
ValueErrorIf the "Final" annotation is not valid.
def findModuleLevelAssign(mod_ast):
Find module level Assign. Yields tuples containing the assigment name and the Assign node.
Parameters
mod​_ast:ast.ModuleUndocumented
Returns
Iterator[Tuple[str, ast.Assign]]Undocumented
def is_attrib(expr, ctx):
Does this expression return an attr.ib?
Parameters
expr:Optional[ast.expr]Undocumented
ctx:model.DocumentableUndocumented
Returns
boolUndocumented
def is_attribute_overridden(obj, new_value):
Detect if the optional new_value expression override the one already stored in the Attribute.value attribute.
Parameters
obj:model.AttributeUndocumented
new​_value:Optional[ast.expr]Undocumented
Returns
boolUndocumented
def is_constant(obj):

Detect if the given assignment is a constant.

To detect whether a assignment is a constant, this checks two things:

  • all-caps variable name
  • typing.Final annotation
Parameters
obj:model.AttributeUndocumented
Returns
boolUndocumented
Note
Must be called after setting obj.annotation to detect variables using Final.
def is_using_typing_final(obj):
Detect if obj's Attribute.annotation is using typing.Final.
Parameters
obj:model.AttributeUndocumented
Returns
boolUndocumented
def node2fullname(expr, ctx):

Undocumented

Parameters
expr:Optional[ast.expr]Undocumented
ctx:model.DocumentableUndocumented
Returns
Optional[str]Undocumented
def parseAll(node, mod):
Find and attempt to parse into a list of names the __all__ variable of a module's AST and set Module.all accordingly.
Parameters
node:ast.AssignUndocumented
mod:model.ModuleUndocumented
def parseDocformat(node, mod):

Find __docformat__ variable of this module's AST and set Module.docformat accordingly.

This is all valid:

    __docformat__ = "reStructuredText en"
    __docformat__ = "epytext"
    __docformat__ = "restructuredtext"
Parameters
node:ast.AssignUndocumented
mod:model.ModuleUndocumented
def parseFile(path):
Parse the contents of a Python source file.
Parameters
path:PathUndocumented
Returns
ast.ModuleUndocumented
MODULE_VARIABLES_META_PARSERS: Mapping[str, Callable[[ast.Assign, model.Module], None]] =

Undocumented

Value
{'__all__': parseAll, '__docformat__': parseDocformat}
DocumentableT =

Undocumented

def _annotation_for_elements(sequence):

Undocumented

Parameters
sequence:Iterable[object]Undocumented
Returns
Optional[ast.expr]Undocumented
def _annotation_for_value(value):

Undocumented

Parameters
value:objectUndocumented
Returns
Optional[ast.expr]Undocumented
def _extract_annotation_subscript(annotation):
Extract the "str, bytes" part from annotations like "Union[str, bytes]".
Parameters
annotation:ast.SubscriptUndocumented
Returns
ast.ASTUndocumented
def _handleAliasing(ctx, target, expr):
If the given expression is a name assigned to a target that is not yet in use, create an alias.
Parameters
ctx:model.CanContainImportsDocumentableUndocumented
target:strUndocumented
expr:Optional[ast.expr]Undocumented
Returns
boolTrue iff an alias was created.
def _infer_type(expr):
Infer an expression's type.
Parameters
expr:ast.exprThe expression's AST.
Returns
Optional[ast.expr]A type annotation, or None if the expression has no obvious type.
def _maybeAttribute(cls, name):
Check whether a name is a potential attribute of the given class. This is used to prevent an assignment that wraps a method from creating an attribute that would overwrite or shadow that method.
Parameters
name:strUndocumented
Returns
boolTrue if the name does not exist or is an existing (possibly inherited) attribute, False otherwise
def _uses_auto_attribs(call, module):
Does the given attr.s() decoration contain auto_attribs=True?
Parameters
call:ast.CallAST of the call to attr.s(). This function will assume that attr.s() is called without verifying that.
module:model.ModuleModule that contains the call, used for error reporting.
Returns
boolTrue if True is passed for auto_attribs, False in all other cases: if auto_attribs is not passed, if an explicit False is passed or if an error was reported.
_attrib_signature =
Signature of the attr.ib function for defining class attributes.
_attrs_decorator_signature =
Signature of the attr.s class decorator.
_parse =

Undocumented