question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-docs: Support JSDoc params to describe the signature of a function in the props table

See original GitHub issue

Is your feature request related to a problem? Please describe. I would like to be able to define the signature of my function in description column of the props table.

I love how it’s done in Semantic UI React documentation

image

This is define with JSDoc:

    /**
     * Called on blur.
     *
     * @param {SyntheticEvent} event - React's original SyntheticEvent.
     * @param {object} data - All props.
     */
    onBlur: PropTypes.func,

This doesn’t seem to be a native feature of react-docgen. I made a quick test on the playground and I get the following:

    "bar": {
      "type": {
        "name": "custom",
        "raw": "function(props, propName, componentName) {\n  // ...\n}"
      },
      "required": false,
      "description": "Description of prop \"bar\" (a custom validation function).\n@param {SyntheticEvent} event - Test",
      "defaultValue": {
        "value": "21",
        "computed": false
      }
    },

I guess they somehow parse the JSDoc in the description prop.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Apr 23, 2020

@Losses there are two different codepaths, one for react-docgen-typescript-loader (the recommended 5.3 setup) and one for babel-plugin-react-docgen (the recommended 6.0 setup). i’m guessing @patricklafrance fixed this for the former but not the latter.

More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#rolling-back

1reaction
patricklafrancecommented, Nov 1, 2019

Still need to add the @params and @returns tags optional description under the func type.

Working on it now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSDoc: @param
The @param tag provides the name, type, and description of a function parameter. The @param tag requires you to specify the name of...
Read more >
storybook/addon-docs - npm
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into ...
Read more >
ArgsTable - Storybook - JS.ORG
Storybook Docs automatically generates component args tables for components in supported frameworks. These tables list the arguments (args for short) of the ...
Read more >
Documenting design systems with Storybook Docs
Storybook is a playground for UI development. It's a great tool to help designers, project managers, and developers understand and visualize ...
Read more >
JSDoc Reference - TypeScript: Documentation
Note any tags which are not explicitly listed below (such as @async ) are not yet supported. Types. @type; @param (or @arg or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found