Skip to content

📖🔧:make the API examples run as written - #120

Open
DerekNonGeneric wants to merge 1 commit into
mainfrom
claude/project-thread-9bivk4
Open

DerekNonGeneric wants to merge 1 commit into
mainfrom
claude/project-thread-9bivk4

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Requested by DerekNonGeneric

Before: 24 examples in the API reference opened with import util from '@openinf/util'. The package has no default export, so copying any of them failed on the first line (does not provide an export named 'default' under ESM, TS1192 in TypeScript). Examples documented in util-core, util-number, util-date, util-object and util-types imported through @openinf/util's re-exports, so they only worked if you had also installed @openinf/util. The isAsyncGenerator example threw (new on something that is not a constructor), isBigIntObject() was called with no argument, and cross-package links rendered as @openinf/util!Comparable, with the isIterator → isIterable link not resolving from @openinf/util at all (a TypeDoc warning).

After: every example imports the names it calls from the package that defines them (isNull from @openinf/util-core, isInt32 from @openinf/util-number, and so on). The and example in util-core takes isPositive from @openinf/util-number, because util-core has no such guard. The two broken examples run and their ↪ results hold, and cross-package links read as the name they point to. TypeDoc's link warning is gone.

How: the imports were rewritten by a script that looks up which package's src defines each name. Every ts example under packages/*/src was then compiled against the built declarations and its ↪ claims run, the way lint:examples does for READMEs. What still fails there is illustrative on purpose (the branding example's deliberate type error, DOM and Temporal examples). Rebased onto main now that sdk#121 has landed, so or(isNull, isUndefined) compiles too. A patch changeset covers the shipped declarations.

Summary by CodeRabbit

  • Documentation
    • Updated API reference examples across utility packages to import functions and types from the packages that provide them, with expected results unchanged.
    • Corrected examples with invalid or missing inputs, including bigint checks and async generator guards.
    • Improved cross-package links so referenced types and guards display clear names.
    • Clarified the async generator example by contrasting a generator with its function.

@DerekNonGeneric DerekNonGeneric self-assigned this Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: ab1f24fd-7b0d-45fb-b447-f535b589219b
📥 Commits

Reviewing files that changed from the base of the PR and between 84ef916 and 234a52f.

📒 Files selected for processing: 31
  • .changeset/examples-that-run.md
  • packages/util-core/src/guards/and.ts
  • packages/util-core/src/guards/has-interface.ts
  • packages/util-core/src/guards/is-array.ts
  • packages/util-core/src/guards/is-big-int.ts
  • packages/util-core/src/guards/is-boolean.ts
  • packages/util-core/src/guards/is-defined.ts
  • packages/util-core/src/guards/is-function.ts
  • packages/util-core/src/guards/is-non-nullish.ts
  • packages/util-core/src/guards/is-null.ts
  • packages/util-core/src/guards/is-nullish.ts
  • packages/util-core/src/guards/is-number.ts
  • packages/util-core/src/guards/is-object.ts
  • packages/util-core/src/guards/is-primitive.ts
  • packages/util-core/src/guards/is-string.ts
  • packages/util-core/src/guards/is-symbol.ts
  • packages/util-core/src/guards/is-undefined.ts
  • packages/util-core/src/guards/or.ts
  • packages/util-core/src/types.ts
  • packages/util-date/src/guards/is-valid-date.ts
  • packages/util-number/src/guards/is-finite-number.ts
  • packages/util-number/src/guards/is-int32.ts
  • packages/util-number/src/guards/is-integer.ts
  • packages/util-number/src/guards/is-nan.ts
  • packages/util-number/src/guards/is-negative-integer.ts
  • packages/util-number/src/guards/is-negative.ts
  • packages/util-number/src/guards/is-positive-integer.ts
  • packages/util-number/src/guards/is-positive.ts
  • packages/util-number/src/guards/is-uint32.ts
  • packages/util-object/src/guards/is-error.ts
  • packages/util-types/src/guards/is-iterator.ts
