Skip to content
compodocx
Skip to article content

Guide 02

Getting Started

cngxjs (opens in new tab)Updated Guide02of 13

A working compodocx setup is three things: the package,a tsconfig that points at yourAngular (opens in new tab) source, and an output location. Defaults handle the rest. RequiresNode (opens in new tab) 22 or newer and a project on Angular 21 or 22 written with standalone APIs.

bash
npm install --save-dev @cngxjs/compodocx
npx compodocx -p tsconfig.doc.json

The default output goes to ./documentation/<versionLabel>/.
Multi-version layout is on by default. versionLabel is auto-detected from the nearest package.json.
Pass--no-multiVersion for the flat single-version layout.

Inside an Angular workspace, ng add @cngxjs/compodocx does the setup in one pass: it seeds tsconfig.doc.json and registerscompodocx:build, compodocx:build-and-serve, and compodocx:serve scripts.

Add --watch --serve while authoring to get a local dev server that rebuilds on every source change.

A minimal tsconfig

compodocx uses TypeScript’s own resolver. A doc-specific tsconfig keeps test files, storybook, and dev-only entries out of the rendered API surface.

jsontsconfig.doc.json
{
  "extends": "./tsconfig.json",
  "include": ["src/**/*.ts"],
  "exclude": ["**/*.spec.ts", "**/*.stories.ts"]
}

Coming from compodoc

compodocx is a fork of compodoc for modern Angular, not a drop-in replacement. These are not documented, and a run reports them in one legacy notice with their locations:

  • NgModules and everything tied to them.
  • Decorator members: @Input, @Output,@HostBinding, and @HostListener.
  • Constructor injection in components, directives, pipes, and injectables.
  • Class-based guards, interceptors, and resolvers.

Switching means changing the package and the script, running it once, and acting on the warnings it prints. ng add @cngxjs/compodocx removes@compodoc/compodoc and rewrites your scripts. Removed flags and config keys are ignored with a warning instead of failing the build.

A few things need work of your own. Page URLs changed (redirects.json maps the old paths), output is multi-version by default (--no-multiVersion keeps a flat folder), tools that read documentation.json need the new schema, and Handlebars templates must be rewritten as JS overrides by hand.compodocx migrate jsdoc <dir> removes retired@category and @docsKind tags. Themigration guide (opens in new tab) explains each warning.