Skip to content

Commit ea7c522

Browse files
Add API reference generation and website (#89)
* Add API reference generation tooling * Add static API reference website * Deploy API reference website with GitHub Pages * Complete public API documentation
1 parent f3e1e78 commit ea7c522

48 files changed

Lines changed: 4072 additions & 527 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@typeonce/effect-machine": patch
3+
---
4+
5+
Add Effect-compatible TypeDoc API reference generation and a lightweight static reference website with module navigation, declaration pages, source links, responsive layouts, and local search. Document the public API with library-native version metadata and focused examples for the primary machine, persistence, testing, reactivity, and Cluster workflows.

.github/workflows/release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches: [main]
66

7+
concurrency:
8+
group: release-${{ github.ref }}
9+
cancel-in-progress: false
10+
711
permissions:
812
contents: write
913
pull-requests: write
@@ -13,6 +17,8 @@ jobs:
1317
release:
1418
runs-on: ubuntu-latest
1519
environment: npm
20+
outputs:
21+
published: ${{ steps.changesets.outputs.published }}
1622
steps:
1723
- uses: actions/checkout@v7
1824
- uses: pnpm/action-setup@v6
@@ -23,8 +29,18 @@ jobs:
2329
registry-url: https://registry.npmjs.org
2430
- run: pnpm install --frozen-lockfile
2531
- run: pnpm check
26-
- uses: changesets/action@v1
32+
- id: changesets
33+
uses: changesets/action@v1
2734
with:
2835
publish: pnpm release
2936
env:
3037
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
deploy-website:
40+
needs: release
41+
if: needs.release.outputs.published == 'true'
42+
uses: ./.github/workflows/website.yml
43+
permissions:
44+
contents: read
45+
pages: write
46+
id-token: write

.github/workflows/website.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Website
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: github-pages
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
pages: read
23+
steps:
24+
- uses: actions/checkout@v7
25+
- uses: pnpm/action-setup@v6
26+
- uses: actions/setup-node@v7
27+
with:
28+
node-version: 24
29+
cache: pnpm
30+
- run: pnpm install --frozen-lockfile
31+
- id: pages
32+
uses: actions/configure-pages@v5
33+
- run: pnpm docs:site
34+
env:
35+
API_REFERENCE_BASE_PATH: ${{ steps.pages.outputs.base_path }}
36+
- uses: actions/upload-pages-artifact@v4
37+
with:
38+
path: .data/api-reference-site/v4
39+
40+
deploy:
41+
name: Deploy
42+
needs: build
43+
runs-on: ubuntu-latest
44+
permissions:
45+
pages: write
46+
id-token: write
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
steps:
51+
- id: deployment
52+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules/
22
dist/
33
references/
4+
.data/
45
*.tgz
56
.DS_Store
67
.pnpm-store

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,26 @@ understands imports, re-exports, and dynamic imports, and enforces:
5555

5656
The checker has executable fixture tests and runs as part of `pnpm check`. Add
5757
new rules only with a failing fixture that demonstrates the boundary.
58+
59+
## API reference data
60+
61+
`pnpm docs:api` generates an Effect-compatible TypeDoc dataset under
62+
`.data/api-reference/v4`. The dataset contains a top-level manifest, a package
63+
manifest, and one checksummed reflection JSON file per module configured in
64+
`api-reference.config.json`. Generated data is not committed.
65+
66+
`pnpm docs:api:check` runs the API reference unit tests, generates the complete
67+
dataset in a temporary directory, validates its manifests and checksums, and
68+
ensures every reflection can be consumed by the site-facing normalizer. It runs
69+
as part of `pnpm check`.
70+
71+
`pnpm docs:site` turns that dataset into a multi-page static website under
72+
`.data/api-reference-site/v4` and creates its Pagefind search index. Run
73+
`pnpm docs:site:serve` to preview the latest generated site locally. Site output
74+
is also generated data and is not committed.
75+
76+
The release workflow calls the GitHub Pages workflow after Changesets publishes
77+
a package. The Pages workflow can also be run manually to deploy the current
78+
commit before a release without invoking the package-release job. Pages supplies
79+
`API_REFERENCE_BASE_PATH` during the build so project URLs and custom domains
80+
use the same generated site without configuration edits.

api-reference-site.config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"input": ".data/api-reference/v4",
3+
"output": ".data/api-reference-site/v4",
4+
"basePath": "/",
5+
"title": "Effect Machine",
6+
"description": "API reference for Effect Machine"
7+
}

