Skip to content

ast_utils

ast_utils

Shared AST helpers for docstring range extraction and symbol mapping.

Provides the Symbol dataclass, utilities for walking an AST tree to extract documented symbols, and :func:module_display_name for converting file paths to dotted Python module names. Used by all check modules to map source locations to semantic symbols.

Examples:

Extract documented symbols from a source file:

from docvet.ast_utils import get_documented_symbols

tree = ast.parse(source)
symbols = get_documented_symbols(tree)

See Also

docvet.checks.enrichment: Enrichment rules that consume symbols. docvet.checks.freshness: Freshness checks that map lines to symbols.