feat(navigation-menu): enhance context handling and lifecycle management

This commit is contained in:
2026-06-10 16:16:12 +07:00
parent a82f5f2dfd
commit 9375304e1a
55 changed files with 1997 additions and 179 deletions
+16 -1
View File
@@ -154,11 +154,26 @@ function getDescription(jsdocs: JSDoc[], tags: JSDocTag[]): string {
return '';
}
/**
* Example text straight from the tag SOURCE. `getCommentText()` runs through
* the TS JSDoc parser, which strips each line's leading whitespace — code
* indentation is gone. Instead take the raw tag text and remove only the
* comment scaffolding (`@example` head, per-line ` * ` prefixes).
*/
function rawExampleText(tag: JSDocTag): string {
return tag.getText()
.replace(/^@example[ \t]?/, '')
.split('\n')
.map(line => line.replace(/^\s*\*(?: |\/\s*$)?/, ''))
.join('\n')
.replace(/\s*\*?\/?\s*$/, '');
}
function getExamples(tags: JSDocTag[]): string[] {
return tags
.filter(t => t.getTagName() === 'example')
.map((t) => {
let text = t.getCommentText()?.trim() ?? '';
let text = rawExampleText(t).trim();
// A leading `<caption>…</caption>` (JSDoc example title) isn't valid code —
// turn it into a leading comment so the snippet stays clean & highlightable.
let caption = '';