Index
core
Core parsing and analysis engine.
This module re-exports the main entry points:
- parse_file / extract_module_info — tree-sitter parsing
- analyze_package — high-level package analysis
- get_package / clear_cache — cached package access
analyze_package(path)
Analyze a Python package directory.
Discovers all .py files, parses them with tree-sitter, and
builds a complete PackageInfo with dependency edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the package root directory. |
required |
Returns:
| Type | Description |
|---|---|
PackageInfo
|
PackageInfo with all modules and dependency edges. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path is not a directory. |
Example
pkg = analyze_package(Path("src/mylib")) pkg.name 'mylib'
Source code in packages/axm-ast/src/axm_ast/core/analyzer.py
clear_cache()
extract_module_info(path)
Extract full module information from a Python file.
Parses the file using tree-sitter and extracts all functions, classes, imports, variables, and the module docstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to a .py file. |
required |
Returns:
| Type | Description |
|---|---|
ModuleInfo
|
ModuleInfo with all extracted metadata. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
ValueError
|
If the file is not a .py file. |
Example
from pathlib import Path mod = extract_module_info(Path("my_module.py")) mod.path.name 'my_module.py'
Source code in packages/axm-ast/src/axm_ast/core/parser.py
get_package(path)
Return PackageInfo for path, using the global cache.
Equivalent to analyze_package(path) but avoids re-parsing
if the same path was already analyzed in this session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the package root directory. |
required |
Returns:
| Type | Description |
|---|---|
PackageInfo
|
Cached or freshly parsed |
Source code in packages/axm-ast/src/axm_ast/core/cache.py
parse_file(path)
Parse a Python file into a tree-sitter Tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to a .py file. |
required |
Returns:
| Type | Description |
|---|---|
Tree
|
Parsed tree-sitter Tree. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
ValueError
|
If the file is not a .py file. |
Example
from pathlib import Path tree = parse_file(Path("setup.py")) tree.root_node.type 'module'