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
docs: refine babel-types docs generator #13148
docs: refine babel-types docs generator #13148
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/45186/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 243518c:
|
We might use a GH action to update |
Yeah. Since most |
Object.keys(t.BUILDER_KEYS) | ||
.sort() | ||
.forEach(function (key) { | ||
readme.push("### " + toFunctionName(key)); |
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.
this is outside your PR but just wanted to note it! Looking at the rendered part again, maybe in another PR, we should have a quick section above that explains the terms "builder" and the difference between
t.anyTypeAnnotation();
t.isAnyTypeAnnotation(node, opts)
t.assertAnyTypeAnnotation(node, opts).
I would just mention that instead of manually creating the AST node as an object, we provide this interface with some assertions etc. And then the other two methods as an alias t.isX = node.type === "x", and same with assert?
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.
Not sure where we would do it, but it would also be nice to have a short snippet of what that code even looks like since this page assume you know what each node is. We can also link to astexplorer as a way to test it.
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.
have a quick section above that explains the terms "builder" and the difference between
t.anyTypeAnnotation();
t.isAnyTypeAnnotation(node, opts)
t.assertAnyTypeAnnotation(node, opts).
Agreed. I have split the "API" section, tentatively, to "Node Builders" and "Aliases" in #13151, maybe we can add new sections about the usage of is*
and assert*
.
This PR revives the
@babel/types
docs generator. Now it supports rendering API history. Some whitespace changes are adopted to adapt to the prettier style used in babel website.I plan to draft a new section on the alias of AST node.
Related: see babel/website#2490 for the rendered diff and preview.