Skip to content

Overhaul example snippets - #6808

Merged
fubhy merged 5 commits into
mainfrom
doctest-snippets
Jul 31, 2026
Merged

Overhaul example snippets#6808
fubhy merged 5 commits into
mainfrom
doctest-snippets

Conversation

@fubhy

@fubhy fubhy commented Jul 31, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 31, 2026
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e0d5d52

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@effect/doctest Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-slopcop effect-slopcop Bot added the 4.0 label Jul 31, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ One rough edge in Chunk.ts — orphaned old-style output comments. Otherwise clean.

Reviewed changes — A systematic, mechanical overhaul of JSDoc example snippets across 173 files, standardizing output annotations to // > and making examples runnable as doctests. Also includes a small bugfix for SubscriptionRef.getAndUpdateEffect.

  • Output annotation standardization — All inline output comments now use // > prefix consistently (e.g. console.log(x) // > 42), replacing ad-hoc // 42 or bare // Output: 42 patterns.
  • Runnable examples — Many examples that previously only showed construction now also demonstrate execution via Effect.runSync or await Effect.runPromise, with verifiable output assertions.
  • Removed node:assert imports — Examples are converted to console.log-based output verification.
  • import.meta.vitest markers — Previously unmarked ts code fences are now annotated for doctest execution.
  • Simplified verbose examples — Long multi-worker examples (e.g. Fiber.interruptAll) reduced to essentials with Effect.never.
  • SubscriptionRef.getAndUpdateEffect fix — A changeset-documented bugfix with a companion test.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Comment thread packages/effect/src/Chunk.ts Outdated
Comment thread packages/effect/src/Chunk.ts Outdated
@fubhy
fubhy force-pushed the doctest-snippets branch from 3bb203c to 7542838 Compare July 31, 2026 07:40

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Four orphaned old-style output comments — the two from the prior review are still present, plus two new ones in DateTime.ts. Otherwise clean.

Reviewed changes — A force-push of the same mechanical JSDoc overhaul, now squashed into a single commit. The SubscriptionRef fix is corrected from Effect.sync to Effect.suspend inside the semaphore permit scope.

  • Output annotation standardization — All inline output comments converted to // > prefix, with node:assert patterns replaced by console.log-based verification.
  • SubscriptionRef.getAndUpdateEffect fix — Changed Effect.sync to Effect.suspend so the effectful update is evaluated lazily within the semaphore permit. A test and changeset accompany the fix.
  • Runnable examples — Examples now include import.meta.vitest markers and Effect.runSync/await Effect.runPromise execution. All Effect.runSync calls verified safe (no async service dependencies).

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Comment thread packages/effect/src/Chunk.ts Outdated
Comment thread packages/effect/src/Chunk.ts Outdated
Comment thread packages/effect/src/DateTime.ts Outdated
Comment thread packages/effect/src/DateTime.ts Outdated
@fubhy
fubhy force-pushed the doctest-snippets branch from 7542838 to 69cba85 Compare July 31, 2026 09:49
@effect-slopcop effect-slopcop Bot added the enhancement New feature or request label Jul 31, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — A force-push replacing // > console-output assertions with // => value-comparison assertions backed by AST transformation and Equal.equals semantics. Also addresses all six prior-review orphaned-comment threads.

  • Transform.ts — new AST-based assertion transform — A new 208-line module in @effect/doctest that parses each snippet with Rolldown, rewrites trailing // => comments into assertEquals(actual, expected) calls, and injects the import. Handles expression statements, single const declarations, indentation preservation, binding-name collision avoidance, and rejects unsupported constructs (standalone markers, let/var, unbraced control flow) with descriptive errors. Eight test cases cover the happy path and error paths.
  • Runtime.ts simplified — Console interception and // > wildcard logic removed. Replaced with a single assertEquals export that compares values using Equal.equals, falling back to assert.deepStrictEqual on mismatch for readable failure messages.
  • Source.ts — dropped expected field — No longer extracts // > markers; the Snippet interface now carries only source, line, and name.
  • Plugin.ts — pipes snippets through the transform — Each resolved snippet module now passes through transform() before being returned as source.
  • Example snippets (173 files) convertedconsole.log(x) // > value patterns replaced with x // => value where value assertions apply. Effect-based examples (SubscriptionRef, Cache, etc.) retain console.log(...) // > as visual annotations and are now execution-only tests.
  • SubscriptionRef.getAndUpdateEffect fixEffect.syncEffect.suspend so the effectful update is evaluated lazily within the semaphore permit scope. Accompanied by a test (getAndUpdateEffect) and a new changeset.
  • Documentation and conventions updated — AGENTS.md, .patterns/jsdoc.md, .agents/skills/jsdocs/SKILL.md, and the doctest README now describe // => assertion style and pnpm doctest --run <files> invocation.
  • All six prior Pullfrog threads resolved — Orphaned old-style output comments removed from Chunk.ts and DateTime.ts.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@fubhy
