0.2.1 • Published 7 years ago

react-extract-component-meta v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

React Extract Component Metadata

npm

react-extract-component-meta is a Webpack plugin to extract React component metadata. It generates a JSON file as output.

Installation

Install the module directly from npm:

npm install --save-dev react-extract-component-meta

Usage

Import the plugin in your webpack.config.js file and create a new instance.

const ReactExtractComponentMeta = require('react-extract-component-meta');

module.exports = {
    ...    
    plugins: [new ReactExtractComponentMeta()]
};

react-extract-component-meta accpets a config object which allows you to specify the pattern to match your react components as well as name of the output JSON file.

const ReactExtractComponentMeta = require('react-extract-component-meta');

module.exports = {
    ...    
    plugins: [new ReactExtractComponentMeta({
        'filter': /component/gi,
        'output': {
            'filename': 'components-meta.json'
        }
    })]
};

Sample JSON file output

{
    "MyComponent": {
        "name": "MyComponent",
        "description": "MyComponent description",
        "methods": [
            {
                "name": "someFuction",
                "docblock": "Component function description",
                "modifiers": [],
                "params": [],
                "returns": null,
                "description": "Component function description"
            }
        ],
        "props": {
            "someProp": {
                "type": {
                    "name": "custom",
                    "raw": "PropTypes.string.isrequired"
                },
                "required": false,
                "description": ""
            },
            "someMoreProp": {
                "type": {
                    "name": "custom",
                    "raw": "PropTypes.array"
                },
                "required": false,
                "description": ""
            }
        }
    },
    
    "MyOtherComponent": {
        ...
    }
    ...
}

Changelog

The changelog can be found on the Change log page.

Authors and license

Sunil Kumar

MIT License, see the included License file.

0.2.1

7 years ago

0.2.0

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago