Skip to content

[Discussion] Handling Markdown JSDoc Content #16468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mjbvz opened this issue Jun 12, 2017 · 2 comments
Closed

[Discussion] Handling Markdown JSDoc Content #16468

mjbvz opened this issue Jun 12, 2017 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation Duplicate An existing issue was already created Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jun 12, 2017

From: microsoft/vscode#27936

Problem
JSDocs often contain markdown content. TypeScript does not try to parse markdown when generating the documentation for intellisense and hovers. VSCode does try to show the documentation it gets from TypeScript as markdown. In certain edge cases, this can cause unexpected behavior:

/**
 * ```
 * @Hello
 * ```
 */
class Demo {}

In this case, @Hello is treated as a jsdoc tag instead of part of the markdown code block.

[Trace  - 3:43:51 PM] Response received: quickinfo (764). Request took 2 ms. Success: true 
Result: {
    "kind": "class",
    "kindModifiers": "",
    "start": {
        "line": 6,
        "offset": 7
    },
    "end": {
        "line": 6,
        "offset": 11
    },
    "displayString": "class Demo",
    "documentation": "```",
    "tags": [
        {
            "name": "Hello",
            "text": "```"
        }
    ]
}

Possible solutions
A few thoughts on how we could work around this:

  • TypeScript parses jsdocs as markdown. Not ideal because it adds a dependency to typescript but this would be the most complete solution.

  • TypeScript special cases a few markdown patterns (such as those for codeblocks) but does not try to fully parse the documentation as markdown.

  • TypeScript treats any tag that is not part of the jsdoc spec as content instead of as a jsdocs tag. This is the simplest solution but I'm not sure if people are using custom jsdocs tags that this would break

// cc @mhegazy

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jun 12, 2017
@mhegazy mhegazy added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation labels Aug 29, 2017
@csvn
Copy link

csvn commented Jun 1, 2018

This issue can be very bothersome when trying to document code that contains decorators.

/**
 * @example
 * 
 * ```
 * class ListenerExample {
 *  name = 'John Doe';
 * 
 *  @bind()
 *  onClick(e: Event) {
 *    console.log(this.name);
 *  }
 *   
 *  connectedCallback() {
 *    this.addEventListener('click', this.onClick);
 *  }
 * }
 * ```
 */
export function bind() { /* ... */ }

Is rendered as:

image

Right now I have to replace the @ in documentation/JSDoc comments with something else, which is not very user friendly.

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 27, 2020

Same basic issue as #39371: @ is always treated as the start of a jsdoc tag

Closing this in favor of that issue since it has more comments

@mjbvz mjbvz closed this as completed Oct 27, 2020
@mjbvz mjbvz added the Duplicate An existing issue was already created label Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation Duplicate An existing issue was already created Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants