Storybook: [addon-docs] prop descriptions not extracted for default exports

Created on 30 Jun 2020  路  6Comments  路  Source: storybookjs/storybook

I noticed that docgen is not able to extract any prop descriptions for default exports, why is that? Where this limitation comes from? It is a huge shortcoming for any containers (which I think constitute majority of components in any react app), since they are usually exported as defaults.

Should we export them separately from the module, or what's the recommended approach to deal with that?

Environment Info:

  System:
    OS: macOS 10.15.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 10.20.1 - ~/.nvm/versions/node/v10.20.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v10.20.1/bin/npm
  Browsers:
    Chrome: 83.0.4103.116
    Safari: 13.1.1
  npmPackages:
    @storybook/addon-actions: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/addon-controls: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/addon-docs: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/addon-knobs: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/addon-links: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/addons: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/preset-create-react-app: ^2.1.2 => 2.1.2 
    @storybook/react: ^6.0.0-beta.37 => 6.0.0-beta.37 
    @storybook/theming: ^6.0.0-beta.37 => 6.0.0-beta.37 
docs props inactive question / support

Most helpful comment

We are using typescript types and they aren't picked up from default exports.

All 6 comments

I noticed a similar problem but only with my components wrapped in functions :

This one works fine :

const Test = () => (<div>Test</div>);

Test.propTypes = {
    /**
    * Js doc to display
    */
    foo: PropTypes.string,
}

export default Test;

But the following fails to display props :

import { withTheme } from '@material-ui/core';

const Test = withTheme(() => (<div>Test</div>));

Test.propTypes = {
    /**
    * Js doc to display
    */
    foo: PropTypes.string,
}

export default Test;

We are using typescript types and they aren't picked up from default exports.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Please upgrade preset-create-react-app to the latest: npx sb@next upgrade --prerelease

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sakulstra picture sakulstra  路  3Comments

dnlsandiego picture dnlsandiego  路  3Comments

Jonovono picture Jonovono  路  3Comments

arunoda picture arunoda  路  3Comments

wahengchang picture wahengchang  路  3Comments