Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 1.2 KB

File metadata and controls

70 lines (57 loc) · 1.2 KB

propDocblockHandler

Tries to find the prop types on react components and extracts their Docblock description. It uses the same logic as the propTypeHandler to find the prop types.

Examples

When the propDocblockHandler is active any of these components will result in the output below

import PropTypes from 'prop-types';

class MyComponent extends React.Component {
  static propTypes = {
    /** Foo */
    foo: PropTypes.string,
    bar: PropTypes.number,
  };
  render() {
    return <div />;
  }
}
import PropTypes from 'prop-types';

class MyComponent extends React.Component {
  render() {
    return <div />;
  }
}

MyComponent.propTypes = {
  /** Foo */
  foo: PropTypes.string,
  bar: PropTypes.number,
};
import PropTypes from 'prop-types';

const MyComponent = () => <div />;

MyComponent.propTypes = {
  /** Foo */
  foo: PropTypes.string,
  bar: PropTypes.number,
};

Output

[
  {
    "props": {
      "foo": {
        "description": "Foo"
      },
      "bar": {
        "description": ""
      }
    }
  }
]