autodoc2.analysis#

Analyse of Python code using astroid.

The core function though analyse_module is agnostic to the implementation, It simply yields ItemData typed-dicts.

Module Contents#

Classes#

Functions#

analyse_module

Analyse the given module and yield items.

_get_full_name

Get the full name of a node.

_get_parent_name

Get the parent name of a node.

fix_docstring_indent

Remove common leading indentation, where the indentation of the first line is ignored.

walk_node

yield_module

yield_annotation_assign

Yield data for an annotation assignment node.

yield_assign

Yield data for an assignment node.

_yield_assign

Yield data for an assignment node.

yield_function_def

Yield data for a function definition node.

yield_class_def

Yield data for a class definition node.

Data#

API#

autodoc2.analysis.__all__ = ['analyse_module']#
autodoc2.analysis.analyse_module(file_path: pathlib.Path, name: str, exclude_external_imports: Pattern[str] | None = None) Iterable[autodoc2.utils.ItemData][source]#

Analyse the given module and yield items.

Parameters:
  • file_path – The path to the module.

  • name – The name of the module, e.g. β€œfoo.bar”.

  • record_external_imports – If given, record these external imports on the module. These are only used to determine what is exposed by __all__, which is only usually objects in the same package. But if you want to expose objects from other packages, you can use this to record them.

autodoc2.analysis._dc_kwargs: dict[str, bool] = None#
class autodoc2.analysis.State[source]#
package_name: str = None#
name_stack: list[str] = None#
exclude_external_imports: Pattern[str] | None = None#
copy(**kwargs: Any) autodoc2.analysis.State[source]#

Copy the state and update the given attributes.

autodoc2.analysis._get_full_name(name: str, name_stack: list[str]) str[source]#

Get the full name of a node.

autodoc2.analysis._get_parent_name(name: str) str[source]#

Get the parent name of a node.

autodoc2.analysis.fix_docstring_indent(s: None | str, tabsize: int = 8) str[source]#

Remove common leading indentation, where the indentation of the first line is ignored.

autodoc2.analysis.walk_node(node: astroid.nodes.NodeNG, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#
autodoc2.analysis.yield_module(node: astroid.nodes.Module, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#
autodoc2.analysis.yield_annotation_assign(node: astroid.nodes.AnnAssign, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#

Yield data for an annotation assignment node.

autodoc2.analysis.yield_assign(node: astroid.nodes.Assign, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#

Yield data for an assignment node.

autodoc2.analysis._yield_assign(node: astroid.nodes.Assign | astroid.nodes.AnnAssign, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#

Yield data for an assignment node.

autodoc2.analysis.yield_function_def(node: astroid.nodes.FunctionDef | astroid.nodes.AsyncFunctionDef, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#

Yield data for a function definition node.

autodoc2.analysis.yield_class_def(node: astroid.nodes.ClassDef, state: autodoc2.analysis.State) Iterable[autodoc2.utils.ItemData][source]#

Yield data for a class definition node.

autodoc2.analysis._FUNC_MAPPER: dict[astroid.nodes.NodeNG, Callable[[astroid.nodes.NodeNG, autodoc2.analysis.State], Iterable[autodoc2.utils.ItemData]]] = None#