py-ast - v1.16.0
    Preparing search index...

    Function getDocstring

    AST inspection and construction utilities.

    • Get the docstring from a function, class, or module node.

      The docstring is the string literal that forms the first statement in the node's body, matching CPython's ast.get_docstring semantics.

      Parameters

      • node: ASTNodeUnion

        The function, class, or module node to inspect

      Returns string | null

      The docstring text, or null if the node has no body, isn't a function/class/module, or its first statement isn't a string constant