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 🙏

© 2024 – Pkg Stats / Ryan Hefner

docts

v0.2.0

Published

README.md API section autogenerator for TypeScript projects

Downloads

15

Readme

docts

build status dependency status npm version

This is a command-line tool to generate API documentation for TypeScript projects based on information about types and exported declarations extracted using readts. Run docts inside your package and it parses the .d.ts files referenced from the typings key of your package.json. Then it replaces any section titled API in your README.md file with new automatically generated content. For an example of its output, see the API section below.

If your package is a Git working tree and the repository field in package.json points to a Github URL, links to relevant parts of the code published on Github are added next to functions, classes and methods. Each link looks like <> and includes the hash of the latest commit which changed the relevant file. If that file is dirty in the working tree, the link points to whatever is on the current branch instead. This minimizes changes to the links while trying to keep them pointed to the correct location in latest code.

Any additional TypeScript configuration should be defined in tsconfig.json in the root if your package.

Usage

Start by making a backup of your README.md.

Then install:

npm install --save-dev docts

Make sure your package.json has a typings section and add in the scripts section:

  "scripts": {
    "docts": "docts"
  }

Finally run:

npm run docts

API

Docs generated using docts

Class DocBuilder

TypeScript project Markdown documentation builder.
Source code: <>

Methods:

new( ) DocBuilder <>
 ▪ basePath string
.build( ) Promise<any> <>
Generate API documentation for the package.
Returns promise resolving to an array of text split by line breaks.

Class Markdown

Represents a Markdown file.
Source code: <>

Methods:

new( ) Markdown <>
 ▪ markdownPath string
.readSections( ) Section[] <>
Read the file and split each heading into a separate section.
.writeSections( ) Promise<void> <>
Replace file contents with a new list of sections.
 ▪ sectionList Section[]

Properties:

.path string

Class Section

Represents a section in a Markdown file.
Source code: <>

Properties:

.header string[]
Heading and its markup split by newlines.
Heading is a line beginning with # or followed by another line full of - or =.
.content string[]
Section content split by newlines.
.name string
Heading with markup stripped.

Function patchReadme

Patch section titled API of README.md file in given directory.
Source code: <>

patchReadme( ) void <>
 ▪ basePath string

License

The MIT License

Copyright (c) 2016 BusFaster Ltd