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

@benjamins94/simple-docs-extractor

v1.2.0

Published

A lightweight TypeScript library for extracting documentation from source files and organizing them into a structured output directory

Readme

About

A lightweight TypeScript library for extracting documentation from source files and organizing them into a structured output directory.

Having trouble getting started? Send me an email or create an issue.

Why this approach?

I built this library so I could write documentation directly in my source code, and have it automatically pulled out and organized for me.

This way, I can focus on coding while the library takes care of collecting and structuring the docs.

With GitHub Actions, the documentation is published to GitHub Pages automatically, so everything stays up to date with no extra effort.

Documentation

View the documentation on GitHub Pages.

Features

  • Easy Documentation Writing - Write docs directly in your code using simple tags like <docs> and <method>
  • Beautiful Output - Automatically creates clean, organized documentation files with your own custom templates
  • Smart Organization - Keeps your docs organized by automatically creating index pages and preserving your folder structure
  • Works with Any Code - Extract documentation from JavaScript, TypeScript, and other files using flexible patterns
  • Clean Content - Automatically removes messy comment formatting and makes your docs look professional
  • Simple Setup - Easy-to-use builder pattern that lets you configure everything in just a few lines
  • TypeScript Ready - Built with TypeScript for better development experience and fewer errors
  • Multiple Projects - Handle different parts of your codebase with separate documentation setups

Proof is in the pudding

  • The entirity of this project's documentation is powered by this library.
  • (Apart from some pages that are manually written )

Examples

Basic Configuration with Minimal Configuration

const service = SimpleDocExtractor
  .create(process.cwd())
  .target((target) => {
    target.cwd(path.join(process.cwd(), 'src'))
    target.outDir(path.join(process.cwd(), "docs"))
    target.patterns("**/*")
    target.createIndexFiles()
  })
  .addRecommendedFormatters()
  .buildService();

await service.start();

Simple Doc Configuration Example

This is the same example as used in our publish-docs.ts script.

  • Extracts content from from the top of the classes.
  • Extracts content from from the top of the methods.
  • It also copies the README.md file to the root index file.
  • It only targets js/ts files.
import path from "path";
import { SimpleDocExtractor } from "@/simple-docs-scraper/index.js";
import { TagExtractorPlugin } from "@/simple-docs-scraper/extractors/TagExtractorPlugin.js";
import { CopyContentsPlugin } from "@/simple-docs-scraper/extractors/CopyContentsPlugin.js";

export const DEFAULT_CONFIG = SimpleDocExtractor
  .create(process.cwd())
    // Define our global templates (This can also be done on a target level)
    .indexTemplate((template) => {
      template.useFile(path.join(process.cwd(), "src/templates/index.template.md"));
      template.useMarkdownLinks();
    })
    .documentationTemplate((template) => {
      template.useFile(path.join(process.cwd(), "src/templates/documentation.template.md"));
    })
  // Define our target(s) to extract documentation from
  .target((target) => {
    target.cwd(path.join(process.cwd(), 'src')) // The directory to search for files to extract documentation from
    target.outDir(path.join(process.cwd(), "docs")) // The directory to output the generated documentation to
    target.patterns("**/*.{js,ts}") // The patterns to match files to extract documentation from
    target.ignores(["**/tests/**", "**/scripts/**"]) // The patterns to ignore when searching for files to extract documentation from
    target.createIndexFiles() // Whether to create an index.md file for this target
    target.plugins([ // The plugins to use when extracting documentation
      new TagExtractorPlugin({
        tag: "docs",
        searchAndReplace: "%content%",
      }),
      new TagExtractorPlugin({
        tag: "method",
        searchAndReplace: "%methods%",
        attributeFormat: "### **{value}**",
      })
    ])
    // Define the template to use for the root index file
    target.rootIndexTemplate((template) => {
      template.useFile(path.join(process.cwd(), "src/templates/root-index.template.md")); // The template to use for the root index file
      template.useMarkdownLinks(); // Whether to use markdown links in the root index file
      template.plugins( // The plugins to use when generating the root index file
        new CopyContentsPlugin({
          fileToCopy: path.join(process.cwd(), "README.md"),
          searchAndReplace: "%readme%",
        }),
      )
    })
  })
  .addRecommendedFormatters() // Add the recommended formatters to the configuration
  .buildConfig(); // Build the configuration

new SimpleDocExtractor(config).start()
    .then(result => {
        console.log('Success count: ', result.successCount);
        console.log('Total count: ', result.totalCount);
        console.log('Missing documentation files: ', result.missingDocumentationFiles);
        console.log('Logs:');
        result.logs.forEach(log => {
            console.log(log);
        });
    });