clean-jsdoc-theme 5.1.0 → 5.2.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 +272 -254
- package/dist/publish.d.ts +272 -254
- package/dist/publish.js +1523 -1264
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +1504 -1217
- package/dist/publish.mjs.map +1 -1
- package/package.json +9 -9
package/dist/publish.js
CHANGED
|
@@ -1,1382 +1,1641 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/publish.ts
|
|
31
|
-
var publish_exports = {};
|
|
32
|
-
__export(publish_exports, {
|
|
33
|
-
cleanOutputDirEnabled: () => cleanOutputDirEnabled,
|
|
34
|
-
collectDocs: () => collectDocs,
|
|
35
|
-
collectStaticFiles: () => collectStaticFiles,
|
|
36
|
-
computeRelPaths: () => computeRelPaths,
|
|
37
|
-
createImageCollector: () => createImageCollector,
|
|
38
|
-
hasMarkdownPlugin: () => hasMarkdownPlugin,
|
|
39
|
-
normalizeColors: () => normalizeColors,
|
|
40
|
-
normalizeCopyPage: () => normalizeCopyPage,
|
|
41
|
-
normalizeDocGroups: () => normalizeDocGroups,
|
|
42
|
-
normalizeMenu: () => normalizeMenu,
|
|
43
|
-
normalizeMeta: () => normalizeMeta,
|
|
44
|
-
normalizePageNav: () => normalizePageNav,
|
|
45
|
-
normalizePlayground: () => normalizePlayground,
|
|
46
|
-
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
47
|
-
normalizeStaticFilesConfig: () => normalizeStaticFilesConfig,
|
|
48
|
-
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
49
|
-
overlayDocs: () => overlayDocs,
|
|
50
|
-
publish: () => publish,
|
|
51
|
-
readStaticFilesConfig: () => readStaticFilesConfig,
|
|
52
|
-
resolveDocImages: () => resolveDocImages,
|
|
53
|
-
resolveDocletImages: () => resolveDocletImages,
|
|
54
|
-
resolveFavicon: () => resolveFavicon,
|
|
55
|
-
resolveFooter: () => resolveFooter,
|
|
56
|
-
resolveTutorialImages: () => resolveTutorialImages,
|
|
57
|
-
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled,
|
|
58
|
-
staticFileIncluded: () => staticFileIncluded,
|
|
59
|
-
staticFileOutputName: () => staticFileOutputName
|
|
60
|
-
});
|
|
61
|
-
module.exports = __toCommonJS(publish_exports);
|
|
62
|
-
var import_promises2 = require("fs/promises");
|
|
63
|
-
var import_node_fs = require("fs");
|
|
64
|
-
var import_node_crypto = require("crypto");
|
|
65
|
-
var import_node_path2 = require("path");
|
|
66
|
-
var import_node_url = require("url");
|
|
67
|
-
|
|
68
|
-
// src/write-output-files.ts
|
|
69
|
-
var import_promises = require("fs/promises");
|
|
70
|
-
var import_node_path = require("path");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_crypto = require("node:crypto");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
let node_url = require("node:url");
|
|
8
|
+
//#region src/write-output-files.ts
|
|
71
9
|
async function writeOutputFiles(destination, files) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
10
|
+
for (const file of files) {
|
|
11
|
+
const target = (0, node_path.join)(destination, file.path);
|
|
12
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(target), { recursive: true });
|
|
13
|
+
const contents = typeof file.contents === "string" ? file.contents : Buffer.from(file.contents);
|
|
14
|
+
await (0, node_fs_promises.writeFile)(target, contents);
|
|
15
|
+
}
|
|
78
16
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/publish.ts
|
|
19
|
+
const JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
82
20
|
function anchorPath() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"clean-jsdoc-theme: could not determine the running module path (__filename is unavailable)."
|
|
86
|
-
);
|
|
21
|
+
if (typeof __filename === "string") return __filename;
|
|
22
|
+
throw new Error("clean-jsdoc-theme: could not determine the running module path (__filename is unavailable).");
|
|
87
23
|
}
|
|
88
24
|
function resolvePackageDir(name) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
|
|
25
|
+
const start = anchorPath();
|
|
26
|
+
let dir = (0, node_path.dirname)(start);
|
|
27
|
+
let prev = "";
|
|
28
|
+
while (dir !== prev) {
|
|
29
|
+
const candidate = (0, node_path.resolve)(dir, "node_modules", name);
|
|
30
|
+
try {
|
|
31
|
+
(0, node_fs.readFileSync)((0, node_path.resolve)(candidate, "package.json"), "utf8");
|
|
32
|
+
return candidate;
|
|
33
|
+
} catch {}
|
|
34
|
+
prev = dir;
|
|
35
|
+
dir = (0, node_path.dirname)(dir);
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
|
|
103
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve an `exports` condition subtree (a string target, or a conditions
|
|
41
|
+
* object like `{ import, require, default, types }`) to an absolute path,
|
|
42
|
+
* preferring the ESM condition (`import`, then a bare `default`). Recurses for
|
|
43
|
+
* nested conditions (`import: { default: "…" }`). Returns `undefined` when no
|
|
44
|
+
* usable target is present.
|
|
45
|
+
*/
|
|
104
46
|
function resolveExportTarget(node, pkgRoot) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return void 0;
|
|
47
|
+
if (typeof node === "string") return (0, node_path.resolve)(pkgRoot, node);
|
|
48
|
+
if (!node || typeof node !== "object") return void 0;
|
|
49
|
+
const o = node;
|
|
50
|
+
const imp = resolveExportTarget(o.import, pkgRoot);
|
|
51
|
+
if (imp) return imp;
|
|
52
|
+
if (typeof o.default === "string") return (0, node_path.resolve)(pkgRoot, o.default);
|
|
112
53
|
}
|
|
113
54
|
function resolveEsmEntry(name) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (typeof pkg.main === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.main);
|
|
127
|
-
throw new Error(
|
|
128
|
-
`clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`
|
|
129
|
-
);
|
|
55
|
+
const pkgRoot = resolvePackageDir(name);
|
|
56
|
+
const pkg = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(pkgRoot, "package.json"), "utf8"));
|
|
57
|
+
const exp = pkg.exports;
|
|
58
|
+
if (typeof exp === "string") return (0, node_path.resolve)(pkgRoot, exp);
|
|
59
|
+
if (exp && typeof exp === "object") {
|
|
60
|
+
const dot = exp["."];
|
|
61
|
+
const target = resolveExportTarget(dot !== void 0 ? dot : exp, pkgRoot);
|
|
62
|
+
if (target) return target;
|
|
63
|
+
}
|
|
64
|
+
if (typeof pkg.module === "string") return (0, node_path.resolve)(pkgRoot, pkg.module);
|
|
65
|
+
if (typeof pkg.main === "string") return (0, node_path.resolve)(pkgRoot, pkg.main);
|
|
66
|
+
throw new Error(`clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`);
|
|
130
67
|
}
|
|
131
68
|
async function loadDep(name, requiredExports) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (typeof mod[key] !== "function") {
|
|
137
|
-
throw new Error(
|
|
138
|
-
`clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return mod;
|
|
69
|
+
const entry = resolveEsmEntry(name);
|
|
70
|
+
const mod = await import((0, node_url.pathToFileURL)(entry).href);
|
|
71
|
+
for (const key of requiredExports) if (typeof mod[key] !== "function") throw new Error(`clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`);
|
|
72
|
+
return mod;
|
|
143
73
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
74
|
+
const loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite", "stampSite"]);
|
|
75
|
+
const loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render", "runPagefindAgainstDir"]);
|
|
76
|
+
const loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
77
|
+
"validateThemeOpts",
|
|
78
|
+
"createGoogleFontResolver",
|
|
79
|
+
"formatDiagnostics",
|
|
80
|
+
"warningsOnly",
|
|
81
|
+
"formatBuildReport",
|
|
82
|
+
"formatRenderError",
|
|
83
|
+
"normalizeBasePath",
|
|
84
|
+
"withBase",
|
|
85
|
+
"toExtractManifest",
|
|
86
|
+
"normalizeCollapsibleSidebarSections",
|
|
87
|
+
"unmatchedCollapsibleSections",
|
|
88
|
+
"topLevelSectionLabels",
|
|
89
|
+
"normalizeScrollbar"
|
|
158
90
|
]);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Load `ora` (ESM-only) the same way as the other deps — via a resolved
|
|
93
|
+
* `file://` URL so the CJS bundle doesn't `require()` it. Returns `null` if
|
|
94
|
+
* `ora` can't be loaded, so progress degrades to silent rather than failing
|
|
95
|
+
* the build.
|
|
96
|
+
*/
|
|
97
|
+
const loadOra = async () => {
|
|
98
|
+
try {
|
|
99
|
+
return (await loadDep("ora", ["default"])).default;
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
166
103
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
104
|
+
/**
|
|
105
|
+
* JSDoc's own standard `opts` keys (`jsdoc/lib/jsdoc/opts/argparser.js` +
|
|
106
|
+
* `conf` schema). These share the flat `opts` namespace with the theme's
|
|
107
|
+
* options, so they must never be flagged as unknown theme keys — even by a
|
|
108
|
+
* near-miss typo distance. Theme keys (`docs`, `docGroups`, …) live in
|
|
109
|
+
* `THEME_OPT_KEYS`, NOT here.
|
|
110
|
+
*/
|
|
111
|
+
const JSDOC_OWN_OPTS = /* @__PURE__ */ new Set([
|
|
112
|
+
"destination",
|
|
113
|
+
"template",
|
|
114
|
+
"encoding",
|
|
115
|
+
"recurse",
|
|
116
|
+
"readme",
|
|
117
|
+
"package",
|
|
118
|
+
"tutorials",
|
|
119
|
+
"query",
|
|
120
|
+
"private",
|
|
121
|
+
"access",
|
|
122
|
+
"explain",
|
|
123
|
+
"debug",
|
|
124
|
+
"verbose",
|
|
125
|
+
"pedantic",
|
|
126
|
+
"match",
|
|
127
|
+
"nocolor",
|
|
128
|
+
"templates"
|
|
185
129
|
]);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
basePath: "/"
|
|
130
|
+
const defaultTheme = {
|
|
131
|
+
tokens: {
|
|
132
|
+
colors: {
|
|
133
|
+
bg: "oklch(0.9924 0.0079 106.54)",
|
|
134
|
+
bgMuted: "oklch(0.9595 0.0079 106.55)",
|
|
135
|
+
fg: "oklch(0.3639 0 0)",
|
|
136
|
+
fgMuted: "oklch(0.5278 0 0)",
|
|
137
|
+
accent: "oklch(0 0 0)",
|
|
138
|
+
accentFg: "oklch(1 0 0)",
|
|
139
|
+
border: "oklch(0.9561 0 0)"
|
|
140
|
+
},
|
|
141
|
+
darkColors: {
|
|
142
|
+
bg: "oklch(0.1408 0.0044 285.82)",
|
|
143
|
+
bgMuted: "oklch(0.2103 0.0059 285.89)",
|
|
144
|
+
fg: "oklch(0.6993 0 0)",
|
|
145
|
+
fgMuted: "oklch(0.5382 0 0)",
|
|
146
|
+
accent: "oklch(1 0 0)",
|
|
147
|
+
accentFg: "oklch(0 0 0)",
|
|
148
|
+
border: "oklch(0.2321 0.004 286.02)"
|
|
149
|
+
},
|
|
150
|
+
fonts: {
|
|
151
|
+
heading: "Source Serif 4",
|
|
152
|
+
body: "Roboto",
|
|
153
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
154
|
+
},
|
|
155
|
+
shiki: {
|
|
156
|
+
light: "github-light",
|
|
157
|
+
dark: "github-dark"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
basePath: "/"
|
|
218
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* Resolve the font triple for the active `locale`: a per-locale override wins,
|
|
164
|
+
* then the base font, then the theme default — per slot. With no locale (a
|
|
165
|
+
* normal, non-localized build) only the base + default apply, so the result is
|
|
166
|
+
* byte-identical to before per-locale fonts existed.
|
|
167
|
+
*/
|
|
219
168
|
function resolveFontSet(fonts, locale) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
169
|
+
const base = defaultTheme.tokens.fonts;
|
|
170
|
+
const override = locale && fonts.locales?.[locale] || {};
|
|
171
|
+
return {
|
|
172
|
+
heading: override.heading ?? fonts.heading ?? base.heading,
|
|
173
|
+
body: override.body ?? fonts.body ?? base.body,
|
|
174
|
+
mono: override.mono ?? fonts.mono ?? base.mono
|
|
175
|
+
};
|
|
227
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Merge validated user overrides from `jsdoc.json` (`siteName`, `fonts`) over
|
|
179
|
+
* the defaults. Only the keys the user supplies are overridden; everything else
|
|
180
|
+
* keeps the default theme. `siteName` is pre-resolved/validated and its local
|
|
181
|
+
* logos copied by `prepareSiteName`; `fonts` is the validated subset (any
|
|
182
|
+
* family flagged `fonts/not-google` is dropped upstream so the default applies).
|
|
183
|
+
* `locale` (set in build mode) selects per-locale font overrides.
|
|
184
|
+
*/
|
|
228
185
|
function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
186
|
+
const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
|
|
187
|
+
const copyPage = normalizeCopyPage(opts.copyPage);
|
|
188
|
+
const pageNav = normalizePageNav(opts.pageNav);
|
|
189
|
+
const playground = normalizePlayground(opts.playground);
|
|
190
|
+
const colors = normalizeColors(opts.colors);
|
|
191
|
+
const darkColors = normalizeColors(opts.darkColors);
|
|
192
|
+
return {
|
|
193
|
+
...defaultTheme,
|
|
194
|
+
basePath,
|
|
195
|
+
...aiPrompt ? { aiPrompt } : {},
|
|
196
|
+
...copyPage ? { copyPage } : {},
|
|
197
|
+
...pageNav ? { pageNav } : {},
|
|
198
|
+
...playground ? { playground: playground.theme } : {},
|
|
199
|
+
tokens: {
|
|
200
|
+
...defaultTheme.tokens,
|
|
201
|
+
colors: {
|
|
202
|
+
...defaultTheme.tokens.colors,
|
|
203
|
+
...colors ?? {}
|
|
204
|
+
},
|
|
205
|
+
darkColors: {
|
|
206
|
+
...defaultTheme.tokens.darkColors,
|
|
207
|
+
...darkColors ?? {}
|
|
208
|
+
},
|
|
209
|
+
fonts: resolveFontSet(fonts, locale),
|
|
210
|
+
...siteName ? { siteName } : {}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
250
213
|
}
|
|
214
|
+
/** Trim a value to a non-empty string, or `undefined`. */
|
|
251
215
|
function nonEmptyString(value) {
|
|
252
|
-
|
|
216
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
253
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Short, deterministic content hash for cache-stable custom-asset filenames.
|
|
220
|
+
* Derived from the file's bytes (NOT random), so an unchanged file produces the
|
|
221
|
+
* same name across builds (browser cache hit) and a changed file cache-busts.
|
|
222
|
+
*/
|
|
254
223
|
function contentHash(bytes) {
|
|
255
|
-
|
|
224
|
+
return (0, node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
256
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Copy custom CSS/JS file(s) (a path or array, relative to the working dir) to
|
|
228
|
+
* served `_assets` files and return their hrefs. Each file is copied AS-IS (its
|
|
229
|
+
* own bytes — never concatenated). The asset name is `<base>.<hash>.<ext>` when
|
|
230
|
+
* `hash` is on (the hash is content-derived → stable URL for unchanged files),
|
|
231
|
+
* else the bare `<base><ext>`. A file that can't be read is skipped with a
|
|
232
|
+
* warning (resilient, like `prepareSiteName`); an identical served name is
|
|
233
|
+
* emitted once.
|
|
234
|
+
*/
|
|
257
235
|
async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
236
|
+
const paths = (Array.isArray(raw) ? raw : [raw]).filter((p) => typeof p === "string" && p.trim().length > 0);
|
|
237
|
+
const links = [];
|
|
238
|
+
const files = [];
|
|
239
|
+
const seen = /* @__PURE__ */ new Set();
|
|
240
|
+
for (const p of paths) {
|
|
241
|
+
const trimmed = p.trim();
|
|
242
|
+
let bytes;
|
|
243
|
+
try {
|
|
244
|
+
bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
|
|
245
|
+
} catch {
|
|
246
|
+
console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const base = (0, node_path.basename)(trimmed, (0, node_path.extname)(trimmed)) || "custom";
|
|
250
|
+
const servedPath = `_assets/${hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`}`;
|
|
251
|
+
if (seen.has(servedPath)) continue;
|
|
252
|
+
seen.add(servedPath);
|
|
253
|
+
files.push({
|
|
254
|
+
path: servedPath,
|
|
255
|
+
contents: bytes
|
|
256
|
+
});
|
|
257
|
+
links.push(hrefForServed(servedPath));
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
links,
|
|
261
|
+
files
|
|
262
|
+
};
|
|
282
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Resolve the custom CSS/JS injection options into render-ready `ThemeConfig`
|
|
266
|
+
* fields plus the asset files to write. Inline strings (`customCss`/`customJs`)
|
|
267
|
+
* pass through; file options (`customCssFile`/`customJsFile`) are read + copied
|
|
268
|
+
* to content-hashed assets here — the bridge is the I/O layer, so dwar's
|
|
269
|
+
* `render()` stays pure and just links the resulting hrefs. `hashCustomAssets`
|
|
270
|
+
* (default `true`) toggles the content-hash suffix.
|
|
271
|
+
*/
|
|
283
272
|
async function resolveCustomAssets(opts, hrefForServed) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
files: [...cssAssets.files, ...jsAssets.files]
|
|
299
|
-
};
|
|
273
|
+
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)]);
|
|
275
|
+
const customCss = nonEmptyString(opts.customCss)?.trim();
|
|
276
|
+
const customJs = nonEmptyString(opts.customJs)?.trim();
|
|
277
|
+
return {
|
|
278
|
+
theme: {
|
|
279
|
+
...customCss ? { customCss } : {},
|
|
280
|
+
...cssAssets.links.length > 0 ? { customCssLinks: cssAssets.links } : {},
|
|
281
|
+
...customJs ? { customJs } : {},
|
|
282
|
+
...jsAssets.links.length > 0 ? { customJsLinks: jsAssets.links } : {}
|
|
283
|
+
},
|
|
284
|
+
files: [...cssAssets.files, ...jsAssets.files]
|
|
285
|
+
};
|
|
300
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
|
|
289
|
+
* `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
|
|
290
|
+
* bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
|
|
291
|
+
* string. A missing/unreadable file is warned about and dropped (resilient,
|
|
292
|
+
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
293
|
+
* the default footer renders. Exported for testing.
|
|
294
|
+
*/
|
|
301
295
|
async function resolveFooter(raw) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return void 0;
|
|
296
|
+
if (typeof raw === "string") {
|
|
297
|
+
const trimmed = raw.trim();
|
|
298
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
299
|
+
}
|
|
300
|
+
if (raw && typeof raw === "object" && typeof raw.file === "string") {
|
|
301
|
+
const file = raw.file.trim();
|
|
302
|
+
if (!file) return void 0;
|
|
303
|
+
try {
|
|
304
|
+
const html = await (0, node_fs_promises.readFile)((0, node_path.resolve)(file), "utf8");
|
|
305
|
+
return html.trim().length > 0 ? html : void 0;
|
|
306
|
+
} catch {
|
|
307
|
+
console.warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
320
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Resolve `opts.favicon` (a file path) into a served `_assets/` href + the file
|
|
314
|
+
* to write — the bridge is the I/O layer, so dwar only sees the final URL and
|
|
315
|
+
* `render()` stays pure. The asset name is content-hashed (cache-busted) unless
|
|
316
|
+
* `hash` is off, and the source extension is preserved so dwar can derive the
|
|
317
|
+
* `<link>` `type`. A missing/unreadable file is warned about and dropped
|
|
318
|
+
* (resilient, like the logo/custom-asset paths). Exported for testing.
|
|
319
|
+
*/
|
|
321
320
|
async function resolveFavicon(raw, hash, hrefForServed) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
321
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
322
|
+
const trimmed = raw.trim();
|
|
323
|
+
let bytes;
|
|
324
|
+
try {
|
|
325
|
+
bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
|
|
326
|
+
} catch {
|
|
327
|
+
console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const ext = (0, node_path.extname)(trimmed) || ".ico";
|
|
331
|
+
const base = (0, node_path.basename)(trimmed, (0, node_path.extname)(trimmed)) || "favicon";
|
|
332
|
+
const servedPath = `_assets/${hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`}`;
|
|
333
|
+
return {
|
|
334
|
+
href: hrefForServed(servedPath),
|
|
335
|
+
files: [{
|
|
336
|
+
path: servedPath,
|
|
337
|
+
contents: bytes
|
|
338
|
+
}]
|
|
339
|
+
};
|
|
336
340
|
}
|
|
337
|
-
|
|
341
|
+
/** Attributes that identify a `<meta>` tag (so an entry must carry at least one). */
|
|
342
|
+
const META_IDENTITY_ATTRS = [
|
|
343
|
+
"name",
|
|
344
|
+
"property",
|
|
345
|
+
"http-equiv",
|
|
346
|
+
"charset",
|
|
347
|
+
"itemprop"
|
|
348
|
+
];
|
|
349
|
+
/**
|
|
350
|
+
* Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
|
|
351
|
+
* when there's nothing usable. Accepts only an array of objects; within each,
|
|
352
|
+
* keeps string→string pairs (trimming the value, coercing finite numbers to
|
|
353
|
+
* strings for convenience) and drops the rest. An entry with no recognized
|
|
354
|
+
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
355
|
+
* dropped with a warning — dwar does the final escaping + key validation.
|
|
356
|
+
*/
|
|
338
357
|
function normalizeMeta(raw) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
|
|
357
|
-
);
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
out.push(tag);
|
|
361
|
-
}
|
|
362
|
-
return out.length > 0 ? out : void 0;
|
|
358
|
+
if (!Array.isArray(raw)) return void 0;
|
|
359
|
+
const out = [];
|
|
360
|
+
for (const entry of raw) {
|
|
361
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
362
|
+
const o = entry;
|
|
363
|
+
const tag = {};
|
|
364
|
+
for (const [k, v] of Object.entries(o)) if (typeof v === "string") {
|
|
365
|
+
const t = v.trim();
|
|
366
|
+
if (t.length > 0) tag[k] = t;
|
|
367
|
+
} else if (typeof v === "number" && Number.isFinite(v)) tag[k] = String(v);
|
|
368
|
+
if (!META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string") || Object.keys(tag).length === 0) {
|
|
369
|
+
console.warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
out.push(tag);
|
|
373
|
+
}
|
|
374
|
+
return out.length > 0 ? out : void 0;
|
|
363
375
|
}
|
|
376
|
+
/** A logo value that's already a servable URL/URI needs no copying. */
|
|
364
377
|
function isServableUrl(value) {
|
|
365
|
-
|
|
378
|
+
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
366
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Resolve `opts.siteName` into a render-ready value plus any image files to
|
|
382
|
+
* write. A string passes through (trimmed). For a logo set, each local image
|
|
383
|
+
* path is read and emitted as a content-hashed output asset
|
|
384
|
+
* (`_assets/logo-<key>.<hash><ext>`, cache-busted like the custom assets) with
|
|
385
|
+
* its value rewritten to the served path; `http(s)://` / `data:` values pass
|
|
386
|
+
* through untouched, and the `alt` label is preserved. A path that can't be
|
|
387
|
+
* read is left verbatim with a warning rather than aborting the build.
|
|
388
|
+
*/
|
|
367
389
|
async function prepareSiteName(raw, hrefForServed) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
390
|
+
if (typeof raw === "string") {
|
|
391
|
+
const trimmed = raw.trim();
|
|
392
|
+
return {
|
|
393
|
+
siteName: trimmed.length > 0 ? trimmed : void 0,
|
|
394
|
+
files: []
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
if (!raw || typeof raw !== "object") return {
|
|
398
|
+
siteName: void 0,
|
|
399
|
+
files: []
|
|
400
|
+
};
|
|
401
|
+
const files = [];
|
|
402
|
+
const out = {};
|
|
403
|
+
if (typeof raw.alt === "string" && raw.alt.trim().length > 0) out.alt = raw.alt.trim();
|
|
404
|
+
for (const key of [
|
|
405
|
+
"default",
|
|
406
|
+
"dark",
|
|
407
|
+
"light"
|
|
408
|
+
]) {
|
|
409
|
+
const value = raw[key];
|
|
410
|
+
if (typeof value !== "string" || value.trim().length === 0) continue;
|
|
411
|
+
const v = value.trim();
|
|
412
|
+
if (isServableUrl(v)) {
|
|
413
|
+
out[key] = v;
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const abs = (0, node_path.resolve)(v);
|
|
418
|
+
const buf = await (0, node_fs_promises.readFile)(abs);
|
|
419
|
+
const served = `_assets/logo-${key}.${contentHash(buf)}${(0, node_path.extname)(abs)}`;
|
|
420
|
+
files.push({
|
|
421
|
+
path: served,
|
|
422
|
+
contents: buf
|
|
423
|
+
});
|
|
424
|
+
out[key] = hrefForServed(served);
|
|
425
|
+
} catch {
|
|
426
|
+
console.warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
|
|
427
|
+
out[key] = v;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
siteName: out.default || out.dark || out.light || out.alt ? out : void 0,
|
|
432
|
+
files
|
|
433
|
+
};
|
|
399
434
|
}
|
|
400
435
|
async function resolvePkg(data, opts) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (typeof data === "function") {
|
|
410
|
-
try {
|
|
411
|
-
const pkgDoclets = data({ kind: "package" }).get();
|
|
412
|
-
if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) {
|
|
413
|
-
return pickPkgFields(pkgDoclets[0]);
|
|
414
|
-
}
|
|
415
|
-
} catch {
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return void 0;
|
|
436
|
+
if (typeof opts.package === "string" && opts.package.length > 0) try {
|
|
437
|
+
const json = await (0, node_fs_promises.readFile)(opts.package, "utf8");
|
|
438
|
+
return pickPkgFields(JSON.parse(json));
|
|
439
|
+
} catch {}
|
|
440
|
+
if (typeof data === "function") try {
|
|
441
|
+
const pkgDoclets = data({ kind: "package" }).get();
|
|
442
|
+
if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) return pickPkgFields(pkgDoclets[0]);
|
|
443
|
+
} catch {}
|
|
419
444
|
}
|
|
420
445
|
function pickPkgFields(raw) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
pkg.repository = raw.repository.url;
|
|
430
|
-
}
|
|
431
|
-
return pkg;
|
|
446
|
+
const pkg = {};
|
|
447
|
+
if (typeof raw.name === "string") pkg.name = raw.name;
|
|
448
|
+
if (typeof raw.version === "string") pkg.version = raw.version;
|
|
449
|
+
if (typeof raw.description === "string") pkg.description = raw.description;
|
|
450
|
+
if (typeof raw.homepage === "string") pkg.homepage = raw.homepage;
|
|
451
|
+
if (typeof raw.repository === "string") pkg.repository = raw.repository;
|
|
452
|
+
else if (raw.repository && typeof raw.repository === "object" && typeof raw.repository.url === "string") pkg.repository = raw.repository.url;
|
|
453
|
+
return pkg;
|
|
432
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* Normalize JSDoc's tutorial resolver tree (the `tutorials` arg to `publish`)
|
|
457
|
+
* into setu's plain {@link TutorialInput} shape. The root's `children` are the
|
|
458
|
+
* top-level tutorials; each child carries its own `children`, so a depth-first
|
|
459
|
+
* walk preserves the resolved hierarchy. Content is taken raw (`.content`);
|
|
460
|
+
* `.type === 2` (MARKDOWN) is markdown, everything else is treated as HTML.
|
|
461
|
+
*/
|
|
433
462
|
function normalizeTutorials(root) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
463
|
+
const walk = (node) => {
|
|
464
|
+
const name = typeof node.name === "string" ? node.name : "";
|
|
465
|
+
if (!name) return null;
|
|
466
|
+
return {
|
|
467
|
+
name,
|
|
468
|
+
title: typeof node.title === "string" && node.title.length > 0 ? node.title : name,
|
|
469
|
+
content: typeof node.content === "string" ? node.content : "",
|
|
470
|
+
type: node.type === JSDOC_TUTORIAL_TYPE_MARKDOWN ? "markdown" : "html",
|
|
471
|
+
children: Array.isArray(node.children) ? node.children.map(walk).filter((t) => t !== null) : []
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
const children = root?.children;
|
|
475
|
+
if (!Array.isArray(children)) return [];
|
|
476
|
+
return children.map(walk).filter((t) => t !== null);
|
|
446
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
|
|
480
|
+
* `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
|
|
481
|
+
* root-level `templates` block, so we probe in priority order and default ON:
|
|
482
|
+
* 1. `require('jsdoc/env').conf.templates.default.outputSourceFiles` (the
|
|
483
|
+
* canonical location at runtime; wrapped in try/catch so a missing
|
|
484
|
+
* `jsdoc/env` — e.g. in unit tests — never throws the build).
|
|
485
|
+
* 2. `opts.templates.default.outputSourceFiles` (in case a user nests it
|
|
486
|
+
* under `opts`).
|
|
487
|
+
* Resolves to `false` ONLY when one of those is exactly `=== false`; otherwise
|
|
488
|
+
* `true` (matching JSDoc's default-template default).
|
|
489
|
+
*/
|
|
447
490
|
function outputSourceFilesEnabled(opts) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (opts?.templates?.default?.outputSourceFiles === false) return false;
|
|
454
|
-
return true;
|
|
491
|
+
try {
|
|
492
|
+
if (require("jsdoc/env")?.conf?.templates?.default?.outputSourceFiles === false) return false;
|
|
493
|
+
} catch {}
|
|
494
|
+
if (opts?.templates?.default?.outputSourceFiles === false) return false;
|
|
495
|
+
return true;
|
|
455
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Resolve `templates.default.sourceLinkToComment`. Probed in the same priority
|
|
499
|
+
* order as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a
|
|
500
|
+
* nested `opts.templates` fallback). Resolves to `true` ONLY when one of those
|
|
501
|
+
* is exactly `=== true`; otherwise `false` (the default: links jump to code).
|
|
502
|
+
*/
|
|
456
503
|
function sourceLinkToCommentEnabled(opts) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
463
|
-
return false;
|
|
504
|
+
try {
|
|
505
|
+
if (require("jsdoc/env")?.conf?.templates?.default?.sourceLinkToComment === true) return true;
|
|
506
|
+
} catch {}
|
|
507
|
+
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
508
|
+
return false;
|
|
464
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Resolve `templates.default.cleanOutputDir`. Probed in the same priority order
|
|
512
|
+
* as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a nested
|
|
513
|
+
* `opts.templates` fallback). Defaults to `true` — the build empties its
|
|
514
|
+
* destination first so a page removed or renamed between runs (e.g. a deleted
|
|
515
|
+
* class, or a stale content-hashed `styles.<hash>.css`) doesn't linger in the
|
|
516
|
+
* served site. Resolves to `false` ONLY when one is exactly `=== false`.
|
|
517
|
+
*/
|
|
465
518
|
function cleanOutputDirEnabled(opts) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (opts?.templates?.default?.cleanOutputDir === false) return false;
|
|
472
|
-
return true;
|
|
519
|
+
try {
|
|
520
|
+
if (require("jsdoc/env")?.conf?.templates?.default?.cleanOutputDir === false) return false;
|
|
521
|
+
} catch {}
|
|
522
|
+
if (opts?.templates?.default?.cleanOutputDir === false) return false;
|
|
523
|
+
return true;
|
|
473
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Whether a JSDoc `conf.plugins` list enables the bundled `plugins/markdown`
|
|
527
|
+
* plugin. The theme relies on it: JSDoc runs `plugins/markdown` to convert the
|
|
528
|
+
* Markdown in doclet descriptions/tags to HTML *before* `publish` ever sees the
|
|
529
|
+
* doclets, so without it descriptions arrive as raw Markdown and render wrong.
|
|
530
|
+
* Pure + exported for testing — accepts the `plugins` array (module specifiers,
|
|
531
|
+
* e.g. `"plugins/markdown"`; tolerant of a `.js` suffix or path separators).
|
|
532
|
+
*/
|
|
474
533
|
function hasMarkdownPlugin(plugins) {
|
|
475
|
-
|
|
476
|
-
|
|
534
|
+
if (!Array.isArray(plugins)) return false;
|
|
535
|
+
return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
|
|
477
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Hard-require JSDoc's `plugins/markdown` plugin (see {@link hasMarkdownPlugin}).
|
|
539
|
+
* Reads the merged config from `require('jsdoc/env').conf.plugins` — the
|
|
540
|
+
* canonical location at runtime — and throws if the plugin is absent so the
|
|
541
|
+
* build stops early with an actionable message. When `jsdoc/env` can't be
|
|
542
|
+
* resolved (e.g. unit tests, or a non-JSDoc caller) the check is skipped: the
|
|
543
|
+
* plugin list is unknowable there, so it can't be enforced.
|
|
544
|
+
*/
|
|
478
545
|
function assertMarkdownPlugin() {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
throw new Error(
|
|
488
|
-
`clean-jsdoc-theme requires JSDoc's "plugins/markdown" plugin, which renders Markdown in doclet descriptions to HTML. Add it to your jsdoc.json:
|
|
489
|
-
|
|
490
|
-
"plugins": ["plugins/markdown"]
|
|
491
|
-
`
|
|
492
|
-
);
|
|
493
|
-
}
|
|
546
|
+
let conf;
|
|
547
|
+
try {
|
|
548
|
+
conf = require("jsdoc/env").conf;
|
|
549
|
+
} catch {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (!conf) return;
|
|
553
|
+
if (!hasMarkdownPlugin(conf.plugins)) throw new Error("clean-jsdoc-theme requires JSDoc's \"plugins/markdown\" plugin, which renders Markdown in doclet descriptions to HTML. Add it to your jsdoc.json:\n\n \"plugins\": [\"plugins/markdown\"]\n");
|
|
494
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Validate `opts.sectionOrder` into a clean `string[]`, or `undefined` to fall
|
|
557
|
+
* back to setu's default order. Accepts only an array; trims string entries and
|
|
558
|
+
* drops non-strings/empties. An array that yields no usable labels → `undefined`.
|
|
559
|
+
*/
|
|
495
560
|
function normalizeSectionOrder(raw) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
561
|
+
if (!Array.isArray(raw)) return void 0;
|
|
562
|
+
const out = raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
563
|
+
return out.length > 0 ? out : void 0;
|
|
499
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* Validate `opts.menu` into a clean `MenuItem[]`, or `undefined` when there's no
|
|
567
|
+
* usable menu. Accepts only an array of objects; trims string fields. The link
|
|
568
|
+
* URL is read from `link` (preferred) or `href`. Keeps only actionable entries —
|
|
569
|
+
* a built-in (`id`) or an external link (`link`/`href`).
|
|
570
|
+
*/
|
|
500
571
|
function normalizeMenu(raw) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
572
|
+
if (!Array.isArray(raw)) return void 0;
|
|
573
|
+
const out = [];
|
|
574
|
+
for (const entry of raw) {
|
|
575
|
+
if (!entry || typeof entry !== "object") continue;
|
|
576
|
+
const o = entry;
|
|
577
|
+
const item = {};
|
|
578
|
+
if (typeof o.id === "string" && o.id.trim()) item.id = o.id.trim();
|
|
579
|
+
if (typeof o.title === "string" && o.title.trim()) item.title = o.title.trim();
|
|
580
|
+
const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
|
|
581
|
+
if (link) item.link = link;
|
|
582
|
+
if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
|
|
583
|
+
if (typeof o.target === "string" && o.target.trim()) item.target = o.target.trim();
|
|
584
|
+
if (typeof o.class === "string" && o.class.trim()) item.class = o.class.trim();
|
|
585
|
+
if (item.id || item.link) out.push(item);
|
|
586
|
+
}
|
|
587
|
+
return out.length > 0 ? out : void 0;
|
|
517
588
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
589
|
+
/** Valid copy-page dropdown actions (mirrors setu/dwar's `CopyPageAction`). */
|
|
590
|
+
const COPY_PAGE_ACTIONS = [
|
|
591
|
+
"copy",
|
|
592
|
+
"view",
|
|
593
|
+
"claude",
|
|
594
|
+
"chatgpt",
|
|
595
|
+
"perplexity"
|
|
524
596
|
];
|
|
597
|
+
/**
|
|
598
|
+
* Validate `opts.copyPage` into a {@link CopyPageConfig}, or `undefined` to use
|
|
599
|
+
* the defaults (enabled, all actions). Accepts a boolean shorthand (`false`
|
|
600
|
+
* hides the button) or an object: `enabled` is read if boolean; `actions`, if an
|
|
601
|
+
* array, is filtered to the known action ids (preserving order, dropping
|
|
602
|
+
* unknowns/dupes) — an empty/all-invalid array still yields `[]` (primary button
|
|
603
|
+
* only), which is meaningful and kept.
|
|
604
|
+
*/
|
|
525
605
|
function normalizeCopyPage(raw) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
|
|
540
|
-
}
|
|
541
|
-
return Object.keys(config).length > 0 ? config : void 0;
|
|
606
|
+
if (raw === false) return { enabled: false };
|
|
607
|
+
if (raw === true || raw == null) return void 0;
|
|
608
|
+
if (typeof raw !== "object") return void 0;
|
|
609
|
+
const o = raw;
|
|
610
|
+
const config = {};
|
|
611
|
+
if (typeof o.enabled === "boolean") config.enabled = o.enabled;
|
|
612
|
+
if (Array.isArray(o.actions)) {
|
|
613
|
+
const seen = /* @__PURE__ */ new Set();
|
|
614
|
+
for (const a of o.actions) if (typeof a === "string" && COPY_PAGE_ACTIONS.includes(a)) seen.add(a);
|
|
615
|
+
config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
|
|
616
|
+
}
|
|
617
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
542
618
|
}
|
|
619
|
+
/**
|
|
620
|
+
* Validate `opts.pageNav` into a {@link PageNavConfig}, or `undefined` to use the
|
|
621
|
+
* default (enabled). Accepts a boolean shorthand (`false` hides the pager) or an
|
|
622
|
+
* object whose `enabled` is read when boolean.
|
|
623
|
+
*/
|
|
543
624
|
function normalizePageNav(raw) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
625
|
+
if (raw === false) return { enabled: false };
|
|
626
|
+
if (raw === true || raw == null) return void 0;
|
|
627
|
+
if (typeof raw !== "object") return void 0;
|
|
628
|
+
const enabled = raw.enabled;
|
|
629
|
+
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
549
630
|
}
|
|
550
|
-
|
|
631
|
+
/** Valid code-playground providers (mirrors utils' `PlaygroundProvider`). */
|
|
632
|
+
const PLAYGROUND_PROVIDERS = [
|
|
633
|
+
"codepen",
|
|
634
|
+
"jsfiddle",
|
|
635
|
+
"codesandbox"
|
|
636
|
+
];
|
|
637
|
+
/** A site-wide per-provider options record, or `undefined` for a non-object. */
|
|
551
638
|
function playgroundOptionRecord(raw) {
|
|
552
|
-
|
|
639
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
553
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Validate `opts.playground` into its two consumer slices, or `undefined` when
|
|
643
|
+
* the feature is off (absent or `false`). `playground: true` / `{}` turns it on
|
|
644
|
+
* with defaults — every provider available, opt-in per `@playground`. The
|
|
645
|
+
* **`site`** slice feeds setu's `@playground` resolver (enablement + provider
|
|
646
|
+
* selection); the **`theme`** slice becomes `ThemeConfig.playground` (the
|
|
647
|
+
* site-wide per-provider runtime options dwar hands the browser island). Unknown
|
|
648
|
+
* providers/keys are dropped (lenient, like {@link normalizeCopyPage}). setu
|
|
649
|
+
* gates on the `site` slice's presence, so returning `undefined` keeps output
|
|
650
|
+
* byte-identical.
|
|
651
|
+
*/
|
|
554
652
|
function normalizePlayground(raw) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return { site, theme };
|
|
653
|
+
if (raw == null || raw === false) return void 0;
|
|
654
|
+
const o = raw === true ? {} : raw;
|
|
655
|
+
if (typeof o !== "object" || Array.isArray(o)) return void 0;
|
|
656
|
+
const obj = o;
|
|
657
|
+
const site = {};
|
|
658
|
+
if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
|
|
659
|
+
if (Array.isArray(obj.providers)) {
|
|
660
|
+
const providers = [];
|
|
661
|
+
for (const p of obj.providers) if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) providers.push(p);
|
|
662
|
+
if (providers.length > 0) site.providers = providers;
|
|
663
|
+
}
|
|
664
|
+
const theme = { enabled: true };
|
|
665
|
+
const codepen = playgroundOptionRecord(obj.codepen);
|
|
666
|
+
const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
|
|
667
|
+
const codesandbox = playgroundOptionRecord(obj.codesandbox);
|
|
668
|
+
if (codepen) theme.codepen = codepen;
|
|
669
|
+
if (jsfiddle) theme.jsfiddle = jsfiddle;
|
|
670
|
+
if (codesandbox) theme.codesandbox = codesandbox;
|
|
671
|
+
return {
|
|
672
|
+
site,
|
|
673
|
+
theme
|
|
674
|
+
};
|
|
578
675
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
676
|
+
/** The palette keys a user may override under `opts.colors` / `opts.darkColors`. */
|
|
677
|
+
const COLOR_KEYS = [
|
|
678
|
+
"bg",
|
|
679
|
+
"bgMuted",
|
|
680
|
+
"fg",
|
|
681
|
+
"fgMuted",
|
|
682
|
+
"accent",
|
|
683
|
+
"accentFg",
|
|
684
|
+
"border",
|
|
685
|
+
"codeHeaderBg",
|
|
686
|
+
"codeHeaderFg",
|
|
687
|
+
"codeHighlightBg"
|
|
590
688
|
];
|
|
689
|
+
/**
|
|
690
|
+
* Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
|
|
691
|
+
* `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
|
|
692
|
+
* non-empty string, dropping everything else. Returns `undefined` when the input
|
|
693
|
+
* is not an object or yields no usable keys, so callers can fall back cleanly.
|
|
694
|
+
* Values are passed through verbatim (any CSS color is valid).
|
|
695
|
+
*/
|
|
591
696
|
function normalizeColors(raw) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
697
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
698
|
+
const src = raw;
|
|
699
|
+
const out = {};
|
|
700
|
+
for (const key of COLOR_KEYS) {
|
|
701
|
+
const v = src[key];
|
|
702
|
+
if (typeof v === "string" && v.trim().length > 0) out[key] = v.trim();
|
|
703
|
+
}
|
|
704
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
600
705
|
}
|
|
601
|
-
|
|
706
|
+
/** Extensions we treat as "source" worth emitting a viewer page for. */
|
|
707
|
+
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
708
|
+
".js",
|
|
709
|
+
".mjs",
|
|
710
|
+
".cjs",
|
|
711
|
+
".jsx",
|
|
712
|
+
".ts",
|
|
713
|
+
".mts",
|
|
714
|
+
".cts",
|
|
715
|
+
".tsx"
|
|
716
|
+
]);
|
|
717
|
+
/**
|
|
718
|
+
* Compute project-relative paths for a set of absolute source paths by stripping
|
|
719
|
+
* their longest common directory prefix. Returns a `Map<absPath, relPath>` with
|
|
720
|
+
* `relPath` normalized to forward slashes. Pure + exported for testing.
|
|
721
|
+
*
|
|
722
|
+
* Windows-aware: paths are split on both `/` and `\\`, and segment comparison is
|
|
723
|
+
* case-insensitive (NTFS is case-insensitive, and JSDoc's `meta.path` casing can
|
|
724
|
+
* differ from disk). The single-file case yields just its basename. If the paths
|
|
725
|
+
* share no common leading segment (e.g. different drives / UNC vs. drive), each
|
|
726
|
+
* file falls back to its basename so the index stays sane.
|
|
727
|
+
*/
|
|
602
728
|
function computeRelPaths(absPaths) {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
729
|
+
const out = /* @__PURE__ */ new Map();
|
|
730
|
+
if (absPaths.length === 0) return out;
|
|
731
|
+
const split = (p) => p.split(/[\\/]+/).filter((s) => s.length > 0);
|
|
732
|
+
const segLists = absPaths.map(split);
|
|
733
|
+
let common = segLists[0].slice(0, -1);
|
|
734
|
+
for (let i = 1; i < segLists.length && common.length > 0; i++) {
|
|
735
|
+
const segs = segLists[i];
|
|
736
|
+
let j = 0;
|
|
737
|
+
const max = Math.min(common.length, segs.length - 1);
|
|
738
|
+
while (j < max && common[j].toLowerCase() === segs[j].toLowerCase()) j++;
|
|
739
|
+
common = common.slice(0, j);
|
|
740
|
+
}
|
|
741
|
+
for (let i = 0; i < absPaths.length; i++) {
|
|
742
|
+
const segs = segLists[i];
|
|
743
|
+
const rel = common.length > 0 && segs.length > common.length ? segs.slice(common.length).join("/") : segs[segs.length - 1] ?? absPaths[i];
|
|
744
|
+
out.set(absPaths[i], rel);
|
|
745
|
+
}
|
|
746
|
+
return out;
|
|
621
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Collect every source file referenced by a doclet's `meta` and read its
|
|
750
|
+
* contents, ready to hand to setu as {@link SourceFileInput}s. `absPath` is the
|
|
751
|
+
* exact `resolve(meta.path, meta.filename)` so setu's `Source: file:line`
|
|
752
|
+
* matching (which joins the same fields) lines up. Files that can't be read are
|
|
753
|
+
* warned about and skipped — never fatal. Returns sorted-by-`relPath` for
|
|
754
|
+
* stable output.
|
|
755
|
+
*/
|
|
622
756
|
async function collectSourceFiles(data) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
660
|
-
return inputs;
|
|
757
|
+
let doclets = [];
|
|
758
|
+
if (typeof data === "function") try {
|
|
759
|
+
doclets = data({}).get();
|
|
760
|
+
} catch {
|
|
761
|
+
try {
|
|
762
|
+
doclets = data().get();
|
|
763
|
+
} catch {
|
|
764
|
+
doclets = [];
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (!Array.isArray(doclets) || doclets.length === 0) return [];
|
|
768
|
+
const absSet = /* @__PURE__ */ new Set();
|
|
769
|
+
for (const d of doclets) {
|
|
770
|
+
const meta = d?.meta;
|
|
771
|
+
if (!meta || typeof meta.path !== "string" || typeof meta.filename !== "string") continue;
|
|
772
|
+
const filename = meta.filename;
|
|
773
|
+
const ext = (0, node_path.extname)(filename).toLowerCase();
|
|
774
|
+
if (ext.length > 0 && !SOURCE_EXTENSIONS.has(ext)) continue;
|
|
775
|
+
absSet.add((0, node_path.resolve)(meta.path, filename));
|
|
776
|
+
}
|
|
777
|
+
if (absSet.size === 0) return [];
|
|
778
|
+
const absPaths = [...absSet];
|
|
779
|
+
const relPaths = computeRelPaths(absPaths);
|
|
780
|
+
const inputs = [];
|
|
781
|
+
for (const abs of absPaths) try {
|
|
782
|
+
const content = await (0, node_fs_promises.readFile)(abs, "utf8");
|
|
783
|
+
inputs.push({
|
|
784
|
+
absPath: abs,
|
|
785
|
+
relPath: relPaths.get(abs) ?? abs,
|
|
786
|
+
content
|
|
787
|
+
});
|
|
788
|
+
} catch (err) {
|
|
789
|
+
console.warn(`clean-jsdoc-theme: could not read source file '${abs}' — ${err.message}; skipping.`);
|
|
790
|
+
}
|
|
791
|
+
inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
792
|
+
return inputs;
|
|
661
793
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
794
|
+
/** Doc-file extensions → `DocInput.type`. Markdown is the priority; html maps to 'html'. */
|
|
795
|
+
const DOC_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
796
|
+
[".md", "markdown"],
|
|
797
|
+
[".markdown", "markdown"],
|
|
798
|
+
[".html", "html"],
|
|
799
|
+
[".htm", "html"]
|
|
667
800
|
]);
|
|
668
|
-
|
|
801
|
+
/** Directory names skipped while walking a docs tree (build/vcs noise). */
|
|
802
|
+
const DOC_DIR_SKIP = /* @__PURE__ */ new Set([
|
|
803
|
+
"node_modules",
|
|
804
|
+
".git",
|
|
805
|
+
".svn",
|
|
806
|
+
".hg"
|
|
807
|
+
]);
|
|
808
|
+
/**
|
|
809
|
+
* Recursively walk a docs directory and read each Markdown/HTML file into a
|
|
810
|
+
* {@link DocInput} for setu's docs front-end. Mirrors {@link collectSourceFiles}'s
|
|
811
|
+
* safe-probe style:
|
|
812
|
+
*
|
|
813
|
+
* - `path` is the file path relative to `dir`, POSIX-normalized (forward slashes)
|
|
814
|
+
* with the extension stripped (`<dir>/guides/advanced.md` → `'guides/advanced'`,
|
|
815
|
+
* `<dir>/index.md` → `'index'`).
|
|
816
|
+
* - `content` is the raw UTF-8 text (frontmatter stays embedded — setu parses it).
|
|
817
|
+
* - `type` is `'markdown'` for `.md`/`.markdown`, `'html'` for `.html`/`.htm`.
|
|
818
|
+
*
|
|
819
|
+
* Resilient by design: a missing/unreadable directory yields `[]` (never throws);
|
|
820
|
+
* dotfiles/dot-dirs and `node_modules`-like noise are skipped; a single
|
|
821
|
+
* unreadable file is warned about and skipped. Results are sorted by `path` so
|
|
822
|
+
* the output is stable build-to-build. Setu does no I/O — this is the only place
|
|
823
|
+
* the docs tree is read.
|
|
824
|
+
*/
|
|
669
825
|
async function collectDocs(dir) {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
826
|
+
if (typeof dir !== "string" || dir.trim().length === 0) return [];
|
|
827
|
+
const root = (0, node_path.resolve)(dir);
|
|
828
|
+
const docs = [];
|
|
829
|
+
const walk = async (absDir, relPrefix) => {
|
|
830
|
+
let entries;
|
|
831
|
+
try {
|
|
832
|
+
entries = await (0, node_fs_promises.readdir)(absDir, { withFileTypes: true });
|
|
833
|
+
} catch {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
for (const entry of entries) {
|
|
837
|
+
const name = entry.name;
|
|
838
|
+
if (name.startsWith(".")) continue;
|
|
839
|
+
if (entry.isDirectory()) {
|
|
840
|
+
if (DOC_DIR_SKIP.has(name)) continue;
|
|
841
|
+
await walk((0, node_path.join)(absDir, name), relPrefix ? `${relPrefix}/${name}` : name);
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
if (!entry.isFile()) continue;
|
|
845
|
+
const ext = (0, node_path.extname)(name).toLowerCase();
|
|
846
|
+
const type = DOC_EXTENSIONS.get(ext);
|
|
847
|
+
if (!type) continue;
|
|
848
|
+
const abs = (0, node_path.join)(absDir, name);
|
|
849
|
+
const stem = name.slice(0, name.length - ext.length);
|
|
850
|
+
const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
|
|
851
|
+
try {
|
|
852
|
+
const content = await (0, node_fs_promises.readFile)(abs, "utf8");
|
|
853
|
+
docs.push({
|
|
854
|
+
path: relPath,
|
|
855
|
+
content,
|
|
856
|
+
type
|
|
857
|
+
});
|
|
858
|
+
} catch (err) {
|
|
859
|
+
console.warn(`clean-jsdoc-theme: could not read doc file '${abs}' — ${err.message}; skipping.`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
await walk(root, "");
|
|
864
|
+
docs.sort((a, b) => a.path.localeCompare(b.path));
|
|
865
|
+
return docs;
|
|
708
866
|
}
|
|
709
|
-
|
|
710
|
-
|
|
867
|
+
/** Markdown image: captures ``. */
|
|
868
|
+
const DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
|
|
869
|
+
/**
|
|
870
|
+
* HTML image: captures the `<img …src=` prefix (through the opening quote), the
|
|
871
|
+
* quote char, the src value, and the closing quote (a backreference to the
|
|
872
|
+
* opener). JSDoc's `plugins/markdown` renders a comment's `` to
|
|
873
|
+
* `<img src="…" alt="…">`, and prose can embed raw `<img>`; this matches both
|
|
874
|
+
* quote styles wherever `src` sits in the tag.
|
|
875
|
+
*/
|
|
876
|
+
const HTML_IMAGE_RE = /(<img\b[^>]*?\bsrc\s*=\s*(["']))([^"']*)(\2)/gi;
|
|
711
877
|
function createImageCollector(staticDirs = []) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
878
|
+
const files = [];
|
|
879
|
+
const inlineSvgs = {};
|
|
880
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
881
|
+
const seenServed = /* @__PURE__ */ new Set();
|
|
882
|
+
const cache = /* @__PURE__ */ new Map();
|
|
883
|
+
const warnedMisses = /* @__PURE__ */ new Set();
|
|
884
|
+
const resolve = async (rawSrc, baseDir) => {
|
|
885
|
+
const src = rawSrc.trim();
|
|
886
|
+
if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
|
|
887
|
+
const candidates = [src.startsWith("/") ? (0, node_path.resolve)(src.slice(1)) : (0, node_path.resolve)(baseDir, src)];
|
|
888
|
+
if (staticDirs.length > 0) {
|
|
889
|
+
const outName = src.replace(/^\/+/, "");
|
|
890
|
+
if (outName) for (const dir of staticDirs) candidates.push((0, node_path.resolve)(dir, outName));
|
|
891
|
+
}
|
|
892
|
+
for (const abs of candidates) {
|
|
893
|
+
const cached = cache.get(abs);
|
|
894
|
+
if (cached !== void 0) {
|
|
895
|
+
if (cached) return cached;
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
let bytes;
|
|
899
|
+
try {
|
|
900
|
+
bytes = await (0, node_fs_promises.readFile)(abs);
|
|
901
|
+
} catch {
|
|
902
|
+
cache.set(abs, null);
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
const ext = (0, node_path.extname)(abs);
|
|
906
|
+
const served = `_assets/${(0, node_path.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
|
|
907
|
+
if (!seenServed.has(served)) {
|
|
908
|
+
seenServed.add(served);
|
|
909
|
+
files.push({
|
|
910
|
+
path: served,
|
|
911
|
+
contents: bytes
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
const href = "/" + served;
|
|
915
|
+
if (ext.toLowerCase() === ".svg") inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, "<svg style=\"max-width:100%;height:auto;display:block\"");
|
|
916
|
+
cache.set(abs, href);
|
|
917
|
+
consumed.add(abs);
|
|
918
|
+
return href;
|
|
919
|
+
}
|
|
920
|
+
if (!warnedMisses.has(src)) {
|
|
921
|
+
warnedMisses.add(src);
|
|
922
|
+
console.warn(`clean-jsdoc-theme: could not read image '${src}' (looked in: ${candidates.join(", ")}); leaving it as-is.`);
|
|
923
|
+
}
|
|
924
|
+
return null;
|
|
925
|
+
};
|
|
926
|
+
return {
|
|
927
|
+
resolve,
|
|
928
|
+
files,
|
|
929
|
+
inlineSvgs,
|
|
930
|
+
consumed
|
|
931
|
+
};
|
|
763
932
|
}
|
|
764
|
-
|
|
933
|
+
/**
|
|
934
|
+
* Rewrite the local image references in `content` to their content-hashed
|
|
935
|
+
* `/_assets/…` paths, routing each through `collector`. Handles BOTH Markdown
|
|
936
|
+
* `` and raw HTML `<img src="…">` (JSDoc renders comment/tutorial
|
|
937
|
+
* images to the latter), so prose in either form is covered. Relative srcs
|
|
938
|
+
* resolve against `baseDir`, `/`-rooted srcs against the project root, and
|
|
939
|
+
* external/`data:`/anchor srcs are left untouched. Returns the original string
|
|
940
|
+
* unchanged when nothing was rewritten.
|
|
941
|
+
*/
|
|
942
|
+
/**
|
|
943
|
+
* Char ranges of Markdown/HTML **code** regions — fenced blocks (` ``` `/`~~~`),
|
|
944
|
+
* HTML `<pre>`/`<code>`, and inline backtick spans. Image references inside these
|
|
945
|
+
* are literal example syntax an author is *documenting*, not real images, so the
|
|
946
|
+
* rewriter skips them (no spurious copy/rewrite, no "could not read" warning).
|
|
947
|
+
* Order matters: the multi-line block forms come before the inline span so a
|
|
948
|
+
* fence isn't chopped at its first inner backtick.
|
|
949
|
+
*/
|
|
950
|
+
const CODE_REGION_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[^>]*>[\s\S]*?<\/code>|`[^`\n]+`/gi;
|
|
951
|
+
/** Collect the [start, end) char ranges of code regions in `content`. */
|
|
765
952
|
function codeRanges(content) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
return ranges;
|
|
953
|
+
const ranges = [];
|
|
954
|
+
for (const m of content.matchAll(CODE_REGION_RE)) if (m.index !== void 0) ranges.push([m.index, m.index + m[0].length]);
|
|
955
|
+
return ranges;
|
|
771
956
|
}
|
|
957
|
+
/** Whether char offset `idx` falls inside any of the (sorted-ish) code ranges. */
|
|
772
958
|
function indexInCode(idx, ranges) {
|
|
773
|
-
|
|
774
|
-
|
|
959
|
+
for (const [s, e] of ranges) if (idx >= s && idx < e) return true;
|
|
960
|
+
return false;
|
|
775
961
|
}
|
|
776
962
|
async function rewriteImageRefs(content, baseDir, collector) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
DOC_IMAGE_RE,
|
|
794
|
-
(full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full
|
|
795
|
-
).replace(
|
|
796
|
-
HTML_IMAGE_RE,
|
|
797
|
-
(full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full
|
|
798
|
-
);
|
|
963
|
+
if (!content) return content;
|
|
964
|
+
const ranges = codeRanges(content);
|
|
965
|
+
const map = /* @__PURE__ */ new Map();
|
|
966
|
+
const collect = async (re, srcGroup) => {
|
|
967
|
+
for (const m of content.matchAll(re)) {
|
|
968
|
+
if (m.index !== void 0 && indexInCode(m.index, ranges)) continue;
|
|
969
|
+
const src = m[srcGroup];
|
|
970
|
+
if (map.has(src)) continue;
|
|
971
|
+
const href = await collector.resolve(src, baseDir);
|
|
972
|
+
if (href) map.set(src, href);
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
await collect(DOC_IMAGE_RE, 2);
|
|
976
|
+
await collect(HTML_IMAGE_RE, 3);
|
|
977
|
+
if (map.size === 0) return content;
|
|
978
|
+
return content.replace(DOC_IMAGE_RE, (full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full).replace(HTML_IMAGE_RE, (full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full);
|
|
799
979
|
}
|
|
980
|
+
/**
|
|
981
|
+
* Resolve the local images a doc references and route them through the shared
|
|
982
|
+
* content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
|
|
983
|
+
* `` / `<img src>` whose `src` points to a file on disk is copied and
|
|
984
|
+
* its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
985
|
+
* `MdxImg` adds the base path, like it does for links), resolved relative to the
|
|
986
|
+
* project root when it starts with `/`, else relative to the doc's own directory.
|
|
987
|
+
* Returns the docs with rewritten content plus the asset files to write. The
|
|
988
|
+
* bridge is the I/O layer here, so setu/dwar only ever see the final `_assets/`
|
|
989
|
+
* paths.
|
|
990
|
+
*/
|
|
800
991
|
async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
992
|
+
if (docs.length === 0) return {
|
|
993
|
+
docs,
|
|
994
|
+
files: collector.files,
|
|
995
|
+
inlineSvgs: collector.inlineSvgs
|
|
996
|
+
};
|
|
997
|
+
const root = (0, node_path.resolve)(docsDir);
|
|
998
|
+
const out = [];
|
|
999
|
+
for (const doc of docs) {
|
|
1000
|
+
const docDir = (0, node_path.dirname)((0, node_path.resolve)(root, doc.path));
|
|
1001
|
+
const content = await rewriteImageRefs(doc.content, docDir, collector);
|
|
1002
|
+
out.push(content === doc.content ? doc : {
|
|
1003
|
+
...doc,
|
|
1004
|
+
content
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
docs: out,
|
|
1009
|
+
files: collector.files,
|
|
1010
|
+
inlineSvgs: collector.inlineSvgs
|
|
1011
|
+
};
|
|
810
1012
|
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Resolve the local images referenced by tutorial content, routing them through
|
|
1015
|
+
* the shared `collector` (the same content-hashed `_assets/` pipeline as docs).
|
|
1016
|
+
* JSDoc reads every tutorial from a single directory, so each tutorial's relative
|
|
1017
|
+
* srcs (``, `<img src>`) resolve against `tutorialsDir`. Walks
|
|
1018
|
+
* the resolved tree (sub-tutorials included), rewriting each node's content —
|
|
1019
|
+
* Markdown or HTML; the tree shape is preserved. Returns a new tree (the input is
|
|
1020
|
+
* left untouched). Exported for testing.
|
|
1021
|
+
*/
|
|
811
1022
|
async function resolveTutorialImages(tree, tutorialsDir, collector) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
1023
|
+
const base = (0, node_path.resolve)(tutorialsDir);
|
|
1024
|
+
const walk = async (node) => {
|
|
1025
|
+
const content = await rewriteImageRefs(node.content, base, collector);
|
|
1026
|
+
const children = [];
|
|
1027
|
+
for (const child of node.children ?? []) children.push(await walk(child));
|
|
1028
|
+
return {
|
|
1029
|
+
...node,
|
|
1030
|
+
content,
|
|
1031
|
+
children
|
|
1032
|
+
};
|
|
1033
|
+
};
|
|
1034
|
+
const out = [];
|
|
1035
|
+
for (const node of tree) out.push(await walk(node));
|
|
1036
|
+
return out;
|
|
822
1037
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1038
|
+
/**
|
|
1039
|
+
* Doclet keys whose string values are raw source/code/meta, NOT rendered prose —
|
|
1040
|
+
* never scanned for images (a stray `<img`/`![` there must not be rewritten).
|
|
1041
|
+
*/
|
|
1042
|
+
const DOCLET_IMAGE_SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
1043
|
+
"meta",
|
|
1044
|
+
"comment",
|
|
1045
|
+
"examples",
|
|
1046
|
+
"tags",
|
|
1047
|
+
"___id",
|
|
1048
|
+
"___s"
|
|
830
1049
|
]);
|
|
1050
|
+
/**
|
|
1051
|
+
* Recursively rewrite the `<img>`/`![]()` image srcs in every prose string
|
|
1052
|
+
* reachable from a doclet object, resolving against `baseDir`. Only strings that
|
|
1053
|
+
* actually carry an image marker (`<img` or `![`) are touched — a cheap guard so
|
|
1054
|
+
* names/identifiers/code are never scanned — and raw/code keys
|
|
1055
|
+
* ({@link DOCLET_IMAGE_SKIP_KEYS}) are skipped entirely. Recurses into nested
|
|
1056
|
+
* objects/arrays (e.g. `params[].description`). Mutates `node` in place.
|
|
1057
|
+
*/
|
|
831
1058
|
async function rewriteDocletStrings(node, baseDir, collector) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
} else if (value && typeof value === "object") {
|
|
852
|
-
await rewriteDocletStrings(value, baseDir, collector);
|
|
853
|
-
}
|
|
854
|
-
}
|
|
1059
|
+
for (const [key, value] of Object.entries(node)) {
|
|
1060
|
+
if (DOCLET_IMAGE_SKIP_KEYS.has(key)) continue;
|
|
1061
|
+
if (typeof value === "string") {
|
|
1062
|
+
if (value.includes("<img") || value.includes("![")) {
|
|
1063
|
+
const rewritten = await rewriteImageRefs(value, baseDir, collector);
|
|
1064
|
+
if (rewritten !== value) node[key] = rewritten;
|
|
1065
|
+
}
|
|
1066
|
+
} else if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
|
|
1067
|
+
const item = value[i];
|
|
1068
|
+
if (typeof item === "string") {
|
|
1069
|
+
if (item.includes("<img") || item.includes("![")) {
|
|
1070
|
+
const rewritten = await rewriteImageRefs(item, baseDir, collector);
|
|
1071
|
+
if (rewritten !== item) value[i] = rewritten;
|
|
1072
|
+
}
|
|
1073
|
+
} else if (item && typeof item === "object") await rewriteDocletStrings(item, baseDir, collector);
|
|
1074
|
+
}
|
|
1075
|
+
else if (value && typeof value === "object") await rewriteDocletStrings(value, baseDir, collector);
|
|
1076
|
+
}
|
|
855
1077
|
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Resolve the local images referenced inside JSDoc-comment prose (doclet
|
|
1080
|
+
* descriptions, `@classdesc`, nested `@param`/`@property`/`@returns`
|
|
1081
|
+
* descriptions, …) and route them through the shared `collector`. JSDoc's
|
|
1082
|
+
* `plugins/markdown` has already turned a comment's `` into
|
|
1083
|
+
* an HTML `<img src="../img/x.png">` by the time `publish` runs, so each src is
|
|
1084
|
+
* resolved **relative to that doclet's own source file** (`meta.path` — the
|
|
1085
|
+
* directory of the file the comment lives in). Doclets are mutated IN PLACE:
|
|
1086
|
+
* salty's `get()` hands out live object references, so the rewrite is visible
|
|
1087
|
+
* when setu later reads the same collection. Resilient — a non-collection `data`
|
|
1088
|
+
* or unreadable image is skipped (the latter warned), never fatal.
|
|
1089
|
+
*/
|
|
856
1090
|
async function resolveDocletImages(data, collector) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1091
|
+
if (typeof data !== "function") return;
|
|
1092
|
+
let doclets = [];
|
|
1093
|
+
try {
|
|
1094
|
+
doclets = data({}).get();
|
|
1095
|
+
} catch {
|
|
1096
|
+
try {
|
|
1097
|
+
doclets = data().get();
|
|
1098
|
+
} catch {
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (!Array.isArray(doclets)) return;
|
|
1103
|
+
for (const d of doclets) {
|
|
1104
|
+
if (!d || typeof d !== "object") continue;
|
|
1105
|
+
const meta = d.meta;
|
|
1106
|
+
if (!meta || typeof meta.path !== "string" || meta.path.length === 0) continue;
|
|
1107
|
+
await rewriteDocletStrings(d, meta.path, collector);
|
|
1108
|
+
}
|
|
875
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Normalize a raw `staticFiles` block into a {@link StaticFilesConfig}, or
|
|
1112
|
+
* `undefined` when there's nothing to include. `include`/`exclude` accept a
|
|
1113
|
+
* string or string[]; patterns are kept as source strings (compiled later, so a
|
|
1114
|
+
* bad pattern fails open rather than throwing). Pure + exported for testing.
|
|
1115
|
+
*/
|
|
876
1116
|
function normalizeStaticFilesConfig(raw) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1117
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
1118
|
+
const o = raw;
|
|
1119
|
+
const toStrArr = (v) => (Array.isArray(v) ? v : typeof v === "string" ? [v] : []).filter((s) => typeof s === "string" && s.trim().length > 0).map((s) => s.trim());
|
|
1120
|
+
const include = toStrArr(o.include);
|
|
1121
|
+
if (include.length === 0) return void 0;
|
|
1122
|
+
const includePattern = typeof o.includePattern === "string" && o.includePattern.trim().length > 0 ? o.includePattern : void 0;
|
|
1123
|
+
const excludePattern = typeof o.excludePattern === "string" && o.excludePattern.trim().length > 0 ? o.excludePattern : void 0;
|
|
1124
|
+
return {
|
|
1125
|
+
include,
|
|
1126
|
+
exclude: toStrArr(o.exclude),
|
|
1127
|
+
...includePattern ? { includePattern } : {},
|
|
1128
|
+
...excludePattern ? { excludePattern } : {}
|
|
1129
|
+
};
|
|
890
1130
|
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Read `templates.default.staticFiles` from JSDoc's canonical `jsdoc/env` conf
|
|
1133
|
+
* (the only place the root-level `templates` block lives at runtime), falling
|
|
1134
|
+
* back to a nested `opts.templates.default.staticFiles`. Mirrors the probe order
|
|
1135
|
+
* of {@link outputSourceFilesEnabled}. Returns `undefined` when unset/unusable.
|
|
1136
|
+
*/
|
|
891
1137
|
function readStaticFilesConfig(opts) {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
|
|
1138
|
+
try {
|
|
1139
|
+
const fromEnv = normalizeStaticFilesConfig(require("jsdoc/env")?.conf?.templates?.default?.staticFiles);
|
|
1140
|
+
if (fromEnv) return fromEnv;
|
|
1141
|
+
} catch {}
|
|
1142
|
+
return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
|
|
899
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Output-relative path (POSIX) for a static file under an include root: strip the
|
|
1146
|
+
* resolved-root prefix so `<root>/img/sub/x.png` under root `<root>/img` →
|
|
1147
|
+
* `sub/x.png` (JSDoc maps an include dir's contents to the output ROOT). When the
|
|
1148
|
+
* include was a single FILE (`absFile === includeRootAbs`), the output name is its
|
|
1149
|
+
* basename. Windows-aware: separators are normalized and the prefix match is
|
|
1150
|
+
* case-insensitive (NTFS). Pure + exported for testing.
|
|
1151
|
+
*/
|
|
900
1152
|
function staticFileOutputName(absFile, includeRootAbs) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1153
|
+
const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
1154
|
+
const f = norm(absFile);
|
|
1155
|
+
const root = norm(includeRootAbs);
|
|
1156
|
+
const baseOf = (p) => p.slice(p.lastIndexOf("/") + 1);
|
|
1157
|
+
if (f === root) return baseOf(f);
|
|
1158
|
+
const prefix = root + "/";
|
|
1159
|
+
return f.toLowerCase().startsWith(prefix.toLowerCase()) ? f.slice(prefix.length) : baseOf(f);
|
|
908
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Whether a static file passes a config's filter — `includePattern` (must match),
|
|
1163
|
+
* `excludePattern` (must not match), and `exclude` (file equal to, or nested
|
|
1164
|
+
* under, an excluded path is dropped). Patterns are tested against the file's
|
|
1165
|
+
* POSIX-normalized absolute path; a malformed pattern fails open (ignored). Pure
|
|
1166
|
+
* + exported for testing.
|
|
1167
|
+
*/
|
|
909
1168
|
function staticFileIncluded(absFile, config) {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
for (const ex of config.exclude) {
|
|
925
|
-
const exAbs = norm(ex);
|
|
926
|
-
if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
|
|
927
|
-
}
|
|
928
|
-
return true;
|
|
1169
|
+
const norm = (p) => (0, node_path.resolve)(p).replace(/\\/g, "/");
|
|
1170
|
+
const fn = norm(absFile);
|
|
1171
|
+
if (config.includePattern) try {
|
|
1172
|
+
if (!new RegExp(config.includePattern).test(fn)) return false;
|
|
1173
|
+
} catch {}
|
|
1174
|
+
if (config.excludePattern) try {
|
|
1175
|
+
if (new RegExp(config.excludePattern).test(fn)) return false;
|
|
1176
|
+
} catch {}
|
|
1177
|
+
for (const ex of config.exclude) {
|
|
1178
|
+
const exAbs = norm(ex);
|
|
1179
|
+
if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
|
|
1180
|
+
}
|
|
1181
|
+
return true;
|
|
929
1182
|
}
|
|
930
|
-
|
|
1183
|
+
/** Directory names skipped while walking a staticFiles tree (build/vcs noise). */
|
|
1184
|
+
const STATIC_DIR_SKIP = /* @__PURE__ */ new Set([
|
|
1185
|
+
"node_modules",
|
|
1186
|
+
".git",
|
|
1187
|
+
".svn",
|
|
1188
|
+
".hg"
|
|
1189
|
+
]);
|
|
1190
|
+
/**
|
|
1191
|
+
* Collect the files matched by a {@link StaticFilesConfig}: walk each include
|
|
1192
|
+
* path (a directory recursively, or a single file), apply
|
|
1193
|
+
* {@link staticFileIncluded}, and read each match. Returns the verbatim copy
|
|
1194
|
+
* entries (output path = include-root-stripped, JSDoc's "contents → output root"
|
|
1195
|
+
* mapping) plus the resolved `searchDirs` the image resolver uses as fallback
|
|
1196
|
+
* roots (an include dir as-is; a file include's parent dir). Resilient: a missing
|
|
1197
|
+
* include path / unreadable file is warned + skipped, never fatal. Exported for
|
|
1198
|
+
* testing.
|
|
1199
|
+
*/
|
|
931
1200
|
async function collectStaticFiles(config, warn = (m) => console.warn(m)) {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1201
|
+
const files = [];
|
|
1202
|
+
const searchDirs = /* @__PURE__ */ new Set();
|
|
1203
|
+
const seenOutput = /* @__PURE__ */ new Set();
|
|
1204
|
+
for (const inc of config.include) {
|
|
1205
|
+
const root = (0, node_path.resolve)(inc);
|
|
1206
|
+
let st;
|
|
1207
|
+
try {
|
|
1208
|
+
st = await (0, node_fs_promises.stat)(root);
|
|
1209
|
+
} catch {
|
|
1210
|
+
warn(`clean-jsdoc-theme: staticFiles include '${inc}' (resolved '${root}') was not found; skipping it.`);
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if (st.isDirectory()) {
|
|
1214
|
+
searchDirs.add(root);
|
|
1215
|
+
const walk = async (absDir) => {
|
|
1216
|
+
let entries;
|
|
1217
|
+
try {
|
|
1218
|
+
entries = await (0, node_fs_promises.readdir)(absDir, { withFileTypes: true });
|
|
1219
|
+
} catch {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
for (const entry of entries) {
|
|
1223
|
+
if (entry.name.startsWith(".")) continue;
|
|
1224
|
+
const abs = (0, node_path.join)(absDir, entry.name);
|
|
1225
|
+
if (entry.isDirectory()) {
|
|
1226
|
+
if (!STATIC_DIR_SKIP.has(entry.name)) await walk(abs);
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
if (!entry.isFile()) continue;
|
|
1230
|
+
if (!staticFileIncluded(abs, config)) continue;
|
|
1231
|
+
const outputPath = staticFileOutputName(abs, root);
|
|
1232
|
+
if (seenOutput.has(outputPath)) continue;
|
|
1233
|
+
let contents;
|
|
1234
|
+
try {
|
|
1235
|
+
contents = await (0, node_fs_promises.readFile)(abs);
|
|
1236
|
+
} catch (err) {
|
|
1237
|
+
warn(`clean-jsdoc-theme: could not read static file '${abs}' — ${err.message}; skipping.`);
|
|
1238
|
+
continue;
|
|
1239
|
+
}
|
|
1240
|
+
seenOutput.add(outputPath);
|
|
1241
|
+
files.push({
|
|
1242
|
+
outputPath,
|
|
1243
|
+
absSource: (0, node_path.resolve)(abs),
|
|
1244
|
+
contents
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
await walk(root);
|
|
1249
|
+
} else if (st.isFile()) {
|
|
1250
|
+
searchDirs.add((0, node_path.dirname)(root));
|
|
1251
|
+
if (!staticFileIncluded(root, config)) continue;
|
|
1252
|
+
const outputPath = staticFileOutputName(root, root);
|
|
1253
|
+
if (!seenOutput.has(outputPath)) try {
|
|
1254
|
+
const contents = await (0, node_fs_promises.readFile)(root);
|
|
1255
|
+
seenOutput.add(outputPath);
|
|
1256
|
+
files.push({
|
|
1257
|
+
outputPath,
|
|
1258
|
+
absSource: (0, node_path.resolve)(root),
|
|
1259
|
+
contents
|
|
1260
|
+
});
|
|
1261
|
+
} catch (err) {
|
|
1262
|
+
warn(`clean-jsdoc-theme: could not read static file '${root}' — ${err.message}; skipping.`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
files.sort((a, b) => a.outputPath.localeCompare(b.outputPath));
|
|
1267
|
+
return {
|
|
1268
|
+
files,
|
|
1269
|
+
searchDirs: [...searchDirs]
|
|
1270
|
+
};
|
|
999
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Overlay a locale's resolved docs over the default set (the per-locale docs
|
|
1274
|
+
* track). A locale page WINS over the default page with the same `path`; a
|
|
1275
|
+
* default page absent from the locale falls back (stays). Image asset files are
|
|
1276
|
+
* deduped by served path (same content-hashed name → one copy), and inline SVGs
|
|
1277
|
+
* merge locale-over-default. Output docs are re-sorted by `path` so the manifest
|
|
1278
|
+
* stays stable regardless of merge order. Pure — the I/O already happened in the
|
|
1279
|
+
* two {@link resolveDocImages} calls that produced `base`/`locale`.
|
|
1280
|
+
*/
|
|
1000
1281
|
function overlayDocs(base, locale) {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1282
|
+
const byPath = new Map(base.docs.map((d) => [d.path, d]));
|
|
1283
|
+
for (const d of locale.docs) byPath.set(d.path, d);
|
|
1284
|
+
const filesByPath = /* @__PURE__ */ new Map();
|
|
1285
|
+
for (const f of [...base.files, ...locale.files]) filesByPath.set(f.path, f);
|
|
1286
|
+
return {
|
|
1287
|
+
docs: [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path)),
|
|
1288
|
+
files: [...filesByPath.values()],
|
|
1289
|
+
inlineSvgs: {
|
|
1290
|
+
...base.inlineSvgs,
|
|
1291
|
+
...locale.inlineSvgs
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1010
1294
|
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
|
|
1297
|
+
* to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
|
|
1298
|
+
* accepts only an array; trims string entries and drops non-strings/empties.
|
|
1299
|
+
*/
|
|
1011
1300
|
function normalizeDocGroups(raw) {
|
|
1012
|
-
|
|
1301
|
+
return normalizeSectionOrder(raw);
|
|
1013
1302
|
}
|
|
1303
|
+
/** Format an elapsed-ms span compactly: `840ms` under a second, else `5.2s`. */
|
|
1014
1304
|
function formatElapsed(ms) {
|
|
1015
|
-
|
|
1305
|
+
return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
|
|
1016
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Build-stage narrator backed by `ora`. The setu→dwar pipeline does much more
|
|
1309
|
+
* than a bare jsdoc run (per-page MDX compile, per-island esbuild bundling, the
|
|
1310
|
+
* Pagefind index), so a 7–8s build can otherwise look hung. `stage(label, fn)`
|
|
1311
|
+
* starts an ora spinner, runs `fn`, then resolves it to `✔ <label> (<elapsed>)`
|
|
1312
|
+
* on success or `✖ <label>` on failure. ora handles the spinner animation, TTY
|
|
1313
|
+
* detection (no animation when piped/CI), and the success/fail symbols.
|
|
1314
|
+
*
|
|
1315
|
+
* The catch: ora animates its frame on a `setInterval`, but each stage does
|
|
1316
|
+
* heavy *synchronous* work (module evaluation during the dynamic `import()`,
|
|
1317
|
+
* per-page MDX compile/SSR) that blocks the event loop — so the interval can't
|
|
1318
|
+
* fire and the spinner freezes on one frame, looking hung. Two things keep it
|
|
1319
|
+
* visibly alive: an elapsed-seconds **heartbeat** appended to the label (so it
|
|
1320
|
+
* advances whenever the loop breathes — module-graph I/O gaps, esbuild/Pagefind
|
|
1321
|
+
* subprocess waits), and the `setText` handle, which long stages use to report
|
|
1322
|
+
* their current sub-step (e.g. the renderer load steps setu → dwar → utils).
|
|
1323
|
+
*
|
|
1324
|
+
* `ora` is `null` when progress is disabled (`opts.progress === false`) or the
|
|
1325
|
+
* package couldn't be loaded — then `stage` just runs `fn` with no output.
|
|
1326
|
+
*/
|
|
1017
1327
|
function createBuildProgress(ora) {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
return { stage };
|
|
1328
|
+
async function stage(label, fn) {
|
|
1329
|
+
const noop = { setText: () => {} };
|
|
1330
|
+
if (!ora) return await fn(noop);
|
|
1331
|
+
const spinner = ora(label).start();
|
|
1332
|
+
const begin = Date.now();
|
|
1333
|
+
let current = label;
|
|
1334
|
+
const refresh = () => {
|
|
1335
|
+
const secs = Math.floor((Date.now() - begin) / 1e3);
|
|
1336
|
+
spinner.text = secs > 0 ? `${current} (${secs}s)` : current;
|
|
1337
|
+
};
|
|
1338
|
+
const heartbeat = setInterval(refresh, 1e3);
|
|
1339
|
+
if (typeof heartbeat.unref === "function") heartbeat.unref();
|
|
1340
|
+
const handle = { setText(text) {
|
|
1341
|
+
current = text;
|
|
1342
|
+
refresh();
|
|
1343
|
+
} };
|
|
1344
|
+
try {
|
|
1345
|
+
const result = await fn(handle);
|
|
1346
|
+
clearInterval(heartbeat);
|
|
1347
|
+
spinner.succeed(`${label} (${formatElapsed(Date.now() - begin)})`);
|
|
1348
|
+
return result;
|
|
1349
|
+
} catch (err) {
|
|
1350
|
+
clearInterval(heartbeat);
|
|
1351
|
+
spinner.fail(label);
|
|
1352
|
+
throw err;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
return { stage };
|
|
1049
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Read the localization build spec when `CLEAN_JSDOC_THEME_BUILD` points at one
|
|
1359
|
+
* (set by `aadesh build` per locale). When present, the theme stamps the API
|
|
1360
|
+
* translations and renders to the spec's `destination`/`basePath` instead of the
|
|
1361
|
+
* jsdoc.json values. Returns `null` for a normal (single-locale) build.
|
|
1362
|
+
*/
|
|
1050
1363
|
function readBuildSpec() {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
destination: spec.destination,
|
|
1068
|
-
basePath: spec.basePath,
|
|
1069
|
-
siteBasePath: typeof spec.siteBasePath === "string" ? spec.siteBasePath : "/",
|
|
1070
|
-
locales: Array.isArray(spec.locales) ? spec.locales : [],
|
|
1071
|
-
...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
|
|
1072
|
-
};
|
|
1364
|
+
const path = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
|
|
1365
|
+
if (!path) return null;
|
|
1366
|
+
const spec = JSON.parse((0, node_fs.readFileSync)(path, "utf8"));
|
|
1367
|
+
if (typeof spec.version === "number" && spec.version !== 1) throw new Error(`clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) — update clean-jsdoc-theme and aadesh together.`);
|
|
1368
|
+
if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") throw new Error(`clean-jsdoc-theme: malformed build spec at "${path}".`);
|
|
1369
|
+
return {
|
|
1370
|
+
locale: typeof spec.locale === "string" ? spec.locale : "",
|
|
1371
|
+
defaultLocale: typeof spec.defaultLocale === "string" ? spec.defaultLocale : "en",
|
|
1372
|
+
apiMessages: spec.apiMessages ?? {},
|
|
1373
|
+
chromeMessages: spec.chromeMessages ?? {},
|
|
1374
|
+
destination: spec.destination,
|
|
1375
|
+
basePath: spec.basePath,
|
|
1376
|
+
siteBasePath: typeof spec.siteBasePath === "string" ? spec.siteBasePath : "/",
|
|
1377
|
+
locales: Array.isArray(spec.locales) ? spec.locales : [],
|
|
1378
|
+
...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
|
|
1379
|
+
};
|
|
1073
1380
|
}
|
|
1074
1381
|
async function publish(data, opts, tutorials) {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
`clean-jsdoc-theme: staticFiles \u2014 copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + "."
|
|
1305
|
-
);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
const outputFiles = [...generatedFiles, ...staticOutputFiles];
|
|
1309
|
-
if (!buildSpec && cleanOutputDirEnabled(opts)) {
|
|
1310
|
-
await progress.stage(
|
|
1311
|
-
"Cleaning output",
|
|
1312
|
-
() => (0, import_promises2.rm)(absoluteDestination, { recursive: true, force: true })
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
1316
|
-
const zlib = await import("zlib");
|
|
1317
|
-
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
1318
|
-
console.log(
|
|
1319
|
-
formatBuildReport({
|
|
1320
|
-
files: outputFiles,
|
|
1321
|
-
stats: result.stats,
|
|
1322
|
-
destination,
|
|
1323
|
-
gzipSizer,
|
|
1324
|
-
color
|
|
1325
|
-
})
|
|
1326
|
-
);
|
|
1327
|
-
if (result.errors && result.errors.length > 0) {
|
|
1328
|
-
console.warn(
|
|
1329
|
-
`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`
|
|
1330
|
-
);
|
|
1331
|
-
for (const e of result.errors) {
|
|
1332
|
-
console.warn(formatRenderError(e));
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
if (result.warnings && result.warnings.length > 0) {
|
|
1336
|
-
console.warn(
|
|
1337
|
-
`clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`
|
|
1338
|
-
);
|
|
1339
|
-
for (const w of result.warnings) {
|
|
1340
|
-
console.warn(formatRenderError(w));
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
try {
|
|
1344
|
-
await progress.stage(
|
|
1345
|
-
"Indexing search (pagefind)",
|
|
1346
|
-
() => runPagefindAgainstDir(absoluteDestination)
|
|
1347
|
-
);
|
|
1348
|
-
} catch (err) {
|
|
1349
|
-
console.warn(`clean-jsdoc-theme: pagefind step skipped (optional) \u2014 ${err.message}`);
|
|
1350
|
-
}
|
|
1382
|
+
const buildSpec = readBuildSpec();
|
|
1383
|
+
const destination = buildSpec?.destination ?? opts.destination;
|
|
1384
|
+
if (!destination || typeof destination !== "string") throw new Error("clean-jsdoc-theme publish: opts.destination is required (set \"opts.destination\" in your jsdoc.json).");
|
|
1385
|
+
assertMarkdownPlugin();
|
|
1386
|
+
const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
|
|
1387
|
+
const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
|
|
1388
|
+
const tutorialsDir = typeof opts.tutorials === "string" && opts.tutorials.trim().length > 0 ? opts.tutorials.trim() : void 0;
|
|
1389
|
+
const staticCfg = readStaticFilesConfig(opts);
|
|
1390
|
+
const pkgPromise = resolvePkg(data, opts);
|
|
1391
|
+
const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
|
|
1392
|
+
const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
|
|
1393
|
+
const progress = createBuildProgress(opts.progress === false ? null : await loadOra());
|
|
1394
|
+
const [{ generateSite, stampSite }, { render, runPagefindAgainstDir }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics, warningsOnly, formatBuildReport, formatRenderError, normalizeBasePath, withBase, toExtractManifest, normalizeCollapsibleSidebarSections, unmatchedCollapsibleSections, topLevelSectionLabels, normalizeScrollbar }] = await progress.stage("Loading renderer", async ({ setText }) => {
|
|
1395
|
+
setText("Loading renderer (setu)");
|
|
1396
|
+
const setu = await loadSetu();
|
|
1397
|
+
setText("Loading renderer (dwar)");
|
|
1398
|
+
const dwar = await loadDwar();
|
|
1399
|
+
setText("Loading renderer (utils)");
|
|
1400
|
+
return [
|
|
1401
|
+
setu,
|
|
1402
|
+
dwar,
|
|
1403
|
+
await loadUtils()
|
|
1404
|
+
];
|
|
1405
|
+
});
|
|
1406
|
+
const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
|
|
1407
|
+
const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
|
|
1408
|
+
const fontResolver = createGoogleFontResolver();
|
|
1409
|
+
const { value, diagnostics } = await progress.stage("Validating options", () => validateThemeOpts({
|
|
1410
|
+
opts,
|
|
1411
|
+
fontResolver,
|
|
1412
|
+
unknownKeyPolicy: "suggest-typos",
|
|
1413
|
+
knownNonThemeKeys: JSDOC_OWN_OPTS
|
|
1414
|
+
}));
|
|
1415
|
+
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
1416
|
+
if (diagnostics.list.length > 0) {
|
|
1417
|
+
const formatted = formatDiagnostics(diagnostics, { color });
|
|
1418
|
+
if (strict && diagnostics.hasErrors()) {
|
|
1419
|
+
console.error(formatted);
|
|
1420
|
+
throw new Error("clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`.");
|
|
1421
|
+
}
|
|
1422
|
+
console.log(formatted);
|
|
1423
|
+
}
|
|
1424
|
+
const pkg = await pkgPromise;
|
|
1425
|
+
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
1426
|
+
const tutorialTree = normalizeTutorials(tutorials);
|
|
1427
|
+
const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
|
|
1428
|
+
const staticFiles = staticCfg ? await progress.stage("Reading static files", () => collectStaticFiles(staticCfg, (m) => console.warn(m))) : void 0;
|
|
1429
|
+
const images = createImageCollector(staticFiles?.searchDirs ?? []);
|
|
1430
|
+
const { sources, docs } = await progress.stage("Reading sources & docs", async () => {
|
|
1431
|
+
const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
|
|
1432
|
+
const base = docsDir ? await resolveDocImages(rawDocs, docsDir, images) : { docs: rawDocs };
|
|
1433
|
+
if (!buildSpec?.docsDir) return {
|
|
1434
|
+
sources: srcs,
|
|
1435
|
+
docs: base.docs
|
|
1436
|
+
};
|
|
1437
|
+
const locale = await resolveDocImages(await collectDocs(buildSpec.docsDir), buildSpec.docsDir, images);
|
|
1438
|
+
return {
|
|
1439
|
+
sources: srcs,
|
|
1440
|
+
docs: overlayDocs({
|
|
1441
|
+
docs: base.docs,
|
|
1442
|
+
files: [],
|
|
1443
|
+
inlineSvgs: {}
|
|
1444
|
+
}, {
|
|
1445
|
+
docs: locale.docs,
|
|
1446
|
+
files: [],
|
|
1447
|
+
inlineSvgs: {}
|
|
1448
|
+
}).docs
|
|
1449
|
+
};
|
|
1450
|
+
});
|
|
1451
|
+
const { tutorialTree: resolvedTutorials, readme: resolvedReadme } = await progress.stage("Resolving prose images", async () => {
|
|
1452
|
+
const tree = tutorialsDir && tutorialTree.length > 0 ? await resolveTutorialImages(tutorialTree, tutorialsDir, images) : tutorialTree;
|
|
1453
|
+
const md = readme ? await rewriteImageRefs(readme, process.cwd(), images) : readme;
|
|
1454
|
+
await resolveDocletImages(data, images);
|
|
1455
|
+
return {
|
|
1456
|
+
tutorialTree: tree,
|
|
1457
|
+
readme: md
|
|
1458
|
+
};
|
|
1459
|
+
});
|
|
1460
|
+
const imageFiles = images.files;
|
|
1461
|
+
const allInlineSvgs = images.inlineSvgs;
|
|
1462
|
+
const docGroups = normalizeDocGroups(opts.docGroups);
|
|
1463
|
+
const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
|
|
1464
|
+
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
1465
|
+
const menu = normalizeMenu(opts.menu);
|
|
1466
|
+
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
1467
|
+
const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
|
|
1468
|
+
collapsibleWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
|
|
1469
|
+
const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
|
|
1470
|
+
scrollbarWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
|
|
1471
|
+
const playground = normalizePlayground(opts.playground);
|
|
1472
|
+
const siteOptions = {
|
|
1473
|
+
...pkg ? { pkg } : {},
|
|
1474
|
+
...resolvedReadme ? { readme: resolvedReadme } : {},
|
|
1475
|
+
...resolvedTutorials.length > 0 ? { tutorials: resolvedTutorials } : {},
|
|
1476
|
+
...sources.length > 0 ? { sources } : {},
|
|
1477
|
+
...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
|
|
1478
|
+
...docs.length > 0 ? { docs } : {},
|
|
1479
|
+
...docGroups ? { docGroups } : {},
|
|
1480
|
+
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
1481
|
+
...sectionOrder ? { sectionOrder } : {},
|
|
1482
|
+
...menu ? { menu } : {},
|
|
1483
|
+
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
1484
|
+
...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
|
|
1485
|
+
...playground ? { playground: playground.site } : {}
|
|
1486
|
+
};
|
|
1487
|
+
const manifest = await progress.stage("Generating pages", () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions));
|
|
1488
|
+
if (Array.isArray(collapsibleSidebarSections)) {
|
|
1489
|
+
const present = topLevelSectionLabels(manifest.nav);
|
|
1490
|
+
const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
|
|
1491
|
+
if (unmatched.length > 0) console.warn(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
|
|
1492
|
+
}
|
|
1493
|
+
const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
|
|
1494
|
+
if (extractPath) {
|
|
1495
|
+
const target = (0, node_path.resolve)(extractPath);
|
|
1496
|
+
await progress.stage("Writing extract manifest", async () => {
|
|
1497
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(target), { recursive: true });
|
|
1498
|
+
await (0, node_fs_promises.writeFile)(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
|
|
1499
|
+
});
|
|
1500
|
+
console.log(`clean-jsdoc-theme: extract mode — wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
|
|
1504
|
+
const notGoogle = new Set(diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path));
|
|
1505
|
+
const fonts = { ...value.fonts };
|
|
1506
|
+
if (notGoogle.has("fonts.heading")) delete fonts.heading;
|
|
1507
|
+
if (notGoogle.has("fonts.body")) delete fonts.body;
|
|
1508
|
+
if (fonts.locales) {
|
|
1509
|
+
const cleaned = {};
|
|
1510
|
+
for (const [loc, set] of Object.entries(fonts.locales)) {
|
|
1511
|
+
const s = { ...set };
|
|
1512
|
+
if (notGoogle.has(`fonts.${loc}:heading`)) delete s.heading;
|
|
1513
|
+
if (notGoogle.has(`fonts.${loc}:body`)) delete s.body;
|
|
1514
|
+
cleaned[loc] = s;
|
|
1515
|
+
}
|
|
1516
|
+
fonts.locales = cleaned;
|
|
1517
|
+
}
|
|
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);
|
|
1522
|
+
const absoluteDestination = (0, node_path.resolve)(destination);
|
|
1523
|
+
const islandCacheDir = (0, node_path.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
1524
|
+
const result = await progress.stage("Rendering site", () => render(manifest, {
|
|
1525
|
+
theme: {
|
|
1526
|
+
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
1527
|
+
...customAssets.theme,
|
|
1528
|
+
...footer ? { footer } : {},
|
|
1529
|
+
...favicon ? { favicon: favicon.href } : {},
|
|
1530
|
+
...meta ? { meta } : {},
|
|
1531
|
+
...scrollbar ? { scrollbar } : {}
|
|
1532
|
+
},
|
|
1533
|
+
destination: absoluteDestination,
|
|
1534
|
+
islandCacheDir,
|
|
1535
|
+
inlineSvgs: allInlineSvgs,
|
|
1536
|
+
...value.siteUrl ? { siteUrl: value.siteUrl } : {},
|
|
1537
|
+
...value.llmsTxt ? { llmsTxt: value.llmsTxt } : {},
|
|
1538
|
+
...buildSpec ? { locale: {
|
|
1539
|
+
code: buildSpec.locale,
|
|
1540
|
+
defaultLocale: buildSpec.defaultLocale,
|
|
1541
|
+
messages: buildSpec.chromeMessages,
|
|
1542
|
+
siteBasePath: buildSpec.siteBasePath,
|
|
1543
|
+
locales: buildSpec.locales.map((l) => ({
|
|
1544
|
+
code: l.code,
|
|
1545
|
+
label: l.name ?? l.code
|
|
1546
|
+
}))
|
|
1547
|
+
} } : {}
|
|
1548
|
+
}));
|
|
1549
|
+
const generatedFiles = [
|
|
1550
|
+
...result.files,
|
|
1551
|
+
...logoFiles,
|
|
1552
|
+
...customAssets.files,
|
|
1553
|
+
...imageFiles,
|
|
1554
|
+
...favicon?.files ?? []
|
|
1555
|
+
];
|
|
1556
|
+
const staticOutputFiles = [];
|
|
1557
|
+
if (staticFiles) {
|
|
1558
|
+
const generatedPaths = new Set(generatedFiles.map((f) => f.path));
|
|
1559
|
+
const RESERVED_PREFIXES = [
|
|
1560
|
+
"_assets/",
|
|
1561
|
+
"_islands/",
|
|
1562
|
+
"pagefind/"
|
|
1563
|
+
];
|
|
1564
|
+
let skippedConsumed = 0;
|
|
1565
|
+
for (const f of staticFiles.files) {
|
|
1566
|
+
if (images.consumed.has(f.absSource)) {
|
|
1567
|
+
skippedConsumed++;
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
if (generatedPaths.has(f.outputPath) || RESERVED_PREFIXES.some((p) => f.outputPath.startsWith(p))) {
|
|
1571
|
+
console.warn(`clean-jsdoc-theme: static file '${f.outputPath}' would clobber generated output; skipping it.`);
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
staticOutputFiles.push({
|
|
1575
|
+
path: f.outputPath,
|
|
1576
|
+
contents: f.contents
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
if (staticFiles.files.length > 0) console.log(`clean-jsdoc-theme: staticFiles — copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + ".");
|
|
1580
|
+
}
|
|
1581
|
+
const outputFiles = [...generatedFiles, ...staticOutputFiles];
|
|
1582
|
+
if (!buildSpec && cleanOutputDirEnabled(opts)) await progress.stage("Cleaning output", () => (0, node_fs_promises.rm)(absoluteDestination, {
|
|
1583
|
+
recursive: true,
|
|
1584
|
+
force: true
|
|
1585
|
+
}));
|
|
1586
|
+
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
1587
|
+
const zlib = await import("node:zlib");
|
|
1588
|
+
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
1589
|
+
console.log(formatBuildReport({
|
|
1590
|
+
files: outputFiles,
|
|
1591
|
+
stats: result.stats,
|
|
1592
|
+
destination,
|
|
1593
|
+
gzipSizer,
|
|
1594
|
+
color
|
|
1595
|
+
}));
|
|
1596
|
+
const optsWarnings = warningsOnly(diagnostics);
|
|
1597
|
+
if (optsWarnings.list.length > 0) console.warn(formatDiagnostics(optsWarnings, { color }));
|
|
1598
|
+
if (result.errors && result.errors.length > 0) {
|
|
1599
|
+
console.warn(`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`);
|
|
1600
|
+
for (const e of result.errors) console.warn(formatRenderError(e));
|
|
1601
|
+
}
|
|
1602
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
1603
|
+
console.warn(`clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`);
|
|
1604
|
+
for (const w of result.warnings) console.warn(formatRenderError(w));
|
|
1605
|
+
}
|
|
1606
|
+
try {
|
|
1607
|
+
await progress.stage("Indexing search (pagefind)", () => runPagefindAgainstDir(absoluteDestination));
|
|
1608
|
+
} catch (err) {
|
|
1609
|
+
console.warn(`clean-jsdoc-theme: pagefind step skipped (optional) — ${err.message}`);
|
|
1610
|
+
}
|
|
1351
1611
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
});
|
|
1612
|
+
//#endregion
|
|
1613
|
+
exports.cleanOutputDirEnabled = cleanOutputDirEnabled;
|
|
1614
|
+
exports.collectDocs = collectDocs;
|
|
1615
|
+
exports.collectStaticFiles = collectStaticFiles;
|
|
1616
|
+
exports.computeRelPaths = computeRelPaths;
|
|
1617
|
+
exports.createImageCollector = createImageCollector;
|
|
1618
|
+
exports.hasMarkdownPlugin = hasMarkdownPlugin;
|
|
1619
|
+
exports.normalizeColors = normalizeColors;
|
|
1620
|
+
exports.normalizeCopyPage = normalizeCopyPage;
|
|
1621
|
+
exports.normalizeDocGroups = normalizeDocGroups;
|
|
1622
|
+
exports.normalizeMenu = normalizeMenu;
|
|
1623
|
+
exports.normalizeMeta = normalizeMeta;
|
|
1624
|
+
exports.normalizePageNav = normalizePageNav;
|
|
1625
|
+
exports.normalizePlayground = normalizePlayground;
|
|
1626
|
+
exports.normalizeSectionOrder = normalizeSectionOrder;
|
|
1627
|
+
exports.normalizeStaticFilesConfig = normalizeStaticFilesConfig;
|
|
1628
|
+
exports.outputSourceFilesEnabled = outputSourceFilesEnabled;
|
|
1629
|
+
exports.overlayDocs = overlayDocs;
|
|
1630
|
+
exports.publish = publish;
|
|
1631
|
+
exports.readStaticFilesConfig = readStaticFilesConfig;
|
|
1632
|
+
exports.resolveDocImages = resolveDocImages;
|
|
1633
|
+
exports.resolveDocletImages = resolveDocletImages;
|
|
1634
|
+
exports.resolveFavicon = resolveFavicon;
|
|
1635
|
+
exports.resolveFooter = resolveFooter;
|
|
1636
|
+
exports.resolveTutorialImages = resolveTutorialImages;
|
|
1637
|
+
exports.sourceLinkToCommentEnabled = sourceLinkToCommentEnabled;
|
|
1638
|
+
exports.staticFileIncluded = staticFileIncluded;
|
|
1639
|
+
exports.staticFileOutputName = staticFileOutputName;
|
|
1640
|
+
|
|
1382
1641
|
//# sourceMappingURL=publish.js.map
|