clean-jsdoc-theme 4.3.2 → 5.0.0-alpha.2
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/LICENSE +21 -21
- package/README.md +82 -625
- package/dist/publish.d.mts +287 -0
- package/dist/publish.d.ts +287 -0
- package/dist/publish.js +819 -0
- package/dist/publish.js.map +1 -0
- package/dist/publish.mjs +779 -0
- package/dist/publish.mjs.map +1 -0
- package/package.json +66 -55
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -43
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
- package/.github/dependabot.yml +0 -9
- package/.github/pull_request_template.md +0 -16
- package/.github/workflows/codeql.yml +0 -72
- package/.github/workflows/greetings.yml +0 -16
- package/.prettierignore +0 -2
- package/.prettierrc +0 -5
- package/.stylelintignore +0 -4
- package/.stylelintrc +0 -18
- package/.travis.yml +0 -30
- package/CHANGELOG.md +0 -260
- package/CODE_OF_CONDUCT.md +0 -76
- package/CODE_OF_CONDUCT_HINDI.md +0 -61
- package/CONTRIBUTING.md +0 -36
- package/SECURITY.md +0 -21
- package/clean-jsdoc-theme-defaults.js +0 -37
- package/clean-jsdoc-theme-helper.js +0 -186
- package/css-property-order-fix.js +0 -56
- package/helpers/Environment.html +0 -3
- package/helpers/down-arrow.js +0 -9
- package/jsdoc-config.json +0 -102
- package/minify.js +0 -72
- package/publish.js +0 -1110
- package/static/fonts/Inconsolata-Regular.ttf +0 -0
- package/static/fonts/OpenSans-Regular.ttf +0 -0
- package/static/fonts/WorkSans-Bold.ttf +0 -0
- package/static/scripts/core.js +0 -726
- package/static/scripts/core.min.js +0 -23
- package/static/scripts/resize.js +0 -90
- package/static/scripts/search.js +0 -265
- package/static/scripts/search.min.js +0 -6
- package/static/scripts/third-party/Apache-License-2.0.txt +0 -202
- package/static/scripts/third-party/fuse.js +0 -9
- package/static/scripts/third-party/hljs-line-num-original.js +0 -369
- package/static/scripts/third-party/hljs-line-num.js +0 -1
- package/static/scripts/third-party/hljs-original.js +0 -5171
- package/static/scripts/third-party/hljs.js +0 -1
- package/static/scripts/third-party/popper.js +0 -5
- package/static/scripts/third-party/tippy.js +0 -1
- package/static/scripts/third-party/tocbot.js +0 -672
- package/static/scripts/third-party/tocbot.min.js +0 -1
- package/static/styles/clean-jsdoc-theme-base.css +0 -1159
- package/static/styles/clean-jsdoc-theme-dark.css +0 -412
- package/static/styles/clean-jsdoc-theme-light.css +0 -482
- package/static/styles/clean-jsdoc-theme-scrollbar.css +0 -30
- package/static/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -1
- package/static/styles/clean-jsdoc-theme.min.css +0 -1
- package/tmpl/augments.tmpl +0 -10
- package/tmpl/container.tmpl +0 -208
- package/tmpl/details.tmpl +0 -207
- package/tmpl/example.tmpl +0 -3
- package/tmpl/examples.tmpl +0 -48
- package/tmpl/exceptions.tmpl +0 -32
- package/tmpl/icons.tmpl +0 -73
- package/tmpl/include-target-script-and-styles.tmpl +0 -43
- package/tmpl/layout.tmpl +0 -167
- package/tmpl/mainpage.tmpl +0 -10
- package/tmpl/members.tmpl +0 -42
- package/tmpl/method.tmpl +0 -175
- package/tmpl/mobile-sidebar.tmpl +0 -21
- package/tmpl/navbar-actions.tmpl +0 -19
- package/tmpl/navbar-menu.tmpl +0 -25
- package/tmpl/navbar.tmpl +0 -14
- package/tmpl/params.tmpl +0 -131
- package/tmpl/properties.tmpl +0 -109
- package/tmpl/returns.tmpl +0 -19
- package/tmpl/search.tmpl +0 -17
- package/tmpl/sidebar-items.tmpl +0 -24
- package/tmpl/sidebar-title.tmpl +0 -8
- package/tmpl/sidebar.tmpl +0 -9
- package/tmpl/source.tmpl +0 -13
- package/tmpl/toc.tmpl +0 -4
- package/tmpl/tutorial.tmpl +0 -32
- package/tmpl/type.tmpl +0 -13
package/dist/publish.js
ADDED
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
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
|
+
collectDocs: () => collectDocs,
|
|
34
|
+
computeRelPaths: () => computeRelPaths,
|
|
35
|
+
hasMarkdownPlugin: () => hasMarkdownPlugin,
|
|
36
|
+
normalizeColors: () => normalizeColors,
|
|
37
|
+
normalizeCopyPage: () => normalizeCopyPage,
|
|
38
|
+
normalizeDocGroups: () => normalizeDocGroups,
|
|
39
|
+
normalizeMenu: () => normalizeMenu,
|
|
40
|
+
normalizePageNav: () => normalizePageNav,
|
|
41
|
+
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
42
|
+
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
43
|
+
publish: () => publish,
|
|
44
|
+
resolveDocImages: () => resolveDocImages,
|
|
45
|
+
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(publish_exports);
|
|
48
|
+
var import_promises2 = require("fs/promises");
|
|
49
|
+
var import_node_fs = require("fs");
|
|
50
|
+
var import_node_crypto = require("crypto");
|
|
51
|
+
var import_node_path2 = require("path");
|
|
52
|
+
var import_node_url = require("url");
|
|
53
|
+
|
|
54
|
+
// src/write-output-files.ts
|
|
55
|
+
var import_promises = require("fs/promises");
|
|
56
|
+
var import_node_path = require("path");
|
|
57
|
+
async function writeOutputFiles(destination, files) {
|
|
58
|
+
for (const file of files) {
|
|
59
|
+
const target = (0, import_node_path.join)(destination, file.path);
|
|
60
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(target), { recursive: true });
|
|
61
|
+
const contents = typeof file.contents === "string" ? file.contents : Buffer.from(file.contents);
|
|
62
|
+
await (0, import_promises.writeFile)(target, contents);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/publish.ts
|
|
67
|
+
var JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
68
|
+
function anchorPath() {
|
|
69
|
+
if (typeof __filename === "string") return __filename;
|
|
70
|
+
try {
|
|
71
|
+
const getEsmUrl = new Function(
|
|
72
|
+
"try { return import.meta && import.meta.url; } catch { return undefined; }"
|
|
73
|
+
);
|
|
74
|
+
const url = getEsmUrl();
|
|
75
|
+
if (typeof url === "string" && url.startsWith("file://")) {
|
|
76
|
+
return (0, import_node_url.fileURLToPath)(url);
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
throw new Error(
|
|
81
|
+
"clean-jsdoc-theme: could not determine the running module path (neither __filename nor import.meta.url resolved)."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function resolvePackageDir(name) {
|
|
85
|
+
const start = anchorPath();
|
|
86
|
+
let dir = (0, import_node_path2.dirname)(start);
|
|
87
|
+
let prev = "";
|
|
88
|
+
while (dir !== prev) {
|
|
89
|
+
const candidate = (0, import_node_path2.resolve)(dir, "node_modules", name);
|
|
90
|
+
try {
|
|
91
|
+
(0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(candidate, "package.json"), "utf8");
|
|
92
|
+
return candidate;
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
prev = dir;
|
|
96
|
+
dir = (0, import_node_path2.dirname)(dir);
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
|
|
99
|
+
}
|
|
100
|
+
function resolveExportTarget(node, pkgRoot) {
|
|
101
|
+
if (typeof node === "string") return (0, import_node_path2.resolve)(pkgRoot, node);
|
|
102
|
+
if (!node || typeof node !== "object") return void 0;
|
|
103
|
+
const o = node;
|
|
104
|
+
const imp = resolveExportTarget(o.import, pkgRoot);
|
|
105
|
+
if (imp) return imp;
|
|
106
|
+
if (typeof o.default === "string") return (0, import_node_path2.resolve)(pkgRoot, o.default);
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
function resolveEsmEntry(name) {
|
|
110
|
+
const pkgRoot = resolvePackageDir(name);
|
|
111
|
+
const pkg = JSON.parse(
|
|
112
|
+
(0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(pkgRoot, "package.json"), "utf8")
|
|
113
|
+
);
|
|
114
|
+
const exp = pkg.exports;
|
|
115
|
+
if (typeof exp === "string") return (0, import_node_path2.resolve)(pkgRoot, exp);
|
|
116
|
+
if (exp && typeof exp === "object") {
|
|
117
|
+
const dot = exp["."];
|
|
118
|
+
const target = resolveExportTarget(dot !== void 0 ? dot : exp, pkgRoot);
|
|
119
|
+
if (target) return target;
|
|
120
|
+
}
|
|
121
|
+
if (typeof pkg.module === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.module);
|
|
122
|
+
if (typeof pkg.main === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.main);
|
|
123
|
+
throw new Error(
|
|
124
|
+
`clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
async function loadDep(name, requiredExports) {
|
|
128
|
+
const entry = resolveEsmEntry(name);
|
|
129
|
+
const id = (0, import_node_url.pathToFileURL)(entry).href;
|
|
130
|
+
const mod = await import(id);
|
|
131
|
+
for (const key of requiredExports) {
|
|
132
|
+
if (typeof mod[key] !== "function") {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return mod;
|
|
139
|
+
}
|
|
140
|
+
var loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite"]);
|
|
141
|
+
var loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render", "runPagefindAgainstDir"]);
|
|
142
|
+
var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
143
|
+
"validateThemeOpts",
|
|
144
|
+
"createGoogleFontResolver",
|
|
145
|
+
"formatDiagnostics",
|
|
146
|
+
"formatBuildReport",
|
|
147
|
+
"normalizeBasePath",
|
|
148
|
+
"withBase"
|
|
149
|
+
]);
|
|
150
|
+
var loadOra = async () => {
|
|
151
|
+
try {
|
|
152
|
+
const mod = await loadDep("ora", ["default"]);
|
|
153
|
+
return mod.default;
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var JSDOC_OWN_OPTS = /* @__PURE__ */ new Set([
|
|
159
|
+
"destination",
|
|
160
|
+
"template",
|
|
161
|
+
"encoding",
|
|
162
|
+
"recurse",
|
|
163
|
+
"readme",
|
|
164
|
+
"package",
|
|
165
|
+
"tutorials",
|
|
166
|
+
"query",
|
|
167
|
+
"private",
|
|
168
|
+
"access",
|
|
169
|
+
"explain",
|
|
170
|
+
"debug",
|
|
171
|
+
"verbose",
|
|
172
|
+
"pedantic",
|
|
173
|
+
"match",
|
|
174
|
+
"nocolor",
|
|
175
|
+
"templates"
|
|
176
|
+
]);
|
|
177
|
+
var defaultTheme = {
|
|
178
|
+
tokens: {
|
|
179
|
+
// Light palette (oklch). bg #fdfdf7 · fg #3e3e3e · border #eeeeee;
|
|
180
|
+
// muted/accent derived to harmonize.
|
|
181
|
+
colors: {
|
|
182
|
+
bg: "oklch(0.9924 0.0079 106.54)",
|
|
183
|
+
bgMuted: "oklch(0.9595 0.0079 106.55)",
|
|
184
|
+
fg: "oklch(0.3639 0 0)",
|
|
185
|
+
fgMuted: "oklch(0.5278 0 0)",
|
|
186
|
+
accent: "oklch(0 0 0)",
|
|
187
|
+
accentFg: "oklch(1 0 0)",
|
|
188
|
+
border: "oklch(0.9561 0 0)"
|
|
189
|
+
},
|
|
190
|
+
// Dark palette (oklch). bg #09090b · fg #9e9e9e · border #141416;
|
|
191
|
+
// muted/accent derived to harmonize.
|
|
192
|
+
darkColors: {
|
|
193
|
+
bg: "oklch(0.1408 0.0044 285.82)",
|
|
194
|
+
bgMuted: "oklch(0.2103 0.0059 285.89)",
|
|
195
|
+
fg: "oklch(0.6993 0 0)",
|
|
196
|
+
fgMuted: "oklch(0.5382 0 0)",
|
|
197
|
+
accent: "oklch(1 0 0)",
|
|
198
|
+
accentFg: "oklch(0 0 0)",
|
|
199
|
+
border: "oklch(0.2321 0.004 286.02)"
|
|
200
|
+
},
|
|
201
|
+
fonts: {
|
|
202
|
+
heading: "Source Serif 4",
|
|
203
|
+
body: "Roboto",
|
|
204
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
205
|
+
},
|
|
206
|
+
shiki: { light: "github-light", dark: "github-dark" }
|
|
207
|
+
},
|
|
208
|
+
basePath: "/"
|
|
209
|
+
};
|
|
210
|
+
function resolveTheme(opts, siteName, fonts, basePath) {
|
|
211
|
+
const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
|
|
212
|
+
const copyPage = normalizeCopyPage(opts.copyPage);
|
|
213
|
+
const pageNav = normalizePageNav(opts.pageNav);
|
|
214
|
+
const colors = normalizeColors(opts.colors);
|
|
215
|
+
const darkColors = normalizeColors(opts.darkColors);
|
|
216
|
+
return {
|
|
217
|
+
...defaultTheme,
|
|
218
|
+
basePath,
|
|
219
|
+
...aiPrompt ? { aiPrompt } : {},
|
|
220
|
+
...copyPage ? { copyPage } : {},
|
|
221
|
+
...pageNav ? { pageNav } : {},
|
|
222
|
+
tokens: {
|
|
223
|
+
...defaultTheme.tokens,
|
|
224
|
+
colors: { ...defaultTheme.tokens.colors, ...colors ?? {} },
|
|
225
|
+
darkColors: { ...defaultTheme.tokens.darkColors, ...darkColors ?? {} },
|
|
226
|
+
fonts: {
|
|
227
|
+
heading: fonts.heading ?? defaultTheme.tokens.fonts.heading,
|
|
228
|
+
body: fonts.body ?? defaultTheme.tokens.fonts.body,
|
|
229
|
+
mono: fonts.mono ?? defaultTheme.tokens.fonts.mono
|
|
230
|
+
},
|
|
231
|
+
...siteName ? { siteName } : {}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function nonEmptyString(value) {
|
|
236
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
237
|
+
}
|
|
238
|
+
function contentHash(bytes) {
|
|
239
|
+
return (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
240
|
+
}
|
|
241
|
+
async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
242
|
+
const paths = (Array.isArray(raw) ? raw : [raw]).filter(
|
|
243
|
+
(p) => typeof p === "string" && p.trim().length > 0
|
|
244
|
+
);
|
|
245
|
+
const links = [];
|
|
246
|
+
const files = [];
|
|
247
|
+
const seen = /* @__PURE__ */ new Set();
|
|
248
|
+
for (const p of paths) {
|
|
249
|
+
const trimmed = p.trim();
|
|
250
|
+
let bytes;
|
|
251
|
+
try {
|
|
252
|
+
bytes = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(trimmed));
|
|
253
|
+
} catch {
|
|
254
|
+
console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const base = (0, import_node_path2.basename)(trimmed, (0, import_node_path2.extname)(trimmed)) || "custom";
|
|
258
|
+
const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
|
|
259
|
+
const servedPath = `_assets/${name}`;
|
|
260
|
+
if (seen.has(servedPath)) continue;
|
|
261
|
+
seen.add(servedPath);
|
|
262
|
+
files.push({ path: servedPath, contents: bytes });
|
|
263
|
+
links.push(hrefForServed(servedPath));
|
|
264
|
+
}
|
|
265
|
+
return { links, files };
|
|
266
|
+
}
|
|
267
|
+
async function resolveCustomAssets(opts, hrefForServed) {
|
|
268
|
+
const hash = opts.hashCustomAssets !== false;
|
|
269
|
+
const [cssAssets, jsAssets] = await Promise.all([
|
|
270
|
+
copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed),
|
|
271
|
+
copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)
|
|
272
|
+
]);
|
|
273
|
+
const customCss = nonEmptyString(opts.customCss)?.trim();
|
|
274
|
+
const customJs = nonEmptyString(opts.customJs)?.trim();
|
|
275
|
+
return {
|
|
276
|
+
theme: {
|
|
277
|
+
...customCss ? { customCss } : {},
|
|
278
|
+
...cssAssets.links.length > 0 ? { customCssLinks: cssAssets.links } : {},
|
|
279
|
+
...customJs ? { customJs } : {},
|
|
280
|
+
...jsAssets.links.length > 0 ? { customJsLinks: jsAssets.links } : {}
|
|
281
|
+
},
|
|
282
|
+
files: [...cssAssets.files, ...jsAssets.files]
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function isServableUrl(value) {
|
|
286
|
+
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
287
|
+
}
|
|
288
|
+
async function prepareSiteName(raw, hrefForServed) {
|
|
289
|
+
if (typeof raw === "string") {
|
|
290
|
+
const trimmed = raw.trim();
|
|
291
|
+
return { siteName: trimmed.length > 0 ? trimmed : void 0, files: [] };
|
|
292
|
+
}
|
|
293
|
+
if (!raw || typeof raw !== "object") return { siteName: void 0, files: [] };
|
|
294
|
+
const files = [];
|
|
295
|
+
const out = {};
|
|
296
|
+
if (typeof raw.alt === "string" && raw.alt.trim().length > 0) out.alt = raw.alt.trim();
|
|
297
|
+
for (const key of ["default", "dark", "light"]) {
|
|
298
|
+
const value = raw[key];
|
|
299
|
+
if (typeof value !== "string" || value.trim().length === 0) continue;
|
|
300
|
+
const v = value.trim();
|
|
301
|
+
if (isServableUrl(v)) {
|
|
302
|
+
out[key] = v;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const abs = (0, import_node_path2.resolve)(v);
|
|
307
|
+
const buf = await (0, import_promises2.readFile)(abs);
|
|
308
|
+
const served = `_assets/logo-${key}.${contentHash(buf)}${(0, import_node_path2.extname)(abs)}`;
|
|
309
|
+
files.push({ path: served, contents: buf });
|
|
310
|
+
out[key] = hrefForServed(served);
|
|
311
|
+
} catch {
|
|
312
|
+
console.warn(
|
|
313
|
+
`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`
|
|
314
|
+
);
|
|
315
|
+
out[key] = v;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const hasContent = out.default || out.dark || out.light || out.alt;
|
|
319
|
+
return { siteName: hasContent ? out : void 0, files };
|
|
320
|
+
}
|
|
321
|
+
async function resolvePkg(data, opts) {
|
|
322
|
+
if (typeof opts.package === "string" && opts.package.length > 0) {
|
|
323
|
+
try {
|
|
324
|
+
const json = await (0, import_promises2.readFile)(opts.package, "utf8");
|
|
325
|
+
const parsed = JSON.parse(json);
|
|
326
|
+
return pickPkgFields(parsed);
|
|
327
|
+
} catch {
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (typeof data === "function") {
|
|
331
|
+
try {
|
|
332
|
+
const pkgDoclets = data({ kind: "package" }).get();
|
|
333
|
+
if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) {
|
|
334
|
+
return pickPkgFields(pkgDoclets[0]);
|
|
335
|
+
}
|
|
336
|
+
} catch {
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return void 0;
|
|
340
|
+
}
|
|
341
|
+
function pickPkgFields(raw) {
|
|
342
|
+
const pkg = {};
|
|
343
|
+
if (typeof raw.name === "string") pkg.name = raw.name;
|
|
344
|
+
if (typeof raw.version === "string") pkg.version = raw.version;
|
|
345
|
+
if (typeof raw.description === "string") pkg.description = raw.description;
|
|
346
|
+
if (typeof raw.homepage === "string") pkg.homepage = raw.homepage;
|
|
347
|
+
if (typeof raw.repository === "string") {
|
|
348
|
+
pkg.repository = raw.repository;
|
|
349
|
+
} else if (raw.repository && typeof raw.repository === "object" && typeof raw.repository.url === "string") {
|
|
350
|
+
pkg.repository = raw.repository.url;
|
|
351
|
+
}
|
|
352
|
+
return pkg;
|
|
353
|
+
}
|
|
354
|
+
function normalizeTutorials(root) {
|
|
355
|
+
const walk = (node) => {
|
|
356
|
+
const name = typeof node.name === "string" ? node.name : "";
|
|
357
|
+
if (!name) return null;
|
|
358
|
+
const title = typeof node.title === "string" && node.title.length > 0 ? node.title : name;
|
|
359
|
+
const content = typeof node.content === "string" ? node.content : "";
|
|
360
|
+
const type = node.type === JSDOC_TUTORIAL_TYPE_MARKDOWN ? "markdown" : "html";
|
|
361
|
+
const children2 = Array.isArray(node.children) ? node.children.map(walk).filter((t) => t !== null) : [];
|
|
362
|
+
return { name, title, content, type, children: children2 };
|
|
363
|
+
};
|
|
364
|
+
const children = root?.children;
|
|
365
|
+
if (!Array.isArray(children)) return [];
|
|
366
|
+
return children.map(walk).filter((t) => t !== null);
|
|
367
|
+
}
|
|
368
|
+
function outputSourceFilesEnabled(opts) {
|
|
369
|
+
try {
|
|
370
|
+
const env = require("jsdoc/env");
|
|
371
|
+
if (env?.conf?.templates?.default?.outputSourceFiles === false) return false;
|
|
372
|
+
} catch {
|
|
373
|
+
}
|
|
374
|
+
if (opts?.templates?.default?.outputSourceFiles === false) return false;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
function sourceLinkToCommentEnabled(opts) {
|
|
378
|
+
try {
|
|
379
|
+
const env = require("jsdoc/env");
|
|
380
|
+
if (env?.conf?.templates?.default?.sourceLinkToComment === true) return true;
|
|
381
|
+
} catch {
|
|
382
|
+
}
|
|
383
|
+
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
function hasMarkdownPlugin(plugins) {
|
|
387
|
+
if (!Array.isArray(plugins)) return false;
|
|
388
|
+
return plugins.some(
|
|
389
|
+
(p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim())
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
function assertMarkdownPlugin() {
|
|
393
|
+
let conf;
|
|
394
|
+
try {
|
|
395
|
+
conf = require("jsdoc/env").conf;
|
|
396
|
+
} catch {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (!conf) return;
|
|
400
|
+
if (!hasMarkdownPlugin(conf.plugins)) {
|
|
401
|
+
throw new Error(
|
|
402
|
+
`clean-jsdoc-theme requires JSDoc's "plugins/markdown" plugin, which renders Markdown in doclet descriptions to HTML. Add it to your jsdoc.json:
|
|
403
|
+
|
|
404
|
+
"plugins": ["plugins/markdown"]
|
|
405
|
+
`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function normalizeSectionOrder(raw) {
|
|
410
|
+
if (!Array.isArray(raw)) return void 0;
|
|
411
|
+
const out = raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
412
|
+
return out.length > 0 ? out : void 0;
|
|
413
|
+
}
|
|
414
|
+
function normalizeMenu(raw) {
|
|
415
|
+
if (!Array.isArray(raw)) return void 0;
|
|
416
|
+
const out = [];
|
|
417
|
+
for (const entry of raw) {
|
|
418
|
+
if (!entry || typeof entry !== "object") continue;
|
|
419
|
+
const o = entry;
|
|
420
|
+
const item = {};
|
|
421
|
+
if (typeof o.id === "string" && o.id.trim()) item.id = o.id.trim();
|
|
422
|
+
if (typeof o.title === "string" && o.title.trim()) item.title = o.title.trim();
|
|
423
|
+
const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
|
|
424
|
+
if (link) item.link = link;
|
|
425
|
+
if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
|
|
426
|
+
if (item.id || item.link) out.push(item);
|
|
427
|
+
}
|
|
428
|
+
return out.length > 0 ? out : void 0;
|
|
429
|
+
}
|
|
430
|
+
var COPY_PAGE_ACTIONS = [
|
|
431
|
+
"copy",
|
|
432
|
+
"view",
|
|
433
|
+
"claude",
|
|
434
|
+
"chatgpt",
|
|
435
|
+
"perplexity"
|
|
436
|
+
];
|
|
437
|
+
function normalizeCopyPage(raw) {
|
|
438
|
+
if (raw === false) return { enabled: false };
|
|
439
|
+
if (raw === true || raw == null) return void 0;
|
|
440
|
+
if (typeof raw !== "object") return void 0;
|
|
441
|
+
const o = raw;
|
|
442
|
+
const config = {};
|
|
443
|
+
if (typeof o.enabled === "boolean") config.enabled = o.enabled;
|
|
444
|
+
if (Array.isArray(o.actions)) {
|
|
445
|
+
const seen = /* @__PURE__ */ new Set();
|
|
446
|
+
for (const a of o.actions) {
|
|
447
|
+
if (typeof a === "string" && COPY_PAGE_ACTIONS.includes(a)) {
|
|
448
|
+
seen.add(a);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
|
|
452
|
+
}
|
|
453
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
454
|
+
}
|
|
455
|
+
function normalizePageNav(raw) {
|
|
456
|
+
if (raw === false) return { enabled: false };
|
|
457
|
+
if (raw === true || raw == null) return void 0;
|
|
458
|
+
if (typeof raw !== "object") return void 0;
|
|
459
|
+
const enabled = raw.enabled;
|
|
460
|
+
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
461
|
+
}
|
|
462
|
+
var COLOR_KEYS = ["bg", "bgMuted", "fg", "fgMuted", "accent", "accentFg", "border"];
|
|
463
|
+
function normalizeColors(raw) {
|
|
464
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
465
|
+
const src = raw;
|
|
466
|
+
const out = {};
|
|
467
|
+
for (const key of COLOR_KEYS) {
|
|
468
|
+
const v = src[key];
|
|
469
|
+
if (typeof v === "string" && v.trim().length > 0) out[key] = v.trim();
|
|
470
|
+
}
|
|
471
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
472
|
+
}
|
|
473
|
+
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"]);
|
|
474
|
+
function computeRelPaths(absPaths) {
|
|
475
|
+
const out = /* @__PURE__ */ new Map();
|
|
476
|
+
if (absPaths.length === 0) return out;
|
|
477
|
+
const split = (p) => p.split(/[\\/]+/).filter((s) => s.length > 0);
|
|
478
|
+
const segLists = absPaths.map(split);
|
|
479
|
+
let common = segLists[0].slice(0, -1);
|
|
480
|
+
for (let i = 1; i < segLists.length && common.length > 0; i++) {
|
|
481
|
+
const segs = segLists[i];
|
|
482
|
+
let j = 0;
|
|
483
|
+
const max = Math.min(common.length, segs.length - 1);
|
|
484
|
+
while (j < max && common[j].toLowerCase() === segs[j].toLowerCase()) j++;
|
|
485
|
+
common = common.slice(0, j);
|
|
486
|
+
}
|
|
487
|
+
for (let i = 0; i < absPaths.length; i++) {
|
|
488
|
+
const segs = segLists[i];
|
|
489
|
+
const rel = common.length > 0 && segs.length > common.length ? segs.slice(common.length).join("/") : segs[segs.length - 1] ?? absPaths[i];
|
|
490
|
+
out.set(absPaths[i], rel);
|
|
491
|
+
}
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
async function collectSourceFiles(data) {
|
|
495
|
+
let doclets = [];
|
|
496
|
+
if (typeof data === "function") {
|
|
497
|
+
try {
|
|
498
|
+
doclets = data({}).get();
|
|
499
|
+
} catch {
|
|
500
|
+
try {
|
|
501
|
+
doclets = data().get();
|
|
502
|
+
} catch {
|
|
503
|
+
doclets = [];
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (!Array.isArray(doclets) || doclets.length === 0) return [];
|
|
508
|
+
const absSet = /* @__PURE__ */ new Set();
|
|
509
|
+
for (const d of doclets) {
|
|
510
|
+
const meta = d?.meta;
|
|
511
|
+
if (!meta || typeof meta.path !== "string" || typeof meta.filename !== "string") continue;
|
|
512
|
+
const filename = meta.filename;
|
|
513
|
+
const ext = (0, import_node_path2.extname)(filename).toLowerCase();
|
|
514
|
+
if (ext.length > 0 && !SOURCE_EXTENSIONS.has(ext)) continue;
|
|
515
|
+
absSet.add((0, import_node_path2.resolve)(meta.path, filename));
|
|
516
|
+
}
|
|
517
|
+
if (absSet.size === 0) return [];
|
|
518
|
+
const absPaths = [...absSet];
|
|
519
|
+
const relPaths = computeRelPaths(absPaths);
|
|
520
|
+
const inputs = [];
|
|
521
|
+
for (const abs of absPaths) {
|
|
522
|
+
try {
|
|
523
|
+
const content = await (0, import_promises2.readFile)(abs, "utf8");
|
|
524
|
+
inputs.push({ absPath: abs, relPath: relPaths.get(abs) ?? abs, content });
|
|
525
|
+
} catch (err) {
|
|
526
|
+
console.warn(
|
|
527
|
+
`clean-jsdoc-theme: could not read source file '${abs}' \u2014 ${err.message}; skipping.`
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
532
|
+
return inputs;
|
|
533
|
+
}
|
|
534
|
+
var DOC_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
535
|
+
[".md", "markdown"],
|
|
536
|
+
[".markdown", "markdown"],
|
|
537
|
+
[".html", "html"],
|
|
538
|
+
[".htm", "html"]
|
|
539
|
+
]);
|
|
540
|
+
var DOC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
|
|
541
|
+
async function collectDocs(dir) {
|
|
542
|
+
if (typeof dir !== "string" || dir.trim().length === 0) return [];
|
|
543
|
+
const root = (0, import_node_path2.resolve)(dir);
|
|
544
|
+
const docs = [];
|
|
545
|
+
const walk = async (absDir, relPrefix) => {
|
|
546
|
+
let entries;
|
|
547
|
+
try {
|
|
548
|
+
entries = await (0, import_promises2.readdir)(absDir, { withFileTypes: true });
|
|
549
|
+
} catch {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
for (const entry of entries) {
|
|
553
|
+
const name = entry.name;
|
|
554
|
+
if (name.startsWith(".")) continue;
|
|
555
|
+
if (entry.isDirectory()) {
|
|
556
|
+
if (DOC_DIR_SKIP.has(name)) continue;
|
|
557
|
+
await walk((0, import_node_path2.join)(absDir, name), relPrefix ? `${relPrefix}/${name}` : name);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
if (!entry.isFile()) continue;
|
|
561
|
+
const ext = (0, import_node_path2.extname)(name).toLowerCase();
|
|
562
|
+
const type = DOC_EXTENSIONS.get(ext);
|
|
563
|
+
if (!type) continue;
|
|
564
|
+
const abs = (0, import_node_path2.join)(absDir, name);
|
|
565
|
+
const stem = name.slice(0, name.length - ext.length);
|
|
566
|
+
const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
|
|
567
|
+
try {
|
|
568
|
+
const content = await (0, import_promises2.readFile)(abs, "utf8");
|
|
569
|
+
docs.push({ path: relPath, content, type });
|
|
570
|
+
} catch (err) {
|
|
571
|
+
console.warn(
|
|
572
|
+
`clean-jsdoc-theme: could not read doc file '${abs}' \u2014 ${err.message}; skipping.`
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
await walk(root, "");
|
|
578
|
+
docs.sort((a, b) => a.path.localeCompare(b.path));
|
|
579
|
+
return docs;
|
|
580
|
+
}
|
|
581
|
+
var DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
|
|
582
|
+
async function resolveDocImages(docs, docsDir) {
|
|
583
|
+
if (docs.length === 0) return { docs, files: [], inlineSvgs: {} };
|
|
584
|
+
const root = (0, import_node_path2.resolve)(docsDir);
|
|
585
|
+
const files = [];
|
|
586
|
+
const seenServed = /* @__PURE__ */ new Set();
|
|
587
|
+
const inlineSvgs = {};
|
|
588
|
+
const cache = /* @__PURE__ */ new Map();
|
|
589
|
+
const resolveOne = async (rawSrc, docDir) => {
|
|
590
|
+
const src = rawSrc.trim();
|
|
591
|
+
if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
|
|
592
|
+
const abs = src.startsWith("/") ? (0, import_node_path2.resolve)(src.slice(1)) : (0, import_node_path2.resolve)(docDir, src);
|
|
593
|
+
if (cache.has(abs)) return cache.get(abs) ?? null;
|
|
594
|
+
let bytes;
|
|
595
|
+
try {
|
|
596
|
+
bytes = await (0, import_promises2.readFile)(abs);
|
|
597
|
+
} catch {
|
|
598
|
+
console.warn(
|
|
599
|
+
`clean-jsdoc-theme: could not read doc image '${src}' (resolved '${abs}'); leaving it as-is.`
|
|
600
|
+
);
|
|
601
|
+
cache.set(abs, null);
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
const ext = (0, import_node_path2.extname)(abs);
|
|
605
|
+
const served = `_assets/${(0, import_node_path2.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
|
|
606
|
+
if (!seenServed.has(served)) {
|
|
607
|
+
seenServed.add(served);
|
|
608
|
+
files.push({ path: served, contents: bytes });
|
|
609
|
+
}
|
|
610
|
+
const href = "/" + served;
|
|
611
|
+
if (ext.toLowerCase() === ".svg") {
|
|
612
|
+
inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, '<svg style="max-width:100%;height:auto;display:block"');
|
|
613
|
+
}
|
|
614
|
+
cache.set(abs, href);
|
|
615
|
+
return href;
|
|
616
|
+
};
|
|
617
|
+
const out = [];
|
|
618
|
+
for (const doc of docs) {
|
|
619
|
+
const docDir = (0, import_node_path2.dirname)((0, import_node_path2.resolve)(root, doc.path));
|
|
620
|
+
const map = /* @__PURE__ */ new Map();
|
|
621
|
+
for (const m of doc.content.matchAll(DOC_IMAGE_RE)) {
|
|
622
|
+
const src = m[2];
|
|
623
|
+
if (map.has(src)) continue;
|
|
624
|
+
const href = await resolveOne(src, docDir);
|
|
625
|
+
if (href) map.set(src, href);
|
|
626
|
+
}
|
|
627
|
+
if (map.size === 0) {
|
|
628
|
+
out.push(doc);
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
const content = doc.content.replace(
|
|
632
|
+
DOC_IMAGE_RE,
|
|
633
|
+
(full, pre, src, post) => map.has(src) ? `${pre}${map.get(src)}${post}` : full
|
|
634
|
+
);
|
|
635
|
+
out.push({ ...doc, content });
|
|
636
|
+
}
|
|
637
|
+
return { docs: out, files, inlineSvgs };
|
|
638
|
+
}
|
|
639
|
+
function normalizeDocGroups(raw) {
|
|
640
|
+
return normalizeSectionOrder(raw);
|
|
641
|
+
}
|
|
642
|
+
function formatElapsed(ms) {
|
|
643
|
+
return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
|
|
644
|
+
}
|
|
645
|
+
function createBuildProgress(ora) {
|
|
646
|
+
async function stage(label, fn) {
|
|
647
|
+
if (!ora) return await fn();
|
|
648
|
+
const spinner = ora(label).start();
|
|
649
|
+
const begin = Date.now();
|
|
650
|
+
try {
|
|
651
|
+
const result = await fn();
|
|
652
|
+
spinner.succeed(`${label} (${formatElapsed(Date.now() - begin)})`);
|
|
653
|
+
return result;
|
|
654
|
+
} catch (err) {
|
|
655
|
+
spinner.fail(label);
|
|
656
|
+
throw err;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return { stage };
|
|
660
|
+
}
|
|
661
|
+
async function publish(data, opts, tutorials) {
|
|
662
|
+
const destination = opts.destination;
|
|
663
|
+
if (!destination || typeof destination !== "string") {
|
|
664
|
+
throw new Error(
|
|
665
|
+
'clean-jsdoc-theme publish: opts.destination is required (set "opts.destination" in your jsdoc.json).'
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
assertMarkdownPlugin();
|
|
669
|
+
const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
|
|
670
|
+
const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
|
|
671
|
+
const pkgPromise = resolvePkg(data, opts);
|
|
672
|
+
const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
|
|
673
|
+
const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
|
|
674
|
+
const ora = opts.progress === false ? null : await loadOra();
|
|
675
|
+
const progress = createBuildProgress(ora);
|
|
676
|
+
const [
|
|
677
|
+
{ generateSite },
|
|
678
|
+
{ render, runPagefindAgainstDir },
|
|
679
|
+
{
|
|
680
|
+
validateThemeOpts,
|
|
681
|
+
createGoogleFontResolver,
|
|
682
|
+
formatDiagnostics,
|
|
683
|
+
formatBuildReport,
|
|
684
|
+
normalizeBasePath,
|
|
685
|
+
withBase
|
|
686
|
+
}
|
|
687
|
+
] = await progress.stage(
|
|
688
|
+
"Loading renderer",
|
|
689
|
+
() => Promise.all([loadSetu(), loadDwar(), loadUtils()])
|
|
690
|
+
);
|
|
691
|
+
const basePath = normalizeBasePath(opts.basePath);
|
|
692
|
+
const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
|
|
693
|
+
const fontResolver = createGoogleFontResolver();
|
|
694
|
+
const { value, diagnostics } = await progress.stage(
|
|
695
|
+
"Validating options",
|
|
696
|
+
() => validateThemeOpts({
|
|
697
|
+
opts,
|
|
698
|
+
fontResolver,
|
|
699
|
+
unknownKeyPolicy: "suggest-typos",
|
|
700
|
+
knownNonThemeKeys: JSDOC_OWN_OPTS
|
|
701
|
+
})
|
|
702
|
+
);
|
|
703
|
+
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
704
|
+
if (diagnostics.list.length > 0) {
|
|
705
|
+
const formatted = formatDiagnostics(diagnostics, { color });
|
|
706
|
+
if (strict && diagnostics.hasErrors()) {
|
|
707
|
+
console.error(formatted);
|
|
708
|
+
throw new Error(
|
|
709
|
+
"clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`."
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
console.log(formatted);
|
|
713
|
+
}
|
|
714
|
+
const pkg = await pkgPromise;
|
|
715
|
+
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
716
|
+
const tutorialTree = normalizeTutorials(tutorials);
|
|
717
|
+
const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
|
|
718
|
+
const { sources, docs, docImageFiles, inlineSvgs } = await progress.stage(
|
|
719
|
+
"Reading sources & docs",
|
|
720
|
+
async () => {
|
|
721
|
+
const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
|
|
722
|
+
const resolved = docsDir ? await resolveDocImages(rawDocs, docsDir) : { docs: rawDocs, files: [], inlineSvgs: {} };
|
|
723
|
+
return {
|
|
724
|
+
sources: srcs,
|
|
725
|
+
docs: resolved.docs,
|
|
726
|
+
docImageFiles: resolved.files,
|
|
727
|
+
inlineSvgs: resolved.inlineSvgs
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
const docGroups = normalizeDocGroups(opts.docGroups);
|
|
732
|
+
const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
|
|
733
|
+
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
734
|
+
const menu = normalizeMenu(opts.menu);
|
|
735
|
+
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
736
|
+
const manifest = await progress.stage("Generating pages", () => generateSite(data, {
|
|
737
|
+
...pkg ? { pkg } : {},
|
|
738
|
+
...readme ? { readme } : {},
|
|
739
|
+
...tutorialTree.length > 0 ? { tutorials: tutorialTree } : {},
|
|
740
|
+
...sources.length > 0 ? { sources } : {},
|
|
741
|
+
...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
|
|
742
|
+
...docs.length > 0 ? { docs } : {},
|
|
743
|
+
...docGroups ? { docGroups } : {},
|
|
744
|
+
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
745
|
+
...sectionOrder ? { sectionOrder } : {},
|
|
746
|
+
...menu ? { menu } : {},
|
|
747
|
+
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
748
|
+
}));
|
|
749
|
+
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
|
|
750
|
+
const notGoogle = new Set(
|
|
751
|
+
diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path)
|
|
752
|
+
);
|
|
753
|
+
const fonts = { ...value.fonts };
|
|
754
|
+
if (notGoogle.has("fonts.heading")) delete fonts.heading;
|
|
755
|
+
if (notGoogle.has("fonts.body")) delete fonts.body;
|
|
756
|
+
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
757
|
+
const absoluteDestination = (0, import_node_path2.resolve)(destination);
|
|
758
|
+
const islandCacheDir = (0, import_node_path2.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
759
|
+
const result = await progress.stage(
|
|
760
|
+
"Rendering site",
|
|
761
|
+
() => render(manifest, {
|
|
762
|
+
theme: { ...resolveTheme(opts, siteName, fonts, basePath), ...customAssets.theme },
|
|
763
|
+
destination: absoluteDestination,
|
|
764
|
+
islandCacheDir,
|
|
765
|
+
inlineSvgs
|
|
766
|
+
})
|
|
767
|
+
);
|
|
768
|
+
const outputFiles = [...result.files, ...logoFiles, ...customAssets.files, ...docImageFiles];
|
|
769
|
+
await progress.stage(
|
|
770
|
+
"Writing files",
|
|
771
|
+
() => writeOutputFiles(absoluteDestination, outputFiles)
|
|
772
|
+
);
|
|
773
|
+
const zlib = await import("zlib");
|
|
774
|
+
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
775
|
+
console.log(
|
|
776
|
+
formatBuildReport({
|
|
777
|
+
files: outputFiles,
|
|
778
|
+
stats: result.stats,
|
|
779
|
+
destination,
|
|
780
|
+
gzipSizer,
|
|
781
|
+
color
|
|
782
|
+
})
|
|
783
|
+
);
|
|
784
|
+
if (result.errors && result.errors.length > 0) {
|
|
785
|
+
console.warn(
|
|
786
|
+
`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`
|
|
787
|
+
);
|
|
788
|
+
for (const e of result.errors) {
|
|
789
|
+
console.warn(` - ${e.slug}: ${e.message}`);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
try {
|
|
793
|
+
await progress.stage(
|
|
794
|
+
"Indexing search (pagefind)",
|
|
795
|
+
() => runPagefindAgainstDir(absoluteDestination)
|
|
796
|
+
);
|
|
797
|
+
} catch (err) {
|
|
798
|
+
console.warn(
|
|
799
|
+
`clean-jsdoc-theme: pagefind step skipped (optional) \u2014 ${err.message}`
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
804
|
+
0 && (module.exports = {
|
|
805
|
+
collectDocs,
|
|
806
|
+
computeRelPaths,
|
|
807
|
+
hasMarkdownPlugin,
|
|
808
|
+
normalizeColors,
|
|
809
|
+
normalizeCopyPage,
|
|
810
|
+
normalizeDocGroups,
|
|
811
|
+
normalizeMenu,
|
|
812
|
+
normalizePageNav,
|
|
813
|
+
normalizeSectionOrder,
|
|
814
|
+
outputSourceFilesEnabled,
|
|
815
|
+
publish,
|
|
816
|
+
resolveDocImages,
|
|
817
|
+
sourceLinkToCommentEnabled
|
|
818
|
+
});
|
|
819
|
+
//# sourceMappingURL=publish.js.map
|