npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

handoff-docgen

v0.1.0

Published

Generate React component docs with deep TypeScript type mapping.

Readme

handoff-docgen

handoff-docgen is a Node.js + TypeScript package for generating React component documentation with:

  • baseline metadata from react-docgen-typescript
  • deep recursive type mapping via TypeScript Compiler API
  • deterministic JSON output for CI and downstream tooling

Install

npm install handoff-docgen

CLI Usage

handoff-docgen --dir ./src/components --out ./dist/docs.generated.json --tsconfig ./tsconfig.json

Options:

  • --dir directory to scan for .tsx components
  • --out output JSON file path
  • --tsconfig tsconfig used by both docgen and deep mapper
  • --max-depth recursion depth cap (default 7)
  • --path-mode output path mode: relative (default) or absolute
  • --project-root base path used for relative path mode (defaults to tsconfig directory)
  • --exclude-dir directory name to skip during scanning (repeatable)

Programmatic Usage

import { createGenerator, generateDocs } from "handoff-docgen";

// One-off generation
const docs = await generateDocs({
  componentDirectory: "./src/components",
  tsconfigPath: "./tsconfig.json",
  maxDepth: 7,
  pathMode: "relative",
  excludeDirectories: ["dist", "build"]
});

// Reusable generator instance (great for repeated runs)
const generator = createGenerator({
  componentDirectory: "./src/components",
  tsconfigPath: "./tsconfig.json",
  maxDepth: 7
});

const nextDocs = await generator.generate();
const docsForAnotherDir = await generator.generate({
  componentDirectory: "./src/marketing-components"
});

handoff-docgen intentionally focuses on generation, not storage. Persist to disk (JSON, DB, API) in your host app/CLI based on your pipeline needs.

Example custom file persistence in host app:

import { mkdir, writeFile } from "node:fs/promises";
import path from "node:path";
import { generateDocs } from "handoff-docgen";

const docs = await generateDocs({
  componentDirectory: "./src/components",
  tsconfigPath: "./tsconfig.json"
});

const out = path.resolve("./dist/docs.generated.json");
await mkdir(path.dirname(out), { recursive: true });
await writeFile(out, JSON.stringify(docs, null, 2), "utf8");

Module Support

handoff-docgen supports both ESM and CommonJS consumers.

ESM:

import { generateDocs } from "handoff-docgen";

CommonJS:

const { generateDocs } = require("handoff-docgen");

If your TypeScript project compiles with "module": "commonjs", the CommonJS require form is supported.

Output Highlights

Each prop includes:

  • docgen baseline (docgenType, required, defaultValue, description)
  • deep mapping (deepType, typeRefs, warnings)
  • parsed JSDoc annotations (annotations)

Deep mapper handles:

  • interfaces/type aliases
  • unions/intersections
  • arrays/sets/maps/records
  • enums/literals
  • cycle detection and depth truncation

Build & Typecheck

npm run build
npm run typecheck
npm run test:consumers

API Surface

  • generateDocs(options) - one-off generation, returns GeneratedDocs
  • createGenerator(options) - returns reusable generator with generate(overrides?)
  • CLI handoff-docgen - generate + write JSON file for shell workflows