Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@twittwer/compodoc

twittwer11.3kMIT1.13.0TypeScript support: included
nx-plugin, compodoc, documentation

readme

Compodoc (Nx Plugin)

npm version commitizen friendly styled with prettier

Nx Plugin to generate documentation via Compodoc.
NOTE: The whole generation part is done by @compodoc/compodoc, this is just a wrapper plugin for Nx workspaces.

Getting Started

Add the plugin to your Nx workspace:

npm install --save-dev @twittwer/compodoc

Configure Compodoc for a project:

`shell script nx g @twittwer/compodoc:config <project>

adds a compodoc target to the specified project

ensures @compodoc/compodoc as devDependencies


Run `nx run <project>:compodoc --serve` and go to [http://localhost:8080/](http://localhost:8080/)

## Generator

Add Compodoc target to a project:

nx g @twittwer/compodoc:config <project> [options]


| Option        | Default | Description                                                                                                                    |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| workspaceDocs | `false` | Will add a "tsconfig.compodoc.json" to the project that includes the whole workspace. [Workspace Docs Recipe](#workspace-docs) |

## Executor

Generate Compodoc documentation for a project:

```shell script
# HTML Format
nx run <project>:compodoc
# JSON Format
nx run <project>:compodoc:json

The executor supports several configuration options that are passed to the Compodoc command.
Additional options (used exclusively by the executor) are indicated by an italic written option name.

For more details you may have a look at the original Compodoc documentation or the builder's schema.json

Option Default Description
tsConfig <projectRoot>/tsconfig.json Path to project's tsconfig file.
outputPath dist/compodoc/<projectName> The output path of the generated files.
exportFormat html Format of generated documentation. (html, json - enables Compodoc's minimal mode as well)
workspaceDocs false Use readme of workspace root as entry and add the readme files of all project as additional documentation.
|
name <projectName> Title of the documentation. (workspaceDocs uses workspace name as default - defined in package.json)
|
includes | Path to external markdown files, folder should contain a summary.json. (workspaceDocs will override this)
includesName | Name of menu item containing external markdown files. (workspaceDocs uses "Projects" as default)
|
assetsFolder | External assets folder to copy in generated documentation folder.
unitTestCoverage | Path to unit test coverage in json-summary format.
|
disableCoverage true Do not add the documentation coverage report.
disableSourceCode false Do not add source code tab and links to source code.
disableDomTree false Do not add dom tree tab.
disableTemplateTab false Do not add template tab.
disableStyleTab false Do not add style tab.
disableGraph false Disable rendering of the dependency graph.
disablePrivate true Do not show private in generated documentation.
disableProtected false Do not show protected in generated documentation.
disableInternal true Do not show @internal in generated documentation.
disableLifeCycleHooks true Do not show Angular lifecycle hooks in generated documentation.
disableRoutesGraph false Do not add the routes graph.
disableSearch false Do not add the search input.
disableDependencies false Do not add the dependencies list.
|
coverageTest 0 Threshold for global documentation coverage.
coverageMinimumPerFile 0 Threshold for documentation coverage of each file.
coverageTestThresholdFail true Abort compodoc with an error instead of a warn log, if coverage threshold (global or per file) is not reached (true: error, false: warn).
|
language en-US Language used for generated documentation.
theme gitbook Theme used for generated documentation.
extTheme | Path to external theme file.
templates | Path to directory of Handlebars templates to override built-in templates.
customLogo | Path to custom logo.
customFavicon | Path to custom favicon.
hideGenerator false Do not print the Compodoc logo at the bottom of the page.
|
serve false (true in watch mode) Serve generated documentation. (automatically enabled in watch mode)
port 8080 Port for serving of documentation.
watch false Watch for source files changes to automatically rebuild documentation.
silent true (false in watch/serve mode) Suppress verbose build output.
|
debug false Log resulting executor options & the final Compodoc command with all arguments.

All paths should be relative to workspace root

<summary>How to configure an executor?</summary>

The target definition can be found in angular.json/workspace.json in the workspace root or project.json in the project directory:

{
  "targets": {
    "compodoc": {
      "executor": "@twittwer/compodoc:compodoc",
      "options": { /* Define your common options here */ },
      "configurations": {
        "<configuration name>": { /* and provide use case specific options via configurations. */ }
      }
    }
  }
}

Recipes

Workspace Docs

Documentation for the whole workspace incl. the README files of all projects (apps/libs) as additional documentation.

  • Create a library for shared/workspace wide tooling (e.g. workspace)
    nx g @nx/workspace:library workspace --unitTestRunner=none
  • Optionally you can delete some unused code (you should keep at least tsconfig.json & README.md).
  • Configure Compodoc for the created project
    nx g @twittwer/compodoc:config workspace --workspaceDocs
  • Generate your docs:
    nx run workspace:compodoc

Watch Mode

Rebuild your documentation on file changes during development.

The watch mode can be activated via argument:

`shell script nx run <project>:compodoc --watch # watch mode automatically enables serving nx run <project>:compodoc:json --watch


or via explicit configuration:

<!-- prettier-ignore-start -->
```json5
{
  "targets": {
    "compodoc": {
      "executor": "@twittwer/compodoc:compodoc",
      "options": { /* Define your common options here */ },
      "configurations": {
        "serve": { "watch": true }, /* watch mode automatically enables serving */
        "json": { "exportFormat": "json" },
        "json.watch": { "exportFormat": "json", "watch": true }
      }
    }
  }
}

Integration with @nx/storybook

At first you have to configure @nx/storybook & @twittwer/compodoc for the project.
Wrap storybook & build-storybook targets with a @nx/workspace:run-commands executor:

<summary>Option 1: `storybook` / `storybook:build` (1 target with configuration)</summary>
{
  "targets": {
    "_storybook": { /* @nx/storybook */ },
    "_build-storybook": {  /* @nx/storybook */ },
    "compodoc": { /* @twittwer/compodoc */ },
    "storybook": {
      "executor": "@nx/workspace:run-commands",
      "options": {
        "commands": [
          "npx nx run <project>:compodoc:json --watch",
          "npx nx run <project>:_storybook"
        ],
        "parallel": true
      },
      "configurations": {
        "build": {
          "commands": [
            "npx nx run <project>:compodoc:json",
            "npx nx run <project>:_build-storybook"
          ],
          "parallel": false
        }
      }
    }
  }
}
<summary>Option 2: `storybook` / `build-storybook` (2 targets)</summary>
{
  "targets": {
    "_storybook": { /* @nx/storybook */ },
    "_build-storybook": {  /* @nx/storybook */ },
    "compodoc": { /* @twittwer/compodoc */ },
    "storybook": {
      "executor": "@nx/workspace:run-commands",
      "options": {
        "commands": [
          "npx nx run <project>:compodoc:json --watch",
          "npx nx run <project>:_storybook"
        ],
        "parallel": true
      }
    },
    "build-storybook": {
      "executor": "@nx/workspace:run-commands",
      "options": {
        "commands": [
          "npx nx run <project>:compodoc:json",
          "npx nx run <project>:_build-storybook"
        ],
        "parallel": false
      }
    }
  }
}

Configure Storybook Docs in libs/<project>/.storybook/preview.js:

import { setCompodocJson } from '@storybook/addon-docs/angular';
import compodocJson from '../../../dist/compodoc/<project>/documentation.json';

setCompodocJson(compodocJson);

Serve or build it:

`shell script

Option 1

nx run <project>:storybook nx run <project>:storybook:build

Option 2

nx run <project>:storybook nx run <project>:build-storybook `

changelog

Changelog

This file was generated using @jscutlery/semver.

1.13.0 (2024-10-09)

Features

1.12.0 (2024-01-27)

Features

1.11.0 (2024-01-27)

Bug Fixes

  • compodoc: correct coverageTest behavior (0861a68)

Features

  • compodoc: add documentation coverage flags support (#83) (494bf20)

1.10.0 (2023-06-25)

Features

1.9.0 (2022-11-23)

Features

1.8.2 (2022-10-08)

Bug Fixes

  • remove name check for task runner (748df80)

1.8.1 (2022-10-08)

Bug Fixes

  • add nx as dependency for backwards compatibility (3a1261a), closes #70

1.8.0 (2022-05-17)

Features

1.7.0 (2022-04-03)

Features

1.6.6 (2021-12-15)

Bug Fixes

  • ensure consistent root based working directory (4471710)
  • execute compodoc via node_modules instead of package manager (ee0e7fb), closes #56

0.1.0 (2021-12-15)

Bug Fixes

  • add compodoc to cachable operations #54 (d010072)
  • add missing package.json configuration (0698418)
  • deduplicate includes in tsconfig of workspace docs (bf76ae4)
  • ensure public package access (ce69c71)
  • ensure public version access (d4ba25a)
  • wrap compodoc watch with nodemon for workspace docs (a87844e)

Features

  • add debug option to log resulting options & compodoc command (dd8b6de)
  • ensure compodoc installation during project configuration (ecb83e3)
  • rewrite compodoc executor (standalone config & watch mode support) (29fb34c)
  • rewrite compodoc generator (standalone config) (122d772)

1.6.5 (2021-11-14)

Bug Fixes

  • add compodoc to cachable operations #54 (d010072)

1.6.4 (2021-10-31)

Bug Fixes

  • wrap compodoc watch with nodemon for workspace docs (a87844e)

1.6.3 (2021-10-31)

Bug Fixes

  • ensure public package access (ce69c71)

1.6.2 (2021-10-31)

Bug Fixes

  • add missing package.json configuration (0698418)

1.6.1 (2021-10-31)

Bug Fixes

  • ensure public version access (d4ba25a)

1.6.0 (2021-10-31)

Bug Fixes

  • deduplicate includes in tsconfig of workspace docs (bf76ae4)

Features

  • add debug option to log resulting options & compodoc command (dd8b6de)
  • ensure compodoc installation during project configuration (ecb83e3)
  • rewrite compodoc executor (standalone config & watch mode support) (29fb34c)
  • rewrite compodoc generator (standalone config) (122d772)

1.5.3 (2021-05-20)

Bug Fixes

  • compodoc: escape spawn command & args to handle spaces in path (22fc859), closes #39

1.5.2 (2021-05-20)

Bug Fixes

  • compodoc: prefer app's tsconfig.editor in favour of tsconfig.app (76b5f91)
  • compodoc: replace deprecated id property with $id #37 (4efce80)
  • compodoc: windows path normalization #31 (7c32208)

Chores

  • migrate to Nx 12 & update other dependencies (ccf04a7)

Continuous Integration

  • compodoc: temporarily disable config schematic tests (feab415)

Documentation

  • compodoc: ensure JSON syntax in samples (d4218c8)

Miscellaneous

  • Merge pull request #38 from twittwer/update-nx-12 (a846eb1), closes #38
  • Merge pull request #26 from HaveF/patch-1 (897211e), closes #26
  • typo (fa9441f)

1.5.1 (2020-10-29)

Bug Fixes

  • disable next distribution channel (7783a45)

Miscellaneous

  • Merge pull request #24 from twittwer/next (7120c5c), closes #24

1.5.0 (2020-10-28)

Documentation

  • compodoc: add watch mode recipe with storybook integration (479e45b), closes #21
  • compodoc: replace ng with nx command (80e3715)

Features

1.4.0 (2020-10-22)

Chores

  • update @type/node to latest LTS 12.19.1 (#20) (cbb00b1)

Features

Miscellaneous

  • Merge pull request #18 from twittwer/dependabot/npm_and_yarn/http-proxy-1.18.1 (d96fb0b), closes #18
  • Merge pull request #17 from twittwer/dependabot/npm_and_yarn/elliptic-6.5.3 (a9a82f5), closes #17

1.3.2 (2020-07-30)

Bug Fixes

  • compodoc: ensure paths relative to execution directory (1e41a1e), closes #16

Documentation

  • compodoc: document unitTestCoverage option (0a32747)

1.3.1 (2020-06-10)

Bug Fixes

  • compodoc: use shell to fix compodoc spawn on windows (9fb51ad), closes #11

Chores

Miscellaneous

  • Merge pull request #15 from twittwer/alpha (a0a7049), closes #15
  • Merge pull request #13 from twittwer/dependabot/npm_and_yarn/websocket-extensions-0.1.4 (1e6b8a9), closes #13

1.3.1-alpha.1 (2020-06-10)

Bug Fixes

  • compodoc: use shell to fix compodoc spawn on windows (9fb51ad), closes #11

Miscellaneous

  • Merge pull request #13 from twittwer/dependabot/npm_and_yarn/websocket-extensions-0.1.4 (1e6b8a9), closes #13

1.3.0 (2020-06-10)

Features

  • compodoc: add --unitTestCoverage flag support (0f298e2)

Miscellaneous

  • Merge pull request #14 from StalkAltan/as/feat/add-unit-test-coverage-option (b4f4bd0), closes #14

1.2.0 (2020-05-13)

Build System

  • add version injection in release process (442e889)

Chores

Features

  • compodoc: add specific version numbers during ng-add (faf60fc)
  • compodoc: execute ng-add implicitly during config schematic (e1abce0)

Miscellaneous

Tests

  • compodoc: improve unit tests for config schematic (84a2a18)

1.1.1 (2020-05-05)

Code Refactoring

  • compodoc: improve testability of schematics (5d46bcd)

Continuous Integration

  • add tests to release process (e90b29b)

Tests

  • compodoc: add unit tests for config schematic (cc84362)
  • compodoc: add unit tests for ng-add schematic (16eb2e0)

1.1.0 (2020-05-04)

Features

  • compodoc: add schematic option for workspaceDocs (2942d09), closes #9

1.0.2 (2020-05-03)

Chores

  • compodoc: release 1.0.2-beta.1 (1800ce1)
  • remove unused yarn.lock (32ba144)

Code Refactoring

  • compodoc: cleanup schematic definition (ba59e6d)

Documentation

  • compodoc: add more badges (097c97b)

Miscellaneous

1.0.2-beta.1 (2020-05-03)

Chores

  • remove unused yarn.lock (32ba144)

Code Refactoring

  • compodoc: cleanup schematic definition (ba59e6d)

Documentation

  • compodoc: add more badges (097c97b)

1.0.1 (2020-05-02)

Bug Fixes

  • compodoc: use node fs for file existence check (c987daa)

Documentation

1.0.0 (2020-05-02)

Bug Fixes

  • compodoc: check for existence of tsconfig file (8ef7ae2)
  • compodoc: install plugin as devDependency during ng-add (32f5cea), closes #5

Chores

  • compodoc: configure semantic-release for compodoc (323e27b)
  • cleanup workspace (8efb90f)

Continuous Integration

  • add ci tests for pull requests (a7e3372)
  • configure commitlint with commitizen (bfb6921), closes #7
  • configure semantic-release for workspace (2c66a99)
  • enable auto releases via semantic-release & github actions (bbc3a70)

Documentation

  • compodoc: finalize documentation (34f4e27)
  • add project ideas (cbacc39)

Features

  • compodoc: add compodoc plugin (04402fb)
  • compodoc: generate workspace docs (3ab6578)

Miscellaneous