Skip to content

Commit 057e0e3

Browse files
Document the docs build workflow in CLAUDE.md
Adds a Documentation section covering npm run build-docs, and makes clear it is an occasional on-request task rather than something to run after editing source, since it rewrites about a hundred files. Also corrects the testing notes, which said tests should not call engineInit. That is no longer true now that manual step mode exists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c17fb9c commit 057e0e3

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ These instructions are for making changes in the LittleJS repo safely. Optimize
1111
- Make changes in `src/` (and `plugins/` when appropriate), then run the build.
1212
- **Match surrounding style.** Follow the conventions in the files you touch.
1313
- **Avoid breaking public APIs.** If a change could break users, call it out clearly and offer a compatible alternative.
14-
- **Keep agent-generated working files under `.claude/`.** `docs/` is the published JSDoc API site — do not write into it. Superpowers plans go in `.claude/superpowers/plans/` and specs in `.claude/superpowers/specs/` (overrides the skill defaults). The `.claude/` folder is gitignored.
14+
- **Keep agent-generated working files under `.claude/`.** `docs/` is the published JSDoc API site and is fully generated — never hand-edit it, and don't regenerate it unless asked (see Documentation below). Superpowers plans go in `.claude/superpowers/plans/` and specs in `.claude/superpowers/specs/` (overrides the skill defaults). The `.claude/` folder is gitignored.
1515

1616
If anything in this doc conflicts with the actual repo behavior, follow the repo behavior and update this doc.
1717

@@ -171,10 +171,22 @@ npm test
171171
```
172172

173173
- Tests target `dist/littlejs.esm.js` — rebuild with `npm run build` after changing source.
174-
- [test/setup.mjs](test/setup.mjs) stubs minimal DOM and enables headless mode. Tests shouldn't call `engineInit`, `render()`, or assume `time` advances.
174+
- [test/setup.mjs](test/setup.mjs) stubs minimal DOM and enables headless mode. Most tests shouldn't call `engineInit` or `render()`, or assume `time` advances — construct objects directly instead.
175+
- To test time-driven logic (timers, cooldowns, spawns), call `setEngineManualStep(true)` before `engineInit`, then advance with `engineStep(frames)`. See [test/engineStep.test.mjs](test/engineStep.test.mjs). Call `engineInit` once per file at module scope: `frame` and `time` are module globals and monotonic, and `node --test` gives each test file its own process.
175176
- Zero test dependencies — uses Node's built-in `node --test`. Match the style in [test/](test/) when adding new ones.
176177
- CI runs build + test on every push/PR ([.github/workflows/test.yml](.github/workflows/test.yml)).
177178

179+
### Documentation
180+
```bash
181+
npm run build-docs
182+
```
183+
184+
- Generates the JSDoc site into `docs/` from `src/` and `plugins/`, with `README.md` as the homepage. Tooling lives in [tools/](tools/).
185+
- **This is not part of the normal workflow — do not run it after editing source.** It takes ~17s, rewrites ~100 files, and produces a large diff. The docs do not need to be current on every change. The repo owner asks for it when they want it.
186+
- It is worth *suggesting* when a major feature or new plugin lands, after a significant rework, or before a release. A plugin that never gets regenerated never appears on the site at all — `textureSheet` and `threejs` were both missing from the published docs for exactly that reason.
187+
- CI does not run it. `jsdoc` and `clean-jsdoc-theme` are devDependencies.
188+
- jsdoc exits non-zero on the TypeScript-flavored JSDoc used across the engine (tuples like `[Vector2, Vector2, number]`, predicates like `a is Array<any>`) which it cannot parse but which `dist/littlejs.d.ts` needs for precise types. The script verifies the generated output instead of the exit code — don't "fix" those JSDoc types to silence the errors.
189+
178190
### Debug features
179191
- Press `Esc` to toggle debug overlay
180192
- Number keys toggle visualizations

0 commit comments

Comments
 (0)