Convert ASTs into pydoctor.model.Documentable
instances.
Class |
|
Keeps tracks of the state of the AST build, creates documentable and adds objects to the system. |
Class |
|
No class docstring; 0/3 instance variable, 6/33 methods documented |
Class |
|
This visitor implements the handling of type aliases and type variables. |
Function | extract |
Extract the "str" part from annotations like "Final[str]". |
Function | find |
Find module level Assign. Yields tuples containing the assigment name and the Assign node. |
Function | is |
Detect if the optional new_value expression override the one already stored in the Attribute.value attribute. |
Function | is |
Detect if the given assignment is a constant. |
Function | parse |
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 |
Find __docformat__ variable of this module's AST and set Module.docformat accordingly. |
Function | parse |
Parse the contents of a Python source file. |
Function | setup |
Undocumented |
Constant | MODULE |
Undocumented |
Type Variable |
|
Undocumented |
Class | _ |
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 |
Undocumented |
Function | _annotation |
Undocumented |
Function | _extract |
Extract the "str, bytes" part from annotations like "Union[str, bytes]". |
Function | _handle |
If the given expression is a name assigned to a target that is not yet in use, create an alias. |
Function | _infer |
Infer an expression's type. |
Function | _maybe |
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 |
Extract the "str" part from annotations like "Final[str]".
Parameters | |
annotation:ast.Subscript | Undocumented |
Returns | |
ast.expr | Undocumented |
Raises | |
ValueError | If the "Final" annotation is not valid. |
Find module level Assign. Yields tuples containing the assigment name and the Assign node.
Parameters | |
modast.Module | Undocumented |
Returns | |
Iterator[ | Undocumented |
Detect if the optional new_value expression override the one already stored in the Attribute.value
attribute.
Parameters | |
obj:model.Attribute | Undocumented |
newOptional[ | Undocumented |
Returns | |
bool | Undocumented |
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.Attribute | Undocumented |
Returns | |
bool | Undocumented |
Note | |
Must be called after setting obj.annotation to detect variables using Final. |
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.Assign | Undocumented |
mod:model.Module | Undocumented |
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.Assign | Undocumented |
mod:model.Module | Undocumented |
Parse the contents of a Python source file.
Parameters | |
path:Path | Undocumented |
Returns | |
ast.Module | Undocumented |
Mapping[ str, Callable[ [ ast.Assign, model.Module], None]]
=
(source)
¶
Undocumented
Value |
|
Extract the "str, bytes" part from annotations like "Union[str, bytes]".
Parameters | |
annotation:ast.Subscript | Undocumented |
Returns | |
ast.AST | Undocumented |
If the given expression is a name assigned to a target that is not yet in use, create an alias.
Parameters | |
ctx:model.CanContainImportsDocumentable | Undocumented |
target:str | Undocumented |
expr:Optional[ | Undocumented |
Returns | |
bool | True iff an alias was created. |
Infer an expression's type.
Parameters | |
expr:ast.expr | The expression's AST. |
Returns | |
Optional[ | A type annotation, or None if the expression has no obvious type. |
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.Class | Undocumented |
name:str | Undocumented |
Returns | |
bool | True if the name does not exist or is an existing (possibly inherited) attribute, False if this name defines something else than an Attribute . |