Render JSDoc examples as typescript code (#234143)

Currently `@example` produces Markdown code blocks for code examples,
but they are not annotated with a programming language. This commit
annotates those code blocks as `typescript`, allowing for better
highlighting for JS/TS when using Markdown renderers that recognize
these languages.
This commit is contained in:
Riley Bruins
2024-11-22 12:11:59 -08:00
committed by GitHub
parent e1de2a458d
commit 3b7e1c668a
2 changed files with 4 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ function getTagBodyText(
if (/^\s*[~`]{3}/m.test(text)) {
return text;
}
return '```\n' + text + '\n```';
return '```tsx\n' + text + '\n```';
}
let text = convertLinkTags(tag.text, filePathConverter);

View File

@@ -89,7 +89,7 @@ suite('typescript.previewer', () => {
text: 'code();'
}
], noopToResource),
'*@example* \n```\ncode();\n```'
'*@example* \n```tsx\ncode();\n```'
);
});
@@ -113,7 +113,7 @@ suite('typescript.previewer', () => {
text: '<caption>Not code</caption>\ncode();'
}
], noopToResource),
'*@example* \nNot code\n```\ncode();\n```'
'*@example* \nNot code\n```tsx\ncode();\n```'
);
});
@@ -154,7 +154,7 @@ suite('typescript.previewer', () => {
]
}
], noopToResource),
'*@example* \n```\n1 + 1 {@link foo}\n```');
'*@example* \n```tsx\n1 + 1 {@link foo}\n```');
});
test('Should render @linkcode symbol name as code', () => {