Skip to content

Commit 2ff85a9

Browse files
committed
chore: render examples only if they're non-empty
1 parent d5af7b7 commit 2ff85a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/utils/docs/render.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ async function renderJsDocTags(tags: JsDocTag[], symbolLookup: SymbolLookup): Pr
185185
const examples = tags.filter(t => t.kind === 'example')
186186
const deprecated = tags.find(t => t.kind === 'deprecated')
187187
const see = tags.filter(t => t.kind === 'see')
188+
188189
const deprecatedMessagePromise = deprecated?.doc
189190
? renderMarkdown(deprecated.doc.replace(/\n/g, ' '), symbolLookup)
190191
: null
@@ -195,6 +196,7 @@ async function renderJsDocTags(tags: JsDocTag[], symbolLookup: SymbolLookup): Pr
195196
const code = example.doc.replace(/```\w*\n?/g, '').trim()
196197
return highlightCodeBlock(code, lang)
197198
})
199+
198200
const [renderedDeprecatedMessage, ...renderedExamples] = await Promise.all([
199201
deprecatedMessagePromise,
200202
...examplePromises,
@@ -238,7 +240,7 @@ async function renderJsDocTags(tags: JsDocTag[], symbolLookup: SymbolLookup): Pr
238240
}
239241

240242
// Examples (with syntax highlighting)
241-
if (examples.length > 0) {
243+
if (examples.length > 0 && renderedExamples.some(Boolean)) {
242244
lines.push(`<div class="docs-examples">`)
243245
lines.push(`<h4>Example${examples.length > 1 ? 's' : ''}</h4>`)
244246
lines.push(...renderedExamples.filter(Boolean))

0 commit comments

Comments
 (0)