Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"all": true,
"exclude": [
"**/fixtures",
"packages/core/src/generators/legacy-html/assets",
"packages/core/src/generators/web/ui",
"packages/legacy/src/generators/html/assets",
"packages/react/src/generators/web/ui",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.c8rc.json excludes wrong path for web UI

Low Severity

The coverage exclusion path packages/react/src/generators/web/ui is incorrect. The eslint config in the same PR references the web UI at packages/react/src/utils/web/ui/**/*, and the web generator imports ROOT from ../../utils/web/constants.mjs then resolves UI components relative to that. The UI files live under utils/web/ui, not generators/web/ui.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0a923b4. Configure here.

"**/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
with:
ignore_words_list: crate,raison
exclude_file: .gitignore
skip: package-lock.json, ./packages/core/src/generators/mandoc/template.1
skip: package-lock.json, ./packages/extras/src/generators/man-page/template.1
22 changes: 11 additions & 11 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ jobs:
echo "run_id=$ID" >> $GITHUB_OUTPUT

- name: Download metadata artifact
if: ${{ github.event_name == 'pull_request' }}
if: ${{ steps.main.outputs.run_id }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: commit
run-id: ${{ steps.main.outputs.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- id: pr
if: ${{ github.event_name == 'pull_request' }}
if: ${{ steps.main.outputs.run_id }}
run: |
SHA=$(cat commit)
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
Expand All @@ -76,36 +76,36 @@ jobs:
fail-fast: false
matrix:
include:
- target: '@node-core/doc-kit/generators/man-page'
- target: '@doc-kittens/extras/man-page'
input: './node/doc/api/cli.md'

- target: '@node-core/doc-kit/generators/addon-verify'
- target: '@doc-kittens/extras/addon-verify'
input: './node/doc/api/addons.md'

- target: '@node-core/doc-kit/generators/api-links'
- target: '@doc-kittens/website/api-links'
input: './node/lib/*.js'
compare: object-assertion

- target: '@node-core/doc-kit/generators/orama-db'
- target: '@doc-kittens/react/orama-db'
input: './node/doc/api/*.md'
compare: file-size

- target: '@node-core/doc-kit/generators/json-simple'
- target: '@doc-kittens/extras/json-simple'
input: './node/doc/api/*.md'

- target: '@node-core/doc-kit/generators/legacy-json'
- target: '@doc-kittens/legacy/json'
input: './node/doc/api/*.md'
compare: object-assertion

- target: '@node-core/doc-kit/generators/legacy-html'
- target: '@doc-kittens/legacy/html'
input: './node/doc/api/*.md'
compare: file-size

- target: '@node-core/doc-kit/generators/web'
- target: '@doc-kittens/react/web'
input: './node/doc/api/*.md'
compare: file-size

- target: '@node-core/doc-kit/generators/llms-txt'
- target: '@doc-kittens/website/llms-txt'
input: './node/doc/api/*.md'
compare: file-size
steps:
Expand Down
6 changes: 3 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
npm-shrinkwrap.json

# Tests files
packages/core/src/generators/api-links/__tests__/fixtures/
packages/website/src/generators/api-links/__tests__/fixtures/
*.snapshot

# Templates
packages/core/src/generators/web/template.html
packages/legacy/src/generators/web/template.html
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.prettierignore points to wrong package for web template

Low Severity

The web generator template was moved to packages/react/src/generators/web/template.html, but .prettierignore incorrectly references packages/legacy/src/generators/web/template.html. The legacy package has html and json generators, not web. This means Prettier won't ignore the actual template file in the react package.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0a923b4. Configure here.


# Output
out/

# Generated Files
packages/core/src/generators/metadata/maps/mdn.json
packages/internal/src/generators/metadata/maps/mdn.json
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The steps below will give you a general idea of how to prepare your local enviro

```bash
node packages/core/bin/cli.mjs generate \
-t legacy-html \
-t @doc-kittens/legacy/html \
-i ../node/doc/api/fs.md \
-o out \
--index ../node/doc/api/index.md \
Expand All @@ -110,7 +110,7 @@ The steps below will give you a general idea of how to prepare your local enviro
Add `--log-level debug` before the `generate` subcommand to see the full pipeline trace:

```bash
node packages/core/bin/cli.mjs --log-level debug generate -t legacy-html -i ../node/doc/api/fs.md -o out
node packages/core/bin/cli.mjs --log-level debug generate -t @doc-kittens/legacy/html -i ../node/doc/api/fs.md -o out
```

> [!TIP]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Options:
-v, --version <semver> Target Node.js version (default: "v22.14.0")
-c, --changelog <url> Changelog URL or path (default: "https://raw.githubusercontent.com/nodejs/node/HEAD/CHANGELOG.md")
--git-ref <url> Git ref/commit URL (default: "https://github.com/nodejs/node/tree/HEAD")
-t, --target <generator...> Target generator(s) (e.g. @node-core/doc-kit/generators/web)
-t, --target <generator...> Target generator(s) (e.g. @doc-kittens/react/web)
-h, --help display help for command
```

Expand All @@ -87,12 +87,12 @@ Options:

### Legacy

To generate a 1:1 match with the [legacy tooling](https://github.com/nodejs/node/tree/main/tools/doc), use the `legacy-html`, `legacy-json`, `legacy-html-all`, and `legacy-json-all` generators.
To generate a 1:1 match with the [legacy tooling](https://github.com/nodejs/node/tree/main/tools/doc), use the generators from the [`@doc-kittens/legacy`](packages/legacy) package.

```sh
npx doc-kit generate \
-t @node-core/doc-kit/generators/legacy-html \
-t @node-core/doc-kit/generators/legacy-json \
-t @doc-kittens/legacy/html \
-t @doc-kittens/legacy/json \
-i "path/to/node/doc/api/*.md" \
-o out \
--index path/to/node/doc/api/index.md
Expand All @@ -104,8 +104,8 @@ To generate [our redesigned documentation pages](https://nodejs-api-docs-tooling

```sh
npx doc-kit generate \
-t @node-core/doc-kit/generators/web \
-t @node-core/doc-kit/generators/orama-db \
-t @doc-kittens/react/web \
-t @doc-kittens/react/orama-db \
-i "path/to/node/doc/api/*.md" \
-o out \
--index path/to/node/doc/api/index.md
Expand Down
28 changes: 14 additions & 14 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ Configurations are merged in the following order (earlier sources take precedenc

CLI options map to configuration properties:

| CLI Option | Config Property | Example |
| ---------------------- | ------------------ | ---------------------------------------------------- |
| `--input <path>` | `global.input` | `--input src/` |
| `--output <path>` | `global.output` | `--output dist/` |
| `--ignore <pattern>` | `global.ignore[]` | `--ignore test/` |
| `--minify` | `global.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 @node-core/doc-kit/generators/legacy-json` |
| `--threads <n>` | `threads` | `--threads 4` |
| `--chunk-size <n>` | `chunkSize` | `--chunk-size 10` |
| CLI Option | Config Property | Example |
| ---------------------- | ------------------ | ----------------------------------- |
| `--input <path>` | `global.input` | `--input src/` |
| `--output <path>` | `global.output` | `--output dist/` |
| `--ignore <pattern>` | `global.ignore[]` | `--ignore test/` |
| `--minify` | `global.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 @doc-kittens/legacy/json` |
| `--threads <n>` | `threads` | `--threads 4` |
| `--chunk-size <n>` | `chunkSize` | `--chunk-size 10` |
36 changes: 22 additions & 14 deletions docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ A generator is a single module (`index.mjs`) that exports its metadata and logic

### Step 1: Create the Generator Directory

Create a new directory in `src/generators/`:
Generators live inside one of the workspace packages under `packages/<package>/src/generators/`. The existing groupings are:

- `@doc-kittens/legacy` — historical JSON/HTML formats
- `@doc-kittens/internal` — `ast`, `ast-js`, `metadata` (foundational generators consumed by everything else)
- `@doc-kittens/react` — React/JSX-based generators (`web`, `orama-db`, `jsx-ast`)
- `@doc-kittens/website` — public website outputs (`sitemap`, `llms-txt`, `api-links`)
- `@doc-kittens/extras` — specialised one-offs (`addon-verify`, `json-simple`, `man-page`)

Place your new generator in the package whose theme it matches, or create a new workspace package if none fit.

```
src/generators/my-format/
packages/<package>/src/generators/my-format/
├── index.mjs # Generator entry point (required)
├── constants.mjs # Constants (optional)
├── types.d.ts # TypeScript types (required)
Expand Down Expand Up @@ -77,16 +85,16 @@ export type Generator = GeneratorMetadata<
Create `index.mjs` with your generator's metadata and logic:

```javascript
// src/generators/my-format/index.mjs
// packages/<package>/src/generators/my-format/index.mjs
'use strict';

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';

import getConfig from '../../utils/configuration/index.mjs';
import getConfig from '@node-core/doc-kit/src/utils/configuration/index.mjs';

export const name = 'my-format';
export const dependsOn = '@node-core/doc-kit/generators/metadata';
export const dependsOn = '@doc-kittens/internal/metadata';
export const defaultConfiguration = {
myCustomOption: 'myDefaultValue',
};
Expand Down Expand Up @@ -130,7 +138,7 @@ function transformToMyFormat(entries, version) {

### Step 4: Register the Generator

Add an entry to the `exports` map in `packages/core/package.json`. If you follow the `index.mjs` convention, the wildcard pattern `"./generators/*": "./src/generators/*/index.mjs"` handles this automatically — no changes needed.
Add a short subpath entry to the `exports` map in your package's `package.json`, e.g. `"./my-format": "./src/generators/my-format/index.mjs"`. The `./src/*` wildcard already exposes utilities and types under the longer path form for cross-package imports.

## Parallel Processing with Workers

Expand All @@ -139,11 +147,11 @@ For generators processing large datasets, implement parallel processing using wo
### Implementing Worker-Based Processing

```javascript
// src/generators/parallel-generator/index.mjs
import getConfig from '../../utils/configuration/index.mjs';
// packages/<package>/src/generators/parallel-generator/index.mjs
import getConfig from '@node-core/doc-kit/src/utils/configuration/index.mjs';

export const name = 'parallel-generator';
export const dependsOn = '@node-core/doc-kit/generators/metadata';
export const dependsOn = '@doc-kittens/internal/metadata';

/**
* Process a chunk of items in a worker thread.
Expand Down Expand Up @@ -215,7 +223,7 @@ Generators can yield results as they're produced using async generators. Export
```javascript
// src/generators/streaming-generator/index.mjs
export const name = 'streaming-generator';
export const dependsOn = '@node-core/doc-kit/generators/metadata';
export const dependsOn = '@doc-kittens/internal/metadata';

/**
* Process a chunk of data
Expand Down Expand Up @@ -254,7 +262,7 @@ Some generators must collect all input before processing:
```javascript
// src/generators/batch-generator/index.mjs
export const name = 'batch-generator';
export const dependsOn = '@node-core/doc-kit/generators/jsx-ast';
export const dependsOn = '@doc-kittens/react/jsx-ast';

/**
* Non-streaming - returns Promise instead of AsyncGenerator
Expand Down Expand Up @@ -285,7 +293,7 @@ Use non-streaming when:
```javascript
// src/generators/my-generator/index.mjs
export const name = 'my-generator';
export const dependsOn = '@node-core/doc-kit/generators/metadata';
export const dependsOn = '@doc-kittens/internal/metadata';

export async function generate(input, worker) {
// input contains the output from the metadata generator
Expand All @@ -303,12 +311,12 @@ export const name = 'ast';
// Step 2: Extract metadata from AST
// src/generators/metadata/index.mjs
export const name = 'metadata';
export const dependsOn = '@node-core/doc-kit/generators/ast';
export const dependsOn = '@doc-kittens/internal/ast';

// Step 3: Generate HTML from metadata
// src/generators/html-generator/index.mjs
export const name = 'html-generator';
export const dependsOn = '@node-core/doc-kit/generators/metadata';
export const dependsOn = '@doc-kittens/internal/metadata';
```

### Multiple Consumers
Expand Down
9 changes: 3 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export default defineConfig([
importX.flatConfigs.recommended,
react.configs.recommended,
{
ignores: [
'out/',
'packages/core/src/generators/api-links/__tests__/fixtures/',
],
ignores: ['out/', '**/fixtures/'],
},
{
files: ['**/*.{mjs,jsx}'],
Expand Down Expand Up @@ -94,8 +91,8 @@ export default defineConfig([
},
{
files: [
'packages/core/src/generators/legacy-html/assets/*.js',
'packages/core/src/generators/web/ui/**/*',
'packages/legacy/src/generators/html/assets/*.js',
'packages/react/src/utils/web/ui/**/*',
],
languageOptions: {
globals: {
Expand Down
Loading
Loading