codeatlas-viz 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codeatlas/__init__.py +15 -0
- codeatlas/analyzers/__init__.py +72 -0
- codeatlas/analyzers/base.py +20 -0
- codeatlas/analyzers/c_family_analyzer.py +208 -0
- codeatlas/analyzers/js_analyzer.py +207 -0
- codeatlas/analyzers/python_analyzer.py +130 -0
- codeatlas/cli.py +134 -0
- codeatlas/models.py +276 -0
- codeatlas/scanner.py +335 -0
- codeatlas/server.py +208 -0
- codeatlas/web/assets/index-WkvacVWK.js +4 -0
- codeatlas/web/assets/index-vVc60hrc.css +1 -0
- codeatlas/web/index.html +13 -0
- codeatlas_viz-0.2.2.dist-info/METADATA +146 -0
- codeatlas_viz-0.2.2.dist-info/RECORD +19 -0
- codeatlas_viz-0.2.2.dist-info/WHEEL +5 -0
- codeatlas_viz-0.2.2.dist-info/entry_points.txt +2 -0
- codeatlas_viz-0.2.2.dist-info/licenses/LICENSE +21 -0
- codeatlas_viz-0.2.2.dist-info/top_level.txt +1 -0
codeatlas/cli.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Command-line interface for CodeAtlas."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .scanner import scan_directory
|
|
12
|
+
from .server import serve_graph
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _print_summary(root: Path) -> int:
|
|
16
|
+
graph = scan_directory(root)
|
|
17
|
+
stats = graph.stats()
|
|
18
|
+
|
|
19
|
+
print(f"CodeAtlas v{__version__} — {graph.root}")
|
|
20
|
+
print("-" * 60)
|
|
21
|
+
print(
|
|
22
|
+
f"Files: {stats['total_files']} | "
|
|
23
|
+
f"Symbols: {stats['total_symbols']} | "
|
|
24
|
+
f"Call Edges: {stats['total_edges']} | "
|
|
25
|
+
f"Cycles: {stats['cycle_count']} | "
|
|
26
|
+
f"Health: {stats['health_score']}/100"
|
|
27
|
+
)
|
|
28
|
+
if stats["languages"]:
|
|
29
|
+
langs = ", ".join(f"{k}: {v}" for k, v in sorted(stats["languages"].items()))
|
|
30
|
+
print(f"Languages: {langs}")
|
|
31
|
+
|
|
32
|
+
if stats["hotspots"]:
|
|
33
|
+
print("\nTop Call-Graph Hubs:")
|
|
34
|
+
for hub in stats["hotspots"][:8]:
|
|
35
|
+
print(
|
|
36
|
+
f" - {hub['name']} ({hub['file']}) "
|
|
37
|
+
f"[in: {hub['fan_in']}, out: {hub['fan_out']}]"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if graph.cycles:
|
|
41
|
+
print("\nCircular Call Groups:")
|
|
42
|
+
for idx, comp in enumerate(graph.cycles[:5], start=1):
|
|
43
|
+
print(f" {idx}. " + " <-> ".join(comp[:5]))
|
|
44
|
+
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _handle_export(root: Path, fmt: str, output: str | None) -> int:
|
|
49
|
+
graph = scan_directory(root)
|
|
50
|
+
if fmt == "mermaid":
|
|
51
|
+
rendered = graph.to_mermaid()
|
|
52
|
+
elif fmt == "html":
|
|
53
|
+
rendered = graph.to_html()
|
|
54
|
+
elif fmt == "markdown":
|
|
55
|
+
rendered = graph.to_markdown()
|
|
56
|
+
else:
|
|
57
|
+
rendered = json.dumps(graph.to_dict(), indent=2)
|
|
58
|
+
|
|
59
|
+
if output:
|
|
60
|
+
Path(output).write_text(rendered, encoding="utf-8")
|
|
61
|
+
print(f"Exported {fmt} graph to {output}")
|
|
62
|
+
else:
|
|
63
|
+
print(rendered)
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
68
|
+
parser = argparse.ArgumentParser(
|
|
69
|
+
prog="codeatlas",
|
|
70
|
+
description="Zero-config local codebase architecture & call-graph visualizer.",
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
73
|
+
|
|
74
|
+
sub = parser.add_subparsers(dest="command")
|
|
75
|
+
|
|
76
|
+
p_scan = sub.add_parser("scan", help="Print an architectural call-graph summary in the terminal.")
|
|
77
|
+
p_scan.add_argument("path", nargs="?", default=".", help="Target repository path (default: .)")
|
|
78
|
+
|
|
79
|
+
p_serve = sub.add_parser("serve", help="Launch the interactive Svelte call-graph UI.")
|
|
80
|
+
p_serve.add_argument("path", nargs="?", default=".", help="Target repository path (default: .)")
|
|
81
|
+
p_serve.add_argument("--host", default="127.0.0.1", help="Bind host (default: 127.0.0.1)")
|
|
82
|
+
p_serve.add_argument("--port", type=int, default=4173, help="Bind port (default: 4173)")
|
|
83
|
+
p_serve.add_argument("--no-open", action="store_true", help="Do not automatically open the browser.")
|
|
84
|
+
|
|
85
|
+
p_export = sub.add_parser("export", help="Export the call graph as JSON or Mermaid.")
|
|
86
|
+
p_export.add_argument("path", nargs="?", default=".", help="Target repository path (default: .)")
|
|
87
|
+
p_export.add_argument("--format", choices=("json", "mermaid", "html", "markdown"), default="json", help="Output format")
|
|
88
|
+
p_export.add_argument("-o", "--output", default=None, help="Output file path (prints to stdout if omitted)")
|
|
89
|
+
|
|
90
|
+
return parser
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def main(argv: list[str] | None = None) -> int:
|
|
94
|
+
raw_argv = list(sys.argv[1:] if argv is None else argv)
|
|
95
|
+
known_cmds = {"scan", "serve", "export"}
|
|
96
|
+
if raw_argv and not raw_argv[0].startswith("-") and raw_argv[0] not in known_cmds:
|
|
97
|
+
raw_argv = ["scan", *raw_argv]
|
|
98
|
+
|
|
99
|
+
parser = build_parser()
|
|
100
|
+
args = parser.parse_args(raw_argv)
|
|
101
|
+
|
|
102
|
+
if args.command is None:
|
|
103
|
+
# Default convenience: `codeatlas [path]` behaves like `scan`
|
|
104
|
+
return _print_summary(Path("."))
|
|
105
|
+
|
|
106
|
+
target = Path(args.path)
|
|
107
|
+
if not target.exists():
|
|
108
|
+
print(f"Error: path does not exist: {target}", file=sys.stderr)
|
|
109
|
+
return 1
|
|
110
|
+
|
|
111
|
+
if args.command == "scan":
|
|
112
|
+
return _print_summary(target)
|
|
113
|
+
if args.command == "export":
|
|
114
|
+
return _handle_export(target, args.format, args.output)
|
|
115
|
+
if args.command == "serve":
|
|
116
|
+
graph = scan_directory(target)
|
|
117
|
+
try:
|
|
118
|
+
serve_graph(
|
|
119
|
+
target,
|
|
120
|
+
graph,
|
|
121
|
+
host=args.host,
|
|
122
|
+
port=args.port,
|
|
123
|
+
open_browser=not args.no_open,
|
|
124
|
+
)
|
|
125
|
+
except RuntimeError as exc:
|
|
126
|
+
print(f"Error: {exc}", file=sys.stderr)
|
|
127
|
+
return 1
|
|
128
|
+
return 0
|
|
129
|
+
|
|
130
|
+
return 0
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
raise SystemExit(main())
|
codeatlas/models.py
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"""Data models and graph analytics for CodeAtlas."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import asdict, dataclass, field
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(slots=True)
|
|
10
|
+
class SymbolNode:
|
|
11
|
+
"""Represents a function, method, class, or module symbol in the codebase."""
|
|
12
|
+
|
|
13
|
+
id: str
|
|
14
|
+
name: str
|
|
15
|
+
kind: str # "function", "method", "class"
|
|
16
|
+
file: str
|
|
17
|
+
language: str
|
|
18
|
+
start_line: int
|
|
19
|
+
end_line: int
|
|
20
|
+
docstring: str = ""
|
|
21
|
+
parent: str | None = None
|
|
22
|
+
fan_in: int = 0
|
|
23
|
+
fan_out: int = 0
|
|
24
|
+
|
|
25
|
+
def to_dict(self) -> dict[str, Any]:
|
|
26
|
+
return asdict(self)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(slots=True)
|
|
30
|
+
class CallEdge:
|
|
31
|
+
"""Represents a directed call relationship from one symbol to another."""
|
|
32
|
+
|
|
33
|
+
source: str
|
|
34
|
+
target: str
|
|
35
|
+
call_count: int = 1
|
|
36
|
+
|
|
37
|
+
def to_dict(self) -> dict[str, Any]:
|
|
38
|
+
return asdict(self)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(slots=True)
|
|
42
|
+
class FileSummary:
|
|
43
|
+
"""Metadata about a scanned source file."""
|
|
44
|
+
|
|
45
|
+
path: str
|
|
46
|
+
language: str
|
|
47
|
+
lines: int
|
|
48
|
+
symbol_count: int
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> dict[str, Any]:
|
|
51
|
+
return asdict(self)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass(slots=True)
|
|
55
|
+
class CodeGraph:
|
|
56
|
+
"""Complete architectural call graph and summary statistics for a repository."""
|
|
57
|
+
|
|
58
|
+
root: str
|
|
59
|
+
nodes: list[SymbolNode] = field(default_factory=list)
|
|
60
|
+
edges: list[CallEdge] = field(default_factory=list)
|
|
61
|
+
file_edges: list[CallEdge] = field(default_factory=list)
|
|
62
|
+
files: list[FileSummary] = field(default_factory=list)
|
|
63
|
+
cycles: list[list[str]] = field(default_factory=list)
|
|
64
|
+
|
|
65
|
+
def stats(self) -> dict[str, Any]:
|
|
66
|
+
"""Compute summary statistics and top hubs for quick inspection."""
|
|
67
|
+
by_lang: dict[str, int] = {}
|
|
68
|
+
for f in self.files:
|
|
69
|
+
by_lang[f.language] = by_lang.get(f.language, 0) + 1
|
|
70
|
+
|
|
71
|
+
unreferenced = sum(
|
|
72
|
+
1 for n in self.nodes if n.kind != "class" and n.fan_in == 0
|
|
73
|
+
)
|
|
74
|
+
callable_count = max(sum(1 for n in self.nodes if n.kind != "class"), 1)
|
|
75
|
+
cycle_penalty = min(40, len(self.cycles) * 8)
|
|
76
|
+
dead_ratio = unreferenced / callable_count
|
|
77
|
+
dead_penalty = int(max(0.0, (dead_ratio - 0.25) * 35))
|
|
78
|
+
health_score = max(0, min(100, 100 - cycle_penalty - dead_penalty))
|
|
79
|
+
|
|
80
|
+
hotspots = sorted(
|
|
81
|
+
self.nodes,
|
|
82
|
+
key=lambda n: (n.fan_in + n.fan_out, n.fan_in),
|
|
83
|
+
reverse=True,
|
|
84
|
+
)[:10]
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
"total_files": len(self.files),
|
|
88
|
+
"total_symbols": len(self.nodes),
|
|
89
|
+
"total_edges": len(self.edges),
|
|
90
|
+
"cycle_count": len(self.cycles),
|
|
91
|
+
"unreferenced_count": unreferenced,
|
|
92
|
+
"health_score": health_score,
|
|
93
|
+
"languages": by_lang,
|
|
94
|
+
"hotspots": [
|
|
95
|
+
{
|
|
96
|
+
"id": n.id,
|
|
97
|
+
"name": n.name,
|
|
98
|
+
"file": n.file,
|
|
99
|
+
"fan_in": n.fan_in,
|
|
100
|
+
"fan_out": n.fan_out,
|
|
101
|
+
}
|
|
102
|
+
for n in hotspots
|
|
103
|
+
if (n.fan_in + n.fan_out) > 0
|
|
104
|
+
],
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
def to_dict(self) -> dict[str, Any]:
|
|
108
|
+
return {
|
|
109
|
+
"root": self.root,
|
|
110
|
+
"stats": self.stats(),
|
|
111
|
+
"files": [f.to_dict() for f in self.files],
|
|
112
|
+
"nodes": [n.to_dict() for n in self.nodes],
|
|
113
|
+
"edges": [e.to_dict() for e in self.edges],
|
|
114
|
+
"file_edges": [e.to_dict() for e in self.file_edges],
|
|
115
|
+
"cycles": self.cycles,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
def to_mermaid(self, max_edges: int = 80) -> str:
|
|
119
|
+
"""Render the call graph as a Mermaid flowchart."""
|
|
120
|
+
lines = ["flowchart LR"]
|
|
121
|
+
node_map = {n.id: n for n in self.nodes}
|
|
122
|
+
safe_id = lambda raw: "n_" + "".join(c if c.isalnum() else "_" for c in raw)
|
|
123
|
+
|
|
124
|
+
emitted: set[str] = set()
|
|
125
|
+
for edge in self.edges[:max_edges]:
|
|
126
|
+
src = node_map.get(edge.source)
|
|
127
|
+
tgt = node_map.get(edge.target)
|
|
128
|
+
if not src or not tgt:
|
|
129
|
+
continue
|
|
130
|
+
for node in (src, tgt):
|
|
131
|
+
if node.id not in emitted:
|
|
132
|
+
emitted.add(node.id)
|
|
133
|
+
label = f"{node.name} ({node.file})".replace('"', "'")
|
|
134
|
+
lines.append(f' {safe_id(node.id)}["{label}"]')
|
|
135
|
+
lines.append(f" {safe_id(src.id)} --> {safe_id(tgt.id)}")
|
|
136
|
+
|
|
137
|
+
if len(lines) == 1:
|
|
138
|
+
lines.append(' empty["No call edges detected"]')
|
|
139
|
+
return "\n".join(lines)
|
|
140
|
+
|
|
141
|
+
def to_markdown(self, max_hubs: int = 8) -> str:
|
|
142
|
+
"""Render a concise GitHub-flavored Markdown architectural report."""
|
|
143
|
+
st = self.stats()
|
|
144
|
+
lines = [
|
|
145
|
+
"## CodeAtlas Architecture Summary",
|
|
146
|
+
"",
|
|
147
|
+
f"- **Files:** {st['total_files']} | **Symbols:** {st['total_symbols']} | "
|
|
148
|
+
f"**Call Edges:** {st['total_edges']} | **Cycles:** {st['cycle_count']} | "
|
|
149
|
+
f"**Health Score:** `{st['health_score']}/100`",
|
|
150
|
+
]
|
|
151
|
+
if st["languages"]:
|
|
152
|
+
langs = ", ".join(f"{k} ({v})" for k, v in sorted(st["languages"].items()))
|
|
153
|
+
lines.append(f"- **Languages:** {langs}")
|
|
154
|
+
|
|
155
|
+
if st["hotspots"]:
|
|
156
|
+
lines.extend(["", "### Top Call-Graph Hubs", "", "| Symbol | File | Fan-In | Fan-Out |", "|---|---|---|---|"])
|
|
157
|
+
for hub in st["hotspots"][:max_hubs]:
|
|
158
|
+
lines.append(
|
|
159
|
+
f"| `{hub['name']}` | `{hub['file']}` | {hub['fan_in']} | {hub['fan_out']} |"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if self.cycles:
|
|
163
|
+
lines.extend(["", "### Circular Call Groups"])
|
|
164
|
+
for idx, cyc in enumerate(self.cycles[:5], start=1):
|
|
165
|
+
chain = " ↔ ".join(f"`{c.split('::')[-1]}`" for c in cyc[:6])
|
|
166
|
+
lines.append(f"{idx}. {chain}")
|
|
167
|
+
|
|
168
|
+
lines.extend(["", "<details><summary>Mermaid Call Graph</summary>", "", "```mermaid", self.to_mermaid(), "```", "", "</details>"])
|
|
169
|
+
return "\n".join(lines)
|
|
170
|
+
|
|
171
|
+
def to_html(self) -> str:
|
|
172
|
+
"""Render a self-contained single-file HTML architecture report."""
|
|
173
|
+
import html
|
|
174
|
+
import json
|
|
175
|
+
|
|
176
|
+
st = self.stats()
|
|
177
|
+
data_json = json.dumps(self.to_dict()).replace("</", "<\\/")
|
|
178
|
+
root_esc = html.escape(self.root)
|
|
179
|
+
return f"""<!doctype html>
|
|
180
|
+
<html lang="en">
|
|
181
|
+
<head>
|
|
182
|
+
<meta charset="utf-8" />
|
|
183
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
184
|
+
<title>CodeAtlas Report — {root_esc}</title>
|
|
185
|
+
<style>
|
|
186
|
+
body {{ margin:0; font-family:Inter,system-ui,sans-serif; background:#020617; color:#e2e8f0; padding:1.5rem; }}
|
|
187
|
+
header {{ display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:0.75rem; border-bottom:1px solid #1e293b; padding-bottom:1rem; margin-bottom:1.2rem; }}
|
|
188
|
+
.pills span {{ background:#1e293b; padding:0.3rem 0.65rem; border-radius:999px; font-size:0.82rem; margin-left:0.4rem; }}
|
|
189
|
+
.toolbar {{ margin-bottom:1rem; display:flex; gap:0.75rem; align-items:center; }}
|
|
190
|
+
input {{ background:#0f172a; color:#f8fafc; border:1px solid #334155; border-radius:6px; padding:0.45rem 0.7rem; width:300px; font-size:0.86rem; }}
|
|
191
|
+
.grid {{ display:grid; grid-template-columns:repeat(auto-fit, minmax(360px, 1fr)); gap:1rem; }}
|
|
192
|
+
.card {{ background:#0f172a; border:1px solid #1e293b; border-radius:8px; padding:1rem; max-height:420px; overflow:auto; }}
|
|
193
|
+
h2 {{ margin:0 0 0.75rem; font-size:0.85rem; text-transform:uppercase; letter-spacing:0.04em; color:#94a3b8; }}
|
|
194
|
+
table {{ width:100%; border-collapse:collapse; font-size:0.82rem; }}
|
|
195
|
+
th, td {{ text-align:left; padding:0.4rem; border-bottom:1px solid #1e293b; }}
|
|
196
|
+
.score {{ color:#22c55e; font-weight:700; }}
|
|
197
|
+
.warn {{ color:#fb923c; }}
|
|
198
|
+
</style>
|
|
199
|
+
</head>
|
|
200
|
+
<body>
|
|
201
|
+
<header>
|
|
202
|
+
<div><strong>◈ CodeAtlas Architecture Report</strong> — <span>{root_esc}</span></div>
|
|
203
|
+
<div class="pills">
|
|
204
|
+
<span>{st['total_files']} files</span>
|
|
205
|
+
<span>{st['total_symbols']} symbols</span>
|
|
206
|
+
<span>{st['total_edges']} edges</span>
|
|
207
|
+
<span class="warn">{st['cycle_count']} cycles</span>
|
|
208
|
+
<span class="score">Health: {st['health_score']}/100</span>
|
|
209
|
+
</div>
|
|
210
|
+
</header>
|
|
211
|
+
<div class="toolbar">
|
|
212
|
+
<input id="q" type="search" placeholder="Filter hubs, files, or symbols..." />
|
|
213
|
+
<span id="langs" style="font-size:0.82rem;color:#94a3b8"></span>
|
|
214
|
+
</div>
|
|
215
|
+
<div class="grid">
|
|
216
|
+
<div class="card">
|
|
217
|
+
<h2>Top Call-Graph Hubs</h2>
|
|
218
|
+
<table>
|
|
219
|
+
<thead><tr><th>Symbol</th><th>File</th><th>In</th><th>Out</th></tr></thead>
|
|
220
|
+
<tbody id="hubs"></tbody>
|
|
221
|
+
</table>
|
|
222
|
+
</div>
|
|
223
|
+
<div class="card">
|
|
224
|
+
<h2>Files Breakdown (<span id="fcount"></span>)</h2>
|
|
225
|
+
<table>
|
|
226
|
+
<thead><tr><th>File</th><th>Language</th><th>Lines</th><th>Symbols</th></tr></thead>
|
|
227
|
+
<tbody id="files"></tbody>
|
|
228
|
+
</table>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="card">
|
|
231
|
+
<h2>Circular Dependencies (<span id="ccount"></span>)</h2>
|
|
232
|
+
<table>
|
|
233
|
+
<thead><tr><th>#</th><th>Cycle Chain</th></tr></thead>
|
|
234
|
+
<tbody id="cycles"></tbody>
|
|
235
|
+
</table>
|
|
236
|
+
</div>
|
|
237
|
+
<div class="card">
|
|
238
|
+
<h2>Unreferenced Symbols (fan-in = 0)</h2>
|
|
239
|
+
<table>
|
|
240
|
+
<thead><tr><th>Symbol</th><th>Kind</th><th>File</th></tr></thead>
|
|
241
|
+
<tbody id="dead"></tbody>
|
|
242
|
+
</table>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
<script>
|
|
246
|
+
const DATA = {data_json};
|
|
247
|
+
const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({{'&':'&','<':'<','>':'>','"':'"',"'":'''}}[c]));
|
|
248
|
+
document.getElementById('langs').textContent = Object.entries(DATA.stats.languages || {{}}).map(([k,v]) => `${{k}}: ${{v}}`).join(' · ');
|
|
249
|
+
const render = (q = '') => {{
|
|
250
|
+
const s = q.trim().toLowerCase();
|
|
251
|
+
const hubs = DATA.stats.hotspots.filter(h => !s || h.name.toLowerCase().includes(s) || h.file.toLowerCase().includes(s));
|
|
252
|
+
document.getElementById('hubs').innerHTML = hubs.map(h =>
|
|
253
|
+
`<tr><td>${{esc(h.name)}}</td><td>${{esc(h.file)}}</td><td>${{h.fan_in}}</td><td>${{h.fan_out}}</td></tr>`
|
|
254
|
+
).join('') || '<tr><td colspan="4">No matching hubs</td></tr>';
|
|
255
|
+
|
|
256
|
+
const files = DATA.files.filter(f => !s || f.path.toLowerCase().includes(s) || f.language.toLowerCase().includes(s));
|
|
257
|
+
document.getElementById('fcount').textContent = files.length;
|
|
258
|
+
document.getElementById('files').innerHTML = files.map(f =>
|
|
259
|
+
`<tr><td>${{esc(f.path)}}</td><td>${{esc(f.language)}}</td><td>${{f.lines}}</td><td>${{f.symbol_count}}</td></tr>`
|
|
260
|
+
).join('') || '<tr><td colspan="4">No matching files</td></tr>';
|
|
261
|
+
|
|
262
|
+
document.getElementById('ccount').textContent = DATA.cycles.length;
|
|
263
|
+
document.getElementById('cycles').innerHTML = DATA.cycles.map((c, i) =>
|
|
264
|
+
`<tr><td>${{i + 1}}</td><td>${{esc(c.map(x => x.split('::').pop()).join(' ↔ '))}}</td></tr>`
|
|
265
|
+
).join('') || '<tr><td colspan="2">No circular dependencies</td></tr>';
|
|
266
|
+
|
|
267
|
+
const dead = DATA.nodes.filter(n => n.kind !== 'class' && n.fan_in === 0 && (!s || n.name.toLowerCase().includes(s) || n.file.toLowerCase().includes(s))).slice(0, 100);
|
|
268
|
+
document.getElementById('dead').innerHTML = dead.map(n =>
|
|
269
|
+
`<tr><td>${{esc(n.name)}}</td><td>${{esc(n.kind)}}</td><td>${{esc(n.file)}}</td></tr>`
|
|
270
|
+
).join('') || '<tr><td colspan="3">None</td></tr>';
|
|
271
|
+
}};
|
|
272
|
+
document.getElementById('q').addEventListener('input', (e) => render(e.target.value));
|
|
273
|
+
render('');
|
|
274
|
+
</script>
|
|
275
|
+
</body>
|
|
276
|
+
</html>"""
|