All Projects → jquense → react-component-metadata

jquense / react-component-metadata

Licence: MIT License
No description, website, or topics provided.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

react-component-metadata

parse react components for prop data and descriptions as well as leading comments

Install

npm i -S react-component-metadata

Use

var metadata = require('react-component-metadata')
var fs = require('fs')

var result = metadata(fs.readFileSync('./Modal.jsx', 'utf8'), 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 additional mixin: true property on the component metadata. Setting this to true will also try and parse mixins in createClass components and add them to the mixins property.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].