Expand description
Python API extraction by walking the syntax tree.
Statements are read in source order; function bodies are never entered. What each statement becomes:
| Source | Item |
|---|---|
def f(…) / async def f(…) | Function (Method in a class) |
class C(Base) | Class; Enum when a base is an …Enum / …Flag |
@property / @cached_property | Field (setters and deleters are folded away) |
x: int = 0 in a class body, X = 0 | Field (Variant in an enum) |
MAX = 3, x: int = 3 at module level | Const |
X: TypeAlias = …, type X = …, X = NewType(…), X = Union[…] | TypeAlias |
__all__ = [...] (also +=, .extend, .append) | ApiFile::exports; None when any part is computed |
from .x import A as B, from pkg import * | ReExport (.x.A → B) |
Docstrings (the first statement of a module, class or function; a string right after
an assignment; #: comments before one) go through super::pydoc. Decorators are
kept in attrs without the @. @deprecated(…) (PEP 702, typing_extensions,
the deprecation package) and .. deprecated:: set deprecated.
Visibility: a leading _ is Private; a dunder (__init__) is Inherited, and
dunders are hidden except the ones a caller uses directly: __init__ (documented as
the constructor), __call__, and the context-manager, iterator, container and
awaitable protocols. __repr__, __eq__, __hash__ and friends are noise on a
reference page. @typing.overload stubs are dropped when an implementation follows.
Top-level if/try blocks are walked (first branch only), except
if __name__ == "__main__":, so version-gated and optional-import definitions count.