microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.93k stars 598 forks source link

[api-documenter] Do not escape Markdown in doc comments #4940

Open markus-incisive opened 1 month ago

markus-incisive commented 1 month ago

Summary

Most Markdown in the doc comments is escaped, which causes unexpected/unwanted/inconsistent behavior. VSCode allows for Markdown and renders it as expected, but api-documenter doesn't.

Repro steps

Given the following class:

/**
 * I am **bold**.
 *
 * @public
 */
export class MyClass {}

VSCode will render the markdown, but api-documenter emits it with the Markdown escaped as "I am **bold**".

{6598671A-C122-424C-9253-463585D4E2A7}

Putting a backslash in front of the Markdown characters works for VSCode, but only sometimes works with api-documenter. This example throws a tsdoc-unnecessary-backslash warning.

/**
 * I am \_not italic\_.
 *
 * @public
 */
export class MyClass {}

One way to get api-documenter to format text is to use HTML tags, but VSCode will not render HTML tags.

/**
 * I should be <b>bold</b>.
 *
 * @public
 */
export class MyClass {}

{5463356C-0E7C-4892-9F12-AD94BDBD2733}

Details

There doesn't seem to be a way to get both VSCode and api-documenter to both render formatted text. This applies to @example and @remarks blocks as well.

I expected api-documenter to support Markdown in doc comments, and leave it to the user to write proper Markdown (explicitly escaping when needed). This behavior could be turned on via an option, since there may still be situations to disallow Markdown in doc comments especially depending on the intended documentation target.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-documenter version? 7.25.14
Operating system? Windows
Documentation target? Markdown
Would you consider contributing a PR? No
TypeScript compiler version? 5.4.2
Node.js version (node -v)? 22.7.0
markus-incisive commented 1 month ago

May just be a TSDoc issue https://github.com/microsoft/tsdoc/issues/12