You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[GSoC] Automatic Documentation System for TypeScript Components #3056
A better automatic system for documenting EUI TypeScript components. Specifically, we're looking for a better method to extract the acceptable values for each prop on the API. This would be done through automatic transversal of the EUI components itself, combined with the type values from TS and our own inline comments.
Outcome
More accurate, robust prop documentation within the existing "Props" tab for each example section in component documentation. As the EUI team is nearing completion of complete TypeScript conversion, it is possible that the current type and prop traversal system can be entirely replaced.
How well does that loader / react-docgen-typescript work with components like EuiButton, which has a mix of our custom PropsForAnchor, PropsForButton, and ExclusiveUnion types? Or EuiBadge which nests those concepts
Second aspect of react-docgen-typescript that wasn't great in the past was whether or not it supports types from 3rd party libs / node_modules. Ideally, I think we'd want to white list some like react-beautiful-dnd, either including the types directly or even maybe creating a link to their documentation.
And we also don't want to lose support for generating prop types.
With EuiButton and EuiBadge all props are found except the onClick prop 😅. The reason onClick was not found is due to filtering props from node-modules.
react-docgen-typescript support types from node-modules. I tried it with EuiDraggable it displays props from react-beautiful-dnd
This would be follow up work to the PR you already have open, but we'd also like to find a way to directly include types and interfaces in the Props table (see #1688)
Tables are good example of this. We manually add complex types and interfaces through a propsInfo hack so that consumers can see subcomponent types in the table. For instance, Pagination is a valuable type, but one that wouldn't come through via simply including EuiTableProps.
One workaround for this issue I just found was to create a component called TableProps or OtherProps and let its component extend interfaces that we could display like for the table example:
@ashikmeerankutty Thank you so much for all the work you did on this project!!! 🎉 🎉 I know our all our Elastic engineers are extremely grateful for a more robust and reliable prop table with real Typescript types. The "Extends" bit, while seemingly small, is a game changer! Best of luck to you in future endeavors!
Activity
thompsongl commentedon May 11, 2020
@ashikmeerankutty We'll use this issue to discuss and track modifications to your proposal.
Comment in this thread and then I can assign the issue to you.
ashikmeerankutty commentedon May 11, 2020
@thompsongl Thanks!
ashikmeerankutty commentedon May 21, 2020
Should I continue this as a separate project outside
euiand use thepluginineuior shift the plugin development insideeui.thompsongl commentedon May 21, 2020
What do you think, @chandlerprall?
chandlerprall commentedon May 21, 2020
Let's move it inside eui; makes it easier to observer changes against any set of components
ashikmeerankutty commentedon May 21, 2020
Out of curiosity! I just tried adding the plugin to
eui. Few observations:chandlerprall commentedon May 21, 2020
Sounds like it's processing TypeScript code 😀
Sweet!
The only way to make things better :)
Did you remove the existing
./scripts/babel/proptypes-from-ts-propsplugin from babel's config? If not, it might be causing interference.Next week, I can help look into any issues you're not sure about. If this is too much of a problem right now, there's no rush on moving it into EUI.
ashikmeerankutty commentedon May 21, 2020
No, I will try removing that.
It doesn't seem to be trouble. I think it's better to continue in eui. I will get a lot of components to try.
ashikmeerankutty commentedon May 22, 2020
Just found a webpack loader that uses react-docgen-typescript 😐.
Tried the same in eui and the results seems good 😐.
chandlerprall commentedon May 27, 2020
How well does that loader / react-docgen-typescript work with components like EuiButton, which has a mix of our custom
PropsForAnchor,PropsForButton, andExclusiveUniontypes? Or EuiBadge which nests those conceptseui/src/components/badge/badge.tsx
Lines 97 to 102 in c9ae5a0
Second aspect of react-docgen-typescript that wasn't great in the past was whether or not it supports types from 3rd party libs / node_modules. Ideally, I think we'd want to white list some like react-beautiful-dnd, either including the types directly or even maybe creating a link to their documentation.
And we also don't want to lose support for generating prop types.
ashikmeerankutty commentedon May 27, 2020
With EuiButton and EuiBadge all props are found except the
onClickprop 😅. The reasononClickwas not found is due to filtering props fromnode-modules.react-docgen-typescriptsupport types fromnode-modules. I tried it withEuiDraggableit displays props fromreact-beautiful-dnd27 remaining items
chandlerprall commentedon Jun 15, 2020
We can convert all
React.Component<>toComponent<>, that's fine!ashikmeerankutty commentedon Jun 15, 2020
The
EuiScreenReaderOnlycomponent usescloneElementand that was creating issues withreact-docgenI guessthompsongl commentedon Jun 15, 2020
Go ahead and change it if it is no longer the source of problems
thompsongl commentedon Jul 2, 2020
This would be follow up work to the PR you already have open, but we'd also like to find a way to directly include types and interfaces in the Props table (see #1688)
Tables are good example of this. We manually add complex types and interfaces through a propsInfo hack so that consumers can see subcomponent types in the table. For instance,
Paginationis a valuable type, but one that wouldn't come through via simply includingEuiTableProps.ashikmeerankutty commentedon Jul 5, 2020
One workaround for this issue I just found was to create a component called
TablePropsorOtherPropsand let its component extend interfaces that we could display like for the table example:In the generated
docgenInfowe could findextendedInterfacesthat have all the extended props of the component as separate info.We could then pass it like
TableProps.extendedInterfaces.PaginationtoguideSectionPageThe issue here if two of the interface contains the same props only one among them will be shown.
thompsongl commentedon Jul 6, 2020
Thanks for looking into it. Let's move discussion to that issue (#1688).
thompsongl commentedon Aug 13, 2020
Reopening this so all the tracking continues in one issue.
@ashikmeerankutty, please list any follow-up work to #3554 that you plan on doing (#3554 (review); sorting the props, for instance)
ashikmeerankutty commentedon Aug 13, 2020
Follow ups
cchaos commentedon Aug 25, 2020
@ashikmeerankutty Thank you so much for all the work you did on this project!!! 🎉 🎉 I know our all our Elastic engineers are extremely grateful for a more robust and reliable prop table with real Typescript types. The "Extends" bit, while seemingly small, is a game changer! Best of luck to you in future endeavors!
thompsongl commentedon Aug 25, 2020
@ashikmeerankutty I merged #3944, which checks the last box here 🎉
Just make sure you submit all your GSoC evaluations, etc. before the deadline later this week (if you haven't already).
@cchaos is right: we're all thrilled with how it turned out! You did fantastic work over the last few months 🚀
thompsongl commentedon Aug 25, 2020
🙌
ashikmeerankutty commentedon Aug 26, 2020
@cchaos @thompsongl @chandlerprall Thanks for all your support. It was wonderful working with you 😃