clean-jsdoc-theme 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/publish.d.mts +86 -11
- package/dist/publish.d.ts +86 -11
- package/dist/publish.js +200 -52
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +199 -54
- package/dist/publish.mjs.map +1 -1
- package/package.json +22 -9
- package/publish.js +9 -0
package/dist/publish.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
2
|
+
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
+
import { get } from "node:https";
|
|
7
8
|
//#region \0rolldown/runtime.js
|
|
8
9
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
9
10
|
//#endregion
|
|
@@ -21,6 +22,43 @@ async function writeOutputFiles(destination, files) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
25
|
+
//#region src/https-fetch.ts
|
|
26
|
+
/**
|
|
27
|
+
* A `node:https` implementation of utils' `FetchLike`, injected into
|
|
28
|
+
* `createGoogleFontResolver` instead of the global (undici) `fetch`.
|
|
29
|
+
*
|
|
30
|
+
* Why: on Windows, `process.exit` shortly after an undici `fetch()` aborts Node
|
|
31
|
+
* with a libuv assertion (`!(handle->flags & UV_HANDLE_CLOSING)`, exit 127).
|
|
32
|
+
* A strict build that fails validation right after the Google Fonts check
|
|
33
|
+
* exits exactly then, so the failure surfaced as a native crash instead of
|
|
34
|
+
* exit 1. A plain `node:https` request has no such handle and exits cleanly.
|
|
35
|
+
*
|
|
36
|
+
* Only the status code is read; the response body is discarded and the
|
|
37
|
+
* socket destroyed (`res.destroy()`), so nothing lingers after the check.
|
|
38
|
+
* Abort (the resolver's timeout) and network errors reject, which the
|
|
39
|
+
* resolver maps to `'unknown'` (fail-open, an info note) exactly as before.
|
|
40
|
+
* Redirects are not followed: a 3xx resolves the check to `'unknown'`.
|
|
41
|
+
*
|
|
42
|
+
* The request goes through Node's default agent (`https.globalAgent`), so it
|
|
43
|
+
* honours the env proxy (`NODE_USE_ENV_PROXY=1` / `--use-env-proxy` with
|
|
44
|
+
* `HTTPS_PROXY`/`NO_PROXY`, Node >= 24) just like the global `fetch`. Don't
|
|
45
|
+
* pass `agent: false`: that builds a fresh Agent without the proxy settings.
|
|
46
|
+
*
|
|
47
|
+
* utils stays browser-safe because the `node:` import lives here, in the
|
|
48
|
+
* Node-only bridge. The TypeDoc bridge carries a copy
|
|
49
|
+
* (`packages/typedoc/src/https-fetch.ts`); keep the two in sync.
|
|
50
|
+
*/
|
|
51
|
+
const httpsFetch = (url, init) => new Promise((resolve, reject) => {
|
|
52
|
+
get(url, {
|
|
53
|
+
...init?.headers ? { headers: init.headers } : {},
|
|
54
|
+
...init?.signal ? { signal: init.signal } : {}
|
|
55
|
+
}, (res) => {
|
|
56
|
+
const status = res.statusCode ?? 0;
|
|
57
|
+
res.destroy();
|
|
58
|
+
resolve({ status });
|
|
59
|
+
}).on("error", reject);
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
24
62
|
//#region src/publish.ts
|
|
25
63
|
const JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
26
64
|
function anchorPath() {
|
|
@@ -78,12 +116,12 @@ async function loadDep(name, requiredExports) {
|
|
|
78
116
|
return mod;
|
|
79
117
|
}
|
|
80
118
|
const loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite", "stampSite"]);
|
|
81
|
-
const loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render"
|
|
119
|
+
const loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render"]);
|
|
82
120
|
const loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
83
121
|
"validateThemeOpts",
|
|
84
122
|
"createGoogleFontResolver",
|
|
85
123
|
"formatDiagnostics",
|
|
86
|
-
"
|
|
124
|
+
"DiagnosticBag",
|
|
87
125
|
"formatBuildReport",
|
|
88
126
|
"formatRenderError",
|
|
89
127
|
"normalizeBasePath",
|
|
@@ -217,6 +255,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
217
255
|
}
|
|
218
256
|
};
|
|
219
257
|
}
|
|
258
|
+
const consoleWarn = (message) => console.warn(message);
|
|
220
259
|
/** Trim a value to a non-empty string, or `undefined`. */
|
|
221
260
|
function nonEmptyString(value) {
|
|
222
261
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
@@ -237,19 +276,37 @@ function contentHash(bytes) {
|
|
|
237
276
|
* else the bare `<base><ext>`. A file that can't be read is skipped with a
|
|
238
277
|
* warning (resilient, like `prepareSiteName`); an identical served name is
|
|
239
278
|
* emitted once.
|
|
279
|
+
*
|
|
280
|
+
* Only local file paths are copied. An entry that isn't a string (v4's
|
|
281
|
+
* `add_style_path`/`add_script_path` took `{ href, integrity, crossorigin }`
|
|
282
|
+
* CDN objects) or is a remote URL is skipped with a warning naming the
|
|
283
|
+
* alternative (`remoteAlternative`), instead of vanishing silently.
|
|
240
284
|
*/
|
|
241
|
-
async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
242
|
-
const
|
|
285
|
+
async function copyCustomFiles(raw, ext, hash, label, remoteAlternative, hrefForServed, warn = consoleWarn) {
|
|
286
|
+
const entries = raw === void 0 || raw === null ? [] : Array.isArray(raw) ? raw : [raw];
|
|
287
|
+
const paths = [];
|
|
288
|
+
for (const entry of entries) {
|
|
289
|
+
if (typeof entry !== "string") {
|
|
290
|
+
warn(`clean-jsdoc-theme: ${label} takes local file paths; skipping ${JSON.stringify(entry)}. For a remote file, download it or ${remoteAlternative}.`);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const trimmed = entry.trim();
|
|
294
|
+
if (trimmed.length === 0) continue;
|
|
295
|
+
if (/^([a-z][a-z0-9+.-]*:)?\/\//i.test(trimmed)) {
|
|
296
|
+
warn(`clean-jsdoc-theme: ${label} only copies local files; skipping '${trimmed}'. Download it, or ${remoteAlternative}.`);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
paths.push(trimmed);
|
|
300
|
+
}
|
|
243
301
|
const links = [];
|
|
244
302
|
const files = [];
|
|
245
303
|
const seen = /* @__PURE__ */ new Set();
|
|
246
|
-
for (const
|
|
247
|
-
const trimmed = p.trim();
|
|
304
|
+
for (const trimmed of paths) {
|
|
248
305
|
let bytes;
|
|
249
306
|
try {
|
|
250
307
|
bytes = await readFile(resolve(trimmed));
|
|
251
308
|
} catch {
|
|
252
|
-
|
|
309
|
+
warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
|
|
253
310
|
continue;
|
|
254
311
|
}
|
|
255
312
|
const base = basename(trimmed, extname(trimmed)) || "custom";
|
|
@@ -275,9 +332,9 @@ async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
|
275
332
|
* `render()` stays pure and just links the resulting hrefs. `hashCustomAssets`
|
|
276
333
|
* (default `true`) toggles the content-hash suffix.
|
|
277
334
|
*/
|
|
278
|
-
async function resolveCustomAssets(opts, hrefForServed) {
|
|
335
|
+
async function resolveCustomAssets(opts, hrefForServed, warn = consoleWarn) {
|
|
279
336
|
const hash = opts.hashCustomAssets !== false;
|
|
280
|
-
const [cssAssets, jsAssets] = await Promise.all([copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed), copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)]);
|
|
337
|
+
const [cssAssets, jsAssets] = await Promise.all([copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", "`@import url(…)` it from `customCss`", hrefForServed, warn), copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", "load it from `customJs` (e.g. append a `<script src>`)", hrefForServed, warn)]);
|
|
281
338
|
const customCss = nonEmptyString(opts.customCss)?.trim();
|
|
282
339
|
const customJs = nonEmptyString(opts.customJs)?.trim();
|
|
283
340
|
return {
|
|
@@ -298,7 +355,7 @@ async function resolveCustomAssets(opts, hrefForServed) {
|
|
|
298
355
|
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
299
356
|
* the default footer renders. Exported for testing.
|
|
300
357
|
*/
|
|
301
|
-
async function resolveFooter(raw) {
|
|
358
|
+
async function resolveFooter(raw, warn = consoleWarn) {
|
|
302
359
|
if (typeof raw === "string") {
|
|
303
360
|
const trimmed = raw.trim();
|
|
304
361
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
@@ -310,7 +367,7 @@ async function resolveFooter(raw) {
|
|
|
310
367
|
const html = await readFile(resolve(file), "utf8");
|
|
311
368
|
return html.trim().length > 0 ? html : void 0;
|
|
312
369
|
} catch {
|
|
313
|
-
|
|
370
|
+
warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
|
|
314
371
|
return;
|
|
315
372
|
}
|
|
316
373
|
}
|
|
@@ -323,14 +380,14 @@ async function resolveFooter(raw) {
|
|
|
323
380
|
* `<link>` `type`. A missing/unreadable file is warned about and dropped
|
|
324
381
|
* (resilient, like the logo/custom-asset paths). Exported for testing.
|
|
325
382
|
*/
|
|
326
|
-
async function resolveFavicon(raw, hash, hrefForServed) {
|
|
383
|
+
async function resolveFavicon(raw, hash, hrefForServed, warn = consoleWarn) {
|
|
327
384
|
if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
328
385
|
const trimmed = raw.trim();
|
|
329
386
|
let bytes;
|
|
330
387
|
try {
|
|
331
388
|
bytes = await readFile(resolve(trimmed));
|
|
332
389
|
} catch {
|
|
333
|
-
|
|
390
|
+
warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
|
|
334
391
|
return;
|
|
335
392
|
}
|
|
336
393
|
const ext = extname(trimmed) || ".ico";
|
|
@@ -360,7 +417,7 @@ const META_IDENTITY_ATTRS = [
|
|
|
360
417
|
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
361
418
|
* dropped with a warning — dwar does the final escaping + key validation.
|
|
362
419
|
*/
|
|
363
|
-
function normalizeMeta(raw) {
|
|
420
|
+
function normalizeMeta(raw, warn = consoleWarn) {
|
|
364
421
|
if (!Array.isArray(raw)) return void 0;
|
|
365
422
|
const out = [];
|
|
366
423
|
for (const entry of raw) {
|
|
@@ -372,7 +429,7 @@ function normalizeMeta(raw) {
|
|
|
372
429
|
if (t.length > 0) tag[k] = t;
|
|
373
430
|
} else if (typeof v === "number" && Number.isFinite(v)) tag[k] = String(v);
|
|
374
431
|
if (!META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string") || Object.keys(tag).length === 0) {
|
|
375
|
-
|
|
432
|
+
warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
|
|
376
433
|
continue;
|
|
377
434
|
}
|
|
378
435
|
out.push(tag);
|
|
@@ -392,7 +449,7 @@ function isServableUrl(value) {
|
|
|
392
449
|
* through untouched, and the `alt` label is preserved. A path that can't be
|
|
393
450
|
* read is left verbatim with a warning rather than aborting the build.
|
|
394
451
|
*/
|
|
395
|
-
async function prepareSiteName(raw, hrefForServed) {
|
|
452
|
+
async function prepareSiteName(raw, hrefForServed, warn = consoleWarn) {
|
|
396
453
|
if (typeof raw === "string") {
|
|
397
454
|
const trimmed = raw.trim();
|
|
398
455
|
return {
|
|
@@ -429,7 +486,7 @@ async function prepareSiteName(raw, hrefForServed) {
|
|
|
429
486
|
});
|
|
430
487
|
out[key] = hrefForServed(served);
|
|
431
488
|
} catch {
|
|
432
|
-
|
|
489
|
+
warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
|
|
433
490
|
out[key] = v;
|
|
434
491
|
}
|
|
435
492
|
}
|
|
@@ -514,6 +571,25 @@ function sourceLinkToCommentEnabled(opts) {
|
|
|
514
571
|
return false;
|
|
515
572
|
}
|
|
516
573
|
/**
|
|
574
|
+
* Whether private doclets should be documented — the private-access slice of
|
|
575
|
+
* JSDoc's `templateHelper.prune`, with its exact tests: `env.opts.private` is
|
|
576
|
+
* truthy (`--private`), or `env.opts.access` `.includes('private')` or
|
|
577
|
+
* `.includes('all')`. Like prune, `includes` runs on whatever `access` is: an
|
|
578
|
+
* array from the CLI (the flag is repeatable) or a string from `jsdoc.json`, so
|
|
579
|
+
* `"private,protected"` and `"all"` count via substring match, exactly as in
|
|
580
|
+
* JSDoc. Default: hidden.
|
|
581
|
+
*
|
|
582
|
+
* Only this slice is implemented. prune's other `--access` levels (`public`,
|
|
583
|
+
* `protected`, `package`, `undefined` — e.g. `--access public` hiding
|
|
584
|
+
* protected symbols) are NOT applied: those symbols stay documented.
|
|
585
|
+
*/
|
|
586
|
+
function includePrivateEnabled(opts) {
|
|
587
|
+
if (opts?.private) return true;
|
|
588
|
+
const access = opts?.access;
|
|
589
|
+
if (typeof access !== "string" && !Array.isArray(access)) return false;
|
|
590
|
+
return access.includes("private") || access.includes("all");
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
517
593
|
* Resolve `templates.default.cleanOutputDir`. Probed in the same priority order
|
|
518
594
|
* as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a nested
|
|
519
595
|
* `opts.templates` fallback). Defaults to `true` — the build empties its
|
|
@@ -856,10 +932,12 @@ async function collectDocs(dir) {
|
|
|
856
932
|
const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
|
|
857
933
|
try {
|
|
858
934
|
const content = await readFile(abs, "utf8");
|
|
935
|
+
const source = relative(process.cwd(), abs).split(sep).join("/");
|
|
859
936
|
docs.push({
|
|
860
937
|
path: relPath,
|
|
861
938
|
content,
|
|
862
|
-
type
|
|
939
|
+
type,
|
|
940
|
+
source
|
|
863
941
|
});
|
|
864
942
|
} catch (err) {
|
|
865
943
|
console.warn(`clean-jsdoc-theme: could not read doc file '${abs}' — ${err.message}; skipping.`);
|
|
@@ -988,11 +1066,11 @@ async function rewriteImageRefs(content, baseDir, collector) {
|
|
|
988
1066
|
* content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
|
|
989
1067
|
* `` / `<img src>` whose `src` points to a file on disk is copied and
|
|
990
1068
|
* its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
991
|
-
* `MdxImg` adds the base path, like it does for links
|
|
992
|
-
* project root when it starts with
|
|
993
|
-
*
|
|
994
|
-
* bridge is the I/O layer here, so
|
|
995
|
-
* paths.
|
|
1069
|
+
* `MdxImg` adds the base path, like it does for links, and dwar adds it to the
|
|
1070
|
+
* `.md`/llms outputs), resolved relative to the project root when it starts with
|
|
1071
|
+
* `/`, else relative to the doc's own directory. Returns the docs with rewritten
|
|
1072
|
+
* content plus the asset files to write. The bridge is the I/O layer here, so
|
|
1073
|
+
* setu/dwar only ever see the final `_assets/` paths.
|
|
996
1074
|
*/
|
|
997
1075
|
async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
|
|
998
1076
|
if (docs.length === 0) return {
|
|
@@ -1312,8 +1390,8 @@ function formatElapsed(ms) {
|
|
|
1312
1390
|
}
|
|
1313
1391
|
/**
|
|
1314
1392
|
* Build-stage narrator backed by `ora`. The setu→dwar pipeline does much more
|
|
1315
|
-
* than a bare jsdoc run (per-page MDX compile, per-island esbuild bundling,
|
|
1316
|
-
*
|
|
1393
|
+
* than a bare jsdoc run (per-page MDX compile, per-island esbuild bundling), so
|
|
1394
|
+
* a 7–8s build can otherwise look hung. `stage(label, fn)`
|
|
1317
1395
|
* starts an ora spinner, runs `fn`, then resolves it to `✔ <label> (<elapsed>)`
|
|
1318
1396
|
* on success or `✖ <label>` on failure. ora handles the spinner animation, TTY
|
|
1319
1397
|
* detection (no animation when piped/CI), and the success/fail symbols.
|
|
@@ -1323,7 +1401,7 @@ function formatElapsed(ms) {
|
|
|
1323
1401
|
* per-page MDX compile/SSR) that blocks the event loop — so the interval can't
|
|
1324
1402
|
* fire and the spinner freezes on one frame, looking hung. Two things keep it
|
|
1325
1403
|
* visibly alive: an elapsed-seconds **heartbeat** appended to the label (so it
|
|
1326
|
-
* advances whenever the loop breathes — module-graph I/O gaps, esbuild
|
|
1404
|
+
* advances whenever the loop breathes — module-graph I/O gaps, esbuild
|
|
1327
1405
|
* subprocess waits), and the `setText` handle, which long stages use to report
|
|
1328
1406
|
* their current sub-step (e.g. the renderer load steps setu → dwar → utils).
|
|
1329
1407
|
*
|
|
@@ -1384,7 +1462,58 @@ function readBuildSpec() {
|
|
|
1384
1462
|
...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
|
|
1385
1463
|
};
|
|
1386
1464
|
}
|
|
1465
|
+
/**
|
|
1466
|
+
* The template entry JSDoc calls. Wraps {@link runPublish} so a failed build
|
|
1467
|
+
* fails the process: JSDoc 4 runs `publish()` inside a promise chain with no
|
|
1468
|
+
* rejection handler, so a thrown error was printed as `Unhandled rejection
|
|
1469
|
+
* <stack>` and JSDoc still exited 0 — invisible to CI, and to aadesh, which
|
|
1470
|
+
* checks each locale build's exit code. Every failure (strict-mode option
|
|
1471
|
+
* errors, a missing `plugins/markdown`, a bad build spec, a render setup
|
|
1472
|
+
* error) goes through {@link reportBuildFailure} instead.
|
|
1473
|
+
*/
|
|
1387
1474
|
async function publish(data, opts, tutorials) {
|
|
1475
|
+
const report = { optionProblems: () => {} };
|
|
1476
|
+
try {
|
|
1477
|
+
await runPublish(data, opts, tutorials, report);
|
|
1478
|
+
} catch (err) {
|
|
1479
|
+
report.optionProblems();
|
|
1480
|
+
reportBuildFailure(err, opts.debug === true || opts.verbose === true);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
/** JSDoc's logger — resolvable only inside a JSDoc process (see `jsdoc/env` above). */
|
|
1484
|
+
function loadJSDocLogger() {
|
|
1485
|
+
return __require("jsdoc/util/logger");
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Report a failed build once and make the process exit non-zero. Inside JSDoc,
|
|
1489
|
+
* log through JSDoc's own logger: `logger.error` prints the message once and,
|
|
1490
|
+
* through JSDoc's `logger:error` listener, marks the run as failed. Normally
|
|
1491
|
+
* that sets a flag JSDoc turns into exit code 1 once `publish` settles; under
|
|
1492
|
+
* `--pedantic` the listener calls `cli.exit(1)`, which registers a process
|
|
1493
|
+
* `exit` handler that exits with 1 — it doesn't stop the process on the spot,
|
|
1494
|
+
* so the remaining work still finishes. `process.exitCode` is set too, as a
|
|
1495
|
+
* backstop.
|
|
1496
|
+
* Outside a JSDoc process (`jsdoc/util/logger` isn't resolvable — a direct
|
|
1497
|
+
* programmatic call, unit tests) rethrow, so the caller still gets the
|
|
1498
|
+
* rejection, and leave `process.exitCode` alone: the caller decides whether
|
|
1499
|
+
* the failure fails its process. `withStack` (JSDoc's `--debug`/`--verbose`)
|
|
1500
|
+
* adds the stack trace for bug reports. Exported for testing (`loadLogger` is
|
|
1501
|
+
* injectable).
|
|
1502
|
+
*/
|
|
1503
|
+
function reportBuildFailure(err, withStack, loadLogger = loadJSDocLogger) {
|
|
1504
|
+
let logger;
|
|
1505
|
+
try {
|
|
1506
|
+
logger = loadLogger();
|
|
1507
|
+
} catch {
|
|
1508
|
+
logger = void 0;
|
|
1509
|
+
}
|
|
1510
|
+
if (!logger || typeof logger.error !== "function") throw err;
|
|
1511
|
+
process.exitCode = 1;
|
|
1512
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1513
|
+
const stack = withStack && err instanceof Error && err.stack ? `\n${err.stack}` : "";
|
|
1514
|
+
logger.error(`${message}${stack}`);
|
|
1515
|
+
}
|
|
1516
|
+
async function runPublish(data, opts, tutorials, report) {
|
|
1388
1517
|
const buildSpec = readBuildSpec();
|
|
1389
1518
|
const destination = buildSpec?.destination ?? opts.destination;
|
|
1390
1519
|
if (!destination || typeof destination !== "string") throw new Error("clean-jsdoc-theme publish: opts.destination is required (set \"opts.destination\" in your jsdoc.json).");
|
|
@@ -1397,7 +1526,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1397
1526
|
const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
|
|
1398
1527
|
const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
|
|
1399
1528
|
const progress = createBuildProgress(opts.progress === false ? null : await loadOra());
|
|
1400
|
-
const [{ generateSite, stampSite }, { render
|
|
1529
|
+
const [{ generateSite, stampSite }, { render }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics, DiagnosticBag, formatBuildReport, formatRenderError, normalizeBasePath, withBase, toExtractManifest, normalizeCollapsibleSidebarSections, unmatchedCollapsibleSections, topLevelSectionLabels, normalizeScrollbar }] = await progress.stage("Loading renderer", async ({ setText }) => {
|
|
1401
1530
|
setText("Loading renderer (setu)");
|
|
1402
1531
|
const setu = await loadSetu();
|
|
1403
1532
|
setText("Loading renderer (dwar)");
|
|
@@ -1411,22 +1540,44 @@ async function publish(data, opts, tutorials) {
|
|
|
1411
1540
|
});
|
|
1412
1541
|
const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
|
|
1413
1542
|
const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
|
|
1414
|
-
const
|
|
1543
|
+
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
1544
|
+
const strictOptionErrors = [];
|
|
1545
|
+
const warnOption = (message) => {
|
|
1546
|
+
if (!strict) return console.warn(message);
|
|
1547
|
+
strictOptionErrors.push(message);
|
|
1548
|
+
console.error(message);
|
|
1549
|
+
};
|
|
1550
|
+
const failOnStrictOptionErrors = () => {
|
|
1551
|
+
if (strictOptionErrors.length === 0) return;
|
|
1552
|
+
throw new Error(`clean-jsdoc-theme: ${strictOptionErrors.length} option problem(s) in strict mode (see above). Fix them or unset \`strict\`.`);
|
|
1553
|
+
};
|
|
1554
|
+
const fontResolver = createGoogleFontResolver({ fetch: httpsFetch });
|
|
1415
1555
|
const { value, diagnostics } = await progress.stage("Validating options", () => validateThemeOpts({
|
|
1416
1556
|
opts,
|
|
1417
1557
|
fontResolver,
|
|
1418
1558
|
unknownKeyPolicy: "suggest-typos",
|
|
1419
|
-
knownNonThemeKeys: JSDOC_OWN_OPTS
|
|
1559
|
+
knownNonThemeKeys: JSDOC_OWN_OPTS,
|
|
1560
|
+
checkV4Options: true,
|
|
1561
|
+
strict
|
|
1420
1562
|
}));
|
|
1421
|
-
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
1422
1563
|
if (diagnostics.list.length > 0) {
|
|
1423
1564
|
const formatted = formatDiagnostics(diagnostics, { color });
|
|
1424
1565
|
if (strict && diagnostics.hasErrors()) {
|
|
1425
1566
|
console.error(formatted);
|
|
1426
1567
|
throw new Error("clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`.");
|
|
1427
1568
|
}
|
|
1428
|
-
|
|
1569
|
+
const notes = new DiagnosticBag();
|
|
1570
|
+
for (const d of diagnostics.list) if (d.level === "info") notes.add(d);
|
|
1571
|
+
if (notes.list.length > 0) console.log(formatDiagnostics(notes, { color }));
|
|
1429
1572
|
}
|
|
1573
|
+
let reported = false;
|
|
1574
|
+
report.optionProblems = () => {
|
|
1575
|
+
if (reported) return;
|
|
1576
|
+
reported = true;
|
|
1577
|
+
const problems = new DiagnosticBag();
|
|
1578
|
+
for (const d of diagnostics.list) if (d.level !== "info") problems.add(d);
|
|
1579
|
+
if (problems.list.length > 0) console.warn(formatDiagnostics(problems, { color }));
|
|
1580
|
+
};
|
|
1430
1581
|
const pkg = await pkgPromise;
|
|
1431
1582
|
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
1432
1583
|
const tutorialTree = normalizeTutorials(tutorials);
|
|
@@ -1471,9 +1622,9 @@ async function publish(data, opts, tutorials) {
|
|
|
1471
1622
|
const menu = normalizeMenu(opts.menu);
|
|
1472
1623
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
1473
1624
|
const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
|
|
1474
|
-
collapsibleWarnings.forEach((w) =>
|
|
1625
|
+
collapsibleWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
|
|
1475
1626
|
const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
|
|
1476
|
-
scrollbarWarnings.forEach((w) =>
|
|
1627
|
+
scrollbarWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
|
|
1477
1628
|
const playground = normalizePlayground(opts.playground);
|
|
1478
1629
|
const siteOptions = {
|
|
1479
1630
|
...pkg ? { pkg } : {},
|
|
@@ -1488,14 +1639,16 @@ async function publish(data, opts, tutorials) {
|
|
|
1488
1639
|
...menu ? { menu } : {},
|
|
1489
1640
|
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
1490
1641
|
...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
|
|
1491
|
-
...playground ? { playground: playground.site } : {}
|
|
1642
|
+
...playground ? { playground: playground.site } : {},
|
|
1643
|
+
...includePrivateEnabled(opts) ? { includePrivate: true } : {}
|
|
1492
1644
|
};
|
|
1493
1645
|
const manifest = await progress.stage("Generating pages", () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions));
|
|
1494
1646
|
if (Array.isArray(collapsibleSidebarSections)) {
|
|
1495
1647
|
const present = topLevelSectionLabels(manifest.nav);
|
|
1496
1648
|
const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
|
|
1497
|
-
if (unmatched.length > 0)
|
|
1649
|
+
if (unmatched.length > 0) warnOption(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
|
|
1498
1650
|
}
|
|
1651
|
+
failOnStrictOptionErrors();
|
|
1499
1652
|
const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
|
|
1500
1653
|
if (extractPath) {
|
|
1501
1654
|
const target = resolve(extractPath);
|
|
@@ -1504,9 +1657,10 @@ async function publish(data, opts, tutorials) {
|
|
|
1504
1657
|
await writeFile(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
|
|
1505
1658
|
});
|
|
1506
1659
|
console.log(`clean-jsdoc-theme: extract mode — wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`);
|
|
1660
|
+
report.optionProblems();
|
|
1507
1661
|
return;
|
|
1508
1662
|
}
|
|
1509
|
-
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
|
|
1663
|
+
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed, warnOption);
|
|
1510
1664
|
const notGoogle = new Set(diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path));
|
|
1511
1665
|
const fonts = { ...value.fonts };
|
|
1512
1666
|
if (notGoogle.has("fonts.heading")) delete fonts.heading;
|
|
@@ -1521,10 +1675,11 @@ async function publish(data, opts, tutorials) {
|
|
|
1521
1675
|
}
|
|
1522
1676
|
fonts.locales = cleaned;
|
|
1523
1677
|
}
|
|
1524
|
-
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
1525
|
-
const footer = await resolveFooter(opts.footer);
|
|
1526
|
-
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
1527
|
-
const meta = normalizeMeta(opts.meta);
|
|
1678
|
+
const customAssets = await resolveCustomAssets(opts, hrefForServed, warnOption);
|
|
1679
|
+
const footer = await resolveFooter(opts.footer, warnOption);
|
|
1680
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed, warnOption);
|
|
1681
|
+
const meta = normalizeMeta(opts.meta, warnOption);
|
|
1682
|
+
failOnStrictOptionErrors();
|
|
1528
1683
|
const absoluteDestination = resolve(destination);
|
|
1529
1684
|
const islandCacheDir = resolve(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
1530
1685
|
const result = await progress.stage("Rendering site", () => render(manifest, {
|
|
@@ -1562,11 +1717,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1562
1717
|
const staticOutputFiles = [];
|
|
1563
1718
|
if (staticFiles) {
|
|
1564
1719
|
const generatedPaths = new Set(generatedFiles.map((f) => f.path));
|
|
1565
|
-
const RESERVED_PREFIXES = [
|
|
1566
|
-
"_assets/",
|
|
1567
|
-
"_islands/",
|
|
1568
|
-
"pagefind/"
|
|
1569
|
-
];
|
|
1720
|
+
const RESERVED_PREFIXES = ["_assets/", "_islands/"];
|
|
1570
1721
|
let skippedConsumed = 0;
|
|
1571
1722
|
for (const f of staticFiles.files) {
|
|
1572
1723
|
if (images.consumed.has(f.absSource)) {
|
|
@@ -1599,8 +1750,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1599
1750
|
gzipSizer,
|
|
1600
1751
|
color
|
|
1601
1752
|
}));
|
|
1602
|
-
|
|
1603
|
-
if (optsWarnings.list.length > 0) console.warn(formatDiagnostics(optsWarnings, { color }));
|
|
1753
|
+
report.optionProblems();
|
|
1604
1754
|
if (result.errors && result.errors.length > 0) {
|
|
1605
1755
|
console.warn(`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`);
|
|
1606
1756
|
for (const e of result.errors) console.warn(formatRenderError(e));
|
|
@@ -1609,13 +1759,8 @@ async function publish(data, opts, tutorials) {
|
|
|
1609
1759
|
console.warn(`clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`);
|
|
1610
1760
|
for (const w of result.warnings) console.warn(formatRenderError(w));
|
|
1611
1761
|
}
|
|
1612
|
-
try {
|
|
1613
|
-
await progress.stage("Indexing search (pagefind)", () => runPagefindAgainstDir(absoluteDestination));
|
|
1614
|
-
} catch (err) {
|
|
1615
|
-
console.warn(`clean-jsdoc-theme: pagefind step skipped (optional) — ${err.message}`);
|
|
1616
|
-
}
|
|
1617
1762
|
}
|
|
1618
1763
|
//#endregion
|
|
1619
|
-
export { cleanOutputDirEnabled, collectDocs, collectStaticFiles, computeRelPaths, createImageCollector, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, normalizeStaticFilesConfig, outputSourceFilesEnabled, overlayDocs, publish, readStaticFilesConfig, resolveDocImages, resolveDocletImages, resolveFavicon, resolveFooter, resolveTutorialImages, sourceLinkToCommentEnabled, staticFileIncluded, staticFileOutputName };
|
|
1764
|
+
export { cleanOutputDirEnabled, collectDocs, collectStaticFiles, computeRelPaths, createImageCollector, hasMarkdownPlugin, includePrivateEnabled, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, normalizeStaticFilesConfig, outputSourceFilesEnabled, overlayDocs, publish, readStaticFilesConfig, reportBuildFailure, resolveCustomAssets, resolveDocImages, resolveDocletImages, resolveFavicon, resolveFooter, resolveTutorialImages, sourceLinkToCommentEnabled, staticFileIncluded, staticFileOutputName };
|
|
1620
1765
|
|
|
1621
1766
|
//# sourceMappingURL=publish.mjs.map
|