# @gasket/plugin-docs

> Centralize doc files from plugins and modules

Latest version **7.5.7** (published 2026-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gasket/plugin-docs
pnpm add @gasket/plugin-docs
yarn add @gasket/plugin-docs
bun add @gasket/plugin-docs
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.5.7 |
| Published | 2026-08-28 |
| First published | 2019-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 96.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 145 |
| Author | GoDaddy Operating Company, LLC |
| Maintainers | kinetifex, 3rdeden, kawikabader, mmason2, jpina1-godaddy, bbetts, ecarlson-godaddy, rxmarbles |
| Keywords | docs, gasket, plugin |

## Links

- npm: https://www.npmjs.com/package/@gasket/plugin-docs
- Repository: https://github.com/godaddy/gasket
- Homepage: https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-docs
- Issues: https://github.com/godaddy/gasket/issues
- npm.io page: https://npm.io/package/@gasket/plugin-docs

## Dependencies (6)

- [glob](https://npm.io/package/glob.md) ^13.0.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [rimraf](https://npm.io/package/rimraf.md) ^6.1.2
- [markdown-table](https://npm.io/package/markdown-table.md) ^1.1.3
- [lodash.defaultsdeep](https://npm.io/package/lodash.defaultsdeep.md) ^4.6.1
- [@gasket/plugin-command](https://npm.io/package/@gasket/plugin-command.md) ^7.6.7

## Recent versions

- 7.5.7 (latest) — 2026-08-28
- 0.0.0-react19-20260205182644 (react19) — 2026-02-05
- 0.0.0-canary-20260205165418 (canary) — 2026-02-05
- 8.0.0-next.1 (next) — 2026-01-28
- 6.47.5 (lts) — 2024-09-26
- 7.0.0-cli.7 (cli) — 2024-03-25
- 6.46.2-esm.0 (esm) — 2024-02-26
- 7.5.6 — 2026-05-13
- 7.5.5 — 2026-02-23
- 7.5.4 — 2026-02-16
- 7.5.3 — 2026-01-07
- 7.5.2 — 2025-12-19
- 7.5.1 — 2025-11-20
- 7.5.0 — 2025-11-12
- 0.0.0-canary-20251110223653 — 2025-11-10
- … 223 more at https://npm.io/package/@gasket/plugin-docs/versions

## README

# @gasket/plugin-docs

The plugin enables the **docs** command, which centralizes doc files for the
app's plugins, presets, and supporting modules.

## Installation

```bash
npm i @gasket/plugin-docs
```

Update your `gasket` file plugin configuration:

```diff
// gasket.js

+ import pluginDocs from '@gasket/plugin-docs';

 export default makeGasket({
  plugins: [
+   pluginDocs
  ]
});
```

## Configuration

To be set in under `docs` in the `gasket.js`.

- `outputDir` - (string) Name of the directory, relative to the app's package,
  where doc files will be collected to. Default is `.docs`.

## Commands

### docs command

The **docs** command, inspired by [cargo doc][rustdoc] from the Rust language,
allows app developers to generate documentation for their Gasket projects. Only
those presets and plugins that are configured for a project, will be used to
determine what documentation is available.

When running this command, markdown and other files will be gathered from installed
node modules and collated to the output directory when they can be viewed
together.

## Lifecycles

### docsSetup

The **docs** command will assemble configuration for plugins and modules, based
on available `metadata`, enabled by the [@gasket/plugin-metadata].

By default, the files that are collated include a package's `README.md` and any
files that exist under a docs directory. Additionally, if any metadata defines
`link`, these files will be collected, too.

The `docsSetup` lifecycle allows plugin developers to tune the docsConfig that
is compiled for their plugin. Files or file globs can be set, and links changed
as needed. Any lifecycle hooks should return a `docsSetup` object.
The `defaults` are an available option to reference.

#### Example setup

```js
/**
 * @typedef {import('@gasket/plugin-docs').DocsSetup} DocsSetup
 */

export default {
  name: 'example',
  hooks: {
    /**
    * Tune the docsConfig that is compiled for a plugin
    *
    * @param {Gasket} gasket The Gasket API
    * @param {Object} defaults The default docs setup config
    * @returns {DocsSetup}
    */
    async docsSetup(gasket, { defaults = {} }) {
      return {
        ...defaults,
        link: 'OTHER.md',
        files: [
          'API.md',
          'docs/**/*.md'
        ],
        transforms: [{
          test: /\.md$/,
          handler: content => content.replace('something', 'nothing')
        }],
        // collate docs for any supporting modules
        modules: {
          '@some/module': {
            link: 'README.md'
          },
          'another-module': {
            link: 'README.md#go-here',
            files: ['html/**/*.html'],
            transforms: [{
               test: /\.html$/,
               handler: content => content.replace(/everything/g, 'nothing')
             }]
          }
        }
      }
    }
  }
}
```

#### Transforms

Transforms can also be added in the docsSetup lifecycle. These are plugins to
adjust content for files that match the transform's test [RegExp]. By default,
these will only affect docs collected by the plugin's package. If the transform
should be able affect all collected docs, the global property should be set to
true.

Additional data is available to handlers to help with transformations which can
be read about in the `docsTransformHandler` API.

#### Modules

Beside docs for the plugin itself, `docsSetup` for supporting modules can also
be described. For modules from [metadata], if a `docsSetup` is found, the files
described will be collected, and the link for a generated index will go to the link
specified in the `docsSetup`, instead of the module's homepage.

Alternatively, modules can described their own setup in their package.json by
defining a `gasket.docsSetup` property. However, being JSON, transforms or other
setup functions cannot be described this way:

```json
{
  "name": "example",
  "version": "1.2.3",
  "gasket": {
    "docsSetup": {
      "link": "OTHER.md#go-here",
      "files": [
        "more-docs/**/*.*"
      ]
    }
  }
}
```

### docsView

Allows a plugin to provide a view of the docs for the user.

#### Example viewer

```js
import view from 'example-markdown-viewer';

export default {
  name: 'example',
  hooks: {
    async docsView(gasket, docsConfigSet) {
      const { docsRoot } = docsConfigSet;

      await view(docsRoot);
    }
  }
}
```

The [@gasket/plugin-docusaurus] hooks this lifecycle to render the docs using
Docusaurus.

### docsGenerate

Allows a plugin to add documentation that has to be programmatically generated.

#### An example graph

```js
import { promises as fsPromises } from 'fs';

const { writeFile } = fsPromises;

export default {
  name: 'questions',
  hooks: {
    async docsGenerate(gasket, docsConfigSet) {
      await writeFile('FAQ.md', 'Just shoot me a call at (605) 475-6968');

      return {
        name: 'FAQ',
        description: 'Frequently Asked Questions',
        link: '/FAQ.md',
        targetRoot: docsConfigSet.docsRoot
      };
    }
  }
}
```

## Usage

### Presets

Presets can also set up custom docs. This is done by defining a `docsSetup`
property object on the module, which will be used to establish the `docsConfig`
for the preset.

```js
// gasket-preset-example.js
export default {
  name: 'gasket-preset-example',
  docsSetup: {
    link: 'OTHER.md#go-here',
    files: ['more-docs/**/*.*'],
  }
}
```

## How it works

The docs command will gather info about plugins and modules from their
[metadata] and `docsSetup`, and will assemble a `docsConfig` for each. These
configs are are organized by type in a `docsConfigSet`, which is then used to
copy files to the outputDir, and perform any [transforms] as needed. An index is
generated in markdown from docsConfigSet which serves as the entry in the doc
files. If a plugin is installed that hooks the [docsView] lifecycle, it can
serve the content in a more viewable fashion for the user.

## License

[MIT](./LICENSE.md)

<!-- LINKS -->

[transforms]: #transforms
[docsView]: #docsview
[@gasket/plugin-metadata]: /packages/gasket-plugin-metadata/README.md
[@gasket/plugin-docusaurus]: /packages/gasket-plugin-docusaurus/README.md
[metadata]: /packages/gasket-plugin-metadata/README.md
[rustdoc]:https://doc.rust-lang.org/rustdoc/
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

---
_Source: https://npm.io/package/@gasket/plugin-docs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
