-
Notifications
You must be signed in to change notification settings - Fork 16
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
Documentation based on propTypes #25
Comments
Cool. I think this is in line with the project mission, since good interfaces play a bit role in componitization. But before rushing into a PR, let's talk about the implementation a bit. E.g. where in the code will you extract the info and where would it be the best way to display it in the UI. PS. I did a small UI refresh to the header+buttons yesterday, get the latest and see if it's sharper than before :-) |
In my sketch implementation I had a separate script that I ran before playground that generated Markdown files next to components. Then in cosmos I would load these |
I think it should be another panel, hidden by default, with a discrete button somewhere. A bit offtopic, but you could also generate random fixtures from propTypes, akin to factories. That would be pretty cool as well as I'm sure writing fixtures is a drag for people who discover Cosmos. |
We could integrate something like https://github.com/marak/Faker.js/ to generate these fixtures. Based on comment annotation, property type and property name we could make an educated guess on what makes sense to put in there. What do you think? |
For example, we could set a convention that if you annotate your propTypes like this:
you get a nice random fixture every time. |
Cool idea! Faker looks pretty powerful. We could add a 2nd executable like |
It would be nice to display auto-generated component API documentation based on the propTypes and optional comments. I have a partial implementation of this using https://github.com/reactjs/react-docgen and their markdown example. I can prepare a pull request if you think this is a good idea.
The text was updated successfully, but these errors were encountered: