Skip to content

Commit d5c8d59

Browse files
author
Frank
committed
docs: sync
1 parent 3004802 commit d5c8d59

File tree

1 file changed

+79
-49
lines changed

1 file changed

+79
-49
lines changed

www/generate.ts

Lines changed: 79 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ function renderClient() {
164164
`<div class="tsdoc">`,
165165
renderAbout(renderComment(module.comment)),
166166
renderFunctions(module),
167-
renderInterfaces(module),
167+
renderInterfaces(module, {
168+
filter: (i) => i.name === "Client",
169+
renderH3: true,
170+
}),
171+
renderInterfaces(module, { filter: (i) => i.name !== "Client" }),
168172
`</div>`,
169173
])
170174
}
@@ -282,66 +286,92 @@ function renderFunctions(module: TypeDoc.DeclarationReflection) {
282286
])
283287
}
284288

285-
function renderInterfaces(module: TypeDoc.DeclarationReflection) {
289+
function renderInterfaces(
290+
module: TypeDoc.DeclarationReflection,
291+
options: {
292+
filter?: (i: TypeDoc.DeclarationReflection) => boolean
293+
renderH3?: boolean
294+
} = {},
295+
) {
286296
console.debug(` ∟renderInterfaces`)
287-
const interfaces = module.getChildrenByKind(TypeDoc.ReflectionKind.Interface)
297+
const interfaces = module
298+
.getChildrenByKind(TypeDoc.ReflectionKind.Interface)
299+
.filter(options.filter ?? (() => true))
288300
return interfaces.map((i) => {
289301
console.debug(` ∟interface: ${i.name}`)
290302
const properties = i.getChildrenByKind(TypeDoc.ReflectionKind.Property)
291303
const methods = i.getChildrenByKind(TypeDoc.ReflectionKind.Method)
292304
return [
293305
`## ${i.name}`,
294306
`<Segment>`,
295-
`<Section type="parameters">`,
296-
properties.map((p) => [
297-
`- <p>[<code class="key">${renderProperty(p)}</code>](#${buildLinkHash(i.name, p.name)}) ${renderType(p.type!)}</p>`,
298-
flattenNestedTypes(p.type!, p.name).map(
299-
({ depth, prefix, subType }) =>
300-
`${" ".repeat(depth * 2)}- <p>[<code class="key">${renderProperty(
301-
subType,
302-
)}</code>](#${buildLinkHash(prefix, subType.name)}) ${renderType(subType.type!)}</p>`,
303-
),
307+
render(!options.renderH3, [
308+
`<Section type="parameters">`,
309+
properties.map((p) => [
310+
`- <p>[<code class="key">${renderProperty(p)}</code>](#${buildLinkHash(i.name, p.name)}) ${renderType(p.type!)}</p>`,
311+
flattenNestedTypes(p.type!, p.name).map(
312+
({ depth, prefix, subType }) =>
313+
`${" ".repeat(depth * 2)}- <p>[<code class="key">${renderProperty(
314+
subType,
315+
)}</code>](#${buildLinkHash(prefix, subType.name)}) ${renderType(subType.type!)}</p>`,
316+
),
317+
]),
318+
methods.map((m) => {
319+
return `- <p>[<code class="key">${renderProperty(m)}</code>](#${buildLinkHash(i.name, m.name)}) ${renderSignatureAsType(m.signatures![0])}</p>`
320+
}),
321+
`</Section>`,
304322
]),
305-
methods.map((m) => {
306-
return `- <p>[<code class="key">${renderProperty(m)}</code>](#${buildLinkHash(i.name, m.name)}) ${renderSignatureAsType(m.signatures![0])}</p>`
307-
}),
308-
`</Section>`,
309323
renderComment(i.comment),
310324
`</Segment>`,
311-
properties.flatMap((p) => [
312-
`<NestedTitle id="${buildLinkHash(i.name, p.name)}" Tag="h4" parent="${i.name}.">${renderProperty(p)}</NestedTitle>`,
313-
`<Segment>`,
314-
`<Section type="parameters">`,
315-
`<InlineSection>`,
316-
`**Type** ${renderType(p.type!)}`,
317-
`</InlineSection>`,
318-
`</Section>`,
319-
renderComment(p.comment),
320-
`</Segment>`,
321-
flattenNestedTypes(p.type!, p.name).map(
322-
({ depth, prefix, subType }) => [
323-
`<NestedTitle id="${buildLinkHash(prefix, subType.name)}" Tag="h5" parent="${i.name}.${prefix}.">${renderProperty(subType)}</NestedTitle>`,
324-
`<Segment>`,
325-
`<Section type="parameters">`,
326-
`<InlineSection>`,
327-
`**Type** ${renderType(subType.type!)}`,
328-
`</InlineSection>`,
329-
`</Section>`,
330-
renderComment(subType.comment),
331-
`</Segment>`,
332-
],
333-
),
325+
render(!options.renderH3, [
326+
properties.flatMap((p) => [
327+
`<NestedTitle id="${buildLinkHash(i.name, p.name)}" Tag="h4" parent="${i.name}.">${renderProperty(p)}</NestedTitle>`,
328+
`<Segment>`,
329+
`<Section type="parameters">`,
330+
`<InlineSection>`,
331+
`**Type** ${renderType(p.type!)}`,
332+
`</InlineSection>`,
333+
`</Section>`,
334+
renderComment(p.comment),
335+
`</Segment>`,
336+
flattenNestedTypes(p.type!, p.name).map(
337+
({ depth, prefix, subType }) => [
338+
`<NestedTitle id="${buildLinkHash(prefix, subType.name)}" Tag="h5" parent="${i.name}.${prefix}.">${renderProperty(subType)}</NestedTitle>`,
339+
`<Segment>`,
340+
`<Section type="parameters">`,
341+
`<InlineSection>`,
342+
`**Type** ${renderType(subType.type!)}`,
343+
`</InlineSection>`,
344+
`</Section>`,
345+
renderComment(subType.comment),
346+
`</Segment>`,
347+
],
348+
),
349+
]),
350+
methods.flatMap((m) => [
351+
`<NestedTitle id="${buildLinkHash(i.name, m.name)}" Tag="h4" parent="${i.name}.">${renderProperty(m)}</NestedTitle>`,
352+
`<Segment>`,
353+
`<Section type="parameters">`,
354+
`<InlineSection>`,
355+
`**Type** ${renderSignatureAsType(m.signatures![0])}`,
356+
`</InlineSection>`,
357+
`</Section>`,
358+
renderComment(m.signatures![0].comment),
359+
`</Segment>`,
360+
]),
334361
]),
335-
methods.flatMap((m) => [
336-
`<NestedTitle id="${buildLinkHash(i.name, m.name)}" Tag="h4" parent="${i.name}.">${renderProperty(m)}</NestedTitle>`,
337-
`<Segment>`,
338-
`<Section type="parameters">`,
339-
`<InlineSection>`,
340-
`**Type** ${renderSignatureAsType(m.signatures![0])}`,
341-
`</InlineSection>`,
342-
`</Section>`,
343-
renderComment(m.signatures![0].comment),
344-
`</Segment>`,
362+
// Note: currently only used to render the Client interface
363+
render(options.renderH3, [
364+
methods.flatMap((m) => [
365+
`### ${m.name}`,
366+
`<Segment>`,
367+
`<Section type="parameters">`,
368+
`<InlineSection>`,
369+
`**Type** ${renderSignatureAsType(m.signatures![0])}`,
370+
`</InlineSection>`,
371+
`</Section>`,
372+
renderComment(m.signatures![0].comment),
373+
`</Segment>`,
374+
]),
345375
]),
346376
]
347377
})

0 commit comments

Comments
 (0)