# docgen

> Generates documentation targets. An sdkgen package rather than a separate tool. sdkgen defines a `docs` kind, a target whose destination is a documentation system rather than a language; docgen supplies the items for it. Part of the Voxgig SDK toolchain. Checked 8 September 2026.

## What it is

docgen is worth understanding for what it demonstrates as much as for what it does. sdkgen's verbs are built from a kind registry, so a package that supplies a new kind gets its own `add` command with no dispatch code written for it. `docs` is such a kind, and docgen supplies the items.

That is the extension model for the whole toolchain: a new capability ships as a package that an existing project installs, rather than as a change to the generator that every project inherits. Haskell arrived the same way, as `@voxgig/sdkgen-haskell`.

This page is shorter than the two before it, deliberately. docgen is real and published, and its own repository is the authority on what it currently emits.

## Facts

- Package: @voxgig/docgen (https://www.npmjs.com/package/@voxgig/docgen)
- Source: voxgig/docgen (https://github.com/voxgig/docgen)
- Licence: MIT
- Kind supplied: docs

## Concepts

### A documentation target is still a target

It is added, generated and regenerated exactly as a language target is, on the same merge-or-overwrite rules. The only difference is where it points.

### Packages are how the toolchain grows

`voxgig-sdkgen package add <pkg>` installs everything a package provides. `--only <kind>:<name>` narrows that to a subset, and `--alias <name>=<alias>` installs under a different name, which is what lets two packages supplying the same target name coexist.

## Examples

### Install a documentation target

The package is a dev dependency of the SDK project, and `package add` registers what it supplies into `.sdk/`. From then on it regenerates with everything else.

`in an SDK project`

```bash
npm install --save-dev @voxgig/docgen

cd <sdk-project>/.sdk
voxgig-sdkgen package add @voxgig/docgen

npm run build && npm run generate
```

## Reference

### Package commands

| | |
| --- | --- |
| `package add <pkg>` | Install everything the package provides. |
| `package add <pkg> --only docs:<name>` | Install one item rather than all of them. |
| `package update <pkg>` | Refresh an installed package. |
| `package check <path>` | Validate a package. Runs where there is no project. |

## First-party documentation

- [docgen on GitHub](https://github.com/voxgig/docgen)
- [How-to: use an sdkgen package](https://github.com/voxgig/sdkgen/blob/main/docs/how-to/use-an-sdkgen-package.md)
- [How-to: author an sdkgen package](https://github.com/voxgig/sdkgen/blob/main/docs/how-to/author-an-sdkgen-package.md)

## The rest of the toolchain

- [The toolchain documentation index](https://voxgig.com/sdk/docs): the pipeline, the components, and the two worked examples.
- [sdkgen](https://voxgig.com/sdk/docs/sdkgen): Turns the model into SDKs.
- [apidef](https://voxgig.com/sdk/docs/apidef): Turns a spec into a model.
- [create-sdkgen](https://voxgig.com/sdk/docs/create-sdkgen): Scaffolds a project.
- apigen: Not yet published.
- [Voxgig SDK Generator](https://voxgig.com/sdk)
