-
Notifications
You must be signed in to change notification settings - Fork 536
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
Automate component documentation #4466
base: main
Are you sure you want to change the base?
Conversation
oops forgot to commit changes
…docs-passion-week-042024
|
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.
We really need this, awesome work! Does it make sense to merge this PR in its current state and fill in the missing components later? If so, I'm happy to approve it.
@@ -0,0 +1,149 @@ | |||
const docgen = require('react-docgen-typescript') |
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.
Can we use module import
s here instead of require
? I see we're using tsx
so that should be possible?
const {alias, primerid, primerstatus, primera11yreviewed, primerstories = '', primerparentid} = tags | ||
|
||
return { | ||
id: primerid, // TODO: consider auto-generating an ID if one is not present by parsing `displayName` |
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.
Just FYI @broccolinisoup and I just worked up this PR and this PR that introduce a docsId
field for grouping related components that have different names, eg. tooltip
and tooltip_v2
. We'll probably want to generate that field in this script too, although I'm not sure where the data would come from.
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
…docs-passion-week-042024
size-limit report 📦
|
…docs-passion-week-042024
…docs-passion-week-042024
…docs-passion-week-042024
updates resulting output data per last commit
…hey were polymorphic and forwarded refs
…docs-passion-week-042024
…docs-passion-week-042024
… - COMMENTED OUT FOR NOW
…docs-passion-week-042024
I'm trying to automate more of our component documentation by using
react-docgen-typscript
. This could eliminate the need to maintain{ComponentName}.docs.json
files.See this discussion post for a more detailed overview of this work.
Try it out
npm run build:component-docs-json
Raw Docgen output: packages/react/script/prop-docs/docgen-output.json
With data required by components.json schema: packages/react/script/prop-docs/components.json
Overview
The bulk of the changes in this PR are to make component documentation data parseable by
react-docgen
andreact-typescript-docgen
.The main issue was caused by referencing accessing React's modules directly from the
React
import. I found 3 ways to work around this:Still broken
There are a few files I haven't been able to parse yet.
Skipped entirely by
react-docgen-typsecript
Comforting note: We might not even need docs for these because they're only used internally.
Props or args not documented
Comforting note: Some of these components don't have any props besides "children", and some of these files may not even need docs because they're not meant for external use.