|
1 | 1 | # Configuration |
2 | 2 |
|
3 | | -`doc-kit`'s CLI supports a `--config-file` option, allowing for custom configuration files to be passed. |
4 | | -These configuration files must be loadable via a `import()` call, so usually JSON or JavaScript files with default exports. |
| 3 | +`doc-kit` uses [`cosmiconfig`](https://github.com/cosmiconfig/cosmiconfig) to |
| 4 | +discover and load configuration. Run the CLI from your project directory and it |
| 5 | +will automatically look for a `doc-kit` property in `package.json`, rc files |
| 6 | +such as `.doc-kitrc.yml`, and module files such as `doc-kit.config.mjs`. |
5 | 7 |
|
6 | | -By convention, this file is usually named `doc-kit.config.mjs` or `doc-kit.config.json`. |
| 8 | +Use `--config-file <path>` to load a specific file instead of searching. |
7 | 9 |
|
8 | 10 | ## Configuration File Format |
9 | 11 |
|
10 | 12 | Configuration files can be either: |
11 | 13 |
|
12 | | -- **JavaScript/ESM** (`.mjs`, `.js` with `"type": "module"`) |
| 14 | +- **JavaScript** (`.js`, `.mjs`, `.cjs`) |
| 15 | +- **TypeScript** (`.ts`, when `typescript` is installed in the project) |
13 | 16 | - **JSON** (`.json`) |
| 17 | +- **YAML** (`.yaml`, `.yml`, or an extensionless rc file) |
| 18 | + |
| 19 | +JavaScript and TypeScript configuration files export the configuration object. |
| 20 | +JSON and YAML files contain the object directly. A `package.json` configuration |
| 21 | +uses the `doc-kit` property: |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "doc-kit": { |
| 26 | + "target": ["json"], |
| 27 | + "global": { |
| 28 | + "input": "doc/api/*.md", |
| 29 | + "output": "out" |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | +``` |
14 | 34 |
|
15 | 35 | ### Basic Example |
16 | 36 |
|
@@ -94,10 +114,11 @@ export default { |
94 | 114 |
|
95 | 115 | ## Configuration Merging |
96 | 116 |
|
97 | | -Configurations are merged in the following order (earlier sources take precedence): |
| 117 | +Configurations are merged in the following order (higher sources take |
| 118 | +precedence): |
98 | 119 |
|
99 | | -1. **Config file** (`--config-file`) |
100 | | -2. **CLI options** (command-line arguments) |
| 120 | +1. **CLI options** (command-line arguments) |
| 121 | +2. **Configuration file** (discovered or selected with `--config-file`) |
101 | 122 | 3. **Default values** (built-in defaults) |
102 | 123 |
|
103 | 124 | ## CLI Options Mapping |
|
0 commit comments