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.d.mts +85 -10
- package/dist/publish.d.ts +85 -10
- package/dist/publish.js +208 -38
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +207 -40
- package/dist/publish.mjs.map +1 -1
- package/package.json +22 -9
- package/publish.js +9 -0
package/dist/publish.js
CHANGED
|
@@ -5,6 +5,7 @@ let node_fs = require("node:fs");
|
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
let node_url = require("node:url");
|
|
8
|
+
let node_https = require("node:https");
|
|
8
9
|
//#region src/write-output-files.ts
|
|
9
10
|
async function writeOutputFiles(destination, files) {
|
|
10
11
|
for (const file of files) {
|
|
@@ -15,6 +16,43 @@ async function writeOutputFiles(destination, files) {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
|
19
|
+
//#region src/https-fetch.ts
|
|
20
|
+
/**
|
|
21
|
+
* A `node:https` implementation of utils' `FetchLike`, injected into
|
|
22
|
+
* `createGoogleFontResolver` instead of the global (undici) `fetch`.
|
|
23
|
+
*
|
|
24
|
+
* Why: on Windows, `process.exit` shortly after an undici `fetch()` aborts Node
|
|
25
|
+
* with a libuv assertion (`!(handle->flags & UV_HANDLE_CLOSING)`, exit 127).
|
|
26
|
+
* A strict build that fails validation right after the Google Fonts check
|
|
27
|
+
* exits exactly then, so the failure surfaced as a native crash instead of
|
|
28
|
+
* exit 1. A plain `node:https` request has no such handle and exits cleanly.
|
|
29
|
+
*
|
|
30
|
+
* Only the status code is read; the response body is discarded and the
|
|
31
|
+
* socket destroyed (`res.destroy()`), so nothing lingers after the check.
|
|
32
|
+
* Abort (the resolver's timeout) and network errors reject, which the
|
|
33
|
+
* resolver maps to `'unknown'` (fail-open, an info note) exactly as before.
|
|
34
|
+
* Redirects are not followed: a 3xx resolves the check to `'unknown'`.
|
|
35
|
+
*
|
|
36
|
+
* The request goes through Node's default agent (`https.globalAgent`), so it
|
|
37
|
+
* honours the env proxy (`NODE_USE_ENV_PROXY=1` / `--use-env-proxy` with
|
|
38
|
+
* `HTTPS_PROXY`/`NO_PROXY`, Node >= 24) just like the global `fetch`. Don't
|
|
39
|
+
* pass `agent: false`: that builds a fresh Agent without the proxy settings.
|
|
40
|
+
*
|
|
41
|
+
* utils stays browser-safe because the `node:` import lives here, in the
|
|
42
|
+
* Node-only bridge. The TypeDoc bridge carries a copy
|
|
43
|
+
* (`packages/typedoc/src/https-fetch.ts`); keep the two in sync.
|
|
44
|
+
*/
|
|
45
|
+
const httpsFetch = (url, init) => new Promise((resolve, reject) => {
|
|
46
|
+
(0, node_https.get)(url, {
|
|
47
|
+
...init?.headers ? { headers: init.headers } : {},
|
|
48
|
+
...init?.signal ? { signal: init.signal } : {}
|
|
49
|
+
}, (res) => {
|
|
50
|
+
const status = res.statusCode ?? 0;
|
|
51
|
+
res.destroy();
|
|
52
|
+
resolve({ status });
|
|
53
|
+
}).on("error", reject);
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
18
56
|
//#region src/publish.ts
|
|
19
57
|
const JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
20
58
|
function anchorPath() {
|
|
@@ -77,15 +115,17 @@ const loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
|
77
115
|
"validateThemeOpts",
|
|
78
116
|
"createGoogleFontResolver",
|
|
79
117
|
"formatDiagnostics",
|
|
80
|
-
"
|
|
118
|
+
"DiagnosticBag",
|
|
81
119
|
"formatBuildReport",
|
|
82
120
|
"formatRenderError",
|
|
121
|
+
"renderFailureMessage",
|
|
83
122
|
"normalizeBasePath",
|
|
84
123
|
"withBase",
|
|
85
124
|
"toExtractManifest",
|
|
86
125
|
"normalizeCollapsibleSidebarSections",
|
|
87
126
|
"unmatchedCollapsibleSections",
|
|
88
127
|
"topLevelSectionLabels",
|
|
128
|
+
"unknownSectionOrderLabels",
|
|
89
129
|
"normalizeScrollbar"
|
|
90
130
|
]);
|
|
91
131
|
/**
|
|
@@ -211,6 +251,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
211
251
|
}
|
|
212
252
|
};
|
|
213
253
|
}
|
|
254
|
+
const consoleWarn = (message) => console.warn(message);
|
|
214
255
|
/** Trim a value to a non-empty string, or `undefined`. */
|
|
215
256
|
function nonEmptyString(value) {
|
|
216
257
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
@@ -231,19 +272,37 @@ function contentHash(bytes) {
|
|
|
231
272
|
* else the bare `<base><ext>`. A file that can't be read is skipped with a
|
|
232
273
|
* warning (resilient, like `prepareSiteName`); an identical served name is
|
|
233
274
|
* emitted once.
|
|
275
|
+
*
|
|
276
|
+
* Only local file paths are copied. An entry that isn't a string (v4's
|
|
277
|
+
* `add_style_path`/`add_script_path` took `{ href, integrity, crossorigin }`
|
|
278
|
+
* CDN objects) or is a remote URL is skipped with a warning naming the
|
|
279
|
+
* alternative (`remoteAlternative`), instead of vanishing silently.
|
|
234
280
|
*/
|
|
235
|
-
async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
236
|
-
const
|
|
281
|
+
async function copyCustomFiles(raw, ext, hash, label, remoteAlternative, hrefForServed, warn = consoleWarn) {
|
|
282
|
+
const entries = raw === void 0 || raw === null ? [] : Array.isArray(raw) ? raw : [raw];
|
|
283
|
+
const paths = [];
|
|
284
|
+
for (const entry of entries) {
|
|
285
|
+
if (typeof entry !== "string") {
|
|
286
|
+
warn(`clean-jsdoc-theme: ${label} takes local file paths; skipping ${JSON.stringify(entry)}. For a remote file, download it or ${remoteAlternative}.`);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const trimmed = entry.trim();
|
|
290
|
+
if (trimmed.length === 0) continue;
|
|
291
|
+
if (/^([a-z][a-z0-9+.-]*:)?\/\//i.test(trimmed)) {
|
|
292
|
+
warn(`clean-jsdoc-theme: ${label} only copies local files; skipping '${trimmed}'. Download it, or ${remoteAlternative}.`);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
paths.push(trimmed);
|
|
296
|
+
}
|
|
237
297
|
const links = [];
|
|
238
298
|
const files = [];
|
|
239
299
|
const seen = /* @__PURE__ */ new Set();
|
|
240
|
-
for (const
|
|
241
|
-
const trimmed = p.trim();
|
|
300
|
+
for (const trimmed of paths) {
|
|
242
301
|
let bytes;
|
|
243
302
|
try {
|
|
244
303
|
bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
|
|
245
304
|
} catch {
|
|
246
|
-
|
|
305
|
+
warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
|
|
247
306
|
continue;
|
|
248
307
|
}
|
|
249
308
|
const base = (0, node_path.basename)(trimmed, (0, node_path.extname)(trimmed)) || "custom";
|
|
@@ -269,9 +328,9 @@ async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
|
269
328
|
* `render()` stays pure and just links the resulting hrefs. `hashCustomAssets`
|
|
270
329
|
* (default `true`) toggles the content-hash suffix.
|
|
271
330
|
*/
|
|
272
|
-
async function resolveCustomAssets(opts, hrefForServed) {
|
|
331
|
+
async function resolveCustomAssets(opts, hrefForServed, warn = consoleWarn) {
|
|
273
332
|
const hash = opts.hashCustomAssets !== false;
|
|
274
|
-
const [cssAssets, jsAssets] = await Promise.all([copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed), copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)]);
|
|
333
|
+
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)]);
|
|
275
334
|
const customCss = nonEmptyString(opts.customCss)?.trim();
|
|
276
335
|
const customJs = nonEmptyString(opts.customJs)?.trim();
|
|
277
336
|
return {
|
|
@@ -292,7 +351,7 @@ async function resolveCustomAssets(opts, hrefForServed) {
|
|
|
292
351
|
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
293
352
|
* the default footer renders. Exported for testing.
|
|
294
353
|
*/
|
|
295
|
-
async function resolveFooter(raw) {
|
|
354
|
+
async function resolveFooter(raw, warn = consoleWarn) {
|
|
296
355
|
if (typeof raw === "string") {
|
|
297
356
|
const trimmed = raw.trim();
|
|
298
357
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
@@ -304,7 +363,7 @@ async function resolveFooter(raw) {
|
|
|
304
363
|
const html = await (0, node_fs_promises.readFile)((0, node_path.resolve)(file), "utf8");
|
|
305
364
|
return html.trim().length > 0 ? html : void 0;
|
|
306
365
|
} catch {
|
|
307
|
-
|
|
366
|
+
warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
|
|
308
367
|
return;
|
|
309
368
|
}
|
|
310
369
|
}
|
|
@@ -317,14 +376,14 @@ async function resolveFooter(raw) {
|
|
|
317
376
|
* `<link>` `type`. A missing/unreadable file is warned about and dropped
|
|
318
377
|
* (resilient, like the logo/custom-asset paths). Exported for testing.
|
|
319
378
|
*/
|
|
320
|
-
async function resolveFavicon(raw, hash, hrefForServed) {
|
|
379
|
+
async function resolveFavicon(raw, hash, hrefForServed, warn = consoleWarn) {
|
|
321
380
|
if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
322
381
|
const trimmed = raw.trim();
|
|
323
382
|
let bytes;
|
|
324
383
|
try {
|
|
325
384
|
bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
|
|
326
385
|
} catch {
|
|
327
|
-
|
|
386
|
+
warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
|
|
328
387
|
return;
|
|
329
388
|
}
|
|
330
389
|
const ext = (0, node_path.extname)(trimmed) || ".ico";
|
|
@@ -354,7 +413,7 @@ const META_IDENTITY_ATTRS = [
|
|
|
354
413
|
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
355
414
|
* dropped with a warning — dwar does the final escaping + key validation.
|
|
356
415
|
*/
|
|
357
|
-
function normalizeMeta(raw) {
|
|
416
|
+
function normalizeMeta(raw, warn = consoleWarn) {
|
|
358
417
|
if (!Array.isArray(raw)) return void 0;
|
|
359
418
|
const out = [];
|
|
360
419
|
for (const entry of raw) {
|
|
@@ -366,7 +425,7 @@ function normalizeMeta(raw) {
|
|
|
366
425
|
if (t.length > 0) tag[k] = t;
|
|
367
426
|
} else if (typeof v === "number" && Number.isFinite(v)) tag[k] = String(v);
|
|
368
427
|
if (!META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string") || Object.keys(tag).length === 0) {
|
|
369
|
-
|
|
428
|
+
warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
|
|
370
429
|
continue;
|
|
371
430
|
}
|
|
372
431
|
out.push(tag);
|
|
@@ -386,7 +445,7 @@ function isServableUrl(value) {
|
|
|
386
445
|
* through untouched, and the `alt` label is preserved. A path that can't be
|
|
387
446
|
* read is left verbatim with a warning rather than aborting the build.
|
|
388
447
|
*/
|
|
389
|
-
async function prepareSiteName(raw, hrefForServed) {
|
|
448
|
+
async function prepareSiteName(raw, hrefForServed, warn = consoleWarn) {
|
|
390
449
|
if (typeof raw === "string") {
|
|
391
450
|
const trimmed = raw.trim();
|
|
392
451
|
return {
|
|
@@ -423,7 +482,7 @@ async function prepareSiteName(raw, hrefForServed) {
|
|
|
423
482
|
});
|
|
424
483
|
out[key] = hrefForServed(served);
|
|
425
484
|
} catch {
|
|
426
|
-
|
|
485
|
+
warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
|
|
427
486
|
out[key] = v;
|
|
428
487
|
}
|
|
429
488
|
}
|
|
@@ -508,6 +567,25 @@ function sourceLinkToCommentEnabled(opts) {
|
|
|
508
567
|
return false;
|
|
509
568
|
}
|
|
510
569
|
/**
|
|
570
|
+
* Whether private doclets should be documented — the private-access slice of
|
|
571
|
+
* JSDoc's `templateHelper.prune`, with its exact tests: `env.opts.private` is
|
|
572
|
+
* truthy (`--private`), or `env.opts.access` `.includes('private')` or
|
|
573
|
+
* `.includes('all')`. Like prune, `includes` runs on whatever `access` is: an
|
|
574
|
+
* array from the CLI (the flag is repeatable) or a string from `jsdoc.json`, so
|
|
575
|
+
* `"private,protected"` and `"all"` count via substring match, exactly as in
|
|
576
|
+
* JSDoc. Default: hidden.
|
|
577
|
+
*
|
|
578
|
+
* Only this slice is implemented. prune's other `--access` levels (`public`,
|
|
579
|
+
* `protected`, `package`, `undefined` — e.g. `--access public` hiding
|
|
580
|
+
* protected symbols) are NOT applied: those symbols stay documented.
|
|
581
|
+
*/
|
|
582
|
+
function includePrivateEnabled(opts) {
|
|
583
|
+
if (opts?.private) return true;
|
|
584
|
+
const access = opts?.access;
|
|
585
|
+
if (typeof access !== "string" && !Array.isArray(access)) return false;
|
|
586
|
+
return access.includes("private") || access.includes("all");
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
511
589
|
* Resolve `templates.default.cleanOutputDir`. Probed in the same priority order
|
|
512
590
|
* as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a nested
|
|
513
591
|
* `opts.templates` fallback). Defaults to `true` — the build empties its
|
|
@@ -850,10 +928,12 @@ async function collectDocs(dir) {
|
|
|
850
928
|
const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
|
|
851
929
|
try {
|
|
852
930
|
const content = await (0, node_fs_promises.readFile)(abs, "utf8");
|
|
931
|
+
const source = (0, node_path.relative)(process.cwd(), abs).split(node_path.sep).join("/");
|
|
853
932
|
docs.push({
|
|
854
933
|
path: relPath,
|
|
855
934
|
content,
|
|
856
|
-
type
|
|
935
|
+
type,
|
|
936
|
+
source
|
|
857
937
|
});
|
|
858
938
|
} catch (err) {
|
|
859
939
|
console.warn(`clean-jsdoc-theme: could not read doc file '${abs}' — ${err.message}; skipping.`);
|
|
@@ -982,11 +1062,11 @@ async function rewriteImageRefs(content, baseDir, collector) {
|
|
|
982
1062
|
* content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
|
|
983
1063
|
* `` / `<img src>` whose `src` points to a file on disk is copied and
|
|
984
1064
|
* its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
985
|
-
* `MdxImg` adds the base path, like it does for links
|
|
986
|
-
* project root when it starts with
|
|
987
|
-
*
|
|
988
|
-
* bridge is the I/O layer here, so
|
|
989
|
-
* paths.
|
|
1065
|
+
* `MdxImg` adds the base path, like it does for links, and dwar adds it to the
|
|
1066
|
+
* `.md`/llms outputs), resolved relative to the project root when it starts with
|
|
1067
|
+
* `/`, else relative to the doc's own directory. Returns the docs with rewritten
|
|
1068
|
+
* content plus the asset files to write. The bridge is the I/O layer here, so
|
|
1069
|
+
* setu/dwar only ever see the final `_assets/` paths.
|
|
990
1070
|
*/
|
|
991
1071
|
async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
|
|
992
1072
|
if (docs.length === 0) return {
|
|
@@ -1378,7 +1458,58 @@ function readBuildSpec() {
|
|
|
1378
1458
|
...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
|
|
1379
1459
|
};
|
|
1380
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* The template entry JSDoc calls. Wraps {@link runPublish} so a failed build
|
|
1463
|
+
* fails the process: JSDoc 4 runs `publish()` inside a promise chain with no
|
|
1464
|
+
* rejection handler, so a thrown error was printed as `Unhandled rejection
|
|
1465
|
+
* <stack>` and JSDoc still exited 0 — invisible to CI, and to aadesh, which
|
|
1466
|
+
* checks each locale build's exit code. Every failure (strict-mode option
|
|
1467
|
+
* errors, a missing `plugins/markdown`, a bad build spec, a render setup
|
|
1468
|
+
* error) goes through {@link reportBuildFailure} instead.
|
|
1469
|
+
*/
|
|
1381
1470
|
async function publish(data, opts, tutorials) {
|
|
1471
|
+
const report = { optionProblems: () => {} };
|
|
1472
|
+
try {
|
|
1473
|
+
await runPublish(data, opts, tutorials, report);
|
|
1474
|
+
} catch (err) {
|
|
1475
|
+
report.optionProblems();
|
|
1476
|
+
reportBuildFailure(err, opts.debug === true || opts.verbose === true);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
/** JSDoc's logger — resolvable only inside a JSDoc process (see `jsdoc/env` above). */
|
|
1480
|
+
function loadJSDocLogger() {
|
|
1481
|
+
return require("jsdoc/util/logger");
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Report a failed build once and make the process exit non-zero. Inside JSDoc,
|
|
1485
|
+
* log through JSDoc's own logger: `logger.error` prints the message once and,
|
|
1486
|
+
* through JSDoc's `logger:error` listener, marks the run as failed. Normally
|
|
1487
|
+
* that sets a flag JSDoc turns into exit code 1 once `publish` settles; under
|
|
1488
|
+
* `--pedantic` the listener calls `cli.exit(1)`, which registers a process
|
|
1489
|
+
* `exit` handler that exits with 1 — it doesn't stop the process on the spot,
|
|
1490
|
+
* so the remaining work still finishes. `process.exitCode` is set too, as a
|
|
1491
|
+
* backstop.
|
|
1492
|
+
* Outside a JSDoc process (`jsdoc/util/logger` isn't resolvable — a direct
|
|
1493
|
+
* programmatic call, unit tests) rethrow, so the caller still gets the
|
|
1494
|
+
* rejection, and leave `process.exitCode` alone: the caller decides whether
|
|
1495
|
+
* the failure fails its process. `withStack` (JSDoc's `--debug`/`--verbose`)
|
|
1496
|
+
* adds the stack trace for bug reports. Exported for testing (`loadLogger` is
|
|
1497
|
+
* injectable).
|
|
1498
|
+
*/
|
|
1499
|
+
function reportBuildFailure(err, withStack, loadLogger = loadJSDocLogger) {
|
|
1500
|
+
let logger;
|
|
1501
|
+
try {
|
|
1502
|
+
logger = loadLogger();
|
|
1503
|
+
} catch {
|
|
1504
|
+
logger = void 0;
|
|
1505
|
+
}
|
|
1506
|
+
if (!logger || typeof logger.error !== "function") throw err;
|
|
1507
|
+
process.exitCode = 1;
|
|
1508
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1509
|
+
const stack = withStack && err instanceof Error && err.stack ? `\n${err.stack}` : "";
|
|
1510
|
+
logger.error(`${message}${stack}`);
|
|
1511
|
+
}
|
|
1512
|
+
async function runPublish(data, opts, tutorials, report) {
|
|
1382
1513
|
const buildSpec = readBuildSpec();
|
|
1383
1514
|
const destination = buildSpec?.destination ?? opts.destination;
|
|
1384
1515
|
if (!destination || typeof destination !== "string") throw new Error("clean-jsdoc-theme publish: opts.destination is required (set \"opts.destination\" in your jsdoc.json).");
|
|
@@ -1391,7 +1522,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1391
1522
|
const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
|
|
1392
1523
|
const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
|
|
1393
1524
|
const progress = createBuildProgress(opts.progress === false ? null : await loadOra());
|
|
1394
|
-
const [{ generateSite, stampSite }, { render }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics,
|
|
1525
|
+
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 }) => {
|
|
1395
1526
|
setText("Loading renderer (setu)");
|
|
1396
1527
|
const setu = await loadSetu();
|
|
1397
1528
|
setText("Loading renderer (dwar)");
|
|
@@ -1405,22 +1536,44 @@ async function publish(data, opts, tutorials) {
|
|
|
1405
1536
|
});
|
|
1406
1537
|
const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
|
|
1407
1538
|
const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
|
|
1408
|
-
const
|
|
1539
|
+
const strict = opts.strict === true;
|
|
1540
|
+
const strictOptionErrors = [];
|
|
1541
|
+
const warnOption = (message) => {
|
|
1542
|
+
if (!strict) return console.warn(message);
|
|
1543
|
+
strictOptionErrors.push(message);
|
|
1544
|
+
console.error(message);
|
|
1545
|
+
};
|
|
1546
|
+
const failOnStrictOptionErrors = () => {
|
|
1547
|
+
if (strictOptionErrors.length === 0) return;
|
|
1548
|
+
throw new Error(`clean-jsdoc-theme: ${strictOptionErrors.length} option problem(s) in strict mode (see above). Fix them or unset \`strict\`.`);
|
|
1549
|
+
};
|
|
1550
|
+
const fontResolver = createGoogleFontResolver({ fetch: httpsFetch });
|
|
1409
1551
|
const { value, diagnostics } = await progress.stage("Validating options", () => validateThemeOpts({
|
|
1410
1552
|
opts,
|
|
1411
1553
|
fontResolver,
|
|
1412
1554
|
unknownKeyPolicy: "suggest-typos",
|
|
1413
|
-
knownNonThemeKeys: JSDOC_OWN_OPTS
|
|
1555
|
+
knownNonThemeKeys: JSDOC_OWN_OPTS,
|
|
1556
|
+
checkV4Options: true,
|
|
1557
|
+
strict
|
|
1414
1558
|
}));
|
|
1415
|
-
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
1416
1559
|
if (diagnostics.list.length > 0) {
|
|
1417
1560
|
const formatted = formatDiagnostics(diagnostics, { color });
|
|
1418
1561
|
if (strict && diagnostics.hasErrors()) {
|
|
1419
1562
|
console.error(formatted);
|
|
1420
1563
|
throw new Error("clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`.");
|
|
1421
1564
|
}
|
|
1422
|
-
|
|
1565
|
+
const notes = new DiagnosticBag();
|
|
1566
|
+
for (const d of diagnostics.list) if (d.level === "info") notes.add(d);
|
|
1567
|
+
if (notes.list.length > 0) console.log(formatDiagnostics(notes, { color }));
|
|
1423
1568
|
}
|
|
1569
|
+
let reported = false;
|
|
1570
|
+
report.optionProblems = () => {
|
|
1571
|
+
if (reported) return;
|
|
1572
|
+
reported = true;
|
|
1573
|
+
const problems = new DiagnosticBag();
|
|
1574
|
+
for (const d of diagnostics.list) if (d.level !== "info") problems.add(d);
|
|
1575
|
+
if (problems.list.length > 0) console.warn(formatDiagnostics(problems, { color }));
|
|
1576
|
+
};
|
|
1424
1577
|
const pkg = await pkgPromise;
|
|
1425
1578
|
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
1426
1579
|
const tutorialTree = normalizeTutorials(tutorials);
|
|
@@ -1465,9 +1618,9 @@ async function publish(data, opts, tutorials) {
|
|
|
1465
1618
|
const menu = normalizeMenu(opts.menu);
|
|
1466
1619
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
1467
1620
|
const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
|
|
1468
|
-
collapsibleWarnings.forEach((w) =>
|
|
1621
|
+
collapsibleWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
|
|
1469
1622
|
const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
|
|
1470
|
-
scrollbarWarnings.forEach((w) =>
|
|
1623
|
+
scrollbarWarnings.forEach((w) => warnOption(`clean-jsdoc-theme: ${w}`));
|
|
1471
1624
|
const playground = normalizePlayground(opts.playground);
|
|
1472
1625
|
const siteOptions = {
|
|
1473
1626
|
...pkg ? { pkg } : {},
|
|
@@ -1482,14 +1635,25 @@ async function publish(data, opts, tutorials) {
|
|
|
1482
1635
|
...menu ? { menu } : {},
|
|
1483
1636
|
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
1484
1637
|
...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
|
|
1485
|
-
...playground ? { playground: playground.site } : {}
|
|
1638
|
+
...playground ? { playground: playground.site } : {},
|
|
1639
|
+
...includePrivateEnabled(opts) ? { includePrivate: true } : {}
|
|
1486
1640
|
};
|
|
1487
1641
|
const manifest = await progress.stage("Generating pages", () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions));
|
|
1488
1642
|
if (Array.isArray(collapsibleSidebarSections)) {
|
|
1489
1643
|
const present = topLevelSectionLabels(manifest.nav);
|
|
1490
1644
|
const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
|
|
1491
|
-
if (unmatched.length > 0)
|
|
1645
|
+
if (unmatched.length > 0) warnOption(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
|
|
1646
|
+
}
|
|
1647
|
+
if (sectionOrder) {
|
|
1648
|
+
const known = [.../* @__PURE__ */ new Set([
|
|
1649
|
+
...topLevelSectionLabels(manifest.nav),
|
|
1650
|
+
...DEFAULT_SECTION_ORDER,
|
|
1651
|
+
DOCS_SECTION
|
|
1652
|
+
])];
|
|
1653
|
+
const unknown = unknownSectionOrderLabels(sectionOrder, known, ["Global"]);
|
|
1654
|
+
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(", ")}.`);
|
|
1492
1655
|
}
|
|
1656
|
+
failOnStrictOptionErrors();
|
|
1493
1657
|
const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
|
|
1494
1658
|
if (extractPath) {
|
|
1495
1659
|
const target = (0, node_path.resolve)(extractPath);
|
|
@@ -1498,9 +1662,10 @@ async function publish(data, opts, tutorials) {
|
|
|
1498
1662
|
await (0, node_fs_promises.writeFile)(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
|
|
1499
1663
|
});
|
|
1500
1664
|
console.log(`clean-jsdoc-theme: extract mode — wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`);
|
|
1665
|
+
report.optionProblems();
|
|
1501
1666
|
return;
|
|
1502
1667
|
}
|
|
1503
|
-
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
|
|
1668
|
+
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed, warnOption);
|
|
1504
1669
|
const notGoogle = new Set(diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path));
|
|
1505
1670
|
const fonts = { ...value.fonts };
|
|
1506
1671
|
if (notGoogle.has("fonts.heading")) delete fonts.heading;
|
|
@@ -1515,10 +1680,11 @@ async function publish(data, opts, tutorials) {
|
|
|
1515
1680
|
}
|
|
1516
1681
|
fonts.locales = cleaned;
|
|
1517
1682
|
}
|
|
1518
|
-
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
1519
|
-
const footer = await resolveFooter(opts.footer);
|
|
1520
|
-
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
1521
|
-
const meta = normalizeMeta(opts.meta);
|
|
1683
|
+
const customAssets = await resolveCustomAssets(opts, hrefForServed, warnOption);
|
|
1684
|
+
const footer = await resolveFooter(opts.footer, warnOption);
|
|
1685
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed, warnOption);
|
|
1686
|
+
const meta = normalizeMeta(opts.meta, warnOption);
|
|
1687
|
+
failOnStrictOptionErrors();
|
|
1522
1688
|
const absoluteDestination = (0, node_path.resolve)(destination);
|
|
1523
1689
|
const islandCacheDir = (0, node_path.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
1524
1690
|
const result = await progress.stage("Rendering site", () => render(manifest, {
|
|
@@ -1546,6 +1712,8 @@ async function publish(data, opts, tutorials) {
|
|
|
1546
1712
|
}))
|
|
1547
1713
|
} } : {}
|
|
1548
1714
|
}));
|
|
1715
|
+
const renderFailure = renderFailureMessage(result);
|
|
1716
|
+
if (renderFailure) throw new Error(`clean-jsdoc-theme: ${renderFailure}`);
|
|
1549
1717
|
const generatedFiles = [
|
|
1550
1718
|
...result.files,
|
|
1551
1719
|
...logoFiles,
|
|
@@ -1589,8 +1757,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1589
1757
|
gzipSizer,
|
|
1590
1758
|
color
|
|
1591
1759
|
}));
|
|
1592
|
-
|
|
1593
|
-
if (optsWarnings.list.length > 0) console.warn(formatDiagnostics(optsWarnings, { color }));
|
|
1760
|
+
report.optionProblems();
|
|
1594
1761
|
if (result.errors && result.errors.length > 0) {
|
|
1595
1762
|
console.warn(`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`);
|
|
1596
1763
|
for (const e of result.errors) console.warn(formatRenderError(e));
|
|
@@ -1607,6 +1774,7 @@ exports.collectStaticFiles = collectStaticFiles;
|
|
|
1607
1774
|
exports.computeRelPaths = computeRelPaths;
|
|
1608
1775
|
exports.createImageCollector = createImageCollector;
|
|
1609
1776
|
exports.hasMarkdownPlugin = hasMarkdownPlugin;
|
|
1777
|
+
exports.includePrivateEnabled = includePrivateEnabled;
|
|
1610
1778
|
exports.normalizeColors = normalizeColors;
|
|
1611
1779
|
exports.normalizeCopyPage = normalizeCopyPage;
|
|
1612
1780
|
exports.normalizeDocGroups = normalizeDocGroups;
|
|
@@ -1620,6 +1788,8 @@ exports.outputSourceFilesEnabled = outputSourceFilesEnabled;
|
|
|
1620
1788
|
exports.overlayDocs = overlayDocs;
|
|
1621
1789
|
exports.publish = publish;
|
|
1622
1790
|
exports.readStaticFilesConfig = readStaticFilesConfig;
|
|
1791
|
+
exports.reportBuildFailure = reportBuildFailure;
|
|
1792
|
+
exports.resolveCustomAssets = resolveCustomAssets;
|
|
1623
1793
|
exports.resolveDocImages = resolveDocImages;
|
|
1624
1794
|
exports.resolveDocletImages = resolveDocletImages;
|
|
1625
1795
|
exports.resolveFavicon = resolveFavicon;
|