Package Exports
- react-component-metadata
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-component-metadata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-component-metadata
parse react components for prop data and descriptions as well as leading comments
Install
npm i -S react-component-metadataUse
var metadata = require('react-component-metadata')
var fs = require('fs')
var result = metadata(fs.readFileSync('./Modal.jsx'), options)result will be an object hash with component names as keys
{
// component name is either the Identifier name, displayName, the value of the @alias or @name doclet if it exists.
Modal: {
desc: 'A modal component' //the component leading comment
props: {
show: {
type: { name: 'object' },
required: false,
desc: 'Show or hide the modal Component.' //the prop type leading comment
}
}
}
}You can also use metadata.parseDoclets to parse the JSDoc values out of the comments.
Options
mixins: default false, Parse Mixins as components, will have an additionalmixin: trueproperty on the component metadata. Setting this totruewill also try and parse mixins in createClass components and add them to themixinsproperty.