strothj / react-docgen-typescript-loader

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

feat: add propFilter to loader options #21

Closed rkostrzewski closed 5 years ago

rkostrzewski commented 5 years ago

react-docgen-typescript allows users to specify propFilter option as either an object with skipPropsWithName and skipPropsWithoutDoc or as a function for dynamic filtering of props. Currently react-docgen-typescript-loader allows us to specify only skipPropsWithName and skipPropsWithoutDoc.

This PR adds the ability to specify the filter function in loader options to have more control over which props are documented. I've tried to make the change without breaking changes (and that's why there are 3 fields: propFilter, skipPropsWithName, and skipPropsWithoutDoc).

This change is mainly to support https://github.com/styleguidist/react-docgen-typescript/pull/111 if it gets merged which would allow us to filter props by the place where they were declared (e.g. ignoring React.HTMLAttributes) which would solve https://github.com/strothj/react-docgen-typescript-loader/issues/20

strothj commented 5 years ago

Thank you for the pull request! I'm looking things over.

strothj commented 5 years ago

Adding this here for my reference:

prop-filter-0 prop-filter-1 prop-filter-2

For reference, adding this option to the loader causes the prop disabled to be filtered.

strothj commented 5 years ago

Thanks again for the pull request. This has been published as 2.2.0.

rkostrzewski commented 5 years ago

Thanks :) and thanks for the awesome library