Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-docgen

Package Overview
Dependencies
Maintainers
0
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-docgen

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

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

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

Package last updated on 19 Oct 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc