Skip to content

Commit 2f2f2d0

Browse files
committed
chore(monorepo): move everything into packages/core
1 parent 7bd1b5b commit 2f2f2d0

281 files changed

Lines changed: 269 additions & 171 deletions

File tree

Some content is hidden

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

.c8rc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"exclude": [
44
"eslint.config.mjs",
55
"**/fixtures",
6-
"src/generators/legacy-html/assets",
7-
"src/generators/web/ui",
6+
"packages/core/src/generators/legacy-html/assets",
7+
"packages/core/src/generators/web/ui",
88
"**/*.d.ts"
99
]
1010
}

.changeset/monorepo-layout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@node-core/doc-kit': patch
3+
---
4+
5+
Moved the package into a `packages/core` workspace.

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
with:
2424
ignore_words_list: crate,raison
2525
exclude_file: .gitignore
26-
skip: package-lock.json, ./src/generators/mandoc/template.1
26+
skip: package-lock.json, ./packages/core/src/generators/mandoc/template.1

.github/workflows/generate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
/usr/bin/time \
150150
--output out/benchmark.json \
151151
--format '{"elapsedSeconds": %e, "userCpuSeconds": %U, "systemCpuSeconds": %S, "maxRssKiB": %M}' \
152-
node bin/cli.mjs generate \
152+
node packages/core/bin/cli.mjs generate \
153153
-t ${{ matrix.target }} \
154154
-i "${{ matrix.input }}" \
155155
-o out \

.prettierignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
npm-shrinkwrap.json
22

33
# Tests files
4-
src/generators/api-links/__tests__/fixtures/
4+
packages/core/src/generators/api-links/__tests__/fixtures/
55
*.snapshot
66

77
# Templates
8-
src/generators/web/template.html
8+
packages/core/src/generators/web/template.html
99

1010
# Output
1111
out/
@@ -14,7 +14,7 @@ out/
1414
www/content/
1515

1616
# Generated Files
17-
src/generators/metadata/maps/mdn.json
17+
packages/core/src/generators/metadata/maps/mdn.json
1818

1919
# The specification uses things that prettier would not
2020
# approve of, such as bullets with `*`

CONTRIBUTING.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ The steps below will give you a general idea of how to prepare your local enviro
7171
npm install
7272
```
7373

74+
### Repository Layout
75+
76+
This repository is an npm workspaces monorepo. The root package is private and
77+
holds the shared tooling (linting, formatting, tests, changesets); every
78+
published package lives under `packages/`:
79+
80+
- `packages/core`: [`@node-core/doc-kit`](packages/core)
81+
82+
Everything else at the root supports the repo rather than shipping to npm:
83+
`docs/` (the reference docs), `www/` (the documentation site), `scripts/` (build
84+
and comparison helpers), and `e2e/` (Playwright tests).
85+
7486
### Running the Tool Locally
7587

7688
`doc-kit` generates documentation from the Markdown API docs in the [Node.js repository](https://github.com/nodejs/node). To run the tool locally, you need a copy of those source files.
@@ -91,7 +103,7 @@ The steps below will give you a general idea of how to prepare your local enviro
91103
For fast iteration during development, target a single Markdown file instead of all API docs:
92104

93105
```bash
94-
node bin/cli.mjs generate \
106+
node packages/core/bin/cli.mjs generate \
95107
-t legacy-html \
96108
-i ../node/doc/api/fs.md \
97109
-o out \
@@ -112,7 +124,7 @@ The steps below will give you a general idea of how to prepare your local enviro
112124
Add `--log-level debug` before the `generate` subcommand to see the full pipeline trace:
113125

114126
```bash
115-
node bin/cli.mjs --log-level debug generate -t legacy-html -i ../node/doc/api/fs.md -o out
127+
node packages/core/bin/cli.mjs --log-level debug generate -t legacy-html -i ../node/doc/api/fs.md -o out
116128
```
117129

118130
> [!TIP]
@@ -216,7 +228,8 @@ Testing is a crucial part of maintaining code quality and ensuring reliability.
216228

217229
### Test File Organization
218230

219-
Tests should be organized to mirror the source code structure:
231+
Tests should be organized to mirror the source code structure. The paths below
232+
are relative to the package the source file lives in (e.g. `packages/core`):
220233

221234
- For a source file at `/src/index.mjs`, create a test file at `/src/__tests__/index.test.mjs`
222235
- For a source file at `/src/utils/parser.mjs`, create a test file at `/src/utils/__tests__/parser.test.mjs`
@@ -306,7 +319,7 @@ node --run test
306319
node --run test:coverage
307320

308321
# Run specific test file
309-
node --test src/test/index.test.mjs
322+
node --test packages/core/src/utils/__tests__/parser.test.mjs
310323
```
311324

312325
## Code Quality

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $ npx doc-kit --help
3636
```
3737

3838
```sh
39-
$ node bin/cli.mjs --help
39+
$ node packages/core/bin/cli.mjs --help
4040
```
4141

4242
```

docs/commands.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Each command consists of:
2424

2525
### Step 1: Create the Command File
2626

27-
Create a new file in `bin/commands/` with your command name:
27+
Create a new file in `packages/core/bin/commands/` with your command name:
2828

2929
```javascript
30-
// bin/commands/my-command.mjs
30+
// packages/core/bin/commands/my-command.mjs
3131
import logger from '../../src/logger/index.mjs';
3232

3333
/**
@@ -53,7 +53,7 @@ export default {
5353

5454
### Step 2: Register the Command
5555

56-
Add your command to the exports in `bin/commands/index.mjs`:
56+
Add your command to the exports in `packages/core/bin/commands/index.mjs`:
5757

5858
```javascript
5959
import generate from './generate.mjs';
@@ -67,7 +67,7 @@ export default [
6767

6868
### Step 3: Update CLI Entry Point
6969

70-
The CLI in `bin/cli.mjs` automatically loads commands from `bin/commands/index.mjs`, so no changes are needed there if you followed step 2.
70+
The CLI in `packages/core/bin/cli.mjs` automatically loads commands from `packages/core/bin/commands/index.mjs`, so no changes are needed there if you followed step 2.
7171

7272
## Command Options
7373

docs/generators.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ A generator is defined as a module exporting an object conforming to the `Genera
3434

3535
### Step 1: Create the Generator Files
3636

37-
Create a new directory in `src/generators/`:
37+
Create a new directory in `packages/core/src/generators/`:
3838

3939
```
40-
src/generators/my-format/
40+
packages/core/src/generators/my-format/
4141
├── index.mjs # Generator metadata (required)
4242
├── generate.mjs # Generator implementation (required)
4343
├── constants.mjs # Constants (optional)
@@ -72,7 +72,7 @@ export type Generator = GeneratorMetadata<
7272
Create the generator metadata in `index.mjs` using `createLazyGenerator`:
7373

7474
```javascript
75-
// src/generators/my-format/index.mjs
75+
// packages/core/src/generators/my-format/index.mjs
7676
import { createLazyGenerator } from '../../utils/generators.mjs';
7777

7878
/**
@@ -104,7 +104,7 @@ export default createLazyGenerator({
104104
Create the generator implementation in `generate.mjs`:
105105

106106
```javascript
107-
// src/generators/my-format/generate.mjs
107+
// packages/core/src/generators/my-format/generate.mjs
108108
import { writeFile } from 'node:fs/promises';
109109
import { join } from 'node:path';
110110

@@ -149,7 +149,7 @@ function transformToMyFormat(entries, version) {
149149

150150
### Step 5: Register the Generator
151151

152-
Add your generator to the exports in `src/generators/index.mjs`:
152+
Add your generator to the exports in `packages/core/src/generators/index.mjs`:
153153

154154
```javascript
155155
// For public generators (available via CLI)
@@ -178,7 +178,7 @@ For generators processing large datasets, implement parallel processing using wo
178178
First, define the generator metadata in `index.mjs`:
179179

180180
```javascript
181-
// src/generators/parallel-generator/index.mjs
181+
// packages/core/src/generators/parallel-generator/index.mjs
182182
import { createLazyGenerator } from '../../utils/generators.mjs';
183183

184184
/**
@@ -199,7 +199,7 @@ export default createLazyGenerator({
199199
Then, implement both `processChunk` and `generate` in `generate.mjs`:
200200

201201
```javascript
202-
// src/generators/parallel-generator/generate.mjs
202+
// packages/core/src/generators/parallel-generator/generate.mjs
203203
import getConfig from '../../utils/configuration/index.mjs';
204204

205205
/**
@@ -272,7 +272,7 @@ Generators can yield results as they're produced using async generators.
272272
Define the generator metadata in `index.mjs`:
273273

274274
```javascript
275-
// src/generators/streaming-generator/index.mjs
275+
// packages/core/src/generators/streaming-generator/index.mjs
276276
import { createLazyGenerator } from '../../utils/generators.mjs';
277277

278278
/**
@@ -292,7 +292,7 @@ export default createLazyGenerator({
292292
Implement the generator in `generate.mjs`:
293293

294294
```javascript
295-
// src/generators/streaming-generator/generate.mjs
295+
// packages/core/src/generators/streaming-generator/generate.mjs
296296
/**
297297
* Process a chunk of data
298298
*
@@ -330,7 +330,7 @@ Some generators must collect all input before processing.
330330
Generator metadata in `index.mjs`:
331331

332332
```javascript
333-
// src/generators/batch-generator/index.mjs
333+
// packages/core/src/generators/batch-generator/index.mjs
334334
import { createLazyGenerator } from '../../utils/generators.mjs';
335335

336336
/**
@@ -348,7 +348,7 @@ export default createLazyGenerator({
348348
Implementation in `generate.mjs`:
349349

350350
```javascript
351-
// src/generators/batch-generator/generate.mjs
351+
// packages/core/src/generators/batch-generator/generate.mjs
352352
/**
353353
* Non-streaming - returns Promise instead of AsyncGenerator
354354
*
@@ -401,23 +401,23 @@ export async function generate(input, worker) {
401401

402402
```javascript
403403
// Step 1: Parse markdown to AST
404-
// src/generators/ast/index.mjs
404+
// packages/core/src/generators/ast/index.mjs
405405
export default createLazyGenerator({
406406
name: 'ast',
407407
dependsOn: undefined, // No dependency
408408
// Processes raw markdown files
409409
});
410410

411411
// Step 2: Extract metadata from AST
412-
// src/generators/metadata/index.mjs
412+
// packages/core/src/generators/metadata/index.mjs
413413
export default createLazyGenerator({
414414
name: 'metadata',
415415
dependsOn: 'ast', // Depends on AST
416416
// Processes AST output
417417
});
418418

419419
// Step 3: Generate HTML from metadata
420-
// src/generators/html-generator/index.mjs
420+
// packages/core/src/generators/html-generator/index.mjs
421421
export default createLazyGenerator({
422422
name: 'html-generator',
423423
dependsOn: 'metadata', // Depends on metadata

eslint.config.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export default defineConfig([
1010
importX.flatConfigs.recommended,
1111
react.configs.recommended,
1212
{
13-
ignores: ['out/', 'src/generators/api-links/__tests__/fixtures/'],
13+
ignores: [
14+
'out/',
15+
'packages/core/src/generators/api-links/__tests__/fixtures/',
16+
],
1417
},
1518
{
1619
files: ['**/*.{mjs,jsx,js}'],
@@ -54,7 +57,7 @@ export default defineConfig([
5457
},
5558
},
5659
{
57-
files: ['src/**/*.mjs', 'bin/**/*.mjs'],
60+
files: ['packages/*/src/**/*.mjs', 'packages/*/bin/**/*.mjs'],
5861
plugins: {
5962
jsdoc,
6063
},
@@ -91,8 +94,8 @@ export default defineConfig([
9194
},
9295
{
9396
files: [
94-
'src/generators/legacy-html/assets/*.js',
95-
'src/generators/web/ui/**/*',
97+
'packages/core/src/generators/legacy-html/assets/*.js',
98+
'packages/core/src/generators/web/ui/**/*',
9699
],
97100
languageOptions: {
98101
globals: {

0 commit comments

Comments
 (0)