module documentation

Convert ASTs into pydoctor.model.Documentable instances.

Class ASTBuilder Keeps tracks of the state of the AST build, creates documentable and adds objects to the system.
Class ModuleVistor No class docstring; 0/3 instance variable, 6/33 methods documented
Class TypeAliasVisitorExt This visitor implements the handling of type aliases and type variables.
Function extract_final_subscript Extract the "str" part from annotations like "Final[str]".
Function findModuleLevelAssign Find module level Assign. Yields tuples containing the assigment name and the Assign node.
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 parseAll Find and attempt to parse into a list of names the __all__ variable of a module's AST and set Module.all accordingly.
Function parseDocformat Find __docformat__ variable of this module's AST and set Module.docformat accordingly.
Function parseFile Parse the contents of a Python source file.
Function setup_pydoctor_extension Undocumented
Constant MODULE_VARIABLES_META_PARSERS Undocumented
Type Variable DocumentableT Undocumented
Class _ValueFormatter 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 _handleAliasing If the given expression is a name assigned to a target that is not yet in use, create an alias.
Function _infer_type Infer an expression's type.
Function _maybeAttribute 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.
Variable _parse Undocumented
def extract_final_subscript(annotation): (source)

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): (source)

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_attribute_overridden(obj, new_value): (source)

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): (source)

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 parseAll(node, mod): (source)

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): (source)

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): (source)

Parse the contents of a Python source file.

Parameters
path:PathUndocumented
Returns
ast.ModuleUndocumented
def setup_pydoctor_extension(r): (source)

Undocumented

Parameters
r:extensions.ExtRegistrarUndocumented
MODULE_VARIABLES_META_PARSERS: Mapping[str, Callable[[ast.Assign, model.Module], None]] = (source)

Undocumented

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

Undocumented

Value
TypeVar('DocumentableT',
        bound=model.Documentable)
def _annotation_for_elements(sequence): (source)

Undocumented

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

Undocumented

Parameters
value:objectUndocumented
Returns
Optional[ast.expr]Undocumented
def _extract_annotation_subscript(annotation): (source)

Extract the "str, bytes" part from annotations like "Union[str, bytes]".

Parameters
annotation:ast.SubscriptUndocumented
Returns
ast.ASTUndocumented
def _handleAliasing(ctx, target, expr): (source)

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): (source)

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): (source)

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
cls:model.ClassUndocumented
name:strUndocumented
Returns
boolTrue if the name does not exist or is an existing (possibly inherited) attribute, False if this name defines something else than an Attribute.

Undocumented