Skip to content

Commit 1fe9257

Browse files
authored
Move JSDoc tooling under tools/jsdoc and document publish workflow (#1447)
- add a dedicated JSDoc toolchain under tools/jsdoc, including the custom template, static assets, landing-page generator, and gh-pages staging script - switch `npm run docs` to build local versioned docs through tools/jsdoc - add `docs:gh-pages` to stage published docs by preserving the currently published history from `origin/gh-pages` and regenerating the current workspace version - add `docs:gh-pages:full` to fully rebuild only the published docs subset from tags, instead of rebuilding every historical release tag - generate the staged docs landing page automatically from the version directories present in the docs output - hoist shared staged assets into `build/gh-pages-docs/docs/_static` and keep `.nojekyll` for publishing compatibility - clarify the maintainer workflow in [tools/jsdoc/README.md](/home/minggang/proj/rclnodejs/tools/jsdoc/README.md), including local docs builds, staged gh-pages builds, full published-history rebuilds, and manual landing-page regeneration - make small JSDoc comment fixes in [lib/subscription.js](/home/minggang/proj/rclnodejs/lib/subscription.js) and [lib/timer.js](/home/minggang/proj/rclnodejs/lib/timer.js) to improve generated API docs Fix: #1446
1 parent 95e5a42 commit 1fe9257

49 files changed

Lines changed: 16501 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/subscription.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const debug = require('debug')('rclnodejs:subscription');
2121

2222
/**
2323
* @class - Class representing a ROS 2 Subscription
24-
* @hideconstructor
2524
* Includes support for content-filtering topics beginning with the
26-
* ROS Humble release. To learn more about content-filtering
25+
* ROS Humble release. To learn more about content-filtering topics,
26+
* see the references below.
27+
* @hideconstructor
2728
* @see {@link Node#options}
2829
* @see {@link Node#createSubscription}
2930
* @see {@link https://www.omg.org/spec/DDS/1.4/PDF|DDS 1.4 specification, Annex B}

lib/timer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Timer {
3030
}
3131

3232
/**
33-
* @type {bigint} - The period of the timer in nanoseconds.
33+
* The period of the timer in nanoseconds.
34+
* @type {bigint}
3435
*/
3536
get period() {
3637
return this._period;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"clean": "node-gyp clean && npx rimraf ./generated",
2525
"install": "node scripts/install.js",
2626
"postinstall": "npm run generate-messages",
27-
"docs": "cd docs && make",
27+
"docs": "make -C tools/jsdoc",
28+
"docs:gh-pages": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --preserve-published",
29+
"docs:gh-pages:full": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --full-rebuild",
2830
"test": "nyc node --expose-gc ./scripts/run_test.js && tsd && npm install --no-save electron && node test/electron/run_test.js",
2931
"test-idl": "nyc node --expose-gc ./scripts/run_test.js --idl",
3032
"lint": "eslint && node ./scripts/cpplint.js",

tools/jsdoc/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.PHONY: docs
2+
3+
docs:
4+
npx jsdoc --package ../../package.json ../../index.js ../../lib/*.js ../../lib/action/*.js -t . -d ../../docs
5+
node ./build-index.js

tools/jsdoc/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# JSDoc Workflow
2+
3+
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.
6+
7+
## Commands
8+
9+
### `npm run docs`
10+
11+
Build local docs for the current workspace version.
12+
13+
Output:
14+
15+
- `docs/<current-version>/`
16+
- `docs/index.html`
17+
18+
Use this to verify the docs for the version currently declared in
19+
`package.json`.
20+
21+
### `npm run docs:gh-pages`
22+
23+
Stage the publishable docs tree under `build/gh-pages-docs/`.
24+
25+
Behavior:
26+
27+
- reads the currently published version set from `origin/gh-pages`
28+
- preserves that published history
29+
- regenerates docs for the current workspace version
30+
- rebuilds the staged landing page index
31+
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+
39+
### `npm run docs:gh-pages:full`
40+
41+
Fully rebuild the currently published docs history under
42+
`build/gh-pages-docs/`.
43+
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.
53+
54+
## New Release Example
55+
56+
For a new release such as `1.9.0`:
57+
58+
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.
67+
68+
## Manual Landing Page Rebuild
69+
70+
If the staged docs tree already exists and you only want to rebuild
71+
`build/gh-pages-docs/docs/index.html`, run `tools/jsdoc/build-index.js` against
72+
that docs root and point it at the package metadata for the latest published
73+
version.
74+
75+
Example for published version `1.8.0`:
76+
77+
```bash
78+
mkdir -p build/gh-pages-docs/.tmp
79+
git show 1.8.0:package.json > build/gh-pages-docs/.tmp/package-1.8.0.json
80+
81+
export RCLNODEJS_DOCS_ROOT="$PWD/build/gh-pages-docs/docs"
82+
export RCLNODEJS_DOCS_INDEX_PATH="$PWD/build/gh-pages-docs/docs/index.html"
83+
export RCLNODEJS_LOCAL_INDEX_PATH=''
84+
export RCLNODEJS_PACKAGE_JSON_PATH="$PWD/build/gh-pages-docs/.tmp/package-1.8.0.json"
85+
86+
node tools/jsdoc/build-index.js
87+
rm -rf build/gh-pages-docs/.tmp
88+
```
89+
90+
## Notes
91+
92+
- The staged publish output keeps shared assets in `build/gh-pages-docs/docs/_static/`.
93+
- `.nojekyll` must remain in the staged output because the published docs tree
94+
uses an underscore-prefixed directory.
95+
- The live docs index is the source of truth for which versions should remain
96+
published.

0 commit comments

Comments
 (0)