carbon-design-system / sveld

Generate TypeScript definitions for your Svelte components
https://sveld.onrender.com
Apache License 2.0
408 stars 21 forks source link

how to remove code of function in documentation? #52

Open imperator-maximus opened 3 years ago

imperator-maximus commented 3 years ago

Hi, I try to make documentation for a function:

    /**
     * get Theme object
     * @param {string} status
     * @param {string} size
     * @param {string} disabled
     * @param {string} theme
     * @returns {object}
     */
    export function getTheme(status,size,disabled,theme) {

In Markdown and JSON I get the whole code from inside the function inside the markdown/JSON (value attribute) in "Prop" list. How to avoid this?

Thank you!

metonym commented 3 years ago

Currently, the markdown/json generation is lagging behind the TypeScript generation, which should not include the actual function code. Labelling this as a bug.

metonym commented 3 years ago

@imperator-maximus What do you expect the value to be for the Markdown/JSON formats? The type instead?

imperator-maximus commented 3 years ago

each function should have its own table for parameters:

/**
 * A quite wonderful function.
 * @param {object} - Privacy gown
 * @param {object} - Security
 * @returns {survival}
 */
function protection (cloak, dagger) {}
A quite wonderful function.

**Kind**: global function

| Param  | Type                | Description  |
| ------ | ------------------- | ------------ |
| cloak  | <code>object</code> | Privacy gown |
| dagger | <code>object</code> | Security     |
metonym commented 3 years ago

The @param, @returns is currently not supported. Have you tried defining the entire signature using @type?

/** @typedef {any} Survival */
/** @type {(cloak: object, dagger: object) => Survival} */
imperator-maximus commented 3 years ago

well that would be a workaround (@param, @returns support would be better for sure). Anyway the bug still has to be fixed somehow first that the whole function code will not be copied in markdown.