Skip to content

Commit 4f70494

Browse files
committed
doc: Document json schema
1 parent 8966926 commit 4f70494

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,59 @@ stacktower render examples/test/diamond.json -t tower -o diamond.svg
101101
|------|-------------|
102102
| `--detailed` | Show node metadata in labels |
103103

104+
## JSON Format
105+
106+
The render layer accepts a simple JSON format, making it easy to visualize **any** directed graph—not just package dependencies. You can hand-craft graphs for component diagrams, callgraphs, or pipe output from other tools.
107+
108+
### Minimal Example
109+
110+
```json
111+
{
112+
"nodes": [
113+
{ "id": "app" },
114+
{ "id": "lib-a" },
115+
{ "id": "lib-b" }
116+
],
117+
"edges": [
118+
{ "from": "app", "to": "lib-a" },
119+
{ "from": "lib-a", "to": "lib-b" }
120+
]
121+
}
122+
```
123+
124+
### Required Fields
125+
126+
| Field | Type | Description |
127+
|-------|------|-------------|
128+
| `nodes[].id` | string | Unique node identifier (displayed as label) |
129+
| `edges[].from` | string | Source node ID |
130+
| `edges[].to` | string | Target node ID |
131+
132+
### Optional Fields
133+
134+
| Field | Type | Description |
135+
|-------|------|-------------|
136+
| `nodes[].row` | int | Pre-assigned layer (computed automatically if omitted) |
137+
| `nodes[].kind` | string | Internal use: `"subdivider"` or `"auxiliary"` |
138+
| `nodes[].meta` | object | Freeform metadata for display features |
139+
140+
### Recognized `meta` Keys
141+
142+
These keys are read by specific render flags. All are optional—missing keys simply disable the corresponding feature.
143+
144+
| Key | Type | Used By |
145+
|-----|------|---------|
146+
| `repo_url` | string | Clickable blocks, `--popups`, `--nebraska` |
147+
| `repo_stars` | int | `--popups` |
148+
| `repo_owner` | string | `--nebraska` |
149+
| `repo_maintainers` | []string | `--nebraska`, `--popups` |
150+
| `repo_last_commit` | string (date) | `--popups`, brittle detection |
151+
| `repo_last_release` | string (date) | `--popups` |
152+
| `repo_archived` | bool | `--popups`, brittle detection |
153+
| `summary` | string | `--popups` (fallback: `description`) |
154+
155+
The `--detailed` flag (node-link only) displays **all** meta keys in the node label.
156+
104157
## How It Works
105158

106159
1. **Parse** — Fetch package metadata from registries (PyPI, crates.io, npm)

0 commit comments

Comments
 (0)