Skip to content

♻️ Consume @deno/doc v2 natively + fix source-link off-by-one#1208

Closed
taras wants to merge 4 commits into
tm/1200-experimental-badgefrom
tm/deno-doc-native-v2
Closed

♻️ Consume @deno/doc v2 natively + fix source-link off-by-one#1208
taras wants to merge 4 commits into
tm/1200-experimental-badgefrom
tm/deno-doc-native-v2

Conversation

@taras

@taras taras commented Jul 5, 2026

Copy link
Copy Markdown
Member

Motivation

Third in a stack — on top of #1205 (which is on #1204). Review/merge those first.

The @deno/doc upgrade (#1204) kept the old flat-node shape alive with a compatibility adapter — type DocNode = Declaration & { name } plus a per-declaration name re-attachment — so the renderer never actually spoke v2's Symbol/Declaration model. This PR removes that shim and consumes v2 natively.

It also fixes a latent bug the upgrade introduced: @deno/doc v2 (≥0.195.0) changed Location.line from 1-indexed to 0-indexed (deno_doc #150/#777), but the "View code" links feed it straight into GitHub's 1-indexed #L<n> anchor — so every source link pointed one line above the symbol's declaration.

Approach

Two commits.

🐛 Fix off-by-one in "View code" source links — add + 1 where the GitHub #L anchor is built, in package.ts and package/node.ts. Verified: run is declared on source line 32 and the link now points to #L32 (was #L31, landing on the */ above it).

♻️ Drop the DocNode compatibility shim — consume v2's Symbol/Declaration directly:

  • DocPageSection.node: DocNodedeclaration: Declaration.
  • Render helpers take the owning symbol's identity via type SymbolInfo = Omit<Symbol, "declarations"> (a full Symbol is structurally assignable, so build-time code passes the real Symbol; render-time passes { name: page.name }). Signatures become extract(declaration, symbol), Type({ declaration, symbol }), exportHash(declaration, symbol, i).
  • Namespace members recurse over NamespaceDef.elements (real member Symbols) instead of synthesizing flat nodes.
  • DocPage.name is intentionally kept (many call sites read it); SymbolInfo flows only through the three render helpers.
  • Both docs paths updated: package.ts (API routes) and package/node.ts (the /x contrib packages).

No rendered-output change beyond the line-link fix — this is a structural refactor.

Validation

Ran the site locally: /api/v4/run, /api/v4/call, /api/v4-next/experimental/createApi (banner + 2 badges intact), and /api/v3/spawn render with full content; /x/websocket (3 source links) and /x/stream-helpers (25) exercise the package/node.ts path; the run source link verified at the correct line. deno fmt --check, deno lint, and deno check main.tsx pass.

…odel

Bumps `@deno/doc` 0.188.0 -> 0.199.0 and `@deno/graph` 0.89.0 -> 0.100.1, and
aligns the www CI job to Deno v2.9.1 (the only workflow still on 2.6.1; matches
#1202).

`@deno/doc` >= 0.195.0 replaced the flat v1 `DocNode[]` model with a v2
`Document`/`Symbol`/`Declaration` model, so the docs-rendering pipeline is
migrated accordingly:

- `doc()` now returns `Record<url, Document>`; `Document.symbols` group
  declarations by name. `DocNode` is redefined locally as `Declaration & {
  name }` in `use-deno-doc.tsx`, and `useDocPages` iterates `document.symbols`
  instead of `Object.groupBy`.
- `.def` replaces the per-kind def fields (`functionDef`/`classDef`/…);
  `ClassMethodDef.def`; every `TsType*Def` payload is renamed to `.value`;
  `NamespaceDef.elements` is now `Symbol[]`.
- `kind === "import"` checks dropped ("import" is no longer a `DocNodeKind`).
- `blog-image-route.ts`: cast for the newer `Uint8Array` lib type.

Note: `@deno/doc` 0.200.0-0.202.0 ship broken wasm bindings that fail to
instantiate under Deno (`__wbindgen_placeholder__`), so 0.199.0 is the newest
usable v2 release.
@pkg-pr-new

pkg-pr-new Bot commented Jul 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/effection@1208

commit: d028e36

taras added 3 commits July 4, 2026 23:00
Surface symbols exported from the package's `./experimental` entrypoint in the
API Reference section:

- `/api` index lists a stable release's experimental symbols inline with an
  "experimental" badge (none for 4.0.3 today; appears when a stable release
  exports `./experimental`). The prerelease's experimental APIs are reached via
  the "next" toggle / its symbol pages.
- Experimental symbol pages live at `/api/:series/experimental/:symbol` with an
  "Experimental" banner; the sidebar lists stable + experimental symbols with
  badges, resolving each link to the correct (flat vs namespaced) URL.
- Version toggle gains a "next" entry for the prerelease when it's newer than
  its stable parent and documents the current symbol; the active entry is
  derived from the page's own series.

The "experimental" signal is entrypoint membership (`DocPage.experimental`, set
in `package.ts`). Stable pages, older series, and search are unaffected.
`@deno/doc` v2 (>=0.195.0) changed `Location.line` from 1-indexed to 0-indexed
(deno_doc #150/#777). The GitHub `#L<n>` anchor is 1-indexed, so the source
links generated in package.ts / package/node.ts pointed one line above the
symbol's declaration. Add `+ 1`.
Removes the `DocNode = Declaration & { name }` compatibility adapter and the
`{ ...declaration, name }` re-attachment introduced during the v2 upgrade. The
renderer now consumes v2's model directly: a `DocPageSection` holds a raw
`Declaration`, and the render helpers receive the owning symbol's identity via
`type SymbolInfo = Omit<Symbol, "declarations">` — sourced from the real
`Symbol` at build time and from `{ name: page.name }` at render time.

- `extract(declaration, symbol)`, `Type({ declaration, symbol })`,
  `exportHash(declaration, symbol, i)`; `DocPageSection.node` → `declaration`.
- Namespace members recurse over `NamespaceDef.elements` (real member Symbols)
  instead of synthesizing flat nodes.
- `DocPage.name` is kept (many call sites read it); `SymbolInfo` flows only
  through the render helpers.
- Both docs paths updated (`package.ts` and the `/x` `package/node.ts`).

No rendered-output change (verified: API pages, experimental pages, and `/x`
contrib pages render identically).
@taras taras force-pushed the tm/1200-experimental-badge branch from 6c10c4a to 14ed918 Compare July 5, 2026 03:02
@taras taras force-pushed the tm/deno-doc-native-v2 branch from fc7cfe5 to d028e36 Compare July 5, 2026 03:02
@taras taras force-pushed the tm/1200-experimental-badge branch from 14ed918 to 42b8fb1 Compare July 5, 2026 03:23
@taras

taras commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

Folded into #1204 — the @deno/doc upgrade now migrates straight to the native v2 model (no intermediate DocNode shim), and the source-link off-by-one fix rides along. #1205 (experimental APIs) now stacks directly on #1204.

@taras taras closed this Jul 5, 2026
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