[](https://www.npmjs.com/package/@twittwer/compodoc) [](https://comm
npm install @twittwer/compodoc


> 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
- Generator
- Executor
- Recipes
- Workspace Docs
- Watch Mode
- Integration with @nx/storybook
Add the plugin to your Nx workspace:
```
npm install --save-dev @twittwer/compodoc
Configure Compodoc for a project:
`shell scriptcompodoc
nx g @twittwer/compodoc:config adds a
target to the specified project@compodoc/compodocensures
as devDependencies`
Run nx run and go to http://localhost:8080/
Add Compodoc target to a project:
``
nx g @twittwer/compodoc:config
| Option | Default | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| workspaceDocs | false | Will add a "tsconfig.compodoc.json" to the project that includes the whole workspace. Workspace Docs Recipe |
Generate Compodoc documentation for a project:
`shell script`HTML Format
nx run JSON Format
nx run
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 | | Path to project's tsconfig file. |dist/compodoc/
| outputPath | | The output path of the generated files. |html
| exportFormat | | Format of generated documentation. (html, json - enables Compodoc's minimal mode as well) |false
| _workspaceDocs_ | | Use readme of workspace root as entry and add the readme files of all project as additional documentation. |
| | | |
| name | | Title of the documentation. (workspaceDocs uses workspace name as default - defined in package.json) |summary.json
| | | |
| includes | | Path to external markdown files, folder should contain a . (workspaceDocs will override this) |workspaceDocs
| includesName | | Name of menu item containing external markdown files. ( uses "Projects" as default) |true
| | | |
| assetsFolder | | External assets folder to copy in generated documentation folder. |
| unitTestCoverage | | Path to unit test coverage in json-summary format. |
| | | |
| disableCoverage | | Do not add the documentation coverage report. |false
| disableSourceCode | | Do not add source code tab and links to source code. |false
| disableDomTree | | Do not add dom tree tab. |false
| disableTemplateTab | | Do not add template tab. |false
| disableStyleTab | | Do not add style tab. |false
| disableGraph | | Disable rendering of the dependency graph. |true
| disablePrivate | | Do not show private in generated documentation. |false
| disableProtected | | Do not show protected in generated documentation. |true
| disableInternal | | Do not show @internal in generated documentation. |true
| disableLifeCycleHooks | | Do not show Angular lifecycle hooks in generated documentation. |false
| disableRoutesGraph | | Do not add the routes graph. |false
| disableSearch | | Do not add the search input. |false
| disableDependencies | | Do not add the dependencies list. |0
| | | |
| coverageTest | | Threshold for global documentation coverage. |0
| coverageMinimumPerFile | | Threshold for documentation coverage of each file. |true
| coverageTestThresholdFail | | Abort compodoc with an error instead of a warn log, if coverage threshold (global or per file) is not reached (true: error, false: warn). |en-US
| | | |
| language | | Language used for generated documentation. |gitbook
| theme | | Theme used for generated documentation. |false
| 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 | | Do not print the Compodoc logo at the bottom of the page. |false
| | | |
| serve | (true in watch mode) | Serve generated documentation. (_automatically enabled in watch mode_) |8080
| port | | Port for serving of documentation. |false
| watch | | Watch for source files changes to automatically rebuild documentation. |true
| silent | (false in watch/serve mode) | Suppress verbose build output. |false
| | | |
| _debug_ | | Log resulting executor options & the final Compodoc command with all arguments. |
> All paths should be relative to workspace root
How to configure an executor?
The target definition can be found in angular.json/workspace.json in the workspace root or project.json in the project directory:
`json5`
{
"targets": {
"compodoc": {
"executor": "@twittwer/compodoc:compodoc",
"options": { / Define your common options here / },
"configurations": {
"
}
}
}
}
> 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
tsconfig.json
- Optionally you can delete some unused code (you should keep at least & README.md).nx g @twittwer/compodoc:config workspace --workspaceDocs
- Configure Compodoc for the created project
nx run workspace:compodoc
- Generate your docs:
> Rebuild your documentation on file changes during development.
The watch mode can be activated via argument:
`shell script`
nx run
nx run
or via explicit configuration:
`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 }
}
}
}
}
At first you have to configure @nx/storybook & @twittwer/compodoc for the project. storybook
Wrap & build-storybook targets with a @nx/workspace:run-commands executor:
Option 1: storybook
/ storybook:build (1 target with configuration)
`json5`
{
"targets": {
"_storybook": { / @nx/storybook / },
"_build-storybook": { / @nx/storybook / },
"compodoc": { / @twittwer/compodoc / },
"storybook": {
"executor": "@nx/workspace:run-commands",
"options": {
"commands": [
"npx nx run
"npx nx run
],
"parallel": true
},
"configurations": {
"build": {
"commands": [
"npx nx run
"npx nx run
],
"parallel": false
}
}
}
}
}
Option 2: storybook
/ build-storybook (2 targets)
`json5`
{
"targets": {
"_storybook": { / @nx/storybook / },
"_build-storybook": { / @nx/storybook / },
"compodoc": { / @twittwer/compodoc / },
"storybook": {
"executor": "@nx/workspace:run-commands",
"options": {
"commands": [
"npx nx run
"npx nx run
],
"parallel": true
}
},
"build-storybook": {
"executor": "@nx/workspace:run-commands",
"options": {
"commands": [
"npx nx run
"npx nx run
],
"parallel": false
}
}
}
}
Configure Storybook Docs in libs/:
`js
import { setCompodocJson } from '@storybook/addon-docs/angular';
import compodocJson from '../../../dist/compodoc/
setCompodocJson(compodocJson);
`
Serve or build it:
`shell script``Option 1
nx run
nx run Option 2
nx run
nx run