Skip to content

Commit f4dce8d

Browse files
committed
[Docs] Rebuild JSDoc site as a pure function of manifest + git tags
1 parent c45a583 commit f4dce8d

5 files changed

Lines changed: 160 additions & 256 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ jobs:
3131
fetch-depth: 0
3232
fetch-tags: true
3333

34-
- name: Fetch gh-pages branch
35-
run: git fetch origin gh-pages:refs/remotes/origin/gh-pages
36-
3734
- name: Setup Node.js
3835
uses: actions/setup-node@v6
3936
with:
@@ -43,12 +40,12 @@ jobs:
4340
run: npm install --ignore-scripts --no-audit --no-fund
4441

4542
- name: Build docs
46-
run: npm run docs:gh-pages
43+
run: npm run docs:publish
4744

4845
- name: Upload Pages artifact
4946
uses: actions/upload-pages-artifact@v5
5047
with:
51-
path: build/gh-pages-docs
48+
path: build/published-docs
5249

5350
deploy:
5451
needs: build

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
"install": "node scripts/install.cjs",
6363
"postinstall": "npm run generate-messages",
6464
"docs": "make -C tools/jsdoc",
65-
"docs:gh-pages": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --preserve-published",
66-
"docs:gh-pages:full": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --full-rebuild",
65+
"docs:publish": "node tools/jsdoc/regenerate-published-docs.js",
6766
"test": "node --expose-gc ./scripts/run_test.cjs && tsd && npm install --no-save electron && node test/electron/run_test.cjs",
6867
"test:coverage": "c8 node --expose-gc ./scripts/run_test.cjs && tsd && npm install --no-save electron && node test/electron/run_test.cjs",
6968
"test-idl": "node --expose-gc ./scripts/run_test.cjs --idl",

tools/jsdoc/README.md

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# JSDoc Workflow
22

33
This directory contains the custom JSDoc template, the landing-page generator,
4-
and the staging script used to prepare the docs content that is published to the
5-
`gh-pages` branch.
4+
and the staging script used to prepare the docs content that is published to
5+
GitHub Pages.
6+
7+
The published version set is curated in
8+
[`published-versions.json`](./published-versions.json). That manifest is the
9+
source of truth for which versions appear on the live docs site. Each staging
10+
run rebuilds the whole site from scratch: every listed version is rebuilt from
11+
its Git tag and the in-development version from the current workspace. The
12+
staged tree is therefore a pure function of the manifest plus the tags — there
13+
is no `gh-pages` branch state to maintain or drift out of sync.
614

715
## Commands
816

@@ -18,52 +26,46 @@ Output:
1826
Use this to verify the docs for the version currently declared in
1927
`package.json`.
2028

21-
### `npm run docs:gh-pages`
29+
### `npm run docs:publish`
2230

23-
Stage the publishable docs tree under `build/gh-pages-docs/`.
31+
Stage the full publishable docs tree under `build/published-docs/`.
2432

2533
Behavior:
2634

27-
- reads the currently published version set from `origin/gh-pages`
28-
- preserves that published history
29-
- regenerates docs for the current workspace version
35+
- reads the published version set from `published-versions.json`
36+
- rebuilds every listed version from its Git tag
37+
- rebuilds the current workspace version from the working tree (always included)
3038
- rebuilds the staged landing page index
3139

32-
This is the normal command to use for a new release.
33-
34-
If you delete `build/` and rerun `npm run docs:gh-pages`, the staged tree will
35-
still contain all currently published versions. That command recreates
36-
`build/gh-pages-docs/` by copying the published docs snapshot from
37-
`origin/gh-pages`, then regenerating only the current workspace version.
40+
This is the normal command to use for a new release, and it is fully
41+
deterministic: deleting `build/` and rerunning reproduces the identical tree.
3842

39-
### `npm run docs:gh-pages:full`
43+
This does **not** rebuild docs for every historical `rclnodejs` tag — only the
44+
curated subset listed in the manifest. To change which versions are published,
45+
edit `published-versions.json`.
4046

41-
Fully rebuild the currently published docs history under
42-
`build/gh-pages-docs/`.
47+
The script reads the manifest next to it by default. Override the inputs only
48+
for testing:
4349

44-
Behavior:
45-
46-
- reads the published version set from `origin/gh-pages`
47-
- rebuilds only those published versions from tags
48-
- regenerates docs for the current workspace version
49-
- rebuilds the staged landing page index
50-
51-
This does **not** rebuild docs for every historical `rclnodejs` tag. It only
52-
rebuilds the subset that is actually published online.
50+
- `--manifest <path>` — use a different version manifest
51+
- `--out <dir>` — stage into a different directory
52+
- `--keep-worktrees` — leave the temporary Git worktrees in place for inspection
5353

5454
## New Release Example
5555

5656
For a new release such as `1.9.0`:
5757

