scripts/kg/modules¶
scripts.kg.modules.__init__¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | No module description available. |
| Args | — |
| Returns | — |
scripts.kg.modules.analysis¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | Complexity Analysis for Knowledge Graphs |
| =============================== | |
| This module provides tools for analyzing the complexity of knowledge graphs. | |
| It includes metrics for density, degree, busyness, and overall complexity scores. | |
| Args | — |
| Returns | — |
📦 Classes¶
ComplexityAnalyzer¶
Analyzes graph complexity using various metrics. Attributes: None Methods: analyze_density: Analyzes the density and complexity of a given graph. Returns: None
🛠️ Functions¶
analyze_density¶
Analyze the density and complexity of a given graph. Parameters: ['graph: nx.Graph', 'name: str'] Returns: Dict[str, Any]
scripts.kg.modules.data_extractors¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | Data extractors for analyzing Python docstrings and extracting relationships. |
| Args | — |
| Returns | — |
📦 Classes¶
DataRelationExtractor¶
Extracts data relations from module docstrings. Returns: None
FunctionExtractor¶
Extracts function parameters and return values from docstrings. Returns: None
🛠️ Functions¶
extract_data_relations¶
Extract data relations from module docstrings using pattern matching. Parameters: ['cls: Any', 'graph: nx.DiGraph', 'module_node: NodeID', 'description: str'] Returns: None
_add_data_node¶
Add a data node and its relation to the graph. Parameters: ['graph: nx.DiGraph', 'module_node: NodeID', 'data_node: NodeID', 'relation: str', 'confidence: float'] Returns: None
extract_parameters_and_returns¶
Extract parameters and return values from a function entry. Parameters: ['fn_entry: Dict[str, Any]'] Returns: Tuple[List[str], List[str]]
scripts.kg.modules.graph_builder¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | Knowledge graph construction and management tools. |
| Args | — |
| Returns | — |
📦 Classes¶
KnowledgeGraphBuilder¶
Builds knowledge graphs from docmap data. Parameters: ['self: Any', 'docmap: DocMap'] Returns: None
CodebaseAnalyzer¶
Main class for analyzing and visualizing codebase knowledge graphs. Parameters: ['self: Any', 'json_path: str', 'focus_prefix: str'] Returns: None
🛠️ Functions¶
__init__¶
Initialize with normalized docmap data. Parameters: ['self: Any', 'docmap: DocMap'] Returns: Any
build_knowledge_graph¶
Constructs a knowledge graph from the docmap data, optionally filtering by prefix. Parameters: ['self: Any', 'focus_prefix: Optional[str]'] Returns: nx.DiGraph
_build_graph¶
Build the knowledge graph from the filtered docmap. Parameters: ['self: Any', 'docmap: DocMap'] Returns: nx.DiGraph
__init__¶
Initialize the analyzer with JSON data. Parameters: ['self: Any', 'json_path: str', 'focus_prefix: str'] Returns: Any
analyze¶
Analyze the codebase and build knowledge graph. Parameters: ['self: Any'] Returns: Tuple[nx.DiGraph, Dict[str, Any]]
visualize¶
Visualize the knowledge graph with complexity indicators. Parameters: ['self: Any', 'graph: nx.DiGraph', 'density_report: Dict[str, Any]'] Returns: None
export_graph¶
Export the graph to a file. Parameters: ['self: Any', 'graph: nx.DiGraph', 'format_type: str'] Returns: str
scripts.kg.modules.utils¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | Utility functions for the codebase analysis and graph generation. |
| Args | — |
| Returns | — |
📦 Classes¶
DocMapNormalizer¶
Handles normalization of module path keys in docmap dictionaries. Returns: None
🛠️ Functions¶
load_json_file¶
Load and parse a JSON file. Parameters: ['file_path: str'] Returns: DocMap
safe_get¶
Safely get a value from a dictionary. Parameters: ['data: Dict[str, T]', 'key: str', 'default: Optional[T]'] Returns: Optional[T]
normalize_keys¶
Normalize all keys to use forward slashes for consistency. Parameters: ['docmap: DocMap'] Returns: DocMap
scripts.kg.modules.visualization¶
🧠 Docstring Summary
| Section | Content |
|---|---|
| Description | Visualization tools for knowledge graphs. |
| Args | — |
| Returns | — |
📦 Classes¶
GraphVisualizer¶
Handles visualization of knowledge graphs with complexity information. Parameters: ['self: Any'] Returns: None
🛠️ Functions¶
__init__¶
Initialize the visualizer. Parameters: ['self: Any'] Returns: Any
visualize_graph¶
Visualize the graph with complexity scores. Parameters: ['self: Any', 'graph: nx.DiGraph', 'complexity_scores: ComplexityScores', 'title: str'] Returns: None
_position_nodes_in_layers¶
Position nodes in horizontal layers by type. Parameters: ['self: Any', 'layers: Dict[str, list]'] Returns: Dict[NodeID, tuple]
_handle_remaining_nodes¶
Add positions for any nodes that weren't positioned in the initial layout. This modifies the pos dictionary in-place. Parameters: ['self: Any', 'pos: Dict[NodeID, tuple]'] Returns: None
_draw_module_rectangles¶
Draw colored rectangles around modules based on complexity. Parameters: ['self: Any', 'ax: plt.Axes', 'modules: Dict[NodeID, list]', 'pos: Dict[NodeID, tuple]', 'complexity_scores: ComplexityScores'] Returns: None
_get_node_colors¶
Get node colors based on node type and module complexity. Parameters: ['self: Any', 'graph: nx.DiGraph', 'complexity_scores: ComplexityScores'] Returns: list
_get_complexity_color¶
Get the color representation based on the complexity score. Parameters: ['score: float'] Returns: str
_shorten_label¶
Shorten a label for display purposes. Parameters: ['name: str'] Returns: str