api-reference.config.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"channel": "v4",
3+
"output": ".data/api-reference/v4",
4+
"tsconfig": "tsconfig.json",
5+
"barrels": [
6+
{
7+
"export": ".",
8+
"source": "src/index.ts"
9+
},
10+
{
11+
"export": "./testing",
12+
"source": "src/testing/index.ts"
13+
},
14+
{
15+
"export": "./reactivity",
16+
"source": "src/unstable/reactivity/index.ts"
17+
},
18+
{
19+
"export": "./cluster",
20+
"source": "src/unstable/cluster/index.ts"
21+
}
22+
],
23+
"modules": [
24+
{
25+
"export": "./Machine",
26+
"source": "src/Machine.ts",
27+
"barrel": ".",
28+
"examples": [
29+
"after",
30+
"decodeSnapshot",
31+
"defineStates",
32+
"effect",
33+
"encodeSnapshot",
34+
"event",
35+
"invoke",
36+
"invokeEffect",
37+
"make",
38+
"plan",
39+
"planInitial",
40+
"resume",
41+
"start",
42+
"transition"
43+
]
44+
},
45+
{
46+
"export": "./testing/MachineTest",
47+
"source": "src/testing/MachineTest.ts",
48+
"barrel": "./testing",
49+
"examples": [
50+
"coverage",
51+
"explore",
52+
"invariants",
53+
"probe",
54+
"run",
55+
"scenarios",
56+
"verify"
57+
]
58+
},
59+
{
60+
"export": "./unstable/reactivity/AtomMachine",
61+
"source": "src/unstable/reactivity/AtomMachine.ts",
62+
"barrel": "./reactivity",
63+
"examples": ["make", "matches", "select", "selectChild"]
64+
},
65+
{
66+
"export": "./unstable/cluster/ClusterMachine",
67+
"source": "src/unstable/cluster/ClusterMachine.ts",
68+
"barrel": "./cluster",
69+
"examples": ["make"]
70+
}
71+
]
72+
}

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,16 @@
5454
"perf:runtime": "pnpm build && node --expose-gc scripts/runtime-performance.mjs",
5555
"format": "dprint fmt",
5656
"format:check": "dprint check",
57+
"docs:api": "node scripts/api-reference/generate.mjs",
58+
"docs:api:test": "node --test scripts/api-reference/*.test.mjs",
59+
"docs:api:check": "pnpm docs:api:test && node scripts/api-reference/generate.mjs --check",
60+
"docs:site": "pnpm docs:api && node scripts/api-reference-site/generate.mjs && pagefind --site .data/api-reference-site/v4",
61+
"docs:site:test": "node --test scripts/api-reference-site/*.test.mjs",
62+
"docs:site:check": "pnpm docs:site:test && pnpm docs:api && node scripts/api-reference-site/generate.mjs --check",
63+
"docs:site:serve": "node scripts/api-reference-site/serve.mjs",
5764
"test:consumer": "node scripts/test-consumer.mjs",
5865
"pack:check": "node scripts/pack-check.mjs",
59-
"check": "pnpm format:check && pnpm check:architecture && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
66+
"check": "pnpm format:check && pnpm check:architecture && pnpm docs:api:check && pnpm docs:site:check && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
6067
"changeset": "changeset",
6168
"version-packages": "changeset version",
6269
"release": "pnpm build && changeset publish"
@@ -70,8 +77,10 @@
7077
"@types/node": "25.7.0",
7178
"dprint": "0.55.2",
7279
"effect": "4.0.0-beta.107",
80+
"pagefind": "1.5.2",
7381
"tinybench": "2.9.0",
7482
"tstyche": "7.2.1",
83+
"typedoc": "0.28.20",
7584
"typescript": "6.0.3",
7685
"vitest": "4.1.10",
7786
"xstate-v5": "npm:xstate@5.32.5",

0 commit comments

Comments
 (0)