Skip to content

Commit cbf00f0

Browse files
committed
fixup!
1 parent 5decb29 commit cbf00f0

20 files changed

Lines changed: 74 additions & 148 deletions

File tree

.github/workflows/generate.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ jobs:
106106
input: './node/doc/api/*.md'
107107
compare: file-size
108108

109-
- target: web-all
110-
input: './node/doc/api/*.md'
111-
112109
- target: llms-txt
113110
input: './node/doc/api/*.md'
114111
compare: file-size

scripts/vercel-build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ node bin/cli.mjs generate \
33
-t legacy-json \
44
-t llms-txt \
55
-t web \
6-
-t web-all \
76
-i "./node/doc/api/*.md" \
87
-o "./out" \
98
-c "./node/CHANGELOG.md" \

src/generators/index.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import metadata from './metadata/index.mjs';
1616
import oramaDb from './orama-db/index.mjs';
1717
import sitemap from './sitemap/index.mjs';
1818
import web from './web/index.mjs';
19-
import webAll from './web-all/index.mjs';
2019

2120
export const publicGenerators = {
2221
'json-simple': jsonSimple,
@@ -31,7 +30,6 @@ export const publicGenerators = {
3130
'llms-txt': llmsTxt,
3231
sitemap,
3332
web,
34-
'web-all': webAll,
3533
};
3634

3735
// These ones are special since they don't produce standard output,

src/generators/jsx-ast/generate.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export async function processChunk(slicedInput, itemIndices) {
1919

2020
const content = await buildContent(entries, head);
2121

22+
// Preserve the raw section entries so downstream generators (e.g. `web`)
23+
// can build synthetic pages (all.html, index.html) without recomputing
24+
// metadata.
25+
content.sectionEntries = entries;
26+
2227
results.push(content);
2328
}
2429

src/generators/web-all/README.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/generators/web-all/generate.mjs

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/generators/web-all/index.mjs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/generators/web-all/types.d.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/generators/web/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ The `web` generator transforms JSX AST entries into complete web bundles, produc
66

77
The `web` generator accepts the following configuration options:
88

9-
| Name | Type | Default | Description |
10-
| ----------------- | --------- | --------------------------------------------- | --------------------------------------------------------------------- |
11-
| `output` | `string` | - | The directory where HTML, JavaScript, and CSS files will be written |
12-
| `templatePath` | `string` | `'template.html'` | Path to the HTML template file |
13-
| `project` | `string` | `'Node.js'` | Project name used in page titles and the version selector |
14-
| `title` | `string` | `'{project} v{version} Documentation'` | Title template for HTML pages (supports `{project}`, `{version}`) |
15-
| `useAbsoluteURLs` | `boolean` | `false` | When `true`, all internal links use absolute URLs based on `baseURL` |
16-
| `editURL` | `string` | `'${GITHUB_EDIT_URL}/doc/api{path}.md'` | URL template for "edit this page" links |
17-
| `pageURL` | `string` | `'{baseURL}/latest-{version}/api{path}.html'` | URL template for documentation page links |
18-
| `imports` | `object` | See below | Object mapping `#theme/` aliases to component paths for customization |
19-
| `virtualImports` | `object` | `{}` | Additional virtual module mappings merged into the build |
9+
| Name | Type | Default | Description |
10+
| ---------------------- | --------- | --------------------------------------------- | --------------------------------------------------------------------- |
11+
| `output` | `string` | - | The directory where HTML, JavaScript, and CSS files will be written |
12+
| `templatePath` | `string` | `'template.html'` | Path to the HTML template file |
13+
| `project` | `string` | `'Node.js'` | Project name used in page titles and the version selector |
14+
| `title` | `string` | `'{project} v{version} Documentation'` | Title template for HTML pages (supports `{project}`, `{version}`) |
15+
| `useAbsoluteURLs` | `boolean` | `false` | When `true`, all internal links use absolute URLs based on `baseURL` |
16+
| `editURL` | `string` | `'${GITHUB_EDIT_URL}/doc/api{path}.md'` | URL template for "edit this page" links |
17+
| `pageURL` | `string` | `'{baseURL}/latest-{version}/api{path}.html'` | URL template for documentation page links |
18+
| `generateAllPage` | `boolean` | `true` | When `true`, emits `all.html` containing every module's content |
19+
| `generateIndexPage` | `boolean` | `true` | When `true`, emits `index.html` with a stability overview |
20+
| `generateNotFoundPage` | `boolean` | `true` | When `true`, emits `404.html` |
21+
| `imports` | `object` | See below | Object mapping `#theme/` aliases to component paths for customization |
22+
| `virtualImports` | `object` | `{}` | Additional virtual module mappings merged into the build |
2023

2124
#### Default `imports`
2225

src/generators/web/generate.mjs

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,78 @@ import { readFile } from 'node:fs/promises';
44
import { join } from 'node:path';
55

66
import { processJSXEntries } from './utils/processing.mjs';
7+
import { buildNotFoundPage } from './utils/synthetic/404.mjs';
8+
import { buildAllPage } from './utils/synthetic/all.mjs';
9+
import { buildIndexPage } from './utils/synthetic/index.mjs';
710
import getConfig from '../../utils/configuration/index.mjs';
811
import { writeFile } from '../../utils/file.mjs';
12+
import buildContent from '../jsx-ast/utils/buildContent.mjs';
913

1014
/**
1115
* Main generation function that processes JSX AST entries into web bundles.
1216
*
17+
* Generates the regular per-module pages plus, when enabled by configuration,
18+
* the synthetic `all`, `index`, and `404` pages. Everything is bundled in a
19+
* single pass so shared component chunks and CSS are produced once.
20+
*
1321
* @type {import('./types').Generator['generate']}
1422
*/
1523
export async function generate(input) {
1624
const config = getConfig('web');
1725

1826
const template = await readFile(config.templatePath, 'utf-8');
1927

20-
// The `web-all` generator re-generates `index.html` with a stability
21-
// overview, so skip the synthetic `index` entry here.
28+
// The synthetic `index` entry from Core is replaced by our own
29+
// `index.html` (with stability overview) when `generateIndexPage` is on.
2230
//
2331
// TODO(@avivkeller): Once this lands in core, remove the `index.html`
2432
// page from Core, then remove this check.
25-
const entries = input.filter(entry => entry.data.api !== 'index');
33+
const moduleEntries = input.filter(entry => entry.data.api !== 'index');
34+
35+
// Reconstruct the flat metadata list from the per-module section entries
36+
// attached by `jsx-ast`. Used to build the synthetic `all` and `index`
37+
// pages without a separate `metadata` dependency.
38+
const synthDescriptors = [];
39+
40+
if (config.generateAllPage || config.generateIndexPage) {
41+
const metadata = moduleEntries.flatMap(entry => entry.sectionEntries);
42+
43+
if (config.generateAllPage) {
44+
synthDescriptors.push(buildAllPage(metadata));
45+
}
46+
if (config.generateIndexPage) {
47+
synthDescriptors.push(buildIndexPage(metadata));
48+
}
49+
}
50+
51+
if (config.generateNotFoundPage) {
52+
synthDescriptors.push(buildNotFoundPage());
53+
}
54+
55+
const syntheticEntries = await Promise.all(
56+
synthDescriptors.map(({ head, entries }) => buildContent(entries, head))
57+
);
58+
59+
// Sidebar lists only the real module pages.
60+
const sidebarEntries = moduleEntries.map(entry => ({ data: entry.data }));
61+
62+
const allEntries = [...moduleEntries, ...syntheticEntries];
2663

27-
// Process all entries: convert JSX to HTML/CSS/JS
28-
const { results, css, chunks } = await processJSXEntries(entries, template);
64+
const { results, css, chunks } = await processJSXEntries(
65+
allEntries,
66+
template,
67+
sidebarEntries
68+
);
2969

30-
// Process all entries together (required for code-split bundles)
3170
if (config.output) {
32-
// Write HTML files
3371
for (const { html, path } of results) {
3472
await writeFile(join(config.output, `${path}.html`), html, 'utf-8');
3573
}
3674

37-
// Write code-split JavaScript chunks
3875
for (const chunk of chunks) {
3976
await writeFile(join(config.output, chunk.fileName), chunk.code, 'utf-8');
4077
}
4178

42-
// Write CSS bundle
4379
await writeFile(join(config.output, 'styles.css'), css, 'utf-8');
4480
}
4581

0 commit comments

Comments
 (0)