Socket
Socket
Sign inDemoInstall

react-docgen

Package Overview
Dependencies
73
Maintainers
2
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-docgen

A library to extract information from React components for documentation generation.


Version published
Weekly downloads
4.3M
increased by0.35%
Maintainers
2
Install size
11.0 MB
Created
Weekly downloads
 

Package description

What is react-docgen?

The react-docgen npm package is a CLI and toolbox that helps you to extract information from React components, such as prop types, default props, and component descriptions, by analyzing the source code. It is particularly useful for generating documentation automatically and can be integrated into build processes.

What are react-docgen's main functionalities?

Extracting component metadata

This feature allows you to extract metadata from a React component source code. The 'parse' function takes the source code as a string and returns an object containing the component's metadata, such as its name, props, default props, and description.

const reactDocgen = require('react-docgen');
const componentInfo = reactDocgen.parse(source);

Handling different component definitions

React-docgen can handle different ways of defining React components, such as class components, functional components, and higher-order components. By using different resolvers, you can extract metadata from various component definitions.

const reactDocgen = require('react-docgen');
const componentInfo = reactDocgen.parse(source, reactDocgen.resolver.findAllComponentDefinitions);

Custom handlers

You can add custom handlers to the parsing process to extract or modify the information in a way that suits your specific needs. This allows for extensibility and customization of the metadata extraction process.

const reactDocgen = require('react-docgen');
const customHandler = (documentation, path) => { /* custom logic */ };
const componentInfo = reactDocgen.parse(source, null, [customHandler]);

Other packages similar to react-docgen

Keywords

FAQs

Last updated on 12 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc