clean-jsdoc-theme 5.2.1 → 5.4.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/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() {
@@ -83,15 +121,17 @@ const loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
83
121
  "validateThemeOpts",
84
122
  "createGoogleFontResolver",
85
123
  "formatDiagnostics",
86
- "warningsOnly",
124
+ "DiagnosticBag",
87
125
  "formatBuildReport",
88
126
  "formatRenderError",
127
+ "renderFailureMessage",
89
128
  "normalizeBasePath",
90
129
  "withBase",
91
130
  "toExtractManifest",
92
131
  "normalizeCollapsibleSidebarSections",
93
132
  "unmatchedCollapsibleSections",
94
133
  "topLevelSectionLabels",
134
+ "unknownSectionOrderLabels",
95
135
  "normalizeScrollbar"
96
136
  ]);
97
137
  /**
@@ -217,6 +257,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
217
257
  }
218
258
  };
219
259
  }
260
+ const consoleWarn = (message) => console.warn(message);
220
261
  /** Trim a value to a non-empty string, or `undefined`. */
221
262
  function nonEmptyString(value) {
222
263
  return typeof value === "string" && value.trim().length > 0 ? value : void 0;
@@ -237,19 +278,37 @@ function contentHash(bytes) {
237
278
  * else the bare `<base><ext>`. A file that can't be read is skipped with a
238
279
  * warning (resilient, like `prepareSiteName`); an identical served name is
239
280
  * emitted once.
281
+ *
282
+ * Only local file paths are copied. An entry that isn't a string (v4's
283
+ * `add_style_path`/`add_script_path` took `{ href, integrity, crossorigin }`
284
+ * CDN objects) or is a remote URL is skipped with a warning naming the
285
+ * alternative (`remoteAlternative`), instead of vanishing silently.
240
286
  */
241
- async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
242
- const paths = (Array.isArray(raw) ? raw : [raw]).filter((p) => typeof p === "string" && p.trim().length > 0);
287
+ async function copyCustomFiles(raw, ext, hash, label, remoteAlternative, hrefForServed, warn = consoleWarn) {
288
+ const entries = raw === void 0 || raw === null ? [] : Array.isArray(raw) ? raw : [raw];
289
+ const paths = [];
290
+ for (const entry of entries) {
291
+ if (typeof entry !== "string") {
292
+ warn(`clean-jsdoc-theme: ${label} takes local file paths; skipping ${JSON.stringify(entry)}. For a remote file, download it or ${remoteAlternative}.`);
293
+ continue;
294
+ }
295
+ const trimmed = entry.trim();
296
+ if (trimmed.length === 0) continue;
297
+ if (/^([a-z][a-z0-9+.-]*:)?\/\//i.test(trimmed)) {
298
+ warn(`clean-jsdoc-theme: ${label} only copies local files; skipping '${trimmed}'. Download it, or ${remoteAlternative}.`);
299
+ continue;
300
+ }
301
+ paths.push(trimmed);
302
+ }
243
303
  const links = [];
244
304
  const files = [];
245
305
  const seen = /* @__PURE__ */ new Set();
246
- for (const p of paths) {
247
- const trimmed = p.trim();
306
+ for (const trimmed of paths) {
248
307
  let bytes;
249
308
  try {
250
309
  bytes = await readFile(resolve(trimmed));
251
310
  } catch {
252
- console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
311
+ warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
253
312
  continue;
254
313
  }
255
314
  const base = basename(trimmed, extname(trimmed)) || "custom";
@@ -275,9 +334,9 @@ async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
275
334
  * `render()` stays pure and just links the resulting hrefs. `hashCustomAssets`
276
335
  * (default `true`) toggles the content-hash suffix.
277
336
  */
278
- async function resolveCustomAssets(opts, hrefForServed) {
337
+ async function resolveCustomAssets(opts, hrefForServed, warn = consoleWarn) {
279
338
  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)]);
339
+ 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
340
  const customCss = nonEmptyString(opts.customCss)?.trim();
282
341
  const customJs = nonEmptyString(opts.customJs)?.trim();
283
342
  return {
@@ -298,7 +357,7 @@ async function resolveCustomAssets(opts, hrefForServed) {
298
357
  * like the logo/custom-asset paths), and an empty value yields `undefined` so
299
358
  * the default footer renders. Exported for testing.
300
359
  */
301
- async function resolveFooter(raw) {
360
+ async function resolveFooter(raw, warn = consoleWarn) {
302
361
  if (typeof raw === "string") {
303
362
  const trimmed = raw.trim();
304
363
  return trimmed.length > 0 ? trimmed : void 0;
@@ -310,7 +369,7 @@ async function resolveFooter(raw) {
310
369
  const html = await readFile(resolve(file), "utf8");
311
370
  return html.trim().length > 0 ? html : void 0;
312
371
  } catch {
313
- console.warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
372
+ warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
314
373
  return;
315
374
  }
316
375
  }
@@ -323,14 +382,14 @@ async function resolveFooter(raw) {
323
382
  * `<link>` `type`. A missing/unreadable file is warned about and dropped
324
383
  * (resilient, like the logo/custom-asset paths). Exported for testing.
325
384
  */
326
- async function resolveFavicon(raw, hash, hrefForServed) {
385
+ async function resolveFavicon(raw, hash, hrefForServed, warn = consoleWarn) {
327
386
  if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
328
387
  const trimmed = raw.trim();
329
388
  let bytes;
330
389
  try {
331
390
  bytes = await readFile(resolve(trimmed));
332
391
  } catch {
333
- console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
392
+ warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
334
393
  return;
335
394
  }
336
395
  const ext = extname(trimmed) || ".ico";
@@ -360,7 +419,7 @@ const META_IDENTITY_ATTRS = [
360
419
  * identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
361
420
  * dropped with a warning — dwar does the final escaping + key validation.
362
421
  */
363
- function normalizeMeta(raw) {
422
+ function normalizeMeta(raw, warn = consoleWarn) {
364
423
  if (!Array.isArray(raw)) return void 0;
365
424
  const out = [];
366
425
  for (const entry of raw) {
@@ -372,7 +431,7 @@ function normalizeMeta(raw) {
372
431
  if (t.length > 0) tag[k] = t;
373
432
  } else if (typeof v === "number" && Number.isFinite(v)) tag[k] = String(v);
374
433
  if (!META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string") || Object.keys(tag).length === 0) {
375
- console.warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
434
+ warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
376
435
  continue;
377
436
  }
378
437
  out.push(tag);
@@ -392,7 +451,7 @@ function isServableUrl(value) {
392
451
  * through untouched, and the `alt` label is preserved. A path that can't be
393
452
  * read is left verbatim with a warning rather than aborting the build.
394
453
  */
395
- async function prepareSiteName(raw, hrefForServed) {
454
+ async function prepareSiteName(raw, hrefForServed, warn = consoleWarn) {
396
455
  if (typeof raw === "string") {
397
456
  const trimmed = raw.trim();
398
457
  return {
@@ -429,7 +488,7 @@ async function prepareSiteName(raw, hrefForServed) {
429
488
  });
430
489
  out[key] = hrefForServed(served);
431
490
  } catch {
432
- console.warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
491
+ warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
433
492
  out[key] = v;
434
493
  }
435
494
  }
@@ -514,6 +573,25 @@ function sourceLinkToCommentEnabled(opts) {
514
573
  return false;
515
574
  }
516
575
  /**
576
+ * Whether private doclets should be documented — the private-access slice of
577
+ * JSDoc's `templateHelper.prune`, with its exact tests: `env.opts.private` is
578
+ * truthy (`--private`), or `env.opts.access` `.includes('private')` or
579
+ * `.includes('all')`. Like prune, `includes` runs on whatever `access` is: an
580
+ * array from the CLI (the flag is repeatable) or a string from `jsdoc.json`, so
581
+ * `"private,protected"` and `"all"` count via substring match, exactly as in
582
+ * JSDoc. Default: hidden.
583
+ *
584
+ * Only this slice is implemented. prune's other `--access` levels (`public`,
585
+ * `protected`, `package`, `undefined` — e.g. `--access public` hiding
586
+ * protected symbols) are NOT applied: those symbols stay documented.
587
+ */
588
+ function includePrivateEnabled(opts) {
589
+ if (opts?.private) return true;
590
+ const access = opts?.access;
591
+ if (typeof access !== "string" && !Array.isArray(access)) return false;
592
+ return access.includes("private") || access.includes("all");
593
+ }
594
+ /**
517
595
  * Resolve `templates.default.cleanOutputDir`. Probed in the same priority order
518
596
  * as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a nested
519
597
  * `opts.templates` fallback). Defaults to `true` — the build empties its
@@ -856,10 +934,12 @@ async function collectDocs(dir) {
856
934
  const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
857
935
  try {
858
936
  const content = await readFile(abs, "utf8");
937
+ const source = relative(process.cwd(), abs).split(sep).join("/");
859
938
  docs.push({
860
939
  path: relPath,
861
940
  content,
862
- type
941
+ type,
942
+ source
863
943
  });
864
944
  } catch (err) {
865
945
  console.warn(`clean-jsdoc-theme: could not read doc file '${abs}' — ${err.message}; skipping.`);
@@ -988,11 +1068,11 @@ async function rewriteImageRefs(content, baseDir, collector) {
988
1068
  * content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
989
1069
  * `![alt](src)` / `<img src>` whose `src` points to a file on disk is copied and
990
1070
  * its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
991
- * `MdxImg` adds the base path, like it does for links), resolved relative to the
992
- * project root when it starts with `/`, else relative to the doc's own directory.
993
- * Returns the docs with rewritten content plus the asset files to write. The
994
- * bridge is the I/O layer here, so setu/dwar only ever see the final `_assets/`
995
- * paths.
1071
+ * `MdxImg` adds the base path, like it does for links, and dwar adds it to the
1072
+ * `.md`/llms outputs), resolved relative to the project root when it starts with
1073
+ * `/`, else relative to the doc's own directory. Returns the docs with rewritten
1074
+ * content plus the asset files to write. The bridge is the I/O layer here, so
1075
+ * setu/dwar only ever see the final `_assets/` paths.
996
1076
  */
997
1077
  async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
998
1078
  if (docs.length === 0) return {
@@ -1384,7 +1464,58 @@ function readBuildSpec() {
1384
1464
  ...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
1385
1465
  };
1386
1466
  }
1467
+ /**
1468
+ * The template entry JSDoc calls. Wraps {@link runPublish} so a failed build
1469
+ * fails the process: JSDoc 4 runs `publish()` inside a promise chain with no
1470
+ * rejection handler, so a thrown error was printed as `Unhandled rejection
1471
+ * <stack>` and JSDoc still exited 0 — invisible to CI, and to aadesh, which
1472
+ * checks each locale build's exit code. Every failure (strict-mode option
1473
+ * errors, a missing `plugins/markdown`, a bad build spec, a render setup
1474
+ * error) goes through {@link reportBuildFailure} instead.
1475
+ */
1387
1476
  async function publish(data, opts, tutorials) {
1477
+ const report = { optionProblems: () => {} };
1478
+ try {
1479
+ await runPublish(data, opts, tutorials, report);
1480
+ } catch (err) {
1481
+ report.optionProblems();
1482
+ reportBuildFailure(err, opts.debug === true || opts.verbose === true);
1483
+ }
1484
+ }
1485
+ /** JSDoc's logger — resolvable only inside a JSDoc process (see `jsdoc/env` above). */
1486
+ function loadJSDocLogger() {
1487
+ return __require("jsdoc/util/logger");
1488
+ }
1489
+ /**
1490
+ * Report a failed build once and make the process exit non-zero. Inside JSDoc,
1491
+ * log through JSDoc's own logger: `logger.error` prints the message once and,
1492
+ * through JSDoc's `logger:error` listener, marks the run as failed. Normally
1493
+ * that sets a flag JSDoc turns into exit code 1 once `publish` settles; under
1494
+ * `--pedantic` the listener calls `cli.exit(1)`, which registers a process
1495
+ * `exit` handler that exits with 1 — it doesn't stop the process on the spot,
1496
+ * so the remaining work still finishes. `process.exitCode` is set too, as a
1497
+ * backstop.
1498
+ * Outside a JSDoc process (`jsdoc/util/logger` isn't resolvable — a direct
1499
+ * programmatic call, unit tests) rethrow, so the caller still gets the
1500
+ * rejection, and leave `process.exitCode` alone: the caller decides whether
1501
+ * the failure fails its process. `withStack` (JSDoc's `--debug`/`--verbose`)
1502
+ * adds the stack trace for bug reports. Exported for testing (`loadLogger` is
1503
+ * injectable).
1504
+ */
1505
+ function reportBuildFailure(err, withStack, loadLogger = loadJSDocLogger) {
1506
+ let logger;
1507
+ try {
1508
+ logger = loadLogger();
1509
+ } catch {
1510
+ logger = void 0;
1511
+ }
1512
+ if (!logger || typeof logger.error !== "function") throw err;
1513
+ process.exitCode = 1;
1514
+ const message = err instanceof Error ? err.message : String(err);
1515
+ const stack = withStack && err instanceof Error && err.stack ? `\n${err.stack}` : "";
1516
+ logger.error(`${message}${stack}`);
1517
+ }
1518
+ async function runPublish(data, opts, tutorials, report) {
1388
1519
  const buildSpec = readBuildSpec();
1389
1520
  const destination = buildSpec?.destination ?? opts.destination;
1390
1521
  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 +1528,7 @@ async function publish(data, opts, tutorials) {
1397
1528
  const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
1398
1529
  const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
1399
1530
  const progress = createBuildProgress(opts.progress === false ? null : await loadOra());
1400
- const [{ generateSite, stampSite }, { render }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics, warningsOnly, formatBuildReport, formatRenderError, normalizeBasePath, withBase, toExtractManifest, normalizeCollapsibleSidebarSections, unmatchedCollapsibleSections, topLevelSectionLabels, normalizeScrollbar }] = await progress.stage("Loading renderer", async ({ setText }) => {
1531
+ const [{ generateSite, stampSite, DEFAULT_SECTION_ORDER, DOCS_SECTION }, { render }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics, DiagnosticBag, formatBuildReport, formatRenderError, renderFailureMessage, normalizeBasePath, withBase, toExtractManifest, normalizeCollapsibleSidebarSections, unmatchedCollapsibleSections, topLevelSectionLabels, unknownSectionOrderLabels, normalizeScrollbar }] = await progress.stage("Loading renderer", async ({ setText }) => {
1401
1532
  setText("Loading renderer (setu)");
1402
1533
  const setu = await loadSetu();
1403
1534
  setText("Loading renderer (dwar)");
@@ -1411,22 +1542,44 @@ async function publish(data, opts, tutorials) {
1411
1542
  });
1412
1543
  const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
1413
1544
  const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
1414
- const fontResolver = createGoogleFontResolver();
1545
+ const strict = opts.strict === true;
1546
+ const strictOptionErrors = [];
1547
+ const warnOption = (message) => {
1548
+ if (!strict) return console.warn(message);
1549
+ strictOptionErrors.push(message);
1550
+ console.error(message);
1551
+ };
1552
+ const failOnStrictOptionErrors = () => {
1553
+ if (strictOptionErrors.length === 0) return;
1554
+ throw new Error(`clean-jsdoc-theme: ${strictOptionErrors.length} option problem(s) in strict mode (see above). Fix them or unset \`strict\`.`);
1555
+ };
1556
+ const fontResolver = createGoogleFontResolver({ fetch: httpsFetch });
1415
1557
  const { value, diagnostics } = await progress.stage("Validating options", () => validateThemeOpts({
1416
1558
  opts,
1417
1559
  fontResolver,
1418
1560
  unknownKeyPolicy: "suggest-typos",
1419
- knownNonThemeKeys: JSDOC_OWN_OPTS
1561
+ knownNonThemeKeys: JSDOC_OWN_OPTS,
1562
+ checkV4Options: true,
1563
+ strict
1420
1564
  }));
1421
- const strict = opts.strict === true || opts.templates?.default?.strict === true;
1422
1565
  if (diagnostics.list.length > 0) {
1423
1566
  const formatted = formatDiagnostics(diagnostics, { color });
1424
1567
  if (strict && diagnostics.hasErrors()) {
1425
1568
  console.error(formatted);
1426
1569
  throw new Error("clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`.");
1427
1570
  }
1428
- console.log(formatted);
1571
+ const notes = new DiagnosticBag();
1572
+ for (const d of diagnostics.list) if (d.level === "info") notes.add(d);
1573
+ if (notes.list.length > 0) console.log(formatDiagnostics(notes, { color }));
1429
1574
  }
1575
+ let reported = false;
1576
+ report.optionProblems = () => {
1577
+ if (reported) return;
1578
+ reported = true;
1579
+ const problems = new DiagnosticBag();
1580
+ for (const d of diagnostics.list) if (d.level !== "info") problems.add(d);
1581
+ if (problems.list.length > 0) console.warn(formatDiagnostics(problems, { color }));
1582
+ };
1430
1583
  const pkg = await pkgPromise;
1431
1584
  const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
1432
1585
  const tutorialTree = normalizeTutorials(tutorials);
@@ -1471,9 +1624,9 @@ async function publish(data, opts, tutorials) {
1471
1624
  const menu = normalizeMenu(opts.menu);
1472
1625
  const clubSidebarItems = opts.clubSidebarItems === true;
1473
1626
  const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
1474
- collapsibleWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1627
+ collapsibleWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
1475
1628
  const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
1476
- scrollbarWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1629
+ scrollbarWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
1477
1630
  const playground = normalizePlayground(opts.playground);
1478
1631
  const siteOptions = {
1479
1632
  ...pkg ? { pkg } : {},
@@ -1488,14 +1641,25 @@ async function publish(data, opts, tutorials) {
1488
1641
  ...menu ? { menu } : {},
1489
1642
  ...clubSidebarItems ? { clubSidebarItems } : {},
1490
1643
  ...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
1491
- ...playground ? { playground: playground.site } : {}
1644
+ ...playground ? { playground: playground.site } : {},
1645
+ ...includePrivateEnabled(opts) ? { includePrivate: true } : {}
1492
1646
  };
1493
1647
  const manifest = await progress.stage("Generating pages", () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions));
1494
1648
  if (Array.isArray(collapsibleSidebarSections)) {
1495
1649
  const present = topLevelSectionLabels(manifest.nav);
1496
1650
  const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
1497
- if (unmatched.length > 0) console.warn(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
1651
+ if (unmatched.length > 0) warnOption(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
1652
+ }
1653
+ if (sectionOrder) {
1654
+ const known = [.../* @__PURE__ */ new Set([
1655
+ ...topLevelSectionLabels(manifest.nav),
1656
+ ...DEFAULT_SECTION_ORDER,
1657
+ DOCS_SECTION
1658
+ ])];
1659
+ const unknown = unknownSectionOrderLabels(sectionOrder, known, ["Global"]);
1660
+ if (unknown.length > 0) warnOption(`clean-jsdoc-theme: sectionOrder — no sidebar section matches ` + unknown.map((u) => `'${u.label}'` + (u.hint ? ` (${u.hint})` : u.suggestion ? ` (did you mean '${u.suggestion}'?)` : "")).join(", ") + `. Known sections: ${known.join(", ")}.`);
1498
1661
  }
1662
+ failOnStrictOptionErrors();
1499
1663
  const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
1500
1664
  if (extractPath) {
1501
1665
  const target = resolve(extractPath);
@@ -1504,9 +1668,10 @@ async function publish(data, opts, tutorials) {
1504
1668
  await writeFile(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
1505
1669
  });
1506
1670
  console.log(`clean-jsdoc-theme: extract mode — wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`);
1671
+ report.optionProblems();
1507
1672
  return;
1508
1673
  }
1509
- const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
1674
+ const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed, warnOption);
1510
1675
  const notGoogle = new Set(diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path));
1511
1676
  const fonts = { ...value.fonts };
1512
1677
  if (notGoogle.has("fonts.heading")) delete fonts.heading;
@@ -1521,10 +1686,11 @@ async function publish(data, opts, tutorials) {
1521
1686
  }
1522
1687
  fonts.locales = cleaned;
1523
1688
  }
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);
1689
+ const customAssets = await resolveCustomAssets(opts, hrefForServed, warnOption);
1690
+ const footer = await resolveFooter(opts.footer, warnOption);
1691
+ const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed, warnOption);
1692
+ const meta = normalizeMeta(opts.meta, warnOption);
1693
+ failOnStrictOptionErrors();
1528
1694
  const absoluteDestination = resolve(destination);
1529
1695
  const islandCacheDir = resolve(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
1530
1696
  const result = await progress.stage("Rendering site", () => render(manifest, {
@@ -1552,6 +1718,8 @@ async function publish(data, opts, tutorials) {
1552
1718
  }))
1553
1719
  } } : {}
1554
1720
  }));
1721
+ const renderFailure = renderFailureMessage(result);
1722
+ if (renderFailure) throw new Error(`clean-jsdoc-theme: ${renderFailure}`);
1555
1723
  const generatedFiles = [
1556
1724
  ...result.files,
1557
1725
  ...logoFiles,
@@ -1595,8 +1763,7 @@ async function publish(data, opts, tutorials) {
1595
1763
  gzipSizer,
1596
1764
  color
1597
1765
  }));
1598
- const optsWarnings = warningsOnly(diagnostics);
1599
- if (optsWarnings.list.length > 0) console.warn(formatDiagnostics(optsWarnings, { color }));
1766
+ report.optionProblems();
1600
1767
  if (result.errors && result.errors.length > 0) {
1601
1768
  console.warn(`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`);
1602
1769
  for (const e of result.errors) console.warn(formatRenderError(e));
@@ -1607,6 +1774,6 @@ async function publish(data, opts, tutorials) {
1607
1774
  }
1608
1775
  }
1609
1776
  //#endregion
1610
- 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 };
1777
+ 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 };
1611
1778
 
1612
1779
  //# sourceMappingURL=publish.mjs.map