On this page

doc-kit uses cosmiconfig to discover and load configuration. Run the CLI from your project directory and it will automatically look for a doc-kit property in package.json, rc files such as .doc-kitrc.yml, and module files such as doc-kit.config.mjs.

Use --config-file <path> to load a specific file instead of searching.

Configuration files can be either:

  • JavaScript (.js, .mjs, .cjs)
  • TypeScript (.ts, when typescript is installed in the project)
  • JSON (.json)
  • YAML (.yaml, .yml, or an extensionless rc file)

JavaScript and TypeScript configuration files export the configuration object. JSON and YAML files contain the object directly. A package.json configuration uses the doc-kit property:

{
  "doc-kit": {
    "target": ["json"],
    "global": {
      "input": "doc/api/*.md",
      "output": "out"
    }
  }
}
export default {
  // targets, alternatively supplied by command line flags
  target: ['orama-db', 'web'],
  global: {
    version: '20.0.0',
    minify: true,
    repository: 'nodejs/node',
    ref: 'main',
    baseURL: 'https://nodejs.org/docs/',
    input: 'src/',
    output: 'dist/',
    ignore: ['node_modules/', 'test/'],
    changelog:
      'https://raw.githubusercontent.com/nodejs/node/main/CHANGELOG.md',
    index:
      'https://raw.githubusercontent.com/nodejs/node/main/doc/api/index.md',
  },

  threads: 4,
  chunkSize: 10,

  // Generator-specific configurations
  json: {
    format: 'json',
    minify: false, // Override global setting
  },

  html: {
    format: 'html',
  },

  metadata: {
    typeMap: {
      String: 'string',
      Number: 'number',
      Boolean: 'boolean',
    },
  },
};

The global object contains settings that apply to all generators unless overridden:

PropertyTypeDescriptionDefault
versionstring | SemVerDocumentation versionprocess.version
minifybooleanWhether to minify outputtrue
repositorystringGitHub repository in owner/repo format'nodejs/node'
refstringGit reference (branch, tag, or commit SHA)'HEAD'
baseURLstring | URLBase URL for documentation'https://nodejs.org/docs'
inputstring[]Input directory path-
outputstringOutput directory path-
ignorestring[]Patterns to ignore[]
changelogstring | URLChangelog URLAuto-generated URL based on ref and repository
indexstring | URLIndex URL-

Each generator (e.g., json, html, markdown) can have its own configuration that overrides global settings:

export default {
  global: {
    version: '20.0.0',
    minify: true,
  },

  'legacy-json': {
    minify: false, // Override: JSON output won't be minified
  },
};

Configurations are merged in the following order (higher sources take precedence):

  1. CLI options (command-line arguments)
  2. Configuration file (discovered or selected with --config-file)
  3. Default values (built-in defaults)

CLI options map to configuration properties:

CLI OptionConfig PropertyExample
--input <path>global.input--input src/
--output <path>global.output--output dist/
--ignore <pattern>global.ignore[]--ignore test/
--minifyglobal.minify--minify
--git-ref <ref>global.ref--git-ref v20.0.0
--version <version>global.version--version 20.0.0
--changelog <url>global.changelog--changelog https://...
--index <url>global.index--index file://...
--type-map <map>metadata.typeMap--type-map file://...
--target <generator>target--target json
--threads <n>threads--threads 4
--chunk-size <n>chunkSize--chunk-size 10