Skip to content

griffe_typingdoc ¤

Griffe TypingDoc package.

Griffe extension for PEP 727 - Documentation Metadata in Typing.

Modules:

  • debug

    Debugging utilities.

Classes:

TypingDocExtension ¤

TypingDocExtension()

Bases: Extension

Griffe extension that reads documentation from typing.Doc.

Methods:

Source code in src/griffe_typingdoc/_extension.py
22
23
def __init__(self) -> None:
    self._handled: set[str] = set()

on_attribute_instance ¤

on_attribute_instance(
    *,
    node: Annotated[
        AST | ObjectNode,
        Doc(
            "The object/AST node describing the attribute or its definition."
        ),
    ],
    attr: Annotated[
        Attribute,
        Doc("The Griffe attribute just instantiated."),
    ],
    **kwargs: Any
) -> None

Post-process Griffe attributes to create their docstring.

It applies only for dynamic analysis.

Parameters:

  • node (Annotated[AST | ObjectNode, Doc('The object/AST node describing the attribute or its definition.')]) –

    The object/AST node describing the attribute or its definition.

  • attr (Annotated[Attribute, Doc('The Griffe attribute just instantiated.')]) –

    The Griffe attribute just instantiated.

Source code in src/griffe_typingdoc/_extension.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
def on_attribute_instance(
    self,
    *,
    node: Annotated[
        ast.AST | ObjectNode,
        Doc("The object/AST node describing the attribute or its definition."),
    ],
    attr: Annotated[
        Attribute,
        Doc("The Griffe attribute just instantiated."),
    ],
    **kwargs: Any,  # noqa: ARG002
) -> None:
    """Post-process Griffe attributes to create their docstring.

    It applies only for dynamic analysis.
    """
    if isinstance(node, ObjectNode):
        self._handle_attribute(attr, node=node)

on_function_instance ¤

on_function_instance(
    *,
    node: Annotated[
        AST | ObjectNode,
        Doc(
            "The object/AST node describing the function or its definition."
        ),
    ],
    func: Annotated[
        Function,
        Doc("The Griffe function just instantiated."),
    ],
    **kwargs: Any
) -> None

Post-process Griffe functions to add a parameters section.

It applies only for dynamic analysis.

Parameters:

  • node (Annotated[AST | ObjectNode, Doc('The object/AST node describing the function or its definition.')]) –

    The object/AST node describing the function or its definition.

  • func (Annotated[Function, Doc('The Griffe function just instantiated.')]) –

    The Griffe function just instantiated.

Source code in src/griffe_typingdoc/_extension.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def on_function_instance(
    self,
    *,
    node: Annotated[
        ast.AST | ObjectNode,
        Doc("The object/AST node describing the function or its definition."),
    ],
    func: Annotated[
        Function,
        Doc("""The Griffe function just instantiated."""),
    ],
    **kwargs: Any,  # noqa: ARG002
) -> None:
    """Post-process Griffe functions to add a parameters section.

    It applies only for dynamic analysis.
    """
    if isinstance(node, ObjectNode):
        self._handle_function(func, node=node)

on_package_loaded ¤

on_package_loaded(
    *,
    pkg: Annotated[
        Module,
        Doc("The top-level module representing a package."),
    ],
    **kwargs: Any
) -> None

Post-process Griffe packages recursively (non-yet handled objects only).

Parameters:

  • pkg (Annotated[Module, Doc('The top-level module representing a package.')]) –

    The top-level module representing a package.

Source code in src/griffe_typingdoc/_extension.py
117
118
119
120
121
122
123
124
125
126
127
def on_package_loaded(
    self,
    *,
    pkg: Annotated[
        Module,
        Doc("The top-level module representing a package."),
    ],
    **kwargs: Any,  # noqa: ARG002
) -> None:
    """Post-process Griffe packages recursively (non-yet handled objects only)."""
    self._handle_object(pkg)