Skip to content

Commit 6ca3d24

Browse files
committed
Point TypeDoc at docs/api instead of docs, and restore what it deleted
The two deleted files were not an editorial decision. typedoc.json set "out": "docs", and TypeDoc empties its output directory before generating, so running it locally wiped docs/cookbook/ and the deletions were picked up as part of the diff. That is a live bug on main, and it just got worse: #157 removed docs/ from .gitignore, so the next person to run npx typedoc would have deleted DUAL_NETWORK.md, backup-restore.md, event-reference.md and the cookbook, and git would have staged all of it. - typedoc.json: out -> docs/api, so generated and hand-written docs no longer share a directory. Kept this PR's name, entryPointStrategy and navigationLinks additions. - Restored docs/cookbook/portfolio.md and dashboard-preview.jpg from main. - Restored the npm run docs:openapi step the workflow rewrite dropped. Without it the published site keeps a stale OpenAPI spec, and nothing else reads that file so nothing would have flagged it. - .gitignore ignores docs/openapi.json and docs/api/ specifically, rather than docs/ wholesale — the generated artefacts, not the guides. Kept from this PR: npm ci without the || npm install fallback (a lockfile desync should fail rather than silently resolve differently), peaceiris/actions-gh-pages@v4, and keep_files. Verified by running npx typedoc: output lands in docs/api and every hand-written doc is still there afterwards.
1 parent c730ad5 commit 6ca3d24

5 files changed

Lines changed: 65 additions & 2 deletions

File tree

.github/workflows/typedoc.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ jobs:
2828
- name: Generate Prisma client
2929
run: npx prisma generate
3030

31+
# Regenerates docs/openapi.json, which is published alongside the
32+
# TypeDoc output. Dropping it would leave the hosted site with a stale
33+
# OpenAPI spec — silently, since nothing else reads that file.
34+
- name: Generate OpenAPI document
35+
run: npm run docs:openapi
36+
37+
# TypeDoc writes to docs/api (see typedoc.json). It empties its output
38+
# directory first, so it must NOT point at docs/ itself — that is what
39+
# deleted docs/cookbook in an earlier revision of this PR.
3140
- name: Build TypeDoc HTML
3241
run: npx typedoc
3342

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
node_modules/
22
dist/
3-
# Generated by `npm run docs:openapi` alongside the tracked root openapi.json.
3+
# Generated docs output. docs/ itself is tracked (hand-written guides live
4+
# there); only the generated artefacts inside it are ignored.
45
docs/openapi.json
6+
docs/api/
57
.env
68
*.env.local
79
bench/results.json
568 KB
Loading

docs/cookbook/portfolio.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Recipe: Portfolio Tracker
2+
3+
This recipe demonstrates how to build a React dashboard connecting the Wraith API's `/summary` and `/transfers` endpoints to display an address's token holdings and recent activity.
4+
5+
![Portfolio Dashboard Preview](./dashboard-preview.jpg)
6+
7+
## Overview
8+
9+
While Wraith natively indexes Soroban contract events, it exposes a robust REST API perfect for building user-facing dashboards. In this example, we connect two powerful endpoints:
10+
11+
1. `GET /summary/:address` to calculate the current token balances (net flow) along with total tokens received and sent.
12+
2. `GET /transfers/address/:address` to get a chronological history of all incoming and outgoing token transfers.
13+
14+
## Runnable Example
15+
16+
We have provided a complete, deployable Vite + React application in the repository under `examples/portfolio-dashboard`.
17+
18+
### Quick Start
19+
20+
1. Ensure the Wraith backend is running locally on port 3000 (see [Quick Start](../../README.md#quick-start)).
21+
2. Navigate to the example directory and start the frontend:
22+
23+
```bash
24+
cd examples/portfolio-dashboard
25+
npm install
26+
npm run dev
27+
```
28+
29+
3. Open `http://localhost:5173` in your browser.
30+
31+
## Code Walkthrough
32+
33+
The core logic uses `Promise.all` to fetch data from both endpoints concurrently, minimizing the loading time for the user.
34+
35+
```typescript
36+
// From examples/portfolio-dashboard/src/App.tsx
37+
38+
const [summaryRes, transfersRes] = await Promise.all([
39+
fetch(`${API_URL}/summary/${targetAddress}`),
40+
fetch(`${API_URL}/transfers/address/${targetAddress}?limit=10`)
41+
]);
42+
43+
const summaryData = await summaryRes.json();
44+
const transfersData = await transfersRes.json();
45+
```
46+
47+
### Data Structures
48+
49+
- **Summary endpoint** returns an array of `tokens`, giving us the `displayNetFlow` (current balance) and `contractId`.
50+
- **Transfers endpoint** returns `transfers` containing individual ledger events, marked with a `direction` of `incoming` or `outgoing`.
51+
52+
By simply formatting this data into a grid of holdings and a table of transfers, you get a fully functional portfolio tracker without needing complex indexer logic on the frontend.

typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"src/indexer.ts"
1212
],
1313
"entryPointStrategy": "resolve",
14-
"out": "docs",
14+
"out": "docs/api",
1515
"theme": "default",
1616
"readme": "README.md",
1717
"includeVersion": true,

0 commit comments

Comments
 (0)