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

[Question] Is there a way to generate the "@example" tag contents from an external source file? #344

Open
satelllte opened this issue Mar 16, 2023 · 0 comments

Comments

@satelllte
Copy link

For example,

Here's the source file:

/* source/add.ts */

/**
 * Adds two numbers.
 *
 * @param x - First number.
 * @param y - Second number
 * @returns The sum of x and y.
 */
const add = (x: number, y: number): number => x + y

Here's the example source file:

/* examples/add.ts */

import { add } from '@source/add'

add(2, 3) // 5

Is there a way to reference the example source file in TSDoc?

Ideally via something like this:

/* pseudo-code */

/**
 * @example {@ref(./examples/add.ts)}
 */

The key benefit to have such ability is to have a single source of example without any duplications to be able to present it in a multiple ways simultaneously, like running it and listing its source at the same time.

@satelllte satelllte changed the title [Question] Is there a way to generate the "@example" tag contents from a source code file? [Question] Is there a way to generate the "@example" tag contents from an external source file? Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant