Storybook: Addon-docs: Support JSDoc @ignore tag to remove a prop from the props table

Created on 23 Oct 2019  路  7Comments  路  Source: storybookjs/storybook

Is your feature request related to a problem? Please describe.
My component contains props that the consumer shouldn't be bothered with. I would like those props to be ignored by the props table.

Describe the solution you'd like
JSDoc already support the @ignore tag. The props table could also use this tag to ignore the props.

Usage:

static propTypes = {
   /**
    * @ignore
    */
   reactDatesCalendar: node
};
docs feature request good first issue help wanted

Most helpful comment

@eybbus In SB6-beta, you can use the propFilter option of react-docgen-typescript-loader

See: https://github.com/storybookjs/storybook/blob/next/docs/src/pages/configurations/typescript-config/index.md#mainjs-configuration

https://github.com/strothj/react-docgen-typescript-loader#loader-options

As a hack, you can also use the include prop of the Props block to create a whitelist for that particular component.

All 7 comments

Huzzah!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.41 containing PR #8702 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

I'm not sure if It is me being a noob or it is an issue. with this implementation it is not possible to ignore extended interfaces in typescript, right?

for example, how would I ignore DefaultComposeProps, FlexComposeProps and PositionComposeProps in the codeblock below?

interface BackgroundImageProps extends DefaultComposeProps, FlexComposeProps, PositionComposeProps {
  image?: string
  overlay?: string[][]
  overlayOpacity?: number[]
  as?: keyof JSX.IntrinsicElements | React.ComponentType<any>
}

@eybbus In SB6-beta, you can use the propFilter option of react-docgen-typescript-loader

See: https://github.com/storybookjs/storybook/blob/next/docs/src/pages/configurations/typescript-config/index.md#mainjs-configuration

https://github.com/strothj/react-docgen-typescript-loader#loader-options

As a hack, you can also use the include prop of the Props block to create a whitelist for that particular component.

@eybbus I had the same question and @shamin your response was spot-on, so thanks for that. Just in case anyone else is wondering what that actually looks like when you add the propFilter here is the end result from my main.ts file:

config.module.rules.push({
    test: /\.(ts|tsx)$/,
    use: [
        {
            loader: require.resolve('babel-loader'),
            options: {
                presets: [
                    '@babel/preset-react',
                    '@babel/preset-typescript',
                ],
            },
        },
        {
            loader: require.resolve('react-docgen-typescript-loader'),
            options: {
            propFilter: prop =>
                prop.parent
                    ? !/node_modules/.test(prop.parent.fileName)
                    : true,
            },
        },
    ],
});

As a hack, you can also use the include prop of the Props block to create a whitelist for that particular component.

@shilman Do you have any examples of how to use the include prop? Struggling to find documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zvictor picture zvictor  路  3Comments

MrOrz picture MrOrz  路  3Comments

tirli picture tirli  路  3Comments

shilman picture shilman  路  3Comments

wahengchang picture wahengchang  路  3Comments