fubhy force-pushed the doctest-snippets branch from 69cba85 to 7f8dd59 Compare July 31, 2026 10:08

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ One minor suggestion inline — otherwise clean.

Reviewed changes — The incremental delta (dc0212b85619cf) fixes documentation generation for doctest examples, refactors process global accesses away from bare identifiers, and updates JSDoc snippet examples to be runnable.

  • Refactored process references to globalThis patterninternal/effect.ts and ConfigProvider.fromEnv now access process through explicit globalThis type casts instead of bare identifiers. Functionally equivalent; the IIFE/closure wrapping already guarded against bundler side-effect issues, and the new pattern is more explicit.
  • Replaced assert.deepStrictEqual with Equal.equals-based assertEqualsTestSchema.ts drops its node:assert import and uses a local assertEquals helper that compares via Equal.equals. All call sites (succeed, fail, verifyLosslessTransformation, Asserts.ast.fields/elements) updated consistently.
  • Made remaining JSDoc examples runnableClock.ts examples now include monotonicTimeNanosUnsafe/monotonicTimeNanos fields required by the Clock.Clock interface. ConfigProvider.ts examples converted to // => assertions. FastCheck.ts examples use deterministic { seed, numRuns } params. OtelMetrics.ts example switched to InMemoryMetricExporter so it runs without an external OTLP endpoint, and docgen.json gained ESNext.Disposable for Effect.scoped.
  • Prompt.ts examples made runnable — The Prompt.all example now wires up required services (Terminal, FileSystem, Path) via Prompt.succeed. A declare const process type declaration was added for InternalModule typings.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Comment thread packages/effect/src/testing/TestSchema.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — The incremental delta (7c2ad07e0d5d52) fixes cross-runtime test regressions introduced by the prior process refactoring and assertEquals helper.

  • Fixed monotonicNowNanos regression — The prior commit stored hrtime.bigint (the function) directly instead of wrapping it in () => processHrtime.bigint(), causing monotonicNowNanos() to return a function instead of a bigint. Fixed by capturing the hrtime object and restoring the call wrapper.
  • Refactored consolePretty to globalThis pattern — The one remaining bare process access in consolePretty now uses (globalThis as {...}).process, consistent with the rest of the file.
  • Reverted TestSchema.ts assertEquals helper — The custom Equal.equals-based assertion is removed and assert.deepStrictEqual restored, giving back rich diff output on mismatch. This directly addresses the prior review thread.
  • Added // => undefined annotations — Void-returning async doctest examples in TestSchema.ts now carry // => undefined annotations for doctest verification.
  • Added "types": ["node"] to docgen.json — Ensures process.hrtime types resolve during documentation generation.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.42 KB 9.42 KB 0.00 KB (0.00%)
brand.ts 6.31 KB 6.31 KB 0.00 KB (0.00%)
cache.ts 10.16 KB 10.18 KB -0.01 KB (-0.13%)
config.ts 20.04 KB 20.04 KB 0.00 KB (0.00%)
differ.ts 19.93 KB 19.93 KB 0.00 KB (0.00%)
http-client.ts 21.02 KB 21.03 KB -0.01 KB (-0.07%)
logger.ts 10.32 KB 10.34 KB -0.01 KB (-0.15%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.33 KB 7.33 KB 0.00 KB (0.00%)
pubsub.ts 14.46 KB 14.47 KB -0.01 KB (-0.10%)
queue.ts 11.13 KB 11.15 KB -0.02 KB (-0.14%)
schedule.ts 10.31 KB 10.33 KB -0.01 KB (-0.14%)
schema-class.ts 18.86 KB 18.86 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.67 KB 28.67 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.99 KB 24.99 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.99 KB 13.00 KB -0.01 KB (-0.11%)
schema-string.ts 10.65 KB 10.65 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.85 KB 14.85 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.66 KB 21.66 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.08 KB 24.08 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.91 KB 18.91 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.73 KB 18.73 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.59 KB 18.59 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.33 KB 22.33 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.25 KB 19.25 KB 0.00 KB (0.00%)
schema.ts 18.12 KB 18.12 KB 0.00 KB (0.00%)
stm.ts 12.11 KB 12.12 KB -0.02 KB (-0.16%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

@fubhy
fubhy merged commit 5335797 into main Jul 31, 2026
31 of 32 checks passed
@fubhy
fubhy deleted the doctest-snippets branch July 31, 2026 12:13
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant