-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add hooks to enable multiple components per file #106
Add hooks to enable multiple components per file #106
Conversation
Thanks! Could you please update the docs as well? |
I've added documentation for the resolver and handlers properties into the main Readme. Is there anywhere else that needs to be updated? |
}, | ||
{ | ||
module: {displayName: 'Foo'}, | ||
props: {displayName: 'FooOverride'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what does props
mean in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props would be the object generated by the props loader. The displayName property can be injected by a react-docgen handler - either the built in one, or a custom one like I suggest in the docs.
@paulj how will this change affect existing styleguides? How does it integrate with the |
@mik01aj this change should have no effect on existing guides, since if the options aren't specified, the behaviours default to the same as previously. For the examples, they are currently allocated to all components in the file, since spreading the props out is done by duplicating all the other collected data. This isn't ideal - I'm investigating some other ways of targeting examples. |
Should I merge this too? |
@sapegin I've just merged master in, and applied some other stylistic fixes based upon your comments on other PRs. |
@paulj I have a file with about 5 components in it that I'm trying to get working. I have all the components rendering in the sidebar, but only the first is shown in the style guide itself. Any thoughts as to what might be going on? looks like something with keys |
In structuring our application, we often have a number of exports from individual files, since the components are often via tightly linked (for instance, I have a
Columns
component with aColumn
child type).I'd like to be able to use styleguidist to document these. React docgen can be convinced to emit the metadata for these, but the resolver needs to be overriden. This PR adds the ability to configure the react docgen resolver and handlers via the styleguidist configuration file. It also adds some (initially sensible) behaviour for dealing with an array of components being returned in props instead of just a flat set of props.
For reference, with this patch, I'm configuring styleguidist like:
This results in all components being found and props being generated. The additional handler attaches a
displayName
andpath
property to items, enabling the name of the component to be detected. ThedisplayName
property is similar to a default behaviour built-in to react-docgen where aReact.createClass
declarationdisplayName
is carried through in the props.