Skip to content

Commit 602959d

Browse files
ci(docs): auto-publish TypeDoc API reference to gh-pages (#158)
* ci(docs): auto-publish TypeDoc API reference to gh-pages - Add typedoc.json with entryPoints covering public modules - Add .github/workflows/typedoc.yml to run on every main push - Push generated HTML output to gh-pages via peaceiris/actions-gh-pages - Add README link to hosted docs URL Closes #62 * 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. --------- Co-authored-by: Miracle656 <iupacnumen2020@gmail.com>
1 parent 8c96bcd commit 602959d

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

.github/workflows/typedoc.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,41 @@ jobs:
99
name: Generate & publish API docs
1010
runs-on: ubuntu-latest
1111
permissions:
12-
# peaceiris/actions-gh-pages pushes to the gh-pages branch, which needs
13-
# write access to repo contents. The default GITHUB_TOKEN is read-only.
12+
# peaceiris/actions-gh-pages needs write access to push to the gh-pages branch.
1413
contents: write
1514
steps:
1615
- uses: actions/checkout@v4
16+
1717
- uses: actions/setup-node@v4
1818
with:
1919
node-version: '20'
2020
cache: npm
21-
- run: npm ci || npm install
22-
- run: npx prisma generate
23-
- run: npm run docs:openapi
24-
- run: npx typedoc
21+
22+
# Install deps (Prisma client is a peer of typedoc-plugin-* if ever added)
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
# Prisma generate is required so TypeDoc can resolve @prisma/client types
27+
# when it processes db.ts and other modules that import from it.
28+
- name: Generate Prisma client
29+
run: npx prisma generate
30+
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.
40+
- name: Build TypeDoc HTML
41+
run: npx typedoc
42+
2543
- name: Deploy to gh-pages
26-
uses: peaceiris/actions-gh-pages@v3
44+
uses: peaceiris/actions-gh-pages@v4
2745
with:
2846
github_token: ${{ secrets.GITHUB_TOKEN }}
2947
publish_dir: ./docs
48+
# Overwrite only the docs output; keep any other files already on the branch.
49+
keep_files: true

.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

typedoc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "Wraith — API Reference",
23
"entryPoints": [
34
"src/index.ts",
45
"src/api.ts",
@@ -9,7 +10,8 @@
910
"src/events.ts",
1011
"src/indexer.ts"
1112
],
12-
"out": "docs",
13+
"entryPointStrategy": "resolve",
14+
"out": "docs/api",
1315
"theme": "default",
1416
"readme": "README.md",
1517
"includeVersion": true,
@@ -18,5 +20,8 @@
1820
"excludeExternals": true,
1921
"hideGenerator": false,
2022
"sort": "source-order",
21-
"searchInComments": true
23+
"searchInComments": true,
24+
"navigationLinks": {
25+
"GitHub": "https://github.com/Miracle656/wraith"
26+
}
2227
}

0 commit comments

Comments
 (0)