Skip to content

docs: add TSDoc across public APIs and auto-publish TypeDoc site#5

Merged
kelsos merged 1 commit intomainfrom
docs/tsdoc-coverage
Apr 18, 2026
Merged

docs: add TSDoc across public APIs and auto-publish TypeDoc site#5
kelsos merged 1 commit intomainfrom
docs/tsdoc-coverage

Conversation

@kelsos
Copy link
Copy Markdown
Owner

@kelsos kelsos commented Apr 18, 2026

Summary

Two related changes landing together:

  1. TSDoc coverage on every exported function, type, and singleton in the library (109 blocks across 30 files, all 13 namespaces).
  2. TypeDoc site auto-published to GitHub Pages on every merge to main.

What consumers get

  • Hover tooltips in VS Code / JetBrains for every public API — descriptions, realistic domain examples, and edge-case notes.
  • Emitted .d.ts files carry the TSDoc forward, so downstream tooling (language servers, api-extractor, typedoc consumers) sees the same comments.
  • Searchable API reference site at https://kelsos.net/plainfp/ (inherits the user-level Pages custom domain on kelsos.github.io). Refreshes automatically on each merge.

TSDoc style choices

  • Imperative mood ("Transform the value…" not "Transforms…"). No "this function".
  • @example blocks only on user-facing functions; trivial type guards and obvious aliases get one-liner descriptions.
  • No @param / @returns that just restate the TS signature.
  • On overloaded functions the block sits on the first overload only; implementation signatures and internal helpers (isFn, sleep, run closures) are left undocumented.
  • Realistic domain values in examples (users, orders, payments) — no foo/bar/baz.

Edge cases explicitly documented

  • chunkRangeError on fractional/zero/negative sizes
  • minBy/maxByOption<T>, none on empty input
  • find/findIndex → return Option (replacing native undefined / -1)
  • fromZod → throws a wrapped error on async schemas; points at fromZodAsync
  • allWithConcurrency → swallows factory rejections (use fromPromise to preserve)
  • Records.get / getOr → own properties only, prototype chain is skipped
  • unique / uniqueBy → SameValueZero semantics (NaN=NaN, +0=-0)
  • tag → data cannot hijack _tag; Tagged<Tag, Data> omits _tag from Data

TypeDoc wiring

  • pnpm docs / pnpm docs:watch scripts
  • typedoc.json pins entry points (every subpath export), excludes private/internal, validates links
  • docs.yml workflow: build + deploy via actions/configure-pages + actions/upload-pages-artifact + actions/deploy-pages (SHA-pinned, tokenless OIDC, concurrency-guarded)
  • .gitignore excludes packages/*/docs/api/; vite.config.ts fmt+lint ignore the same path

Dist size impact

plainfp grows from 114 KB → 180 KB unminified. This is the cost of shipping TSDoc inline with the .d.ts files. Minified + gzipped size is roughly proportional. For a docs-heavy library this is worth it — consumers who care about raw size can use a bundler that strips comments at build.

No runtime code changed

Purely comments + config + new tooling wiring. All 177 tests still pass, typecheck clean, attw clean, publint clean.

Test plan

  • All required status checks pass
  • docs.yml deploys successfully on merge to main (first run establishes the Pages site)
  • https://kelsos.net/plainfp/ loads the API reference after merge
  • Hover tooltips in an IDE on plainfp imports show the TSDoc content (can verify locally: pnpm build && cd packages/plainfp/dist && ls *.d.ts)

Every exported function, type, and singleton in the library now has a
TSDoc block: concise imperative-mood descriptions, realistic domain
examples for user-facing functions (orders, users, HTTP, payments), and
explicit notes for edge cases (`chunk` RangeError, `minBy`/`maxBy` empty
behaviour, `fromZod` async-schema throw, `allWithConcurrency` rejection
semantics, `Records.get`/`getOr` own-property-only scope).

Covers all 13 namespaces: pipe, Result, ResultAsync, Option, Arrays,
Records, Strings, Predicates, Functions, Brand, NonEmptyArray, Tagged,
interop/zod. 109 TSDoc blocks total. On overloaded functions the block
sits on the first overload only; implementation signatures and internal
helpers (isFn, sleep, run closures) are left undocumented.

Wire TypeDoc for a generated API site:

- `pnpm docs` / `pnpm docs:watch` scripts run typedoc against every
  subpath entry point.
- `typedoc.json` config pins output to `packages/plainfp/docs/api`,
  excludes private/internal, validates missing/invalid links.
- `.github/workflows/docs.yml` builds and deploys to GitHub Pages on
  every push to main via the standard actions/deploy-pages flow
  (actions pinned by SHA, tokenless via OIDC).
- `vite.config.ts` fmt + lint now ignore `docs/api/**` so generated
  HTML does not trip formatter/linter.
- `.gitignore` excludes `packages/*/docs/api/`.

Adds a docs badge pointing at https://kelsos.net/plainfp/ (inherits the
user-level Pages custom domain on kelsos.github.io).

Consumers now get hover tooltips in editors everywhere, the emitted
.d.ts files carry the docs forward for downstream tooling, and a
searchable API reference site publishes automatically on every merge.
Dist grows 114 KB to 180 KB unminified (the cost of shipping the
documentation inline with the types).

No runtime code changed.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.41%. Comparing base (ea43477) to head (377d35d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #5   +/-   ##
=======================================
  Coverage   86.41%   86.41%           
=======================================
  Files          20       20           
  Lines         346      346           
  Branches       71       71           
=======================================
  Hits          299      299           
  Misses         19       19           
  Partials       28       28           
Flag Coverage Δ
unittests 86.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/plainfp/src/arrays/aggregate.ts 85.00% <ø> (ø)
packages/plainfp/src/arrays/group.ts 100.00% <ø> (ø)
packages/plainfp/src/arrays/search.ts 94.11% <ø> (ø)
packages/plainfp/src/arrays/transform.ts 100.00% <ø> (ø)
packages/plainfp/src/arrays/unique.ts 100.00% <ø> (ø)
packages/plainfp/src/option/constructors.ts 100.00% <ø> (ø)
packages/plainfp/src/option/transform.ts 66.66% <ø> (ø)
packages/plainfp/src/option/unwrap.ts 83.33% <ø> (ø)
packages/plainfp/src/pipe.ts 100.00% <ø> (ø)
packages/plainfp/src/records/access.ts 100.00% <ø> (ø)
... and 10 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 18, 2026

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing docs/tsdoc-coverage (377d35d) with main (ea43477)

Open in CodSpeed

@kelsos kelsos merged commit 377d35d into main Apr 18, 2026
11 checks passed
@kelsos kelsos deleted the docs/tsdoc-coverage branch April 18, 2026 15:17
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