Skip to content

Commit a6af64d

Browse files
authored
[Docs] Rebuild JSDoc site as a pure function of manifest + git tags (#1553)
Replace the gh-pages branch cache with a stateless build so the published documentation site is fully reproducible from a curated manifest and the Git release tags. Every deploy rebuilds the complete site from scratch, so there is no branch state that can drift. - Add tools/jsdoc/published-versions.json: a curated manifest (30 versions) that is the single source of truth for which versions are published. - Rewrite tools/jsdoc/regenerate-published-docs.js as one linear build path: every manifest version is rebuilt from its Git release tag via `git worktree` + jsdoc (using the current template, so all versions render consistently), shared assets are hoisted to docs/_static, and the landing index is regenerated. Drop the gh-pages cache, prune/self-heal logic, the per-version asset copies, and all the old mode flags. Remaining flags: --out, --manifest (both now validate that a value follows the flag). - package.json: replace `docs:gh-pages` / `docs:gh-pages:full` with a single `docs:publish` script. - .github/workflows/deploy-docs.yml: set `contents: read`, remove the gh-pages fetch and write-back steps, run `npm run docs:publish`, and upload build/published-docs as the Pages artifact. - tools/jsdoc/README.md: document the stateless manifest + tags model and the new naming; drop the obsolete "Recovering a Dropped Version" section and redundant gh-pages references. Fix: #1552
1 parent 9771c09 commit a6af64d

5 files changed

Lines changed: 166 additions & 329 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: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
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. The staged tree is therefore a pure function of the manifest plus
12+
the tags — there is no `gh-pages` branch state to maintain or drift out of sync.
613

714
## Commands
815

@@ -18,52 +25,46 @@ Output:
1825
Use this to verify the docs for the version currently declared in
1926
`package.json`.
2027

21-
### `npm run docs:gh-pages`
28+
### `npm run docs:publish`
2229

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

2532
Behavior:
2633

27-
- reads the currently published version set from `origin/gh-pages`
28-
- preserves that published history
29-
- regenerates docs for the current workspace version
34+
- reads the published version set from `published-versions.json`
35+
- rebuilds every listed version from its Git tag
3036
- rebuilds the staged landing page index
3137

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.
38+
This is the normal command to use for a new release, and it is fully
39+
deterministic: deleting `build/` and rerunning reproduces the identical tree.
3840

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

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

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.
48+
- `--manifest <path>` — use a different version manifest
49+
- `--out <dir>` — stage into a different directory
5350

5451
## New Release Example
5552

5653
For a new release such as `1.9.0`:
5754

5855
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.
56+
2. Add `1.9.0` to the `versions` array in `published-versions.json`.
57+
3. Run `npm run docs` to preview the new version locally (`docs/1.9.0/` and
58+
`docs/index.html`).
59+
4. Cut and push the `1.9.0` release tag so `npm run docs:publish` can rebuild
60+
it from Git.
61+
5. Run `npm run docs:publish`.
62+
6. Verify the staged output in:
63+
- `build/published-docs/docs/1.9.0/`
64+
- `build/published-docs/docs/index.html`
65+
- `build/published-docs/.nojekyll`
66+
7. Publish the contents of `build/published-docs/` to GitHub Pages (the
67+
`deploy-docs.yml` workflow does this automatically on a `docs-*` tag).
6768

6869
## GitHub Actions Deployment
6970

@@ -82,11 +83,17 @@ so manual dispatches and `docs-*` tag pushes there will not run the docs build.
8283

8384
### What it does
8485

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.
86+
1. Full checkout with all tags.
87+
2. Runs `npm run docs:publish` to stage the docs tree. This reads
88+
`published-versions.json` and rebuilds every listed version from its tag.
8789
3. Uploads the staged output as a Pages artifact.
8890
4. Deploys to GitHub Pages (skipped when `dry_run` is `true`).
8991

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

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

101108
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
109+
`build/published-docs/docs/index.html`, run `tools/jsdoc/build-index.js` against
103110
that docs root and point it at the package metadata for the latest published
104111
version.
105112

106113
Example for published version `1.8.0`:
107114

108115
```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
116+
mkdir -p build/published-docs/.tmp
117+
git show 1.8.0:package.json > build/published-docs/.tmp/package-1.8.0.json
111118

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"
119+
export RCLNODEJS_DOCS_ROOT="$PWD/build/published-docs/docs"
120+
export RCLNODEJS_DOCS_INDEX_PATH="$PWD/build/published-docs/docs/index.html"
114121
export RCLNODEJS_LOCAL_INDEX_PATH=''
115-
export RCLNODEJS_PACKAGE_JSON_PATH="$PWD/build/gh-pages-docs/.tmp/package-1.8.0.json"
122+
export RCLNODEJS_PACKAGE_JSON_PATH="$PWD/build/published-docs/.tmp/package-1.8.0.json"
116123

117124
node tools/jsdoc/build-index.js
118-
rm -rf build/gh-pages-docs/.tmp
125+
rm -rf build/published-docs/.tmp
119126
```
120127

121128
## Notes
122129

123-
- The staged publish output keeps shared assets in `build/gh-pages-docs/docs/_static/`.
130+
- The staged publish output keeps shared assets in `build/published-docs/docs/_static/`.
124131
- `.nojekyll` must remain in the staged output because the published docs tree
125132
uses an underscore-prefixed directory.
126-
- The live docs index is the source of truth for which versions should remain
127-
published.
133+
- `published-versions.json` is the source of truth for which versions are
134+
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)