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

@datalackey/update-markdown-uml

v1.3.0

Published

Generates and validates UML class and package diagrams for TypeScript source trees, injecting them into Markdown documentation files

Readme

@datalackey/update-markdown-uml

Generates and validates UML class and component diagrams for TypeScript source trees, injecting them into Markdown documentation files.


Terminology

This tool uses component to denote a cohesive group of TypeScript source files that live in a single directory under src/. This is the same concept Java developers know as a package — a named namespace boundary that groups related types and controls visibility. The word "package" is avoided here because in a Node/npm workspace it already means something else (a publishable npm artifact), which would create ambiguity.

What It Does

Given a TypeScript project organised into components (one directory per component under src/), this tool:

  • generates a component overview flowchart showing cross-component import dependencies
  • generates a components table with one row per component
  • generates per-component class diagrams showing classes, interfaces, and type aliases

All three sections are injected into a single Markdown file between fixed marker pairs. Running the tool again is a no-op if nothing has changed — output is fully deterministic.


Installation

npm install --save-dev @datalackey/update-markdown-uml

Usage

Place three marker pairs in the Markdown file where you want the diagrams to appear:

  <!-- UML:components:START -->   <!-- UML:components:END -->

  <!-- UML:components-table:START -->   <!-- UML:components-table:END -->

  <!-- UML:component-details:START -->   <!-- UML:component-details:END -->

Then run:

npx update-markdown-uml README.md

The tool discovers src/ automatically when it exists next to the target Markdown file. Use --source <path> to override.

For CI drift detection, use --check:

npx update-markdown-uml --check README.md

Options

update-markdown-uml [options] <file>

Options:
  --source <path>                   Override source root discovery (default: src/)
  --exclude-packages <pkg1,pkg2>    Leaf directory names to exclude from all output
  --check                           Do not write; exit non-zero if content is stale
  --verbose                         Print per-component type counts
  --quiet                           Suppress all non-error output
  --debug                           Print debug diagnostics to stderr
  --help                            Show this help message and exit

This tool processes a single Markdown file per invocation. Recursive folder traversal is not supported — each UML diagram is tied to a specific source tree, so the association must be declared explicitly. For workspace-wide runs use autogen-markdown-doc.

For full documentation of shared CLI behavior (--check, --verbose, --quiet, exit codes) see Common CLI Behavior.


Example

This folder contains a sample project that demonstrates the tool's output.

Running the sample and reproducing the output you see above by actually installing and running the tool is a good way to get a feel for how it works. Copy/paste the code below to clone the sample, install dependencies, and run the tool.

To view the rendered mermaid graph you could use VSCode's built-in markdown preview, or push it to github and view it in the browser.


rm -rf /tmp/run-sample 
mkdir /tmp/run-sample 
cp -r javascript/update-markdown-uml/tests/e2e/fixtures/math-cli/* /tmp/run-sample/  
cd /tmp/run-sample/  
npm install
npx update-markdown-uml README.md
echo Load the README file into your favorite Markdown viewer. Enjoy the injected UML diagrams.

Source tree

A simple two-component project: a cli layer that delegates computation to a math-engine layer.

src/
  cli/
    AddCommand.ts
    ArgParser.ts
    CliCommand.ts
    CliRunner.ts
    CommandRegistry.ts
    ParsedArgs.ts
    SubtractCommand.ts
  math-engine/
    MathEngine.ts
    MathError.ts
    MathResult.ts
    Operation.ts

cli imports from math-engine. math-engine has no dependency on cli.

Generated output

Component overview — one subgraph per component, arrows show import direction:

flowchart TB
  subgraph cli["cli"]
  end
  subgraph math-engine["math-engine"]
  end

  cli --> math-engine

Components table — names link to the class diagram section below. Descriptions are read from an optional _PACKAGE_INFO.md file in each component directory; TBD appears when the file is absent.

| Component | Description | |-----------|-------------| | cli | Command-line interface layer that parses arguments and dispatches math operations to the math-engine component | | math-engine | Code for System Backend -- which enables CLI front-end access to a suite of sophisticated math functions |

Class diagrams — one per component, showing classes, interfaces, type aliases, and relationships:

cli

classDiagram
  direction TB
  class AddCommand {
    +name unknown
    +description unknown
    -engine MathEngine
    +execute(args) void
  }
  class ArgParser {
    +parse(argv) ParsedArgs
  }
  class CliCommand {
    <<interface>>
    +name string
    +description string
    +execute(args) void
  }
  class CliRunner {
    -registry CommandRegistry
    -parser ArgParser
    +run(argv) void
  }
  class CommandRegistry {
    -commands Map<string, CliCommand>
    +register(command) void
    +get(name) CliCommand | undefined
    +listAll() CliCommand[]
  }
  class ParsedArgs {
    <<interface>>
    +command "add" | "subtract"
    +a number
    +b number
  }
  class SubtractCommand {
    +name unknown
    +description unknown
    -engine MathEngine
    +execute(args) void
  }

  AddCommand ..|> CliCommand
  SubtractCommand ..|> CliCommand

math-engine

classDiagram
  direction TB
  class MathEngine {
    +add(a, b) MathResult
    +subtract(a, b) MathResult
    -validate(op, a, b) void
  }
  class MathError {
    +operation Operation
  }
  class MathResult {
    <<interface>>
    +value number
    +operation Operation
    +operands [number, number]
  }
  class Operation {
    <<type>>
  }

Side Note on How to Correct Unknown Properties

Properties initialised with a literal value and no explicit type annotation (e.g. readonly name = "add") are rendered as unknown because the tool reads TypeScript source without full type resolution. Adding an explicit annotation (readonly name: string = "add") resolves this.


Built With

For the full workspace tech stack see: TECH-STACK.md


Contributing and Releasing

For development setup, build workflow, and release procedures (including how to trigger a publish via Changesets), see CONTRIBUTING.md.