Skip to content
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

Support @example tsdoc tag #1201

Closed
hmil opened this issue Mar 30, 2022 · 1 comment · Fixed by #1200
Closed

Support @example tsdoc tag #1201

hmil opened this issue Mar 30, 2022 · 1 comment · Fixed by #1200

Comments

@hmil
Copy link
Contributor

hmil commented Mar 30, 2022

The current implementation supports adding examples using a dedicated tag @examples.

But the TSDoc spec recommends using @example instead.

While the TSDoc tag is mostly intended for documentation, and therefore does not always contain valid JSON data, the tag is still very much aligned with json-schema.

There are multiple levels of support which could be implemented:

Basic

Just support raw JSON data

/**
 * @example
 *     { "foo": 42 }
 * @example
 *     "baz"
 */

Yields:

{
    "examples": [
         { "foo": 42 },
        "baz"
    ]
}

An implementation of this is provided in #1200 .

Support example title

The title would be ignored

/**
 * @example Title of this example
 *     { "foo": 42 }
 */

Advanced

Would parse the markdown and extract the bits of code from the text. This is probably out of scope to be honest, but I'm including it here for the sake of completeness.

@github-actions
Copy link

🚀 Issue was released in v1.0.1-next.1 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant