strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

How to choose just specific props to be generated? #28

Closed samuelcastro closed 5 years ago

samuelcastro commented 5 years ago

I have an ui-elements repo that extends ant-design, some components like Button, Input, etc have many native default props but I just want to document a few of them, is there a way to do that?

This is what it's generate by default:

screen shot 2018-10-15 at 12 36 35 pm

But what I really want is just a few of them.

strothj commented 5 years ago

You can use the PropFilter: https://github.com/strothj/react-docgen-typescript-loader/pull/21 https://github.com/styleguidist/react-docgen-typescript/pull/111

samuelcastro commented 5 years ago

Awesome, thanks @strothj this fixed the problem:

propFilter: (prop) => {
      if (prop.parent == null) {
        return true;
      }

      return prop.parent.fileName.indexOf('node_modules/@types/react') < 0;
    }