Skip to content

Configuration

Every option of the configuration file, ng-doc.config.ts. The file default-exports an NgDocConfiguration object. All options are optional.

ng-doc.config.tsTypeScript
import { NgDocConfiguration } from '@ng-doc/builder';

const config: NgDocConfiguration = {
  routePrefix: 'docs',
};

export default config;

Options

OptionTypeDefaultDescription
docsPathstringThe folder that contains the application's main.tsThe folder with your pages, categories and API files, relative to the workspace root.
outDirstringThe workspace rootThe parent folder of the generated folder. NgDoc writes to <outDir>/ng-doc/<project-name>.
routePrefixstring''A route segment added before every page route, such as docs.
tsConfigstringThe application's TypeScript configurationThe tsconfig file used to analyse your sources, relative to the workspace root.
cachebooleantrue in the new engine, false in the legacy buildersReuses generated results between builds (Performance and caching).
guideNgDocGuideConfiguration–Options for guide pages. See Configuration [guide].
shiki{ themes: { light: string; dark: string } }css-variables (new engine); github-light and ayu-dark (legacy builders)The syntax highlighting themes (Code highlighting).
repoConfigNgDocRepoConfig–Adds "Suggest edits" and "View source" links to pages. See Configuration [repoConfig].
keywordsNgDocKeywordsConfiguration–Global keywords and keyword loaders. See Configuration [keywords].

guide

OptionTypeDefaultDescription
anchorHeadingsNgDocHeading[]['h1', 'h2', 'h3', 'h4']The heading levels that get an anchor. Page keyword anchors use them too.
headerTemplatestringThe built-in headerPath to an HTML file, relative to the workspace root, that renders the page header.

The header template is a Nunjucks template, not Markdown. It can use these variables:

VariableValue
NgDocPageThe page configuration.
MetadataThe page's doc comment: Metadata.description and Metadata.tags.
header-template.htmlTwig
<h1>{{ NgDocPage.title }}</h1>

{{ Metadata.description }}

repoConfig

OptionTypeDefaultDescription
urlstring–The repository URL, for example https://github.com/ng-doc/ng-doc.
mainBranchstring–The branch that "Suggest edits" opens.
releaseBranchstring–The branch that "View source" opens.
platform'github' | 'gitlab''github'The hosting platform, which sets the link format.
ng-doc.config.tsTypeScript
import { NgDocConfiguration } from '@ng-doc/builder';

const config: NgDocConfiguration = {
  repoConfig: {
    url: 'https://github.com/ng-doc/ng-doc',
    mainBranch: 'main',
    releaseBranch: 'release',
  },
};

export default config;

keywords

OptionTypeDescription
keywordsRecord<string, NgDocGlobalKeyword>Global keywords. The key is the keyword (Links and keywords).
loadersNgDocKeywordsLoader[]Functions that load global keywords when the build starts (Link to external APIs).

Each global keyword is an NgDocGlobalKeyword:

FieldTypeDescription
urlstringThe link target.
titlestringThe link text. The key is used by default.
descriptionstringA tooltip shown on hover.
type'link'How inline code with the keyword renders.

Where NgDoc finds the file

NgDoc searches for the configuration file upward, folder by folder. The two engines start and stop the search in different folders: the new engine stops at the workspace root, and the legacy builders stop at your home directory.

EngineSearch starts inFile names
New engineThe parent of the default documentation folder, usually the project folderng-doc.config.ts, ng-doc.config.js, ng-doc.config.mjs, ng-doc.config.cjs
Legacy buildersThe folder of the browser entry file, usually srcng-doc.config.ts, ng-doc.config.js

So a file in src/ng-doc.config.ts is found only by the legacy builders. Put the file in the project folder or at the workspace root, where both engines find it.

The Vite plugin's generator.configFile, the --config flag of the ng-doc command, or the ngDoc.config option of the legacy builders can point to a specific file instead. See Builders, plugin and CLI and Legacy builders. Without a configuration file, every option keeps its default.

Defaults per engine

SettingNew engineLegacy builders
cachetruefalse
Cache folder.cache/ng-doc/<project-name>node_modules/.cache/ng-doc
Generated folderng-doc/<project-name> (.ng-doc/<project-name> for the ng-doc command)ng-doc/<project-name>
Configuration searchStarts in the parent of the documentation folderStarts in the folder of the browser entry file

Paths are relative to the workspace root. The ng-doc command line interface uses its own defaults for the documentation, generated and cache folders (Builders, plugin and CLI).

Edit this page