Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Load prop table from file #7942

Open
atanasster opened this issue Aug 31, 2019 · 8 comments
Open

Addon-docs: Load prop table from file #7942

atanasster opened this issue Aug 31, 2019 · 8 comments

Comments

@atanasster
Copy link
Member

Parsing prop tables for typescript project takes a long time. react-docgen-typescript-loader parses all the prop table on every storybook load.

However most times the prop tables very rarely change. A faster solution would be to generate prop table files only once in a while when the props of the components actually change.

If possible can you allow for loading prop tables from external files. By default, I am naming the external .json files for an example story ComponentName.stories.tsx as ComponentName.json

example external json file generated using directly "react-docgen-typescript":
https://github.com/atanasster/grommet-controls/blob/master/src/components/ColorInput/doc/ColorInput.json

my current (temporary) solution to use a webpack plugin to load the prop tables from files:
https://github.com/atanasster/grommet-controls/blob/master/.storybook/webpack.config.js

my current script to generate external json prop tables:
https://github.com/atanasster/grommet-controls/blob/master/tools/generate-docs.js

If the feature request is accepted I can clean up my script and release it for other people to also use if they have typescript docgen prop tables.

@atanasster atanasster changed the title Haddon-doc: load prop table from file addon-doc: load prop table from file Aug 31, 2019
@shilman shilman changed the title addon-doc: load prop table from file Addon-docs: Load prop table from file Sep 1, 2019
@shilman shilman added this to the 5.3.0 milestone Sep 1, 2019
@shilman
Copy link
Member

shilman commented Sep 1, 2019

Love this. It will also help for frameworks like Angular #6664 where there might not be a loader handy. I'd like some time to think about how to integrate this most cleanly cc @South-Paw https://github.com/South-Paw/storybook-addon-overview-angular

@atanasster
Copy link
Member Author

great, pls let me know when you are ready with how it should work (especially how to configure the file names to load the prop tables from - in my case they are in the same folder as the story, has a name like the component displayName, and an extension .json - but I suppose people can have them in different places.)

@clintandrewhall
Copy link
Contributor

clintandrewhall commented Sep 5, 2019

I'll +1 this. A prop table cache would be pretty sick. I'd gladly help (as available) and/or test (as ready) this kind of feature.

@atanasster
Copy link
Member Author

@clintandrewhall - any chance you can try my temporary solution in the meantime? Would love to get your feedback on the configuration options we can have.

Add the generate-docs script to your package.json and add my webpack loader to your storybook webpack config.

@stale stale bot added the inactive label Sep 26, 2019
@stale stale bot removed the inactive label Sep 26, 2019
@storybookjs storybookjs deleted a comment from stale bot Sep 26, 2019
@shilman
Copy link
Member

shilman commented Oct 28, 2019

@atanasster Relevant: #8585 #8489

@laplacesdemon
Copy link

This is a great idea! I need to customize the props table because I need to filter out some props from the documentation (for some interesting reason specific to my project). A props file would work perfectly in my case.

@shilman
Copy link
Member

shilman commented Nov 15, 2019

@laplacesdemon you can also filter with propsFilter loader option e.g. https://github.com/strothj/react-docgen-typescript-loader#loader-options

@atanasster
Copy link
Member Author

Just released https://github.com/atanasster/webpack-react-docgen-typescript for caching and speed up of parsing typescript prop tables. Feedback and issues welcome to get it stable.

@shilman shilman modified the milestones: 5.3.0, 6.0.0 Jan 11, 2020
@shilman shilman modified the milestones: 6.0, 6.0 docs May 8, 2020
@shilman shilman modified the milestones: 6.0 docs, 6.1 docs Jun 24, 2020
@shilman shilman added P0 and removed P0 labels Oct 12, 2020
@shilman shilman modified the milestones: 6.1 docs, 6.2 docs Oct 13, 2020
@shilman shilman removed this from the 6.2 docs milestone Jun 8, 2021
@shilman shilman removed the P3 label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants