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

@docs-ts/docs-ts

v1.0.13

Published

Documentation tool for TypeScript packages

Downloads

5

Readme

Table of contents

A simple, opinionated, zero-configuration tool for creating beautiful documentation for TypeScript projects.

:warning: DISCLAIMER :warning: docs-ts is used primarily as an opinionated documentation tool for libraries in the fp-ts ecosystem. The structure of source code documentation expected by docs-ts can be best understood by reviewing the source code of the fp-ts repository.

Installation:

npm install --save-dev @docs-ts/docs-ts

Why

Creating and maintaining documentation for a TypeScript project of any size can quickly become a herculean task. docs-ts simplifies this process by allowing you to co-locate your documentation with its associated code. You simply annotate your code with JSDoc comments, and then the CLI will generate beautiful markdown documents containing all of the documentation and examples you associated with your code. In addition, the generated output of docs-ts can be used as a publishing source for your repository's documentation on GitHub.

Usage

Using docs-ts is as simple as annotating your code with JSDoc comments. Specialized JSDoc tags can be used to perform various functions, such as grouping associated code together, versioning documentation, and running and testing source code. A full list of supported JSDoc tags can be found below.

Supported JSDoc Tags

| Tag | Description | Default | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | | @category | Groups associated module exports together in the generated documentation. | 'utils' | | @example | Allows usage examples to be provided for your source code. All examples are type checked using ts-node. Examples are also run using ts-node and the NodeJS assert module can be used for on-the-fly testing (see example below). | | | @since | Allows for documenting most recent library version in which a given piece of source code was updated. | | | @deprecated | Marks source code as deprecated, which will ~~strikethrough~~ the name of the annotated module or function in the generated documentation. | false | | @internal | Prevents docs-ts from generating documentation for the annotated block of code. Additionally, if the stripInternal flag is set to true in tsconfig.json, TypeScript will not emit declarations for the annotated code. | | | @ignore | Prevents docs-ts from generating documentation for the annotated block of code. | |

By default, docs-ts will search for files in the src directory and will output generated files into a docs directory. For information on how to configure docs-ts, see the Configuration section below.

Example

The best usage examples of docs-ts can be found in fp-ts ecosystem libraries that generate their documentation with docs-ts, such as the main fp-ts repository.

To illustrate the power of docs-ts, here is a small example. Running npm run docs-ts (or yarn docs-ts) in the root directory of a project containing the following file in the src directory...

/**
 * @since 0.2.0
 */
import { log } from 'fp-ts/Console'
import { IO } from 'fp-ts/IO'

/**
 * Greets a person by name.
 *
 * @example
 * import { sayHello } from 'docs-ts/lib/greetings'
 *
 * assert.strictEqual(sayHello('Test')(), 'Hello, Test!')
 * // => This assert statement will be run by docs-ts so you can test your code on-the-fly.
 *
 * @category greetings
 * @since 0.6.0
 */
export const sayHello = (name: string): IO<void> => log(`Hello, ${name}!`)

...will, by default, produce a docs directory containing the following markdown document in the modules subfolder.

---
title: greetings.ts
nav_order: 0
parent: Modules
---

## greetings overview

Added in v0.2.0

---

<h2 class="text-delta">Table of contents</h2>

- [greetings](#greetings)
  - [sayHello](#sayhello)

---

# greetings

## sayHello

Greets a person by name.

**Signature**

```ts
export declare const sayHello: (name: string) => IO<void>
```

**Example**

```ts
import { sayHello } from 'docs-ts/lib/greetings'

assert.strictEqual(sayHello('Test')(), 'Hello, Test!')
```

Added in v0.6.0

Configuration

docs-ts is meant to be a zero-configuration command-line tool by default. However, there are several configuration settings that can be specified for docs-ts. To customize the configuration of docs-ts, create a docs-ts.json file in the root directory of your project and indicate the custom configuration parameters that the tool should use when generating documentation.

The docs-ts.json configuration file adheres to the following interface:

interface Config {
  readonly projectHomepage?: string
  readonly srcDir?: string
  readonly outDir?: string
  readonly theme?: string
  readonly enableSearch?: boolean
  readonly enforceDescriptions?: boolean
  readonly enforceExamples?: boolean
  readonly enforceVersion?: boolean
  readonly exclude?: ReadonlyArray<string>
}

The following table describes each configuration parameter, its purpose, and its default value.

| Parameter | Description | Default Value | | :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------- | | projectHomepage | Will link to the project homepage from the Auxiliary Links of the generated documentation. | homepage in package.json | | srcDir | The directory in which docs-ts will search for TypeScript files to parse. | 'src' | | outDir | The directory to which docs-ts will generate its output markdown documents. | 'docs' | | theme | The theme that docs-ts will specify should be used for GitHub Docs in the generated _config.yml file. | 'pmarsceill/just-the-docs' | | enableSearch | Whether or search should be enabled for GitHub Docs in the generated _config.yml file. | true | | enforceDescriptions | Whether or not descriptions for each module export should be required. | false | | enforceExamples | Whether or not @example tags for each module export should be required. (Note: examples will not be enforced in module documentation) | false | | enforceVersion | Whether or not @since tags for each module export should be required. | false | | exclude | An array of glob strings specifying files that should be excluded from the documentation. | [] |

Documentation

FAQ

Q: For functions that have overloaded definitions, is it possible to document each overload separately?

A: No, docs-ts will use the documentation provided for the first overload of a function in its generated output.