Docs
Node.js

Node.js

Install

Install the module with your favorite package manager:

Terminal
npm install --save react-docgen

Usage

Here is a basic example

index.tsx
import { parse } from 'react-docgen';
 
const code = `
/** My first component */
export default ({ name }: { name: string }) => <div>{{name}}</div>;
`;
 
const documentation = parse(code);
 
console.log(documentation);

The documentation that this script is going to print will look like this. If you want to know more about the structure you can head over to the reference of the Documentation

[
  {
    "description": "My first component",
    "methods": [],
    "props": {
      "name": {
        "required": true,
        "tsType": {
          "name": "string"
        },
        "description": ""
      }
    }
  }
]