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
| Python | |
|---|---|
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
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. |
Non-UTF-8 bytes are decoded best-effort with errors="replace"
(undecodable bytes become U+FFFD), so a file with mixed or invalid
encoding is still parsed rather than raising UnicodeDecodeError.
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'