Skip to content

fix(npm): normalize JSDoc comments at the package boundary - #107

Merged
byteland-app merged 4 commits into
mainfrom
stitch/transform-package-jsdoc-comments-jm0-a8ce0928-7302-4de8-a8e8-890d10e61d1b
Nov 26, 2026
Merged

byteland-app merged 4 commits into
mainfrom
stitch/transform-package-jsdoc-comments-jm0-a8ce0928-7302-4de8-a8e8-890d10e61d1b

Conversation

@google-labs-stitch

@google-labs-stitch google-labs-stitch Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request normalizes JSDoc comments in the generated WebAssembly package (pkg/tunelet.d.ts and pkg/tunelet.js) while keeping native Rust documentation and crate lints unchanged.

  • Update begin_drain and drain_mono in src/wasm.rs to state drain completion and mono downmix rules directly without self-references (with mono peak feedback and telemetry measured after the downmix), and state that defaultConfig throws a JavaScript Error on failure.
  • Chain node scripts/postbuild-wasm.mjs && node scripts/normalize-jsdoc.mjs in npm run build:wasm (and export idempotent normalizeJsDoc with line-ending and /// <reference lib="esnext.disposable" /> preservation so both post-build scripts commute cleanly) to convert # Errors headings into @throws JSDoc tags and translate Rust intra-doc links (including all ControlActivity links from #135 and f32 Processor links for #117), :: symbol paths, None optional absence descriptions, Default / u8 / Self::validate remarks, snake_case field names (max_frequency_hz, min_frequency_hz, stereo_output, retune_ms, attack_ms, gain_db, ceiling_db), and backticked or unbackticked ..= inclusive ranges (including spaced fractional bounds and 0..=maxBlockFrames for #84/#117) into idiomatic TypeScript documentation.
  • Extend scripts/verify-pack.mjs across both the tunelet and @bytelandtechnology/tunelet archives (alongside HTTP Wasm loader checks from #105 and strict TypeScript consumer profiles from #123) to check all packed JSDoc blocks in dist/ and pkg/ for clean TypeScript documentation, throwsCount >= 14 plus signature-based @throws checks on each core fallible entry point (including controlActivity), normalized ControlActivity interface and field JSDoc, normalizeJsDoc idempotence and esnext.disposable header preservation, and complete latencyFrames, beginDrain, and drainMono descriptions.

Accessibility and Documentation Verification

  • cargo fmt --check, cargo clippy --locked --lib -- -D warnings, cargo build --locked --release, RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps, and cargo package --locked pass with zero warnings.
  • RUSTDOCFLAGS="-D warnings" npm run check:wasm and npm run verify:pack pass across both unscoped and scoped 0.3.4 archives with zero warnings.
  • Automated headless Chromium DOM checks across simulated localized guides (.twoslash-popup-docs hover popups) and the TypeScript API reference view confirm one page <h1>, zero popup <h1> elements (WCAG 2.2 SC 1.3.1, SC 2.4.6), zero plain <p>Errors</p> labels, and zero leaked ::, ..=, or None tokens.

Normalized TypeScript JSDoc output in Twoslash hover popups and API reference


Automated PR initiated by user @byteland-app via Stitch Loop.

- Explain drain completion and mono downmix directly in src/wasm.rs
- State that defaultConfig throws a JavaScript Error on failure
- Convert Rustdoc # Errors lines to JSDoc @throws tags in pkg/
- Translate Rust paths, None values and ..= ranges for TypeScript
- Check normalized JSDoc comments in scripts/verify-pack.mjs
@byteland-app

Copy link
Copy Markdown
Contributor

Review: High-value JSDoc normalization that fixes raw rustdoc leakage in IDEs and downstream Twoslash docs. Please make two small adjustments:

  1. Relax assert.equal(throwsCount, 13) in scripts/verify-pack.mjs to a >= check (or signature-based check) so adding new methods (feat: add f32 audio and drain methods to Processor and Tunelet #84/feat: expose Float32 buffers in Wasm for in-place audio #117) does not break it.
  2. Coordinate with fix(wasm): sanitize TypeScript declarations and Wasm exports #123 so normalize-jsdoc.mjs and postbuild-wasm.mjs run cleanly together in build:wasm.

- Update drainMono docs for mono peak measurements after downmix
- Translate gain_db and ceiling_db in scripts/normalize-jsdoc.mjs
- Export normalizeJsDoc in scripts/normalize-jsdoc.mjs
- Check JSDoc comments for both archives in scripts/verify-pack.mjs
- Allow 13 or more @throws tags in scripts/verify-pack.mjs
- Map the f32 intra-doc links in scripts/normalize-jsdoc.mjs
- Convert backticked and named ..= ranges in scripts/normalize-jsdoc.mjs
- Check @throws tags on each fallible signature in verify-pack.mjs
- Check normalizeJsDoc idempotence with the esnext.disposable header
- Move the JSDoc checks after verifyPackedArchive in verify-pack.mjs
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Addressed both adjustments in 40f4667 and 041b5db:

  1. Relaxed @throws verification & #84/#117 compatibility (scripts/verify-pack.mjs, scripts/normalize-jsdoc.mjs): Replaced assert.equal(throwsCount, 13) with throwsCount >= 13 paired with per-signature @throws checks on the 13 core fallible entry points, so adding new throwing methods in #84 or #117 passes without changing existing assertions. Also updated scripts/normalize-jsdoc.mjs to normalize backticked, spaced-fractional, and symbolic ..= bounds (such as `-32767 / 32768..=32767 / 32768` and `0..=maxBlockFrames`) and [Processor] / f32 intra-doc links introduced by #84 and #117.
  2. Coordinated build:wasm composition with #123 (scripts/normalize-jsdoc.mjs, scripts/verify-pack.mjs): Merged main (0.3.3 / dual-archive verify-pack.mjs), kept fs.rmSync('pkg/.gitignore', { force: true }) idempotent, and exported idempotent normalizeJsDoc with CRLF and top-level /// <reference lib="esnext.disposable" /> preservation while leaving all wasm-bindgen declaration anchors untouched—so chaining node scripts/postbuild-wasm.mjs && node scripts/normalize-jsdoc.mjs (in either order) in build:wasm commutes byte-for-byte. Also placed the JSDoc helpers after verifyPackedArchive in scripts/verify-pack.mjs to avoid diff hunk overlap with #123, #84, and #117.

@byteland-app

Copy link
Copy Markdown
Contributor

Round 2 review: Approved — relaxed throwsCount check and esnext.disposable idempotency look great. Please rebase onto updated main after #105, #123, and #135:

  1. Chain postbuild-wasm.mjs and normalize-jsdoc.mjs together in package.json build:wasm.
  2. Add EXACT_REPLACEMENTS entries in scripts/normalize-jsdoc.mjs for the new rustdoc links introduced by ControlActivity (feat: add control activity queries #135).

- Merge main with #105, #123 and #135 into the branch.
- Run postbuild-wasm.mjs before normalize-jsdoc.mjs in build:wasm.
- Convert ControlActivity rustdoc links into TypeScript names.
- Check the ControlActivity JSDoc and @throws tag in verify-pack.mjs.
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Addressed both items on updated main (0.3.4, after #105, #123, and #135) in debee18:

  1. Chained Wasm post-build scripts (package.json): Merged main and chained node scripts/postbuild-wasm.mjs && node scripts/normalize-jsdoc.mjs in scripts["build:wasm"] while preserving .wasm subpath exports (#123), HTTP Wasm loader checks (#105), and strict multi-profile TypeScript checks (#123).
  2. Normalized ControlActivity (#135) JSDoc (scripts/normalize-jsdoc.mjs, scripts/verify-pack.mjs): Added EXACT_REPLACEMENTS entries for all ControlActivity rustdoc links ([ProcessorConfig], [ProcessorConfig::control_activity], [crate::Processor::control_activity], [Processor::control_activity], [ControlActivity], all five ResynthesisConfig::* links, all twelve crate::HarmonyConfig::* links, and all five ReverbConfig::* links) plus PROSE_REPLACEMENTS handling for ControlActivity's ProcessorConfig::control_activity and Default trait prose, and added controlActivity @throws and ControlActivity interface assertions in scripts/verify-pack.mjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant