react-docer
v1.1.6
Published
A tool to parse doc from jsx source file
Downloads
53
Readme
react-docer
A tool to parse doc from jsx source file
Installation
$ npm install --save react-docer
Usage
const docer = require('react-docer');
docer(content);
const React = require('react');
import babel from 'babel';
/**
* class description
*/
class Component extends React.Component {
/**
* static prop description
*/
static someProps = 'qwerty'
/**
* constructor description
*/
constructor() {
super();
}
/**
* get value
*/
getValue() {}
/**
* set value
*/
setValue(value) {}
/**
* render description
*/
render() {
return (
<div></div>
);
}
}
Component.propTypes = {
/**
* Description of someProp.
*/
someProp: React.PropTypes.string
};
Component.displayName = 'Component';
Component.defaultProps = {
someProp: ''
};
Then the result will be:
{
"dependencies": [
"react",
"babel"
],
"classes": [
{
"name": "Component",
"superClass": "React.Component",
"description": "class description",
"methods": [
{
"description": "constructor description",
"name": "constructor",
"params": []
},
{
"description": "get value",
"name": "getValue",
"params": []
},
{
"description": "set value",
"name": "setValue",
"params": [
"value"
]
},
{
"description": "render description",
"name": "render",
"params": []
}
],
"properties": [
{
"description": "static prop description",
"name": "someProps",
"value": "'qwerty'",
"static": true
}
],
"propTypes": [
{
"name": "someProp",
"required": false,
"type": {
"name": "string"
},
"description": "Description of someProp.",
"defaultValue": "''"
}
],
"displayName": "Component"
}
]
}
Test
$ npm run test # running unit tests
$ npm run dev # watching files change and building automaticly
License
The MIT License (MIT)
Copyright (c) 2015 ly-tools
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.