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

[GSOC] Automatic Documentation System for TypeScript Components #3554

Merged
merged 100 commits into from
Aug 13, 2020

Conversation

ashikmeerankutty
Copy link
Contributor

@ashikmeerankutty ashikmeerankutty commented Jun 4, 2020

Summary

Fixes #3056

  • Replaced react-docgen with react-docgen-typescript
  • Custom babel plugin to inject doc info to components

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples
- [ ] Added or updated jest tests
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Checked for accessibility including keyboard-only and screenreader modes
- [ ] A changelog entry exists and is marked appropriately

Verifying Props

  • Accordion
  • Bottom Bar
  • Flex
  • Flyout
  • Header
  • Horizontal Rule
  • Modal
  • Nav Drawer
  • Page
  • Panel
  • Popover
  • Resizable container
  • Spacer
  • Breadcrumbs
  • Button
  • Collapsible nav
  • Context Menu
  • Control Bar
  • Facet
  • Key Pad Menu
  • Link
  • Pagination
  • Tree View
  • Side Nav
  • Steps
  • Tabs
  • Data grid
  • Tables
  • In-memory tables
  • Aspect ratio
  • Avatar
  • Badge
  • Callout
  • Card
  • Code
  • Comment list
  • Description List
  • Drag And Drop
  • EmptyPrompt
  • Health
  • Icons
  • Image
  • List Group
  • Loading
  • Progress
  • Stat
  • Text
  • Title
  • Toast
  • ToolTip
  • Tour
  • Form controls
  • Form layouts
  • Compressed forms
  • Form validation
  • SuperSelect
  • Combo Box
  • Color Selection
  • Code Editor
  • Date Picker
  • Expression
  • Filter Group
  • EuiRange
  • EuiDualRange
  • EuiDualRange
  • EuiRangeTicks
  • EuiRangeLevels
  • EuiRangeLevels
  • Search Bar
  • Selectable
  • Suggest
  • Super Date Picker
  • Accessibility
  • Beacon
  • Color
  • Color Palettes
  • Context
  • Copy
  • CSS utility classes
  • Delay Hide
  • Delay Render
  • Error Boundary
  • Focus Trap
  • Highlight and mark
  • I18n
  • Outside Click Detector
  • Overlay Mask
  • Portal
  • ResizeObserver
  • Responsive
  • Toggle
  • Window Events

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@thompsongl
Copy link
Contributor

Nice work making progress on all the checklist items!
Is there anything else you'll need to do after you've checked all the components, or will this be ready for a formal review?

@ashikmeerankutty
Copy link
Contributor Author

I used that checklist for ensuring props are generated for all components. There are still some components that are missing some props. and also there are some issues regarding

  • There is some issue with the unchecked components as the props for them are not generated
  • children prop: if the children prop is given as required it's not shown as required by the parser also the type for children prop is found different.
  • I need to omit some props that are both in HtmlElement and component prop definition as they are removed as the parser removes props from HtmlElement.

Rest all seems fine and I also feel that there are some types that are not much readable like

image

@ashikmeerankutty
Copy link
Contributor Author

@thompsongl There seems to be some issues with the tests of EuiLink can you please check that. It seems like they are flaky

@thompsongl
Copy link
Contributor

There is some issue with the unchecked components as the props for them are not generated

Just EuiFlex?

children prop: if the children prop is given as required it's not shown as required by the parser also the type for children prop is found different.

Is it found different because children was not Omit-ed from the original HTML type?

@ashikmeerankutty
Copy link
Contributor Author

ashikmeerankutty commented Jun 24, 2020

Just EuiFlex?

The issue with EuiFlex is solved. Now props are generated for all the components although some props are missing in some components.

Is it found different because children was not Omit-ed from the original HTML type?

No, even if we omit the type from HTML type we are getting different outputs and the required is always false. When I dig in it was found to be an issue with react-docgen-typescript I will somehow try to fix it there (hopefully).

@chandlerprall
Copy link
Contributor

EuiFieldPassword's props look good!

Remember when I asked you to remove the previous ./scripts/babel/proptypes-from-ts-props plugin? Turns out we still want to keep generating proptypes for our components 😅 Can you please re-add that plugin file & entry in the babel configuration? I don't expect it to conflict with the other changes here, but please let me know if it causes trouble and I'll help clean it up.