5858
1. Update `package.json` to `1.9.0`.
59-
2. Run `npm run docs`.
60-
3. Verify the local output in `docs/1.9.0/` and `docs/index.html`.
61-
4. Run `npm run docs:gh-pages`.
62-
5. Verify the staged output in:
63-
- `build/gh-pages-docs/docs/1.9.0/`
64-
- `build/gh-pages-docs/docs/index.html`
65-
- `build/gh-pages-docs/.nojekyll`
66-
6. Publish the contents of `build/gh-pages-docs/` to the `gh-pages` branch.
59+
2. Add `1.9.0` to the `versions` array in `published-versions.json`.
60+
3. Run `npm run docs`.
61+
4. Verify the local output in `docs/1.9.0/` and `docs/index.html`.
62+
5. Run `npm run docs:publish`.
63+
6. Verify the staged output in:
64+
- `build/published-docs/docs/1.9.0/`
65+
- `build/published-docs/docs/index.html`
66+
- `build/published-docs/.nojekyll`
67+
7. Publish the contents of `build/published-docs/` to GitHub Pages (the
68+
`deploy-docs.yml` workflow does this automatically on a `docs-*` tag).
6769

6870
## GitHub Actions Deployment
6971

@@ -82,11 +84,18 @@ so manual dispatches and `docs-*` tag pushes there will not run the docs build.
8284

8385
### What it does
8486

85-
1. Full checkout with all tags and the `origin/gh-pages` branch.
86-
2. Runs `npm run docs:gh-pages` to stage the docs tree.
87+
1. Full checkout with all tags.
88+
2. Runs `npm run docs:publish` to stage the docs tree. This reads
89+
`published-versions.json` and rebuilds every listed version from its tag
90+
plus the current workspace version.
8791
3. Uploads the staged output as a Pages artifact.
8892
4. Deploys to GitHub Pages (skipped when `dry_run` is `true`).
8993

94+
The workflow only needs `contents: read` and never writes to any branch.
95+
Because the manifest plus the Git tags fully describe the published set, the
96+
live site is always reconstructed from a fresh build — nothing can silently
97+
drop off.
98+
9099
### Testing
91100

92101
- Run the workflow manually with `dry_run` enabled first to verify the build
@@ -99,29 +108,29 @@ so manual dispatches and `docs-*` tag pushes there will not run the docs build.
99108
## Manual Landing Page Rebuild
100109

101110
If the staged docs tree already exists and you only want to rebuild
102-
`build/gh-pages-docs/docs/index.html`, run `tools/jsdoc/build-index.js` against
111+
`build/published-docs/docs/index.html`, run `tools/jsdoc/build-index.js` against
103112
that docs root and point it at the package metadata for the latest published
104113
version.
105114

106115
Example for published version `1.8.0`:
107116

108117
```bash
109-
mkdir -p build/gh-pages-docs/.tmp
110-
git show 1.8.0:package.json > build/gh-pages-docs/.tmp/package-1.8.0.json
118+
mkdir -p build/published-docs/.tmp
119+
git show 1.8.0:package.json > build/published-docs/.tmp/package-1.8.0.json
111120

112-
export RCLNODEJS_DOCS_ROOT="$PWD/build/gh-pages-docs/docs"
113-
export RCLNODEJS_DOCS_INDEX_PATH="$PWD/build/gh-pages-docs/docs/index.html"
121+
export RCLNODEJS_DOCS_ROOT="$PWD/build/published-docs/docs"
122+
export RCLNODEJS_DOCS_INDEX_PATH="$PWD/build/published-docs/docs/index.html"
114123
export RCLNODEJS_LOCAL_INDEX_PATH=''
115-
export RCLNODEJS_PACKAGE_JSON_PATH="$PWD/build/gh-pages-docs/.tmp/package-1.8.0.json"
124+
export RCLNODEJS_PACKAGE_JSON_PATH="$PWD/build/published-docs/.tmp/package-1.8.0.json"
116125

117126
node tools/jsdoc/build-index.js
118-
rm -rf build/gh-pages-docs/.tmp
127+
rm -rf build/published-docs/.tmp
119128
```
120129

121130
## Notes
122131

123-
- The staged publish output keeps shared assets in `build/gh-pages-docs/docs/_static/`.
132+
- The staged publish output keeps shared assets in `build/published-docs/docs/_static/`.
124133
- `.nojekyll` must remain in the staged output because the published docs tree
125134
uses an underscore-prefixed directory.
126-
- The live docs index is the source of truth for which versions should remain
127-
published.
135+
- `published-versions.json` is the source of truth for which versions are
136+
published; the Git tags are the content source.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$comment": "Curated list of rclnodejs versions whose JSDoc is published to GitHub Pages. This file is the source of truth for the published set: add a version here when cutting its release. Each deploy rebuilds every listed version from its Git tag, plus the current package.json version from the workspace, so the live site is a pure function of this manifest and the tags.",
3+
"versions": [
4+
"0.12.0",
5+
"0.13.0",
6+
"0.14.0",
7+
"0.14.1",
8+
"0.15.0",
9+
"0.15.2",
10+
"0.16.0",
11+
"0.17.0",
12+
"0.18.0",
13+
"0.20.0",
14+
"0.21.3",
15+
"0.22.3",
16+
"0.26.0",
17+
"0.28.0",
18+
"0.29.0",
19+
"0.30.0",
20+
"0.31.0",
21+
"0.32.0",
22+
"0.33.0",
23+
"1.0.0",
24+
"1.1.0",
25+
"1.2.0",
26+
"1.3.0",
27+
"1.5.0",
28+
"1.6.0",
29+
"1.7.0",
30+
"1.8.0",
31+
"1.9.0",
32+
"2.0.0",
33+
"2.1.0"
34+
]
35+
}

0 commit comments

Comments
 (0)