Skip to content

Commit d74b4a5

Browse files
committed
⬆️ Upgrade @deno/doc to 0.199.0 and migrate docs pipeline to v2
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 (matches #1202). `@deno/doc` >= 0.195.0 replaced the flat v1 `DocNode[]` model with the v2 `Document`/`Symbol`/`Declaration` model. The docs-rendering pipeline is migrated to consume it natively: - `doc()` returns `Record<url, Document>`; `Document.symbols` group declarations by name. `DocPageSection` holds a raw `Declaration`; render helpers receive the owning symbol via `type SymbolInfo = Omit<Symbol, "declarations">` (`extract(declaration, symbol)`, `Type({ declaration, symbol })`, `exportHash(declaration, symbol, i)`). - `.def` replaces the per-kind def fields; `ClassMethodDef.def`; every `TsType*Def` payload is `.value`; namespace members recurse over `NamespaceDef.elements` (member Symbols). - `kind === "import"` checks dropped; `Uint8Array` cast in blog-image-route.ts. 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.
1 parent 56af00f commit d74b4a5

11 files changed

Lines changed: 230 additions & 200 deletions

File tree

.github/workflows/www.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Deno
2727
uses: denoland/setup-deno@v2
2828
with:
29-
deno-version: v2.6.1
29+
deno-version: v2.9.1
3030

3131
- name: Serve Website
3232
run: |

www/components/api/api-page.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function* ApiPage({
3535
method,
3636
) {
3737
const target = pages &&
38-
pages.find((page) => page.name === symbol && page.kind !== "import");
38+
pages.find((page) => page.name === symbol);
3939

4040
if (target) {
4141
return `[${
@@ -123,14 +123,17 @@ export function* ApiBody({
123123
<h2
124124
class="my-0! grow"
125125
id={section.id}
126-
data-kind={section.node.kind}
127-
data-name={section.node.name}
126+
data-kind={section.declaration.kind}
127+
data-name={page.name}
128128
>
129-
{yield* Type({ node: section.node })}
129+
{yield* Type({
130+
declaration: section.declaration,
131+
symbol: { name: page.name },
132+
})}
130133
</h2>
131134
<a
132135
class="opacity-40 before:content-['View_code'] group-hover:opacity-100 before:flex before:text-xs before:mr-1 p-2 flex-none flex rounded no-underline items-center h-8"
133-
href={`${section.node.location.url}`}
136+
href={`${section.declaration.location.url}`}
134137
>
135138
<SourceCodeIcon />
136139
</a>

www/components/package/exports.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function* PackageExports({
2020
let elements: JSXElement[] = [];
2121

2222
for (let [exportName, docPages] of Object.entries(docs)) {
23-
if (docPages.filter((page) => page.kind !== "import").length > 0) {
23+
if (docPages.length > 0) {
2424
elements.push(
2525
yield* PackageExport({
2626
linkResolver,
@@ -51,8 +51,7 @@ function* PackageExport({
5151
let exports: JSXChild[] = [];
5252

5353
for (
54-
let page of docPages
55-
.flatMap((page) => (page.kind === "import" ? [] : [page]))
54+
let page of [...docPages]
5655
.sort((a, b) => a.name.localeCompare(b.name))
5756
) {
5857
exports.push(

www/components/type/jsx.tsx

Lines changed: 70 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { JSXElement } from "revolution/jsx-runtime";
22
import { type Operation } from "effection";
33
import type {
4-
DocNode,
4+
Declaration,
55
ParamDef,
66
TsTypeDef,
77
TsTypeParamDef,
88
TsTypeRefDef,
99
VariableDef,
1010
} from "@deno/doc";
11+
import type { SymbolInfo } from "../../hooks/use-deno-doc.tsx";
1112
import {
1213
Builtin,
1314
ClassName,
@@ -18,51 +19,53 @@ import {
1819
} from "./tokens.tsx";
1920

2021
interface TypeProps {
21-
node: DocNode;
22+
declaration: Declaration;
23+
symbol: SymbolInfo;
2224
}
2325

2426
export function* Type(props: TypeProps): Operation<JSXElement> {
25-
let { node } = props;
27+
// `node` aliases the declaration; `symbol` supplies the name.
28+
let { declaration: node, symbol } = props;
2629

2730
switch (node.kind) {
28-
case "function":
31+
case "function": {
32+
let typeParams = node.def.typeParams ?? [];
2933
return (
3034
<span class="language-ts code-highlight inline-block">
31-
{node.functionDef.isAsync
32-
? <Punctuation>{"async "}</Punctuation>
33-
: <></>}
35+
{node.def.isAsync ? <Punctuation>{"async "}</Punctuation> : <></>}
3436
<Keyword>{node.kind}</Keyword>
35-
{node.functionDef.isGenerator ? <Punctuation>*</Punctuation> : <></>}
36-
{" "}
37-
<span class="token function">{node.name}</span>
38-
{node.functionDef.typeParams.length > 0
39-
? <InterfaceTypeParams typeParams={node.functionDef.typeParams} />
37+
{node.def.isGenerator ? <Punctuation>*</Punctuation> : <></>}{" "}
38+
<span class="token function">{symbol.name}</span>
39+
{typeParams.length > 0
40+
? <InterfaceTypeParams typeParams={typeParams} />
4041
: <></>}
4142
<Punctuation>(</Punctuation>
42-
<FunctionParams params={node.functionDef.params} />
43-
<Punctuation>)</Punctuation>: {node.functionDef.returnType
44-
? <TypeDef typeDef={node.functionDef.returnType} />
43+
<FunctionParams params={node.def.params} />
44+
<Punctuation>)</Punctuation>: {node.def.returnType
45+
? <TypeDef typeDef={node.def.returnType} />
4546
: <></>}
4647
</span>
4748
);
48-
case "class":
49+
}
50+
case "class": {
51+
let impl /* implements */ = node.def.implements ?? [];
4952
return (
5053
<span class="language-ts code-highlight inline-block">
51-
<Keyword>{node.kind}</Keyword> <ClassName>{node.name}</ClassName>
52-
{node.classDef.extends
54+
<Keyword>{node.kind}</Keyword> <ClassName>{symbol.name}</ClassName>
55+
{node.def.extends
5356
? (
5457
<>
5558
<Keyword>{" extends "}</Keyword>
56-
<ClassName>{node.classDef.extends}</ClassName>
59+
<ClassName>{node.def.extends}</ClassName>
5760
</>
5861
)
5962
: <></>}
60-
{node.classDef.implements
63+
{impl.length > 0
6164
? (
6265
<>
6366
<Keyword>{" implements "}</Keyword>
6467
<>
65-
{node.classDef.implements
68+
{impl
6669
.flatMap((typeDef) => [<TypeDef typeDef={typeDef} />, ", "])
6770
.slice(0, -1)}
6871
</>
@@ -71,19 +74,22 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
7174
: <></>}
7275
</span>
7376
);
74-
case "interface":
77+
}
78+
case "interface": {
79+
let typeParams = node.def.typeParams ?? [];
80+
let ext = node.def.extends ?? [];
7581
return (
7682
<span class="language-ts code-highlight inline-block">
77-
<Keyword>{node.kind}</Keyword> <ClassName>{node.name}</ClassName>
78-
{node.interfaceDef.typeParams.length > 0
79-
? <InterfaceTypeParams typeParams={node.interfaceDef.typeParams} />
83+
<Keyword>{node.kind}</Keyword> <ClassName>{symbol.name}</ClassName>
84+
{typeParams.length > 0
85+
? <InterfaceTypeParams typeParams={typeParams} />
8086
: <></>}
81-
{node.interfaceDef.extends.length > 0
87+
{ext.length > 0
8288
? (
8389
<>
8490
<Keyword>{" extends "}</Keyword>
8591
<>
86-
{node.interfaceDef.extends
92+
{ext
8793
.flatMap((typeDef) => [<TypeDef typeDef={typeDef} />, ", "])
8894
.slice(0, -1)}
8995
</>
@@ -92,30 +98,29 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
9298
: <></>}
9399
</span>
94100
);
101+
}
95102
case "variable":
96103
return (
97104
<span class="inline-block">
98-
<TSVariableDef variableDef={node.variableDef} name={node.name} />
105+
<TSVariableDef variableDef={node.def} name={symbol.name} />
99106
</span>
100107
);
101108
case "typeAlias":
102109
return (
103110
<span class="inline-block">
104111
<Keyword>{"type "}</Keyword>
105-
{node.name}
112+
{symbol.name}
106113
<Operator>{" = "}</Operator>
107-
<TypeDef typeDef={node.typeAliasDef.tsType} />
114+
<TypeDef typeDef={node.def.tsType} />
108115
</span>
109116
);
110117
case "enum":
111-
case "import":
112-
case "moduleDoc":
113118
case "namespace":
114119
default:
115120
console.log("<Type> unimplemented", node.kind);
116121
return (
117122
<span class="inline-block">
118-
<Keyword>{node.kind}</Keyword> {node.name}
123+
<Keyword>{node.kind}</Keyword> {symbol.name}
119124
</span>
120125
);
121126
}
@@ -187,51 +192,51 @@ function TSParam({ param }: { param: ParamDef }) {
187192
export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
188193
switch (typeDef.kind) {
189194
case "literal":
190-
switch (typeDef.literal.kind) {
195+
switch (typeDef.value.kind) {
191196
case "string":
192-
return <span class="token string">"{typeDef.repr}"</span>;
197+
return <span class="token string">"{typeDef.repr ?? ""}"</span>;
193198
case "number":
194-
return <span class="token number">{typeDef.repr}</span>;
199+
return <span class="token number">{typeDef.repr ?? ""}</span>;
195200
case "boolean":
196-
return <span class="token boolean">{typeDef.repr}</span>;
201+
return <span class="token boolean">{typeDef.repr ?? ""}</span>;
197202
case "bigInt":
198-
return <span class="token number">{typeDef.repr}</span>;
203+
return <span class="token number">{typeDef.repr ?? ""}</span>;
199204
default:
200205
// TODO(taras): implement template
201206
return <></>;
202207
}
203208
case "keyword":
204-
if (["number", "string", "boolean", "bigint"].includes(typeDef.keyword)) {
205-
return <Builtin>{typeDef.keyword}</Builtin>;
209+
if (["number", "string", "boolean", "bigint"].includes(typeDef.value)) {
210+
return <Builtin>{typeDef.value}</Builtin>;
206211
} else {
207-
return <Keyword>{typeDef.keyword}</Keyword>;
212+
return <Keyword>{typeDef.value}</Keyword>;
208213
}
209214
case "typeRef":
210-
return <TypeRef typeRef={typeDef.typeRef} />;
215+
return <TypeRef typeRef={typeDef.value} />;
211216
case "union":
212-
return <TypeDefUnion union={typeDef.union} />;
217+
return <TypeDefUnion union={typeDef.value} />;
213218
case "fnOrConstructor":
214-
if (typeDef.fnOrConstructor.constructor) {
215-
console.log(`<TypeDef> unimplemeneted`, typeDef.fnOrConstructor);
219+
if (typeDef.value.constructor) {
220+
console.log(`<TypeDef> unimplemeneted`, typeDef.value);
216221
// TODO(taras): implement
217222
return <></>;
218223
} else {
219224
return (
220225
<>
221226
<Punctuation>(</Punctuation>
222-
<FunctionParams params={typeDef.fnOrConstructor.params} />
227+
<FunctionParams params={typeDef.value.params} />
223228
<Punctuation>)</Punctuation>
224229
<Operator>{" => "}</Operator>
225-
<TypeDef typeDef={typeDef.fnOrConstructor.tsType} />
230+
<TypeDef typeDef={typeDef.value.tsType} />
226231
</>
227232
);
228233
}
229234
case "indexedAccess":
230235
return (
231236
<>
232-
<TypeDef typeDef={typeDef.indexedAccess.objType} />
237+
<TypeDef typeDef={typeDef.value.objType} />
233238
<Punctuation>[</Punctuation>
234-
<TypeDef typeDef={typeDef.indexedAccess.indexType} />
239+
<TypeDef typeDef={typeDef.value.indexType} />
235240
<Punctuation>]</Punctuation>
236241
</>
237242
);
@@ -240,7 +245,7 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
240245
<>
241246
<Punctuation>[</Punctuation>
242247
<>
243-
{typeDef.tuple
248+
{typeDef.value
244249
.flatMap((tp) => [<TypeDef typeDef={tp} />, ", "])
245250
.slice(0, -1)}
246251
</>
@@ -250,30 +255,30 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
250255
case "array":
251256
return (
252257
<>
253-
<TypeDef typeDef={typeDef.array} />
258+
<TypeDef typeDef={typeDef.value} />
254259
<Punctuation>[]</Punctuation>
255260
</>
256261
);
257262
case "typeOperator":
258263
return (
259264
<>
260-
<Keyword>{typeDef.typeOperator.operator}</Keyword>{" "}
261-
<TypeDef typeDef={typeDef.typeOperator.tsType} />
265+
<Keyword>{typeDef.value.operator}</Keyword>{" "}
266+
<TypeDef typeDef={typeDef.value.tsType} />
262267
</>
263268
);
264269
case "parenthesized": {
265270
return (
266271
<>
267272
<Punctuation>(</Punctuation>
268-
<TypeDef typeDef={typeDef.parenthesized} />
273+
<TypeDef typeDef={typeDef.value} />
269274
<Punctuation>)</Punctuation>
270275
</>
271276
);
272277
}
273278
case "intersection": {
274279
return (
275280
<>
276-
{typeDef.intersection
281+
{typeDef.value
277282
.flatMap((tp) => [
278283
<TypeDef typeDef={tp} />,
279284
<Operator>{" & "}</Operator>,
@@ -294,37 +299,37 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
294299
case "conditional": {
295300
return (
296301
<>
297-
<TypeDef typeDef={typeDef.conditionalType.checkType} />
302+
<TypeDef typeDef={typeDef.value.checkType} />
298303
<Keyword>{" extends "}</Keyword>
299-
<TypeDef typeDef={typeDef.conditionalType.extendsType} />
304+
<TypeDef typeDef={typeDef.value.extendsType} />
300305
<Operator>{" ? "}</Operator>
301-
<TypeDef typeDef={typeDef.conditionalType.trueType} />
306+
<TypeDef typeDef={typeDef.value.trueType} />
302307
<Operator>{" : "}</Operator>
303-
<TypeDef typeDef={typeDef.conditionalType.falseType} />
308+
<TypeDef typeDef={typeDef.value.falseType} />
304309
</>
305310
);
306311
}
307312
case "infer": {
308313
return (
309314
<>
310315
<Keyword>{"infer "}</Keyword>
311-
{typeDef.infer.typeParam.name}
316+
{typeDef.value.typeParam.name}
312317
</>
313318
);
314319
}
315320
case "mapped":
316321
return (
317322
<>
318323
<Punctuation>[</Punctuation>
319-
{typeDef.mappedType.typeParam.name}
324+
{typeDef.value.typeParam.name}
320325
<Keyword>{` in `}</Keyword>
321-
{typeDef.mappedType.typeParam.constraint
322-
? <TypeDef typeDef={typeDef.mappedType.typeParam.constraint} />
326+
{typeDef.value.typeParam.constraint
327+
? <TypeDef typeDef={typeDef.value.typeParam.constraint} />
323328
: <></>}
324329
<Punctuation>]</Punctuation>
325330
<Operator>{" : "}</Operator>
326-
{typeDef.mappedType.tsType
327-
? <TypeDef typeDef={typeDef.mappedType.tsType} />
331+
{typeDef.value.tsType
332+
? <TypeDef typeDef={typeDef.value.tsType} />
328333
: <></>}
329334
</>
330335
);

0 commit comments

Comments
 (0)