Commit 891357f
committed
feat(tree): graphify tree — D3 v7 collapsible-tree HTML emitter
Adds a new `graphify tree` subcommand that emits a self-contained D3
v7 collapsible-tree HTML view of an existing graph.json.
Why
---
The existing `graph.html` (force-directed) is great for finding hubs
and unexpected connections. But for code review and onboarding, a
hierarchical tree-of-modules view is much faster: you can collapse
everything and expand only the package you care about, the depth-
based colour palette gives instant orientation, and the layout
mirrors the on-disk structure.
The look + feel is a near-verbatim port of the TGI Taxonomy Viewer
(expand-all / collapse-all / reset-view buttons, multi-line
`wrapText` labels with separately-coloured name + count, depth-based
palette, click-to-toggle subtree, hover-inspector showing top-K
outbound edges per symbol).
Implementation
--------------
- `graphify/tree_html.py` (575 LOC, single file, no new runtime
dependencies). D3 v7 is loaded from cdn.jsdelivr.net at view time.
- Hierarchy is built from `source_file` longest-common-prefix;
symbols are grouped by containing module so the tree mirrors the
on-disk layout exactly.
- Inspector pre-computes top-K outbound edges per symbol so the page
works fully offline once loaded.
- `__main__.py` adds the subcommand + help text after the
`check-update` block.
Configuration
-------------
- `--graph PATH` path to graph.json (default: graphify-out/graph.json)
- `--output HTML` output path (default: graphify-out/GRAPH_TREE.html)
- `--root PATH` filesystem root (default: LCP of source_files)
- `--max-children N` cap visible children per node (default: 200)
- `--top-k-edges N` per-symbol outbound edges in inspector (default: 12)
- `--label NAME` project label shown in the page header
Tested locally on a 17 641-node graph — emits a 4.9 MB HTML file
that renders smoothly in Firefox / Chromium.1 parent 770d7f5 commit 891357f
3 files changed
Lines changed: 653 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
5 | 20 | | |
6 | 21 | | |
7 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1004 | 1004 | | |
1005 | 1005 | | |
1006 | 1006 | | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1007 | 1014 | | |
1008 | 1015 | | |
1009 | 1016 | | |
| |||
1422 | 1429 | | |
1423 | 1430 | | |
1424 | 1431 | | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
1425 | 1488 | | |
1426 | 1489 | | |
1427 | 1490 | | |
| |||
0 commit comments