How to use the react-docgen.handlers 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 microsoft / react-native-windows / website / server / extractDocs.js View on Github external
function renderStyle(filepath) {
  const json = docgen.parse(
    fs.readFileSync(filepath),
    docgenHelpers.findExportedObject,
    [docgen.handlers.propTypeHandler]
  );

  // Remove deprecated transform props from docs
  if (filepath === '../Libraries/StyleSheet/TransformPropTypes.js') {
    ['rotation', 'scaleX', 'scaleY', 'translateX', 'translateY'].forEach(function(key) {
      delete json.props[key];
    });
  }

  return componentsToMarkdown('style', json, filepath, componentCount++);
}
github ansumanshah / css-in-js / packages / atom-css-in-js / scripts / rn / completions.js View on Github external
const styleDocs = paths.reduce((docs, filepath) => {
  const props = docgen.parse(
    fs.readFileSync(path.resolve('node_modules/react-native', filepath)),
    findExportedObject,
    [docgen.handlers.propTypeHandler, docgen.handlers.propDocBlockHandler]
  ).props

  // Remove deprecated transform props from docs
  if (filepath === 'Libraries/StyleSheet/TransformPropTypes.js') {
    ;[
      'rotation',
      'scaleX',
      'scaleY',
      'translateX',
      'translateY',
    ].forEach(function(key) {
      delete props[key]
    })
  }

  let newProps = {}
github facebook / react-360 / website / server / extractDocs.js View on Github external
function renderStyle(filepath) {
  const json = docgen.parse(
    fs.readFileSync(filepath),
    docgenHelpers.findExportedObject,
    [
      docgen.handlers.propTypeHandler,
      docgen.handlers.propDocBlockHandler,
    ]
  );

  json.props = json.props || {};
  if (json.props) {
    // remove styles not yet supported
    UNSUPPORTED_STYLES.forEach(function(key) {
      delete json.props[key];
    });
  }

  // Remove deprecated transform props from docs
  if (filepath === '../Libraries/StyleSheet/TransformPropTypes.js') {
    ['rotation', 'scaleX', 'scaleY', 'translateX', 'translateY'].forEach(function(key) {
      delete json.props[key];
github facebook / react-360 / website / server / extractDocs.js View on Github external
const styleDocs = docsList.stylesForEmbed.reduce(function(docs, filepath) {
  let json =
    docgen.parse(
      fs.readFileSync(filepath),
      docgenHelpers.findExportedObject,
      [
        docgen.handlers.propTypeHandler,
        docgen.handlers.propTypeCompositionHandler,
        docgen.handlers.propDocBlockHandler,
      ]
    );

  json.props = json.props || {};
  if (json.props) {
    // remove styles not yet supported
    UNSUPPORTED_STYLES.forEach(function(key) {
      delete json.props[key];
    });
  }

  docs[path.basename(filepath).replace(path.extname(filepath), '')] = json;

  return docs;
github facebook / react-native / website / server / extractDocs.js View on Github external
function renderStyle(filepath) {
  const json = docgen.parse(
    fs.readFileSync(filepath),
    docgenHelpers.findExportedObject,
    [
      docgen.handlers.propTypeHandler,
      docgen.handlers.propDocBlockHandler,
    ]
  );

  // Remove deprecated transform props from docs
  if (filepath === '../Libraries/StyleSheet/TransformPropTypes.js') {
    ['rotation', 'scaleX', 'scaleY', 'translateX', 'translateY'].forEach(function(key) {
      delete json.props[key];
    });
  }

  return componentsToMarkdown('style', json, filepath, componentCount++);
}
github alfa-laboratory / library-utils / react-doc / index.js View on Github external
const path = require('path');
const reactDocGen = require('react-docgen');
const { createDisplayNameHandler } = require('react-docgen-displayname-handler');
const getSourceFileContent = require('./get-source-file-content');
const createResolver = require('./create-resolver');
const componentPropTypesJsDocHandler = require('./component-prop-types-js-doc-handler');

const documentation = {};
const defaultHandlers = [
    reactDocGen.handlers.propTypeHandler,
    reactDocGen.handlers.propTypeCompositionHandler,
    reactDocGen.handlers.propDocBlockHandler,
    reactDocGen.handlers.flowTypeHandler,
    reactDocGen.handlers.flowTypeDocBlockHandler,
    reactDocGen.handlers.defaultPropsHandler,
    reactDocGen.handlers.componentDocblockHandler,
    reactDocGen.handlers.displayNameHandler,
    reactDocGen.handlers.componentMethodsHandler,
    reactDocGen.handlers.componentMethodsJsDocHandler,
    componentPropTypesJsDocHandler,
].filter(Boolean);

function getReactComponentInfo(filePath, parentPath) {
    if (documentation[filePath]) {
        return documentation[filePath];
    }

    const src = getSourceFileContent(filePath, parentPath);
github alfa-laboratory / library-utils / react-doc / index.js View on Github external
const path = require('path');
const reactDocGen = require('react-docgen');
const { createDisplayNameHandler } = require('react-docgen-displayname-handler');
const getSourceFileContent = require('./get-source-file-content');
const createResolver = require('./create-resolver');
const componentPropTypesJsDocHandler = require('./component-prop-types-js-doc-handler');

const documentation = {};
const defaultHandlers = [
    reactDocGen.handlers.propTypeHandler,
    reactDocGen.handlers.propTypeCompositionHandler,
    reactDocGen.handlers.propDocBlockHandler,
    reactDocGen.handlers.flowTypeHandler,
    reactDocGen.handlers.flowTypeDocBlockHandler,
    reactDocGen.handlers.defaultPropsHandler,
    reactDocGen.handlers.componentDocblockHandler,
    reactDocGen.handlers.displayNameHandler,
    reactDocGen.handlers.componentMethodsHandler,
    reactDocGen.handlers.componentMethodsJsDocHandler,
    componentPropTypesJsDocHandler,
].filter(Boolean);

function getReactComponentInfo(filePath, parentPath) {
    if (documentation[filePath]) {
        return documentation[filePath];
    }
github facebook / react-native / website / server / extractDocs.js View on Github external
const styleDocs = docsList.stylesForEmbed.reduce(function(docs, filepath) {
  docs[path.basename(filepath).replace(path.extname(filepath), '')] =
    docgen.parse(
      fs.readFileSync(filepath),
      docgenHelpers.findExportedObject,
      [
        docgen.handlers.propTypeHandler,
        docgen.handlers.propTypeCompositionHandler,
        docgen.handlers.propDocBlockHandler,
      ]
    );

  return docs;
}, {});
github microsoft / react-native-windows / website / server / extractDocs.js View on Github external
const styleDocs = stylesForEmbed.reduce(function(docs, filepath) {
  docs[path.basename(filepath).replace(path.extname(filepath), '')] =
    docgen.parse(
      fs.readFileSync(filepath),
      docgenHelpers.findExportedObject,
      [
        docgen.handlers.propTypeHandler,
        docgen.handlers.propTypeCompositionHandler,
        docgen.handlers.propDocBlockHandler,
      ]
    );

  return docs;
}, {});