How to use the react-docgen.resolver.findAllComponentDefinitions function in react-docgen

To help you get started, we’ve selected a few react-docgen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / react-instantsearch / docgen / plugins / inlineProps / transformProps.js View on Github external
function findPropTypesDefinitions(ast, recast) {
  const definitions = resolver.findAllComponentDefinitions(ast, recast);

  function objectVisitor(path) {
    // Just check that `propTypes` is present on the object.
    const propTypes = utils.getPropertyValuePath(path, 'propTypes');
    if (propTypes) {
      definitions.push(path);
    }
    return false;
  }

  // The default resolver doesn't traverse function bodies, which means that
  // HOCs propTypes are ignored.
  function classVisitor(path) {
    if (utils.isReactComponentClass(path) && definitions.indexOf(path) === -1) {
      definitions.push(path);
    }
github react-bootstrap / react-overlays / www / gatsby-config.js View on Github external
function combinedResolver(ast, recast) {
  const exportedComponents = resolver.findAllComponentDefinitions(ast, recast);
  const annotated = annotationResolver(ast, recast);
  return exportedComponents.concat(annotated);
}
github react-bootstrap / react-bootstrap / www / resolveHocComponents.js View on Github external
module.exports = (ast, recast) => {
  const {
    types: { namedTypes: types },
  } = recast;

  let components = resolver.findAllComponentDefinitions(ast, recast);

  const getComment = path => {
    let searchPath = path;
    while (searchPath && !types.Statement.check(searchPath.node)) {
      searchPath = searchPath.parent;
    }
    let comment =
      (searchPath &&
        searchPath.node.leadingComments &&
        searchPath.node.leadingComments.map(c => c.value).pop()) ||
      null;

    if (comment) comment = `/${comment}*/`;
    return comment;
  };