Sorry about that 🤦, I expect it to be the last piece of this PR! 🎉

@ashikmeerankutty
Copy link
Contributor Author

I don't expect it to conflict with the other changes here, but please let me know if it causes trouble and I'll help clean it up.

There aren't any conflicts. But the test keeps failing since there is new lines are appended to the source file before

FooComponent.PropTypes = ...

and after

import PropTypes from 'proptypes'

@thompsongl
Copy link
Contributor

I'll look at fixing the tests, @chandlerprall, if you haven't started yet

@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3554/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Confirmed the changes (including re-enabling proptype generation) locally with running the dev server, successfully building the package, and successfully using the package in another project.

@thompsongl
Copy link
Contributor

One last time

jenkins test this

@thompsongl
Copy link
Contributor

JavaScript heap out of memory

jenkins test this

@thompsongl
Copy link
Contributor

hmmm

JavaScript heap out of memory

again. Checking on whether something's up with Jenkins

@thompsongl
Copy link
Contributor

JavaScript heap out of memory

happening locally, also. Looking into increasing memory limit

@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3554/

@thompsongl
Copy link
Contributor

Needed to increase the limit on the axe script, also. As such, I'm going to start work on #3801, but we can still move forward here and not block merging.

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3554/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @ashikmeerankutty! 🎉

@thompsongl thompsongl merged commit 1bb1f24 into elastic:master Aug 13, 2020
nyurik pushed a commit that referenced this pull request Aug 18, 2020
* Add react-docgen-typescript

* Add react-docgen-typescript plugin

* Use ts.createProgram

* Hide errors for now

* Omit id from HTML Attributes in accordion

* Common props to beginning

* Fixed issue with boolean props not generated

* Changed React.Component to Component for props info

* save Prop value as string

* Use react for tsx and jsx in compiler option

* Removed console.log

* Save prop value as string

* Added comment for children prop

* CommonProps to the beginning

* replace React.

* Updated react-docgen-typescript

* Fixed typo in package.json

* Removed screenreader only prop used in docs

* Relaced React.

* Create program must use files from src-docs

* increased uti.inspect maxlength

* Updated export for flex_group

* Removed issues with some files

* Use spread operator

* Replaced React

* Removed logs used to test

* Removed src-docs

* Add  comment to children node to flex grid

* Add description for children node

* Fixed issues with components in generating props

* Omit onClick prop from html elements

* Allow color title onClick

* Removed color title onClick

* Fixed issues with color and title

* Support types from react-dnd

* Fixed title prop in context_menu_panel

* Fixed required issue in checkable card

* Fixed issue with an if loop

* Fixed issues with props not generating

* Fixed issues with props not generating

* tests passing; responsive prop default

* Fix issue with overlay mask props

* Fixed title not generated and props for overlaymask

* Fixed wrong prop generated for children prop

* get children prop from ast

* get children prop from ast

* removed filename usage

* Fixed children prop issue with class components

* playground input updates

* Update src-docs/src/services/playground/props.js

* Update src-docs/src/services/playground/props.js

* use any HTML value instead of printing all html values

* Replace some with every

* Update src/components/toast/global_toast_list_item.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/title/title.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/tabs/tabs.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/steps/step.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/badge/notification_badge/badge_notification.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/resizable_container/resizable_panel.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Removed babel plugin react docgen and props types from ts props

* Apply suggestions from code review

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Removed babel plugin react docgen

* Fixed children prop

* description must respect line breaks

* Fixed issue with any

* Fixed props types

* Add more comments

* Replaces ReactElement<any>

* Replace ReactNode and ReactElement expanded string

* Update src/components/accessibility/screen_reader.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Fixed warnings from webpack

* Fixed issue with facet button

* Fixed issue with link

* Fixed issue with link

* Fixed issue with toggle

* Fixed issue with ReactText

* Fixed issue with link

* Add ; back

* Fixed prettier errors

* Fex prettier problem

* Add proptypes from ts props back

* align test ouput

* increase minified bundle build node memory limit

* increase other prod-like build node memory limit

Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
@ashikmeerankutty ashikmeerankutty changed the title Automatic Documentation System for TypeScript Components [GSOC] Automatic Documentation System for TypeScript Components Aug 25, 2020
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3554/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GSoC] Automatic Documentation System for TypeScript Components
6 participants