Socket
Socket
Sign inDemoInstall

react-docgen-typescript

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-docgen-typescript

[![Build Status](https://github.com/styleguidist/react-docgen-typescript/actions/workflows/nodejs.yml/badge.svg)](https://github.com/styleguidist/react-docgen-typescript/actions/workflows/nodejs.yml)


Version published
Weekly downloads
4.4M
increased by0.48%
Maintainers
1
Weekly downloads
 
Created

What is react-docgen-typescript?

The react-docgen-typescript package is a tool for extracting documentation from TypeScript React components. It parses TypeScript files and generates JSON output that describes the components, their props, methods, and other relevant information. This is particularly useful for creating documentation websites or integrating with other tools that require component metadata.

What are react-docgen-typescript's main functionalities?

Extracting Prop Types

This feature allows you to extract prop types from a TypeScript React component. The `parse` function reads the component file and returns a JSON object containing detailed information about the component's props.

const docgen = require('react-docgen-typescript');
const options = { savePropValueAsString: true };
const componentInfo = docgen.parse('path/to/your/component.tsx', options);
console.log(JSON.stringify(componentInfo, null, 2));

Customizing Parser Options

This feature allows you to customize the parser options to fit your needs. For example, you can choose to extract literal values from enums or remove `undefined` from optional props.

const docgen = require('react-docgen-typescript');
const options = { shouldExtractLiteralValuesFromEnum: true, shouldRemoveUndefinedFromOptional: true };
const componentInfo = docgen.parse('path/to/your/component.tsx', options);
console.log(JSON.stringify(componentInfo, null, 2));

Generating Documentation for Multiple Files

This feature allows you to generate documentation for multiple files at once. You can pass an array of file paths to the `parse` function, and it will return a combined JSON object with information about all the components.

const docgen = require('react-docgen-typescript');
const options = { savePropValueAsString: true };
const files = ['path/to/your/component1.tsx', 'path/to/your/component2.tsx'];
const componentInfo = docgen.parse(files, options);
console.log(JSON.stringify(componentInfo, null, 2));

Other packages similar to react-docgen-typescript

FAQs

Package last updated on 11 Dec 2021

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