Skip to content

Commit 3cecf91

Browse files
committed
⬆️ Upgrade @deno/doc to 0.199.0 and migrate docs pipeline to the v2 model
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.
1 parent 56af00f commit 3cecf91

9 files changed

Lines changed: 175 additions & 157 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: 1 addition & 1 deletion
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 `[${

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: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { JSXElement } from "revolution/jsx-runtime";
22
import { type Operation } from "effection";
33
import type {
4-
DocNode,
54
ParamDef,
65
TsTypeDef,
76
TsTypeParamDef,
87
TsTypeRefDef,
98
VariableDef,
109
} from "@deno/doc";
10+
import type { DocNode } from "../../hooks/use-deno-doc.tsx";
1111
import {
1212
Builtin,
1313
ClassName,
@@ -25,44 +25,44 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
2525
let { node } = props;
2626

2727
switch (node.kind) {
28-
case "function":
28+
case "function": {
29+
let typeParams = node.def.typeParams ?? [];
2930
return (
3031
<span class="language-ts code-highlight inline-block">
31-
{node.functionDef.isAsync
32-
? <Punctuation>{"async "}</Punctuation>
33-
: <></>}
32+
{node.def.isAsync ? <Punctuation>{"async "}</Punctuation> : <></>}
3433
<Keyword>{node.kind}</Keyword>
35-
{node.functionDef.isGenerator ? <Punctuation>*</Punctuation> : <></>}
36-
{" "}
34+
{node.def.isGenerator ? <Punctuation>*</Punctuation> : <></>}{" "}
3735
<span class="token function">{node.name}</span>
38-
{node.functionDef.typeParams.length > 0
39-
? <InterfaceTypeParams typeParams={node.functionDef.typeParams} />
36+
{typeParams.length > 0
37+
? <InterfaceTypeParams typeParams={typeParams} />
4038
: <></>}
4139
<Punctuation>(</Punctuation>
42-
<FunctionParams params={node.functionDef.params} />
43-
<Punctuation>)</Punctuation>: {node.functionDef.returnType
44-
? <TypeDef typeDef={node.functionDef.returnType} />
40+
<FunctionParams params={node.def.params} />
41+
<Punctuation>)</Punctuation>: {node.def.returnType
42+
? <TypeDef typeDef={node.def.returnType} />
4543
: <></>}
4644
</span>
4745
);
48-
case "class":
46+
}
47+
case "class": {
48+
let impl /* implements */ = node.def.implements ?? [];
4949
return (
5050
<span class="language-ts code-highlight inline-block">
5151
<Keyword>{node.kind}</Keyword> <ClassName>{node.name}</ClassName>
52-
{node.classDef.extends
52+
{node.def.extends
5353
? (
5454
<>
5555
<Keyword>{" extends "}</Keyword>
56-
<ClassName>{node.classDef.extends}</ClassName>
56+
<ClassName>{node.def.extends}</ClassName>
5757
</>
5858
)
5959
: <></>}
60-
{node.classDef.implements
60+
{impl.length > 0
6161
? (
6262
<>
6363
<Keyword>{" implements "}</Keyword>
6464
<>
65-
{node.classDef.implements
65+
{impl
6666
.flatMap((typeDef) => [<TypeDef typeDef={typeDef} />, ", "])
6767
.slice(0, -1)}
6868
</>
@@ -71,19 +71,22 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
7171
: <></>}
7272
</span>
7373
);
74-
case "interface":
74+
}
75+
case "interface": {
76+
let typeParams = node.def.typeParams ?? [];
77+
let ext = node.def.extends ?? [];
7578
return (
7679
<span class="language-ts code-highlight inline-block">
7780
<Keyword>{node.kind}</Keyword> <ClassName>{node.name}</ClassName>
78-
{node.interfaceDef.typeParams.length > 0
79-
? <InterfaceTypeParams typeParams={node.interfaceDef.typeParams} />
81+
{typeParams.length > 0
82+
? <InterfaceTypeParams typeParams={typeParams} />
8083
: <></>}
81-
{node.interfaceDef.extends.length > 0
84+
{ext.length > 0
8285
? (
8386
<>
8487
<Keyword>{" extends "}</Keyword>
8588
<>
86-
{node.interfaceDef.extends
89+
{ext
8790
.flatMap((typeDef) => [<TypeDef typeDef={typeDef} />, ", "])
8891
.slice(0, -1)}
8992
</>
@@ -92,10 +95,11 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
9295
: <></>}
9396
</span>
9497
);
98+
}
9599
case "variable":
96100
return (
97101
<span class="inline-block">
98-
<TSVariableDef variableDef={node.variableDef} name={node.name} />
102+
<TSVariableDef variableDef={node.def} name={node.name} />
99103
</span>
100104
);
101105
case "typeAlias":
@@ -104,12 +108,10 @@ export function* Type(props: TypeProps): Operation<JSXElement> {
104108
<Keyword>{"type "}</Keyword>
105109
{node.name}
106110
<Operator>{" = "}</Operator>
107-
<TypeDef typeDef={node.typeAliasDef.tsType} />
111+
<TypeDef typeDef={node.def.tsType} />
108112
</span>
109113
);
110114
case "enum":
111-
case "import":
112-
case "moduleDoc":
113115
case "namespace":
114116
default:
115117
console.log("<Type> unimplemented", node.kind);
@@ -187,51 +189,51 @@ function TSParam({ param }: { param: ParamDef }) {
187189
export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
188190
switch (typeDef.kind) {
189191
case "literal":
190-
switch (typeDef.literal.kind) {
192+
switch (typeDef.value.kind) {
191193
case "string":
192-
return <span class="token string">"{typeDef.repr}"</span>;
194+
return <span class="token string">"{typeDef.repr ?? ""}"</span>;
193195
case "number":
194-
return <span class="token number">{typeDef.repr}</span>;
196+
return <span class="token number">{typeDef.repr ?? ""}</span>;
195197
case "boolean":
196-
return <span class="token boolean">{typeDef.repr}</span>;
198+
return <span class="token boolean">{typeDef.repr ?? ""}</span>;
197199
case "bigInt":
198-
return <span class="token number">{typeDef.repr}</span>;
200+
return <span class="token number">{typeDef.repr ?? ""}</span>;
199201
default:
200202
// TODO(taras): implement template
201203
return <></>;
202204
}
203205
case "keyword":
204-
if (["number", "string", "boolean", "bigint"].includes(typeDef.keyword)) {
205-
return <Builtin>{typeDef.keyword}</Builtin>;
206+
if (["number", "string", "boolean", "bigint"].includes(typeDef.value)) {
207+
return <Builtin>{typeDef.value}</Builtin>;
206208
} else {
207-
return <Keyword>{typeDef.keyword}</Keyword>;
209+
return <Keyword>{typeDef.value}</Keyword>;
208210
}
209211
case "typeRef":
210-
return <TypeRef typeRef={typeDef.typeRef} />;
212+
return <TypeRef typeRef={typeDef.value} />;
211213
case "union":
212-
return <TypeDefUnion union={typeDef.union} />;
214+
return <TypeDefUnion union={typeDef.value} />;
213215
case "fnOrConstructor":
214-
if (typeDef.fnOrConstructor.constructor) {
215-
console.log(`<TypeDef> unimplemeneted`, typeDef.fnOrConstructor);
216+
if (typeDef.value.constructor) {
217+
console.log(`<TypeDef> unimplemeneted`, typeDef.value);
216218
// TODO(taras): implement
217219
return <></>;
218220
} else {
219221
return (
220222
<>
221223
<Punctuation>(</Punctuation>
222-
<FunctionParams params={typeDef.fnOrConstructor.params} />
224+
<FunctionParams params={typeDef.value.params} />
223225
<Punctuation>)</Punctuation>
224226
<Operator>{" => "}</Operator>
225-
<TypeDef typeDef={typeDef.fnOrConstructor.tsType} />
227+
<TypeDef typeDef={typeDef.value.tsType} />
226228
</>
227229
);
228230
}
229231
case "indexedAccess":
230232
return (
231233
<>
232-
<TypeDef typeDef={typeDef.indexedAccess.objType} />
234+
<TypeDef typeDef={typeDef.value.objType} />
233235
<Punctuation>[</Punctuation>
234-
<TypeDef typeDef={typeDef.indexedAccess.indexType} />
236+
<TypeDef typeDef={typeDef.value.indexType} />
235237
<Punctuation>]</Punctuation>
236238
</>
237239
);
@@ -240,7 +242,7 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
240242
<>
241243
<Punctuation>[</Punctuation>
242244
<>
243-
{typeDef.tuple
245+
{typeDef.value
244246
.flatMap((tp) => [<TypeDef typeDef={tp} />, ", "])
245247
.slice(0, -1)}
246248
</>
@@ -250,30 +252,30 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
250252
case "array":
251253
return (
252254
<>
253-
<TypeDef typeDef={typeDef.array} />
255+
<TypeDef typeDef={typeDef.value} />
254256
<Punctuation>[]</Punctuation>
255257
</>
256258
);
257259
case "typeOperator":
258260
return (
259261
<>
260-
<Keyword>{typeDef.typeOperator.operator}</Keyword>{" "}
261-
<TypeDef typeDef={typeDef.typeOperator.tsType} />
262+
<Keyword>{typeDef.value.operator}</Keyword>{" "}
263+
<TypeDef typeDef={typeDef.value.tsType} />
262264
</>
263265
);
264266
case "parenthesized": {
265267
return (
266268
<>
267269
<Punctuation>(</Punctuation>
268-
<TypeDef typeDef={typeDef.parenthesized} />
270+
<TypeDef typeDef={typeDef.value} />
269271
<Punctuation>)</Punctuation>
270272
</>
271273
);
272274
}
273275
case "intersection": {
274276
return (
275277
<>
276-
{typeDef.intersection
278+
{typeDef.value
277279
.flatMap((tp) => [
278280
<TypeDef typeDef={tp} />,
279281
<Operator>{" & "}</Operator>,
@@ -294,37 +296,37 @@ export function TypeDef({ typeDef }: { typeDef: TsTypeDef }) {
294296
case "conditional": {
295297
return (
296298
<>
297-
<TypeDef typeDef={typeDef.conditionalType.checkType} />
299+
<TypeDef typeDef={typeDef.value.checkType} />
298300
<Keyword>{" extends "}</Keyword>
299-
<TypeDef typeDef={typeDef.conditionalType.extendsType} />
301+
<TypeDef typeDef={typeDef.value.extendsType} />
300302
<Operator>{" ? "}</Operator>
301-
<TypeDef typeDef={typeDef.conditionalType.trueType} />
303+
<TypeDef typeDef={typeDef.value.trueType} />
302304
<Operator>{" : "}</Operator>
303-
<TypeDef typeDef={typeDef.conditionalType.falseType} />
305+
<TypeDef typeDef={typeDef.value.falseType} />
304306
</>
305307
);
306308
}
307309
case "infer": {
308310
return (
309311
<>
310312
<Keyword>{"infer "}</Keyword>
311-
{typeDef.infer.typeParam.name}
313+
{typeDef.value.typeParam.name}
312314
</>
313315
);
314316
}
315317
case "mapped":
316318
return (
317319
<>
318320
<Punctuation>[</Punctuation>
319-
{typeDef.mappedType.typeParam.name}
321+
{typeDef.value.typeParam.name}
320322
<Keyword>{` in `}</Keyword>
321-
{typeDef.mappedType.typeParam.constraint
322-
? <TypeDef typeDef={typeDef.mappedType.typeParam.constraint} />
323+
{typeDef.value.typeParam.constraint
324+
? <TypeDef typeDef={typeDef.value.typeParam.constraint} />
323325
: <></>}
324326
<Punctuation>]</Punctuation>
325327
<Operator>{" : "}</Operator>
326-
{typeDef.mappedType.tsType
327-
? <TypeDef typeDef={typeDef.mappedType.tsType} />
328+
{typeDef.value.tsType
329+
? <TypeDef typeDef={typeDef.value.tsType} />
328330
: <></>}
329331
</>
330332
);

0 commit comments

Comments
 (0)