Skip to content

Commit f184750

Browse files
committed
document configuring
1 parent 2cf8154 commit f184750

File tree

43 files changed

+278
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+278
-44
lines changed

docs/configuration.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
`doc-kit`'s CLI supports a `--config-file` option, allowing for custom configuration files to be passed.
44
These configuration files must be loadable via a `import()` call, so usually JSON or JavaScript files with default exports.
55

6-
The structure of these files is the `Configuration` type.
7-
86
## Configuration File Format
97

108
Configuration files can be either:
119

1210
- **JavaScript/ESM** (`.mjs`, `.js` with `"type": "module"`)
1311
- **JSON** (`.json`)
14-
- **Remote URLs** (loaded dynamically)
1512

1613
### Basic Example
1714

18-
```javascript name=doc-kit.config.mjs
15+
```javascript
1916
export default {
2017
global: {
2118
version: '20.0.0',

docs/generators.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export default {
199199
*/
200200
async *generate(input, worker) {
201201
// Configuration for this generator is based on it's name
202-
const { 'parallel-generator': config } = getConfig();
202+
const config = getConfig('parallel-generator');
203203

204204
// Prepare serializable dependencies
205205
const deps = {
@@ -361,7 +361,7 @@ The framework ensures `metadata` runs once and its output is cached for all cons
361361
### Writing Output Files
362362

363363
```javascript
364-
const { 'my-generator': config } = getConfig();
364+
const config = getConfig('my-generator');
365365

366366
if (!config.output) {
367367
// Return data without writing
@@ -389,7 +389,7 @@ return result;
389389
### Copying Assets
390390

391391
```javascript
392-
const { 'my-generator': config } = getConfig();
392+
const config = getConfig('my-generator');
393393

394394
if (config.output) {
395395
// Copy asset directory
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## `addon-verify` Generator
2+
3+
The `addon-verify` generator extracts code blocks from `doc/api/addons.md` and generates a file list to facilitate C++ compilation and JavaScript runtime validations for Node.js addon examples.
4+
5+
### Configuring
6+
7+
The `addon-verify` generator accepts the following configuration options:
8+
9+
| Name | Type | Default | Description |
10+
| -------- | -------- | ------- | -------------------------------------------------------- |
11+
| `output` | `string` | - | The directory where extracted code files will be written |

src/generators/addon-verify/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
* Generates a file list from code blocks.
3636
*/
3737
async generate(input) {
38-
const { 'addon-verify': config } = getConfig();
38+
const config = getConfig('addon-verify');
3939

4040
const sectionsCodeBlocks = input.reduce((addons, node) => {
4141
const sectionName = node.heading.data.name;

src/generators/api-links/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## `api-links` Generator
2+
3+
The `api-links` generator creates a mapping of publicly accessible functions to their source locations in the Node.js repository by analyzing JavaScript source files.
4+
5+
### Configuring
6+
7+
The `api-links` generator accepts the following configuration options:
8+
9+
| Name | Type | Default | Description |
10+
| -------- | --------- | ------- | --------------------------------------------------- |
11+
| `output` | `string` | - | The directory where `apilinks.json` will be written |
12+
| `minify` | `boolean` | `true` | Whether to minify the output JSON |

src/generators/api-links/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
* Generates the `apilinks.json` file.
3939
*/
4040
async generate(input) {
41-
const { 'api-links': config } = getConfig();
41+
const config = getConfig('api-links');
4242
/**
4343
* @type Record<string, string>
4444
*/

src/generators/ast-js/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## `ast-js` Generator
2+
3+
The `ast-js` generator parses JavaScript source files into AST (Abstract Syntax Tree) representations using the Acorn parser.
4+
5+
### Configuring
6+
7+
The `ast-js` generator accepts the following configuration options:
8+
9+
| Name | Type | Default | Description |
10+
| -------- | -------------------- | ------- | ------------------------------------------------- |
11+
| `input` | `string \| string[]` | - | Glob pattern(s) for the JavaScript files to parse |
12+
| `ignore` | `string \| string[]` | - | Glob pattern(s) for files to exclude from parsing |

src/generators/ast-js/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default {
5353
* Generates a JavaScript AST from the input files.
5454
*/
5555
async *generate(_, worker) {
56-
const { 'ast-js': config } = getConfig();
56+
const config = getConfig('ast-js');
5757

5858
const files = globSync(config.input, { ignore: config.ignore }).filter(
5959
p => extname(p) === '.js'

src/generators/ast/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## `ast` Generator
2+
3+
The `ast` generator parses Markdown API documentation files into AST (Abstract Syntax Tree) representations, parallelizing the parsing across worker threads for better performance.
4+
5+
### Configuring
6+
7+
The `ast` generator accepts the following configuration options:
8+
9+
| Name | Type | Default | Description |
10+
| -------- | -------------------- | ------- | ------------------------------------------------- |
11+
| `input` | `string \| string[]` | - | Glob pattern(s) for the Markdown files to parse |
12+
| `ignore` | `string \| string[]` | - | Glob pattern(s) for files to exclude from parsing |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## `json-simple` Generator
2+
3+
The `json-simple` generator creates a simplified JSON version of the API documentation, primarily for debugging and testing purposes.
4+
5+
### Configuring
6+
7+
The `json-simple` generator accepts the following configuration options:
8+
9+
| Name | Type | Default | Description |
10+
| -------- | --------- | ----------------------- | --------------------------------------------------- |
11+
| `output` | `string` | - | The directory where `api-docs.json` will be written |
12+
| `minify` | `boolean` | Inherited from `global` | Whether to minify the output JSON |

0 commit comments

Comments
 (0)