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].
apiNgDocApiConfiguration–Options for API pages (new engine only). See Configuration [api].
isolatedDemosbooleanfalseShows every demo in an iframe of its own page (new engine only). See Configuration [Demo pages].
demoApplicationboolean | NgDocDemoApplicationConfiguration–Which pages get demo pages, and their URL path (new engine only). See Configuration [Demo pages].
demoProvidersNgDocDemoProvidersImport–Imports the providers of the demo pages (new engine only). See Configuration [Demo pages].
shiki{ themes: { light: string; dark: string }; langs?: NgDocShikiLanguage[] }css-variables (new engine); github-light and ayu-dark (legacy builders)The syntax highlighting themes, and extra languages (new engine only) (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 }}

api

Only the new engine reads these options.

OptionTypeDefaultDescription
protectedMembersbooleantrueLists the protected members of classes, inherited ones included. false lists public members only (Generate API pages [Protected members]).

Demo pages

Only the new engine reads these options. Isolated demos show a demo's page in an iframe (Isolated demos).

OptionTypeDefaultDescription
isolatedDemosbooleanfalseShows every demo in an iframe of its page, unless its isolated option is false. Every page with demos gets demo pages.
demoApplicationboolean | NgDocDemoApplicationConfiguration–true or an object gives every page with demos its demo pages. false gives none, and isolated demos render in the page.
demoProvidersNgDocDemoProvidersImport–() => import('./demo.providers'): the module whose default export, an NgDocDemoProviders list, provides for the demo pages.

Without them, only the pages with an isolated demo get demo pages. demoApplication takes an object with one option:

OptionTypeDefaultDescription
pathstring'demo-preview'The URL path of the demo pages under the base href. URL segments that start with a letter or a digit.

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