Skip to content

Commit 61a3428

Browse files
committed
fix(api-docs): output @example doc as raw markdown
The @example tag's doc field from deno doc already contains properly formatted markdown with code blocks. Previously, the generator was wrapping this in additional code fences, causing broken nested markdown. Also exclude dist/ from deno check to avoid validating generated files.
1 parent 710272a commit 61a3428

2 files changed

Lines changed: 7 additions & 27 deletions

File tree

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"marked": "npm:marked@^15.0.12"
2020
},
2121
"exclude": [
22+
"dist/",
2223
"probitas/"
2324
],
2425
"lint": {

lib/api-markdown.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,13 @@ function generateFunctionMarkdown(
252252
lines.push("");
253253
}
254254

255-
// Examples
255+
// Examples - doc field is already Markdown, output as-is
256256
const examples = getExamples(node);
257257
if (examples.length > 0) {
258258
lines.push("**Example:**");
259259
lines.push("");
260260
for (const example of examples) {
261-
const trimmed = example.trim();
262-
if (trimmed.startsWith("```")) {
263-
lines.push(trimmed);
264-
} else {
265-
lines.push("```typescript");
266-
lines.push(trimmed);
267-
lines.push("```");
268-
}
261+
lines.push(example.trim());
269262
lines.push("");
270263
}
271264
}
@@ -360,20 +353,13 @@ function generateClassMarkdown(
360353
}
361354
}
362355

363-
// Examples
356+
// Examples - doc field is already Markdown, output as-is
364357
const examples = getExamples(node);
365358
if (examples.length > 0) {
366359
lines.push("**Example:**");
367360
lines.push("");
368361
for (const example of examples) {
369-
const trimmed = example.trim();
370-
if (trimmed.startsWith("```")) {
371-
lines.push(trimmed);
372-
} else {
373-
lines.push("```typescript");
374-
lines.push(trimmed);
375-
lines.push("```");
376-
}
362+
lines.push(example.trim());
377363
lines.push("");
378364
}
379365
}
@@ -446,20 +432,13 @@ function generateInterfaceMarkdown(
446432
}
447433
}
448434

449-
// Examples
435+
// Examples - doc field is already Markdown, output as-is
450436
const examples = getExamples(node);
451437
if (examples.length > 0) {
452438
lines.push("**Example:**");
453439
lines.push("");
454440
for (const example of examples) {
455-
const trimmed = example.trim();
456-
if (trimmed.startsWith("```")) {
457-
lines.push(trimmed);
458-
} else {
459-
lines.push("```typescript");
460-
lines.push(trimmed);
461-
lines.push("```");
462-
}
441+
lines.push(example.trim());
463442
lines.push("");
464443
}
465444
}

0 commit comments

Comments
 (0)