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} |",
|
||||
|
||||
@@ -333,13 +333,31 @@ def print_result(success: bool, output: str = "", silent: bool = False) -> None:
|
||||
|
||||
|
||||
def get_gd_files(project_root: Path) -> List[Path]:
|
||||
"""Get all .gd files in the project."""
|
||||
return list(project_root.rglob("*.gd"))
|
||||
"""Get all .gd files in the project, respecting gitignore."""
|
||||
gitignore_patterns = read_gitignore(project_root)
|
||||
gd_files = []
|
||||
|
||||
for gd_file in project_root.rglob("*.gd"):
|
||||
if gd_file.is_file() and not is_ignored_by_gitignore(
|
||||
gd_file, project_root, gitignore_patterns
|
||||
):
|
||||
gd_files.append(gd_file)
|
||||
|
||||
return gd_files
|
||||
|
||||
|
||||
def get_py_files(project_root: Path) -> List[Path]:
|
||||
"""Get all .py files in the project."""
|
||||
return list(project_root.rglob("*.py"))
|
||||
"""Get all .py files in the project, respecting gitignore."""
|
||||
gitignore_patterns = read_gitignore(project_root)
|
||||
py_files = []
|
||||
|
||||
for py_file in project_root.rglob("*.py"):
|
||||
if py_file.is_file() and not is_ignored_by_gitignore(
|
||||
py_file, project_root, gitignore_patterns
|
||||
):
|
||||
py_files.append(py_file)
|
||||
|
||||
return py_files
|
||||
|
||||
|
||||
def read_gitignore(project_root: Path) -> List[str]:
|
||||
@@ -661,15 +679,21 @@ def check_naming_convention(file_path: Path) -> Tuple[bool, str]:
|
||||
|
||||
|
||||
def get_naming_files(project_root: Path) -> List[Path]:
|
||||
"""Get all .tscn and .gd files that should follow naming conventions."""
|
||||
"""Get all .tscn and .gd files that should follow naming conventions, respecting gitignore."""
|
||||
gitignore_patterns = read_gitignore(project_root)
|
||||
files = []
|
||||
for pattern in ["**/*.tscn", "**/*.gd"]:
|
||||
files.extend(project_root.glob(pattern))
|
||||
|
||||
# Filter out files that should be ignored
|
||||
for pattern in ["**/*.tscn", "**/*.gd"]:
|
||||
for file_path in project_root.glob(pattern):
|
||||
if file_path.is_file():
|
||||
files.append(file_path)
|
||||
|
||||
# Filter out files that should be ignored (gitignore + TestHelper)
|
||||
filtered_files = []
|
||||
for file_path in files:
|
||||
if not should_skip_file(file_path):
|
||||
if not should_skip_file(file_path) and not is_ignored_by_gitignore(
|
||||
file_path, project_root, gitignore_patterns
|
||||
):
|
||||
filtered_files.append(file_path)
|
||||
|
||||
return filtered_files
|
||||
@@ -1783,7 +1807,15 @@ def run_tests(
|
||||
success = failed_tests == 0
|
||||
|
||||
if yaml_output:
|
||||
output_yaml_results("test", {**stats, "results": test_results}, success)
|
||||
yaml_results = {**stats, "results": test_results}
|
||||
if failed_tests > 0:
|
||||
yaml_results["failed_test_details"] = [
|
||||
{"test": name, "error": error}
|
||||
for name, passed, error in test_results
|
||||
if not passed and error
|
||||
]
|
||||
|
||||
output_yaml_results("test", yaml_results, success)
|
||||
else:
|
||||
print_summary("Test Execution Summary", stats, silent)
|
||||
if not silent:
|
||||
@@ -1890,7 +1922,15 @@ async def run_tests_async(
|
||||
}
|
||||
|
||||
if yaml_output:
|
||||
output_yaml_results("test", {**stats, "results": test_results}, failed == 0)
|
||||
yaml_results = {**stats, "results": test_results}
|
||||
if failed > 0:
|
||||
yaml_results["failed_test_details"] = [
|
||||
{"test": name, "error": error}
|
||||
for name, passed, error in test_results
|
||||
if not passed and error
|
||||
]
|
||||
|
||||
output_yaml_results("test", yaml_results, failed == 0)
|
||||
elif not silent:
|
||||
print_summary("Test Summary", stats)
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user