Classes
DependencyNode
dataclass
A node in the dependency graph.
DependencyNode
dataclass A node in the dependency graph.
Attributes
| Name | Type | Description |
|---|---|---|
path |
str |
File path of this node |
node_type |
str |
Type of node (page, template, partial, data, config) |
dependencies |
set[str] |
Files this node depends on |
dependents |
set[str] |
Files that depend on this node |
metadata |
dict[str, Any] |
Additional node metadata |
Methods 3
is_leaf
property
Check if node has no dependencies.
is_leaf
property def is_leaf(self) -> bool
Check if node has no dependencies.
Returns
bool
is_root
property
Check if nothing depends on this node.
is_root
property def is_root(self) -> bool
Check if nothing depends on this node.
Returns
bool
short_path
property
Get shortened path for display.
short_path
property def short_path(self) -> str
Get shortened path for display.
Returns
str
DependencyGraph
dataclass
Complete dependency graph for a project.
Provides methods for traversal, analysis, and visualization.
DependencyGraph
dataclass Complete dependency graph for a project.
Provides methods for traversal, analysis, and visualization.
Attributes
| Name | Type | Description |
|---|---|---|
nodes |
dict[str, DependencyNode] |
All nodes in the graph |
edges |
set[tuple[str, str]] |
Edges as (from, to) tuples |
Methods 8
add_node
Add or get a node.
add_node
def add_node(self, path: str, node_type: str = 'unknown') -> DependencyNode
Add or get a node.
Parameters 2
path |
str |
|
node_type |
str |
Returns
DependencyNode
add_edge
Add a dependency edge (from depends on to).
add_edge
def add_edge(self, from_path: str, to_path: str) -> None
Add a dependency edge (from depends on to).
Parameters 2
from_path |
str |
|
to_path |
str |
get_dependencies
Get dependencies of a node.
get_dependencies
def get_dependencies(self, path: str, recursive: bool = False) -> set[str]
Get dependencies of a node.
Parameters 2
path |
str |
Node path |
recursive |
bool |
Whether to get transitive dependencies |
Returns
Set of dependency pathsset[str]
—
get_dependents
Get what depends on a node (reverse dependencies).
get_dependents
def get_dependents(self, path: str, recursive: bool = False) -> set[str]
Get what depends on a node (reverse dependencies).
Parameters 2
path |
str |
Node path |
recursive |
bool |
Whether to get transitive dependents |
Returns
Set of dependent pathsset[str]
—
get_blast_radius
Get the "blast radius" of changing a file.
Returns all pages that would need t…
get_blast_radius
def get_blast_radius(self, path: str) -> set[str]
Get the "blast radius" of changing a file.
Returns all pages that would need to rebuild if this file changed.
Parameters 1
path |
str |
Path to the file that would change |
Returns
Set of page paths that would rebuildset[str]
—
to_mermaid
Generate Mermaid diagram of the graph.
to_mermaid
def to_mermaid(self, root: str | None = None, max_depth: int = 3, direction: str = 'TB') -> str
Generate Mermaid diagram of the graph.
Parameters 3
root |
str | None |
Optional root node to start from |
max_depth |
int |
Maximum depth to traverse |
direction |
str |
Diagram direction (TB, BT, LR, RL) |
Returns
Mermaid diagram source codestr
—
to_dot
Generate DOT format for Graphviz.
to_dot
def to_dot(self, root: str | None = None, max_depth: int = 3) -> str
Generate DOT format for Graphviz.
Parameters 2
root |
str | None |
Optional root node to start from |
max_depth |
int |
Maximum depth to traverse |
Returns
DOT format source codestr
—
format_tree
Format dependencies as ASCII tree.
format_tree
def format_tree(self, root: str, max_depth: int = 3) -> str
Format dependencies as ASCII tree.
Parameters 2
root |
str |
Root node to start from |
max_depth |
int |
Maximum depth to show |
Returns
ASCII tree representationstr
—
Internal Methods 1
_get_icon
Get icon for file type.
_get_icon
def _get_icon(self, path: str) -> str
Get icon for file type.
Parameters 1
path |
str |
Returns
str
DependencyVisualizer
Debug tool for visualizing dependencies.
Helps understand the dependency structure of builds and
v…
DependencyVisualizer
Debug tool for visualizing dependencies.
Helps understand the dependency structure of builds and visualize the blast radius of changes.
Creation:
Direct instantiation or via DebugRegistry:
viz = DependencyVisualizer(cache=cache)
DebugToolMethods 6
analyze
Analyze dependency structure.
analyze
def analyze(self) -> DebugReport
Analyze dependency structure.
Returns
DebugReport with dependency analysisDebugReport
—
build_graph
Build dependency graph from cache.
build_graph
def build_graph(self) -> DependencyGraph
Build dependency graph from cache.
Returns
DependencyGraph with all dependenciesDependencyGraph
—
visualize_page
Visualize dependencies for a specific page.
visualize_page
def visualize_page(self, page_path: str, max_depth: int = 3) -> str
Visualize dependencies for a specific page.
Parameters 2
page_path |
str |
Path to the page |
max_depth |
int |
Maximum depth to show |
Returns
ASCII tree of dependenciesstr
—
get_blast_radius
Get pages that would rebuild if file changed.
get_blast_radius
def get_blast_radius(self, file_path: str) -> set[str]
Get pages that would rebuild if file changed.
Parameters 1
file_path |
str |
Path to the file that would change |
Returns
Set of page paths that would rebuildset[str]
—
export_mermaid
Export dependency graph as Mermaid diagram.
export_mermaid
def export_mermaid(self, output_path: Path | None = None, root: str | None = None) -> str
Export dependency graph as Mermaid diagram.
Parameters 2
output_path |
Path | None |
Optional path to save the diagram |
root |
str | None |
Optional root node to start from |
Returns
Mermaid diagram sourcestr
—
export_dot
Export dependency graph as DOT format.
export_dot
def export_dot(self, output_path: Path | None = None, root: str | None = None) -> str
Export dependency graph as DOT format.
Parameters 2
output_path |
Path | None |
Optional path to save the file |
root |
str | None |
Optional root node to start from |
Returns
DOT format sourcestr
—
Internal Methods 2
_classify_file
Classify file type for graph.
_classify_file
def _classify_file(self, path: str) -> str
Classify file type for graph.
Parameters 1
path |
str |
Returns
str
_generate_recommendations
Generate recommendations based on analysis.
_generate_recommendations
def _generate_recommendations(self, graph: DependencyGraph, report: DebugReport) -> list[str]
Generate recommendations based on analysis.
Parameters 2
graph |
DependencyGraph |
|
report |
DebugReport |
Returns
list[str]