-
Notifications
You must be signed in to change notification settings - Fork 5
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
Intention to parse/extract description? #6
Comments
Hi @dennisreimann. I would like to add this feature, but I have no idea how to implement that. I'm open for suggestions. |
I dove a little deeper and checked some possibilities (extract-comments and using @babel/parser directly). Even though it's pretty simple to get the comments from the parsed file, I don't see a way to map them to the PropType definitions. There is no parser information (like line numbers etc.) available in the What's your opinion on consuming a proprietary attribute like const parsePropTypes = ({
propTypes = {},
defaultProps = {},
propDescriptions = {}
} : {
propTypes?: Object,
defaultProps?: Object,
propDescriptions?: Object
}) // … This would allow for defining the descriptions programmatically, similar to the Person.propTypes = {
name: PropTypes.string
}
Person.propDescriptions = {
name: "The persons first and last name"
} It'd be a proprietary way to define this information and it's not as elegant/intuitive as via the comments, but at least there's be a way to further describe the PropTypes and it'd be way easier to implement. What are your thoughts? |
I think that's a good solution. But that Maybe there's some babel plugin that eliminates code with comment flags? Something like this: // babel-eliminate-next
Person.propDescriptions = {
name: "The persons first and last name"
} |
For Babel there is babel-plugin-transform-react-remove-prop-types, but it doesn't trim this proprietary attribute. Another solution would be to leverage Webpacks DefinePlugin. In my case the comments/descriptions aren't as extensive as I would care, but I understand the concern and there have been prior discussions about removing PropTypes alltogether. Thinking about it I'm also intrigued by the idea of having something like |
Any evolvement in this feature? Would be great! |
I came here looking for an alternative to react-docgen, which as you describe lacks proper ways to parse complex prop-types structures, i.e. with imported types. Your library works great and offers what I am looking for, so thanks for that! 👍
The one thing I miss™️ are the
description
prop-type properties as they are offered by react-docgen. As your library does not use a parser this might not be trivial to add, but I wanted to ask about your thoughts regarding this and whether or not you'd be interested in a contribution for this feature.The text was updated successfully, but these errors were encountered: