more lint and formatting
Some checks failed
Some checks failed
This commit is contained in:
@@ -984,12 +984,10 @@ def _create_signal_flows_diagram(code_map: dict[str, Any]) -> str:
|
||||
lines = ["graph LR"]
|
||||
|
||||
connections = code_map.get("dependencies", {}).get("signal_connections", [])
|
||||
for conn in connections[:20]: # Limit to first 20 to avoid clutter
|
||||
scene = Path(conn.get("scene", "")).stem
|
||||
for conn in connections[:2000]:
|
||||
signal = conn.get("signal", "unknown")
|
||||
from_node = conn.get("from_node", "")
|
||||
to_node = conn.get("to_node", "")
|
||||
method = conn.get("method", "")
|
||||
|
||||
if from_node and to_node:
|
||||
lines.append(f" {from_node} -->|{signal}| {to_node}")
|
||||
@@ -1038,10 +1036,13 @@ def _create_dependency_graph(code_map: dict[str, Any]) -> str:
|
||||
)
|
||||
|
||||
|
||||
def _render_diagrams_with_matplotlib(mmd_files: list[Path], verbose: bool = False) -> list[Path]:
|
||||
def _render_diagrams_with_matplotlib(
|
||||
mmd_files: list[Path], verbose: bool = False
|
||||
) -> list[Path]:
|
||||
"""Render diagrams from Mermaid source using matplotlib"""
|
||||
try:
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.patches as patches
|
||||
@@ -1064,28 +1065,28 @@ def _render_diagrams_with_matplotlib(mmd_files: list[Path], verbose: bool = Fals
|
||||
fig, ax = plt.subplots(figsize=(12, 8))
|
||||
ax.set_xlim(0, 10)
|
||||
ax.set_ylim(0, 10)
|
||||
ax.axis('off')
|
||||
ax.axis("off")
|
||||
|
||||
# Add title
|
||||
title_map = {
|
||||
"architecture": "Autoload System Architecture",
|
||||
"signal_flows": "Signal Flow Connections",
|
||||
"scene_hierarchy": "Scene Hierarchy",
|
||||
"dependency_graph": "Module Dependencies"
|
||||
"dependency_graph": "Module Dependencies",
|
||||
}
|
||||
title = title_map.get(diagram_name, diagram_name.replace("_", " ").title())
|
||||
ax.text(5, 9.5, title, ha='center', va='top', fontsize=16, weight='bold')
|
||||
ax.text(5, 9.5, title, ha="center", va="top", fontsize=16, weight="bold")
|
||||
|
||||
# Parse simple nodes from Mermaid (basic extraction)
|
||||
nodes = []
|
||||
for line in content.split('\n'):
|
||||
for line in content.split("\n"):
|
||||
line = line.strip()
|
||||
if '[' in line and ']' in line:
|
||||
if "[" in line and "]" in line:
|
||||
# Extract node name
|
||||
parts = line.split('[')
|
||||
parts = line.split("[")
|
||||
if len(parts) > 1:
|
||||
node_name = parts[1].split(']')[0]
|
||||
if node_name and not node_name.startswith('_'):
|
||||
node_name = parts[1].split("]")[0]
|
||||
if node_name and not node_name.startswith("_"):
|
||||
nodes.append(node_name)
|
||||
|
||||
# Remove duplicates while preserving order
|
||||
@@ -1113,28 +1114,48 @@ def _render_diagrams_with_matplotlib(mmd_files: list[Path], verbose: bool = Fals
|
||||
|
||||
# Draw box
|
||||
rect = patches.FancyBboxPatch(
|
||||
(x - 1, y - 0.3), 2, 0.6,
|
||||
(x - 1, y - 0.3),
|
||||
2,
|
||||
0.6,
|
||||
boxstyle="round,pad=0.1",
|
||||
edgecolor='#3498db',
|
||||
facecolor='#ecf0f1',
|
||||
linewidth=2
|
||||
edgecolor="#3498db",
|
||||
facecolor="#ecf0f1",
|
||||
linewidth=2,
|
||||
)
|
||||
ax.add_patch(rect)
|
||||
|
||||
# Add text
|
||||
ax.text(x, y, node, ha='center', va='center', fontsize=9, weight='bold')
|
||||
ax.text(
|
||||
x, y, node, ha="center", va="center", fontsize=9, weight="bold"
|
||||
)
|
||||
else:
|
||||
# No nodes found
|
||||
ax.text(5, 5, "No diagram data available", ha='center', va='center', fontsize=12, style='italic')
|
||||
ax.text(
|
||||
5,
|
||||
5,
|
||||
"No diagram data available",
|
||||
ha="center",
|
||||
va="center",
|
||||
fontsize=12,
|
||||
style="italic",
|
||||
)
|
||||
|
||||
# Add note
|
||||
ax.text(5, 0.3, "Auto-generated diagram",
|
||||
ha='center', va='bottom', fontsize=8, style='italic', color='gray')
|
||||
ax.text(
|
||||
5,
|
||||
0.3,
|
||||
"Auto-generated diagram",
|
||||
ha="center",
|
||||
va="bottom",
|
||||
fontsize=8,
|
||||
style="italic",
|
||||
color="gray",
|
||||
)
|
||||
|
||||
plt.tight_layout()
|
||||
|
||||
png_file = mmd_file.with_suffix(".png")
|
||||
plt.savefig(png_file, dpi=150, bbox_inches='tight', facecolor='white')
|
||||
plt.savefig(png_file, dpi=150, bbox_inches="tight", facecolor="white")
|
||||
plt.close()
|
||||
|
||||
rendered_files.append(png_file)
|
||||
@@ -1205,7 +1226,7 @@ def _generate_autoloads_api_doc(
|
||||
# Embed architecture diagram if exists
|
||||
arch_diagram = diagrams_dir / "architecture.png"
|
||||
if arch_diagram.exists():
|
||||
output.append(f"")
|
||||
output.append("")
|
||||
output.append("")
|
||||
|
||||
for autoload in code_map.get("autoloads", []):
|
||||
@@ -1266,7 +1287,7 @@ def _generate_signals_catalog(
|
||||
# Embed signal flows diagram if exists
|
||||
signals_diagram = diagrams_dir / "signal_flows.png"
|
||||
if signals_diagram.exists():
|
||||
output.append(f"")
|
||||
output.append("")
|
||||
output.append("")
|
||||
|
||||
output.append("## Signal Definitions")
|
||||
@@ -1334,7 +1355,7 @@ def _generate_scene_reference(
|
||||
# Embed scene hierarchy diagram if exists
|
||||
scene_diagram = diagrams_dir / "scene_hierarchy.png"
|
||||
if scene_diagram.exists():
|
||||
output.append(f"")
|
||||
output.append("")
|
||||
output.append("")
|
||||
|
||||
for scene_path, scene_data in code_map.get("scenes", {}).items():
|
||||
@@ -1385,7 +1406,7 @@ def _generate_metrics_dashboard(
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use("Agg") # Non-GUI backend
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.pyplot as plt # noqa: F401 - Used in chart generation functions
|
||||
except ImportError:
|
||||
if verbose:
|
||||
print(" ⚠️ matplotlib not available, skipping metrics")
|
||||
@@ -1489,8 +1510,8 @@ def _create_dashboard_markdown(code_map: dict[str, Any]) -> str:
|
||||
"",
|
||||
"## Project Statistics",
|
||||
"",
|
||||
f"| Metric | Count |",
|
||||
f"|--------|-------|",
|
||||
"| Metric | Count |",
|
||||
"|--------|-------|",
|
||||
f"| Scripts | {total_scripts} |",
|
||||
f"| Scenes | {total_scenes} |",
|
||||
f"| Functions | {total_functions} |",
|
||||
|
||||
Reference in New Issue
Block a user