How to use the react-docgen.parse 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 callstack / component-docs / src / parsers / component.js View on Github external
for (const line of lines) {
    if (line === '// @component-docs ignore-next-line') {
      skip = true;
      continue;
    }

    if (skip) {
      skip = false;
      continue;
    }

    content += line + '\n';
  }

  const info = parse(
    content,
    undefined,
    [...defaultHandlers, staticPropertyHandler],
    {
      cwd: root,
      filename: filepath,
    }
  );
  const name = info.displayName || getNameFromPath(filepath);

  return {
    filepath: path.relative(root, filepath),
    title: name,
    description: info.description,
    link: dashify(name),
    data: info,
github OriR / react-docgen-markdown-renderer / test / complex-props-render-tests.js View on Github external
lab.test('with arrayOf', ({ context }) => {
      const result = context.renderer.render(
        './some/path',
        reactDocgen.parse(
          simpleComponent({
            componentName: 'MyComponent',
            props: [
              context.getShapeProp([
                { name: 'stringProp', type: 'string' },
                { name: 'arrayOfProp', type: 'arrayOf(PropTypes.number)' },
              ]),
            ],
          }),
        ),
        [],
      );

      expect(result).to.equal(
        simpleMarkdown({
          types: [
github vue-styleguidist / vue-styleguidist / src / rsg-components / Methods / Methods.spec.js View on Github external
function render(methods) {
	const parsed = parse(`
		import { Component } from 'react';
		export default class Cmpnt extends Component {
			${methods.join('\n')}
			render() {
			}
		}
	`);
	return shallow();
}
github ringcentral / ringcentral-js-widgets / docs / src / app / pages / Components / RecentActivityView / index.js View on Github external
const RecentActivityViewPage = () => {
  const info = parse(componentCode);
  return (
    <div>
      
      
        
      
      
    </div>
  );
};
github nerdlabs / react-docgen-displayname-handler / source / index.spec.js View on Github external
function parse(source, handler) {
  const code = `
    var React = require('react');
    ${source}
  `;
  return docgen.parse(code, findAllComponentDefinitions, [handler])[0];
}
github ringcentral / ringcentral-js-widgets / packages / ringcentral-widgets-docs / src / app / pages / Components / TabNavigationView / index.js View on Github external
const TabNavigationViewPage = () =&gt; {
  const info = parse(componentCode);
  return (
    <div>
      
      
        
      
      
    </div>
  );
};