🚧 Files skipped from review as they are similar to previous changes: 23
  • packages/util-number/src/guards/is-negative.ts
  • packages/util-types/src/guards/is-iterator.ts
  • packages/util-core/src/guards/is-defined.ts
  • packages/util-core/src/guards/is-array.ts
  • packages/util-core/src/guards/is-null.ts
  • packages/util-core/src/guards/is-non-nullish.ts
  • packages/util-number/src/guards/is-positive.ts
  • packages/util-core/src/guards/is-big-int.ts
  • packages/util-number/src/guards/is-negative-integer.ts
  • packages/util-number/src/guards/is-nan.ts
  • packages/util-core/src/guards/is-string.ts
  • packages/util-core/src/guards/is-nullish.ts
  • packages/util-core/src/guards/is-object.ts
  • packages/util-number/src/guards/is-positive-integer.ts
  • packages/util-number/src/guards/is-finite-number.ts
  • packages/util-core/src/guards/is-function.ts
  • packages/util-core/src/guards/is-primitive.ts
  • packages/util-core/src/guards/is-undefined.ts
  • packages/util-object/src/guards/is-error.ts
  • .changeset/examples-that-run.md
  • packages/util-core/src/guards/is-symbol.ts
  • packages/util-core/src/guards/is-number.ts
  • packages/util-core/src/guards/is-boolean.ts

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📝 Walkthrough

The pull request updates guard API reference examples to use package-specific named imports, corrects two example cases, qualifies cross-package documentation links, and adds a patch changeset for seven packages.

Changes: API Reference Documentation

Layer / File(s) Summary
Named-import examples and iterator export
packages/util-core/src/guards/*, packages/util-core/src/types.ts, packages/util-date/src/guards/is-valid-date.ts, packages/util-number/src/guards/*, packages/util-object/src/guards/is-error.ts, packages/util-types/src/guards/is-iterator.ts, packages/util/src/guards/*, packages/util/src/index.ts
Guard examples use named imports from the packages that define the referenced APIs. The isIterator re-export remains unchanged and gains a comment explaining why util-types is not re-exported in full.
Example input corrections
packages/util-number/src/guards/is-big-int-object.ts, packages/util-types/src/guards/is-async-generator.ts
The BigInt object example passes 1n. The async generator example checks an instance and contrasts it with the generator function.
Qualified documentation links and release note
packages/assert/src/guards/*, packages/util-types/src/guards/is-iterator.ts, .changeset/examples-that-run.md
Cross-package links now name their package or symbol targets. The changeset declares patch releases for seven packages and describes the example and link updates.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 234a5

The changes update API examples and documentation links without an identified behavior issue. No merge-blocking risk remains beyond normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 42 files. (1 skipped: …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: making the API reference examples run as written. The emojis add minor noise but do not make the title unclear or unrelated.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Twenty-four examples in the API reference opened with
`import util from '@openinf/util'`. The package has no default export,
so the first line of each failed, under ESM and in TypeScript alike.

The examples in util-core, util-number, util-date, util-object and
util-types also imported through @openinf/util's re-exports, so they
only worked for someone who had installed util as well. Every example
now imports from the package that defines what it calls. The `and`
example takes isPositive from util-number, since util-core has none.

Two more could not run at all. The isAsyncGenerator example called
`new` on the prototype of an async generator function, which is not a
constructor, and the isBigIntObject example called the guard with no
argument, which TypeScript rejects.

Links from one package's reference to another's rendered with the
package prefix as their text, and the isIterator link to isIterable did
not resolve from @openinf/util at all. They now name what they point to.

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
@DerekNonGeneric
DerekNonGeneric force-pushed the claude/project-thread-9bivk4 branch from 84ef916 to 234a52f Compare October 13, 2026 21:12
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