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

feat: add JSON docgen generator to feed docusaurus website with accurate prop definitions #7927

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

tkajtoch
Copy link
Member

Summary

Resolves #7926

This PR adds a new private package @elastic/eui-docgen that generates docgen JSON files for all EUI source files just like the babel script did. It reuses most of the old code and results in lots of definition JSON files being generated. This PR also adds an example page to docusaurus and very, very basic PropTable component to the docusaurus-theme package. These will be updated and improved in following PRs.

QA

  1. Checkout this PR and run yarn
  2. Go to packages/website and build all of its local dependencies: yarn workspaces foreach -Rpt --from @elastic/eui-website run build
  3. Run the development server yarn start
  4. Confirm the test page renders a basic prop table

@tkajtoch tkajtoch self-assigned this Jul 29, 2024
@tkajtoch tkajtoch requested a review from a team as a code owner July 29, 2024 17:24
@@ -0,0 +1,73 @@
import { EuiBasicTable, EuiMarkdownFormat, EuiBasicTableColumn, EuiTextColor, EuiCode } from '@elastic/eui';
Copy link
Member Author

Choose a reason for hiding this comment

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

This component is just for demonstration purposes only and will be heavily refactored in a separate PR.

"dist",
"lib"
],
"types": "./lib/index.d.ts",
Copy link
Member Author

Choose a reason for hiding this comment

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

The only exports are the type definitions for the interfaces this package defines

@@ -0,0 +1,96 @@
import type { PropItem } from 'react-docgen-typescript';
Copy link
Member Author

@tkajtoch tkajtoch Jul 29, 2024

Choose a reason for hiding this comment

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

Most of this source code comes from https://github.com/elastic/eui/blob/main/packages/eui/scripts/babel/react-docgen-typescript.js and is purposefully left as is to keep the prop table data the same as on the current documentation site.

Copy link
Contributor

Choose a reason for hiding this comment

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

🗒️ Considering that it's mainly copied, I won't do an in depth review of it.

Copy link
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

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

I checked the output locally on a couple of components and it looks really good! 🎉

I left a couple of comments, most are related to the props table output which can be addressed separately.

@@ -0,0 +1,96 @@
import type { PropItem } from 'react-docgen-typescript';
Copy link
Contributor

Choose a reason for hiding this comment

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

🗒️ Considering that it's mainly copied, I won't do an in depth review of it.

packages/eui-docgen/src/main.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

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

🚢 🐈‍⬛ LGTM! Thanks for the updates!

@tkajtoch tkajtoch enabled auto-merge (squash) July 30, 2024 09:59
@tkajtoch tkajtoch merged commit a2935a8 into elastic:main Jul 30, 2024
5 checks passed
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @tkajtoch

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

Successfully merging this pull request may close these issues.

[New docs] Generate prop table JSON data
3 participants