clean-jsdoc-theme 4.3.0 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -625
- package/dist/publish.d.mts +218 -0
- package/dist/publish.d.ts +218 -0
- package/dist/publish.js +641 -0
- package/dist/publish.js.map +1 -0
- package/dist/publish.mjs +605 -0
- package/dist/publish.mjs.map +1 -0
- package/package.json +65 -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/LICENSE +0 -21
- 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 -1104
- 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,641 @@
|
|
|
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
|
+
normalizeCopyPage: () => normalizeCopyPage,
|
|
36
|
+
normalizeDocGroups: () => normalizeDocGroups,
|
|
37
|
+
normalizeMenu: () => normalizeMenu,
|
|
38
|
+
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
39
|
+
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
40
|
+
publish: () => publish,
|
|
41
|
+
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(publish_exports);
|
|
44
|
+
var import_promises2 = require("fs/promises");
|
|
45
|
+
var import_node_fs = require("fs");
|
|
46
|
+
var import_node_crypto = require("crypto");
|
|
47
|
+
var import_node_path2 = require("path");
|
|
48
|
+
var import_node_url = require("url");
|
|
49
|
+
|
|
50
|
+
// src/write-output-files.ts
|
|
51
|
+
var import_promises = require("fs/promises");
|
|
52
|
+
var import_node_path = require("path");
|
|
53
|
+
async function writeOutputFiles(destination, files) {
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
const target = (0, import_node_path.join)(destination, file.path);
|
|
56
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(target), { recursive: true });
|
|
57
|
+
const contents = typeof file.contents === "string" ? file.contents : Buffer.from(file.contents);
|
|
58
|
+
await (0, import_promises.writeFile)(target, contents);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/publish.ts
|
|
63
|
+
var JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
64
|
+
function anchorPath() {
|
|
65
|
+
if (typeof __filename === "string") return __filename;
|
|
66
|
+
try {
|
|
67
|
+
const getEsmUrl = new Function(
|
|
68
|
+
"try { return import.meta && import.meta.url; } catch { return undefined; }"
|
|
69
|
+
);
|
|
70
|
+
const url = getEsmUrl();
|
|
71
|
+
if (typeof url === "string" && url.startsWith("file://")) {
|
|
72
|
+
return (0, import_node_url.fileURLToPath)(url);
|
|
73
|
+
}
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
throw new Error(
|
|
77
|
+
"clean-jsdoc-theme: could not determine the running module path (neither __filename nor import.meta.url resolved)."
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
function resolvePackageDir(name) {
|
|
81
|
+
const start = anchorPath();
|
|
82
|
+
let dir = (0, import_node_path2.dirname)(start);
|
|
83
|
+
let prev = "";
|
|
84
|
+
while (dir !== prev) {
|
|
85
|
+
const candidate = (0, import_node_path2.resolve)(dir, "node_modules", name);
|
|
86
|
+
try {
|
|
87
|
+
(0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(candidate, "package.json"), "utf8");
|
|
88
|
+
return candidate;
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
prev = dir;
|
|
92
|
+
dir = (0, import_node_path2.dirname)(dir);
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
|
|
95
|
+
}
|
|
96
|
+
function resolveEsmEntry(name) {
|
|
97
|
+
const pkgRoot = resolvePackageDir(name);
|
|
98
|
+
const pkg = JSON.parse(
|
|
99
|
+
(0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(pkgRoot, "package.json"), "utf8")
|
|
100
|
+
);
|
|
101
|
+
const exp = pkg.exports;
|
|
102
|
+
if (exp && typeof exp === "object") {
|
|
103
|
+
const dot = exp["."];
|
|
104
|
+
if (typeof dot === "string") return (0, import_node_path2.resolve)(pkgRoot, dot);
|
|
105
|
+
if (dot && typeof dot === "object") {
|
|
106
|
+
const imp = dot.import;
|
|
107
|
+
if (typeof imp === "string") return (0, import_node_path2.resolve)(pkgRoot, imp);
|
|
108
|
+
if (imp && typeof imp === "object") {
|
|
109
|
+
const def2 = imp.default;
|
|
110
|
+
if (typeof def2 === "string") return (0, import_node_path2.resolve)(pkgRoot, def2);
|
|
111
|
+
}
|
|
112
|
+
const def = dot.default;
|
|
113
|
+
if (typeof def === "string") return (0, import_node_path2.resolve)(pkgRoot, def);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (typeof pkg.module === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.module);
|
|
117
|
+
if (typeof pkg.main === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.main);
|
|
118
|
+
throw new Error(
|
|
119
|
+
`clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
async function loadDep(name, requiredExports) {
|
|
123
|
+
const entry = resolveEsmEntry(name);
|
|
124
|
+
const id = (0, import_node_url.pathToFileURL)(entry).href;
|
|
125
|
+
const mod = await import(id);
|
|
126
|
+
for (const key of requiredExports) {
|
|
127
|
+
if (typeof mod[key] !== "function") {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return mod;
|
|
134
|
+
}
|
|
135
|
+
var loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite"]);
|
|
136
|
+
var loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render", "runPagefindAgainstDir"]);
|
|
137
|
+
var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
138
|
+
"validateThemeOpts",
|
|
139
|
+
"createGoogleFontResolver",
|
|
140
|
+
"formatDiagnostics",
|
|
141
|
+
"formatBuildReport",
|
|
142
|
+
"normalizeBasePath",
|
|
143
|
+
"withBase"
|
|
144
|
+
]);
|
|
145
|
+
var JSDOC_OWN_OPTS = /* @__PURE__ */ new Set([
|
|
146
|
+
"destination",
|
|
147
|
+
"template",
|
|
148
|
+
"encoding",
|
|
149
|
+
"recurse",
|
|
150
|
+
"readme",
|
|
151
|
+
"package",
|
|
152
|
+
"tutorials",
|
|
153
|
+
"query",
|
|
154
|
+
"private",
|
|
155
|
+
"access",
|
|
156
|
+
"explain",
|
|
157
|
+
"debug",
|
|
158
|
+
"verbose",
|
|
159
|
+
"pedantic",
|
|
160
|
+
"match",
|
|
161
|
+
"nocolor",
|
|
162
|
+
"templates"
|
|
163
|
+
]);
|
|
164
|
+
var defaultTheme = {
|
|
165
|
+
tokens: {
|
|
166
|
+
// Light palette (oklch). bg #fdfdf7 · fg #3e3e3e · border #eeeeee;
|
|
167
|
+
// muted/accent derived to harmonize.
|
|
168
|
+
colors: {
|
|
169
|
+
bg: "oklch(0.9924 0.0079 106.54)",
|
|
170
|
+
bgMuted: "oklch(0.9595 0.0079 106.55)",
|
|
171
|
+
fg: "oklch(0.3639 0 0)",
|
|
172
|
+
fgMuted: "oklch(0.5278 0 0)",
|
|
173
|
+
accent: "oklch(0 0 0)",
|
|
174
|
+
accentFg: "oklch(1 0 0)",
|
|
175
|
+
border: "oklch(0.9561 0 0)"
|
|
176
|
+
},
|
|
177
|
+
// Dark palette (oklch). bg #09090b · fg #9e9e9e · border #141416;
|
|
178
|
+
// muted/accent derived to harmonize.
|
|
179
|
+
darkColors: {
|
|
180
|
+
bg: "oklch(0.1408 0.0044 285.82)",
|
|
181
|
+
bgMuted: "oklch(0.2103 0.0059 285.89)",
|
|
182
|
+
fg: "oklch(0.6993 0 0)",
|
|
183
|
+
fgMuted: "oklch(0.5382 0 0)",
|
|
184
|
+
accent: "oklch(1 0 0)",
|
|
185
|
+
accentFg: "oklch(0 0 0)",
|
|
186
|
+
border: "oklch(0.2321 0.004 286.02)"
|
|
187
|
+
},
|
|
188
|
+
fonts: {
|
|
189
|
+
heading: "Source Serif 4",
|
|
190
|
+
body: "Roboto",
|
|
191
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
192
|
+
},
|
|
193
|
+
shiki: { light: "github-light", dark: "github-dark" }
|
|
194
|
+
},
|
|
195
|
+
basePath: "/"
|
|
196
|
+
};
|
|
197
|
+
function resolveTheme(opts, siteName, fonts, basePath) {
|
|
198
|
+
const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
|
|
199
|
+
const copyPage = normalizeCopyPage(opts.copyPage);
|
|
200
|
+
return {
|
|
201
|
+
...defaultTheme,
|
|
202
|
+
basePath,
|
|
203
|
+
...aiPrompt ? { aiPrompt } : {},
|
|
204
|
+
...copyPage ? { copyPage } : {},
|
|
205
|
+
tokens: {
|
|
206
|
+
...defaultTheme.tokens,
|
|
207
|
+
fonts: {
|
|
208
|
+
heading: fonts.heading ?? defaultTheme.tokens.fonts.heading,
|
|
209
|
+
body: fonts.body ?? defaultTheme.tokens.fonts.body,
|
|
210
|
+
mono: fonts.mono ?? defaultTheme.tokens.fonts.mono
|
|
211
|
+
},
|
|
212
|
+
...siteName ? { siteName } : {}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function nonEmptyString(value) {
|
|
217
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
218
|
+
}
|
|
219
|
+
function contentHash(bytes) {
|
|
220
|
+
return (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
221
|
+
}
|
|
222
|
+
async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
|
|
223
|
+
const paths = (Array.isArray(raw) ? raw : [raw]).filter(
|
|
224
|
+
(p) => typeof p === "string" && p.trim().length > 0
|
|
225
|
+
);
|
|
226
|
+
const links = [];
|
|
227
|
+
const files = [];
|
|
228
|
+
const seen = /* @__PURE__ */ new Set();
|
|
229
|
+
for (const p of paths) {
|
|
230
|
+
const trimmed = p.trim();
|
|
231
|
+
let bytes;
|
|
232
|
+
try {
|
|
233
|
+
bytes = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(trimmed));
|
|
234
|
+
} catch {
|
|
235
|
+
console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const base = (0, import_node_path2.basename)(trimmed, (0, import_node_path2.extname)(trimmed)) || "custom";
|
|
239
|
+
const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
|
|
240
|
+
const servedPath = `_assets/${name}`;
|
|
241
|
+
if (seen.has(servedPath)) continue;
|
|
242
|
+
seen.add(servedPath);
|
|
243
|
+
files.push({ path: servedPath, contents: bytes });
|
|
244
|
+
links.push(hrefForServed(servedPath));
|
|
245
|
+
}
|
|
246
|
+
return { links, files };
|
|
247
|
+
}
|
|
248
|
+
async function resolveCustomAssets(opts, hrefForServed) {
|
|
249
|
+
const hash = opts.hashCustomAssets !== false;
|
|
250
|
+
const [cssAssets, jsAssets] = await Promise.all([
|
|
251
|
+
copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed),
|
|
252
|
+
copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)
|
|
253
|
+
]);
|
|
254
|
+
const customCss = nonEmptyString(opts.customCss)?.trim();
|
|
255
|
+
const customJs = nonEmptyString(opts.customJs)?.trim();
|
|
256
|
+
return {
|
|
257
|
+
theme: {
|
|
258
|
+
...customCss ? { customCss } : {},
|
|
259
|
+
...cssAssets.links.length > 0 ? { customCssLinks: cssAssets.links } : {},
|
|
260
|
+
...customJs ? { customJs } : {},
|
|
261
|
+
...jsAssets.links.length > 0 ? { customJsLinks: jsAssets.links } : {}
|
|
262
|
+
},
|
|
263
|
+
files: [...cssAssets.files, ...jsAssets.files]
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function isServableUrl(value) {
|
|
267
|
+
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
268
|
+
}
|
|
269
|
+
async function prepareSiteName(raw, hrefForServed) {
|
|
270
|
+
if (typeof raw === "string") {
|
|
271
|
+
const trimmed = raw.trim();
|
|
272
|
+
return { siteName: trimmed.length > 0 ? trimmed : void 0, files: [] };
|
|
273
|
+
}
|
|
274
|
+
if (!raw || typeof raw !== "object") return { siteName: void 0, files: [] };
|
|
275
|
+
const files = [];
|
|
276
|
+
const out = {};
|
|
277
|
+
if (typeof raw.alt === "string" && raw.alt.trim().length > 0) out.alt = raw.alt.trim();
|
|
278
|
+
for (const key of ["default", "dark", "light"]) {
|
|
279
|
+
const value = raw[key];
|
|
280
|
+
if (typeof value !== "string" || value.trim().length === 0) continue;
|
|
281
|
+
const v = value.trim();
|
|
282
|
+
if (isServableUrl(v)) {
|
|
283
|
+
out[key] = v;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const abs = (0, import_node_path2.resolve)(v);
|
|
288
|
+
const buf = await (0, import_promises2.readFile)(abs);
|
|
289
|
+
const served = `_assets/logo-${key}${(0, import_node_path2.extname)(abs)}`;
|
|
290
|
+
files.push({ path: served, contents: buf });
|
|
291
|
+
out[key] = hrefForServed(served);
|
|
292
|
+
} catch {
|
|
293
|
+
console.warn(
|
|
294
|
+
`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`
|
|
295
|
+
);
|
|
296
|
+
out[key] = v;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const hasContent = out.default || out.dark || out.light || out.alt;
|
|
300
|
+
return { siteName: hasContent ? out : void 0, files };
|
|
301
|
+
}
|
|
302
|
+
async function resolvePkg(data, opts) {
|
|
303
|
+
if (typeof opts.package === "string" && opts.package.length > 0) {
|
|
304
|
+
try {
|
|
305
|
+
const json = await (0, import_promises2.readFile)(opts.package, "utf8");
|
|
306
|
+
const parsed = JSON.parse(json);
|
|
307
|
+
return pickPkgFields(parsed);
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (typeof data === "function") {
|
|
312
|
+
try {
|
|
313
|
+
const pkgDoclets = data({ kind: "package" }).get();
|
|
314
|
+
if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) {
|
|
315
|
+
return pickPkgFields(pkgDoclets[0]);
|
|
316
|
+
}
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
function pickPkgFields(raw) {
|
|
323
|
+
const pkg = {};
|
|
324
|
+
if (typeof raw.name === "string") pkg.name = raw.name;
|
|
325
|
+
if (typeof raw.version === "string") pkg.version = raw.version;
|
|
326
|
+
if (typeof raw.description === "string") pkg.description = raw.description;
|
|
327
|
+
if (typeof raw.homepage === "string") pkg.homepage = raw.homepage;
|
|
328
|
+
if (typeof raw.repository === "string") {
|
|
329
|
+
pkg.repository = raw.repository;
|
|
330
|
+
} else if (raw.repository && typeof raw.repository === "object" && typeof raw.repository.url === "string") {
|
|
331
|
+
pkg.repository = raw.repository.url;
|
|
332
|
+
}
|
|
333
|
+
return pkg;
|
|
334
|
+
}
|
|
335
|
+
function normalizeTutorials(root) {
|
|
336
|
+
const walk = (node) => {
|
|
337
|
+
const name = typeof node.name === "string" ? node.name : "";
|
|
338
|
+
if (!name) return null;
|
|
339
|
+
const title = typeof node.title === "string" && node.title.length > 0 ? node.title : name;
|
|
340
|
+
const content = typeof node.content === "string" ? node.content : "";
|
|
341
|
+
const type = node.type === JSDOC_TUTORIAL_TYPE_MARKDOWN ? "markdown" : "html";
|
|
342
|
+
const children2 = Array.isArray(node.children) ? node.children.map(walk).filter((t) => t !== null) : [];
|
|
343
|
+
return { name, title, content, type, children: children2 };
|
|
344
|
+
};
|
|
345
|
+
const children = root?.children;
|
|
346
|
+
if (!Array.isArray(children)) return [];
|
|
347
|
+
return children.map(walk).filter((t) => t !== null);
|
|
348
|
+
}
|
|
349
|
+
function outputSourceFilesEnabled(opts) {
|
|
350
|
+
try {
|
|
351
|
+
const env = require("jsdoc/env");
|
|
352
|
+
if (env?.conf?.templates?.default?.outputSourceFiles === false) return false;
|
|
353
|
+
} catch {
|
|
354
|
+
}
|
|
355
|
+
if (opts?.templates?.default?.outputSourceFiles === false) return false;
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
function sourceLinkToCommentEnabled(opts) {
|
|
359
|
+
try {
|
|
360
|
+
const env = require("jsdoc/env");
|
|
361
|
+
if (env?.conf?.templates?.default?.sourceLinkToComment === true) return true;
|
|
362
|
+
} catch {
|
|
363
|
+
}
|
|
364
|
+
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
function normalizeSectionOrder(raw) {
|
|
368
|
+
if (!Array.isArray(raw)) return void 0;
|
|
369
|
+
const out = raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
370
|
+
return out.length > 0 ? out : void 0;
|
|
371
|
+
}
|
|
372
|
+
function normalizeMenu(raw) {
|
|
373
|
+
if (!Array.isArray(raw)) return void 0;
|
|
374
|
+
const out = [];
|
|
375
|
+
for (const entry of raw) {
|
|
376
|
+
if (!entry || typeof entry !== "object") continue;
|
|
377
|
+
const o = entry;
|
|
378
|
+
const item = {};
|
|
379
|
+
if (typeof o.id === "string" && o.id.trim()) item.id = o.id.trim();
|
|
380
|
+
if (typeof o.title === "string" && o.title.trim()) item.title = o.title.trim();
|
|
381
|
+
const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
|
|
382
|
+
if (link) item.link = link;
|
|
383
|
+
if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
|
|
384
|
+
if (item.id || item.link) out.push(item);
|
|
385
|
+
}
|
|
386
|
+
return out.length > 0 ? out : void 0;
|
|
387
|
+
}
|
|
388
|
+
var COPY_PAGE_ACTIONS = [
|
|
389
|
+
"copy",
|
|
390
|
+
"view",
|
|
391
|
+
"claude",
|
|
392
|
+
"chatgpt",
|
|
393
|
+
"perplexity"
|
|
394
|
+
];
|
|
395
|
+
function normalizeCopyPage(raw) {
|
|
396
|
+
if (raw === false) return { enabled: false };
|
|
397
|
+
if (raw === true || raw == null) return void 0;
|
|
398
|
+
if (typeof raw !== "object") return void 0;
|
|
399
|
+
const o = raw;
|
|
400
|
+
const config = {};
|
|
401
|
+
if (typeof o.enabled === "boolean") config.enabled = o.enabled;
|
|
402
|
+
if (Array.isArray(o.actions)) {
|
|
403
|
+
const seen = /* @__PURE__ */ new Set();
|
|
404
|
+
for (const a of o.actions) {
|
|
405
|
+
if (typeof a === "string" && COPY_PAGE_ACTIONS.includes(a)) {
|
|
406
|
+
seen.add(a);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
|
|
410
|
+
}
|
|
411
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
412
|
+
}
|
|
413
|
+
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"]);
|
|
414
|
+
function computeRelPaths(absPaths) {
|
|
415
|
+
const out = /* @__PURE__ */ new Map();
|
|
416
|
+
if (absPaths.length === 0) return out;
|
|
417
|
+
const split = (p) => p.split(/[\\/]+/).filter((s) => s.length > 0);
|
|
418
|
+
const segLists = absPaths.map(split);
|
|
419
|
+
let common = segLists[0].slice(0, -1);
|
|
420
|
+
for (let i = 1; i < segLists.length && common.length > 0; i++) {
|
|
421
|
+
const segs = segLists[i];
|
|
422
|
+
let j = 0;
|
|
423
|
+
const max = Math.min(common.length, segs.length - 1);
|
|
424
|
+
while (j < max && common[j].toLowerCase() === segs[j].toLowerCase()) j++;
|
|
425
|
+
common = common.slice(0, j);
|
|
426
|
+
}
|
|
427
|
+
for (let i = 0; i < absPaths.length; i++) {
|
|
428
|
+
const segs = segLists[i];
|
|
429
|
+
const rel = common.length > 0 && segs.length > common.length ? segs.slice(common.length).join("/") : segs[segs.length - 1] ?? absPaths[i];
|
|
430
|
+
out.set(absPaths[i], rel);
|
|
431
|
+
}
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
async function collectSourceFiles(data) {
|
|
435
|
+
let doclets = [];
|
|
436
|
+
if (typeof data === "function") {
|
|
437
|
+
try {
|
|
438
|
+
doclets = data({}).get();
|
|
439
|
+
} catch {
|
|
440
|
+
try {
|
|
441
|
+
doclets = data().get();
|
|
442
|
+
} catch {
|
|
443
|
+
doclets = [];
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (!Array.isArray(doclets) || doclets.length === 0) return [];
|
|
448
|
+
const absSet = /* @__PURE__ */ new Set();
|
|
449
|
+
for (const d of doclets) {
|
|
450
|
+
const meta = d?.meta;
|
|
451
|
+
if (!meta || typeof meta.path !== "string" || typeof meta.filename !== "string") continue;
|
|
452
|
+
const filename = meta.filename;
|
|
453
|
+
const ext = (0, import_node_path2.extname)(filename).toLowerCase();
|
|
454
|
+
if (ext.length > 0 && !SOURCE_EXTENSIONS.has(ext)) continue;
|
|
455
|
+
absSet.add((0, import_node_path2.resolve)(meta.path, filename));
|
|
456
|
+
}
|
|
457
|
+
if (absSet.size === 0) return [];
|
|
458
|
+
const absPaths = [...absSet];
|
|
459
|
+
const relPaths = computeRelPaths(absPaths);
|
|
460
|
+
const inputs = [];
|
|
461
|
+
for (const abs of absPaths) {
|
|
462
|
+
try {
|
|
463
|
+
const content = await (0, import_promises2.readFile)(abs, "utf8");
|
|
464
|
+
inputs.push({ absPath: abs, relPath: relPaths.get(abs) ?? abs, content });
|
|
465
|
+
} catch (err) {
|
|
466
|
+
console.warn(
|
|
467
|
+
`clean-jsdoc-theme: could not read source file '${abs}' \u2014 ${err.message}; skipping.`
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
472
|
+
return inputs;
|
|
473
|
+
}
|
|
474
|
+
var DOC_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
475
|
+
[".md", "markdown"],
|
|
476
|
+
[".markdown", "markdown"],
|
|
477
|
+
[".html", "html"],
|
|
478
|
+
[".htm", "html"]
|
|
479
|
+
]);
|
|
480
|
+
var DOC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
|
|
481
|
+
async function collectDocs(dir) {
|
|
482
|
+
if (typeof dir !== "string" || dir.trim().length === 0) return [];
|
|
483
|
+
const root = (0, import_node_path2.resolve)(dir);
|
|
484
|
+
const docs = [];
|
|
485
|
+
const walk = async (absDir, relPrefix) => {
|
|
486
|
+
let entries;
|
|
487
|
+
try {
|
|
488
|
+
entries = await (0, import_promises2.readdir)(absDir, { withFileTypes: true });
|
|
489
|
+
} catch {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
for (const entry of entries) {
|
|
493
|
+
const name = entry.name;
|
|
494
|
+
if (name.startsWith(".")) continue;
|
|
495
|
+
if (entry.isDirectory()) {
|
|
496
|
+
if (DOC_DIR_SKIP.has(name)) continue;
|
|
497
|
+
await walk((0, import_node_path2.join)(absDir, name), relPrefix ? `${relPrefix}/${name}` : name);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
if (!entry.isFile()) continue;
|
|
501
|
+
const ext = (0, import_node_path2.extname)(name).toLowerCase();
|
|
502
|
+
const type = DOC_EXTENSIONS.get(ext);
|
|
503
|
+
if (!type) continue;
|
|
504
|
+
const abs = (0, import_node_path2.join)(absDir, name);
|
|
505
|
+
const stem = name.slice(0, name.length - ext.length);
|
|
506
|
+
const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
|
|
507
|
+
try {
|
|
508
|
+
const content = await (0, import_promises2.readFile)(abs, "utf8");
|
|
509
|
+
docs.push({ path: relPath, content, type });
|
|
510
|
+
} catch (err) {
|
|
511
|
+
console.warn(
|
|
512
|
+
`clean-jsdoc-theme: could not read doc file '${abs}' \u2014 ${err.message}; skipping.`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
await walk(root, "");
|
|
518
|
+
docs.sort((a, b) => a.path.localeCompare(b.path));
|
|
519
|
+
return docs;
|
|
520
|
+
}
|
|
521
|
+
function normalizeDocGroups(raw) {
|
|
522
|
+
return normalizeSectionOrder(raw);
|
|
523
|
+
}
|
|
524
|
+
async function publish(data, opts, tutorials) {
|
|
525
|
+
const destination = opts.destination;
|
|
526
|
+
if (!destination || typeof destination !== "string") {
|
|
527
|
+
throw new Error(
|
|
528
|
+
'clean-jsdoc-theme publish: opts.destination is required (set "opts.destination" in your jsdoc.json).'
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
const [
|
|
532
|
+
{ generateSite },
|
|
533
|
+
{ render, runPagefindAgainstDir },
|
|
534
|
+
{
|
|
535
|
+
validateThemeOpts,
|
|
536
|
+
createGoogleFontResolver,
|
|
537
|
+
formatDiagnostics,
|
|
538
|
+
formatBuildReport,
|
|
539
|
+
normalizeBasePath,
|
|
540
|
+
withBase
|
|
541
|
+
}
|
|
542
|
+
] = await Promise.all([loadSetu(), loadDwar(), loadUtils()]);
|
|
543
|
+
const basePath = normalizeBasePath(opts.basePath);
|
|
544
|
+
const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
|
|
545
|
+
const fontResolver = createGoogleFontResolver();
|
|
546
|
+
const { value, diagnostics } = await validateThemeOpts({
|
|
547
|
+
opts,
|
|
548
|
+
fontResolver,
|
|
549
|
+
unknownKeyPolicy: "suggest-typos",
|
|
550
|
+
knownNonThemeKeys: JSDOC_OWN_OPTS
|
|
551
|
+
});
|
|
552
|
+
const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
|
|
553
|
+
const strict = opts.strict === true || opts.templates?.default?.strict === true;
|
|
554
|
+
if (diagnostics.list.length > 0) {
|
|
555
|
+
const formatted = formatDiagnostics(diagnostics, { color });
|
|
556
|
+
if (strict && diagnostics.hasErrors()) {
|
|
557
|
+
console.error(formatted);
|
|
558
|
+
throw new Error(
|
|
559
|
+
"clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`."
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
console.log(formatted);
|
|
563
|
+
}
|
|
564
|
+
const pkg = await resolvePkg(data, opts);
|
|
565
|
+
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
566
|
+
const tutorialTree = normalizeTutorials(tutorials);
|
|
567
|
+
const sources = outputSourceFilesEnabled(opts) ? await collectSourceFiles(data) : [];
|
|
568
|
+
const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
|
|
569
|
+
const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
|
|
570
|
+
const docs = docsDir ? await collectDocs(docsDir) : [];
|
|
571
|
+
const docGroups = normalizeDocGroups(opts.docGroups);
|
|
572
|
+
const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
|
|
573
|
+
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
574
|
+
const menu = normalizeMenu(opts.menu);
|
|
575
|
+
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
576
|
+
const manifest = generateSite(data, {
|
|
577
|
+
...pkg ? { pkg } : {},
|
|
578
|
+
...readme ? { readme } : {},
|
|
579
|
+
...tutorialTree.length > 0 ? { tutorials: tutorialTree } : {},
|
|
580
|
+
...sources.length > 0 ? { sources } : {},
|
|
581
|
+
...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
|
|
582
|
+
...docs.length > 0 ? { docs } : {},
|
|
583
|
+
...docGroups ? { docGroups } : {},
|
|
584
|
+
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
585
|
+
...sectionOrder ? { sectionOrder } : {},
|
|
586
|
+
...menu ? { menu } : {},
|
|
587
|
+
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
588
|
+
});
|
|
589
|
+
const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
|
|
590
|
+
const notGoogle = new Set(
|
|
591
|
+
diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path)
|
|
592
|
+
);
|
|
593
|
+
const fonts = { ...value.fonts };
|
|
594
|
+
if (notGoogle.has("fonts.heading")) delete fonts.heading;
|
|
595
|
+
if (notGoogle.has("fonts.body")) delete fonts.body;
|
|
596
|
+
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
597
|
+
const absoluteDestination = (0, import_node_path2.resolve)(destination);
|
|
598
|
+
const result = await render(manifest, {
|
|
599
|
+
theme: { ...resolveTheme(opts, siteName, fonts, basePath), ...customAssets.theme },
|
|
600
|
+
destination: absoluteDestination
|
|
601
|
+
});
|
|
602
|
+
const outputFiles = [...result.files, ...logoFiles, ...customAssets.files];
|
|
603
|
+
await writeOutputFiles(absoluteDestination, outputFiles);
|
|
604
|
+
const zlib = await import("zlib");
|
|
605
|
+
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
606
|
+
console.log(
|
|
607
|
+
formatBuildReport({
|
|
608
|
+
files: outputFiles,
|
|
609
|
+
stats: result.stats,
|
|
610
|
+
destination,
|
|
611
|
+
gzipSizer,
|
|
612
|
+
color
|
|
613
|
+
})
|
|
614
|
+
);
|
|
615
|
+
if (result.errors && result.errors.length > 0) {
|
|
616
|
+
console.warn(
|
|
617
|
+
`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`
|
|
618
|
+
);
|
|
619
|
+
for (const e of result.errors) {
|
|
620
|
+
console.warn(` - ${e.slug}: ${e.message}`);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
try {
|
|
624
|
+
await runPagefindAgainstDir(absoluteDestination);
|
|
625
|
+
} catch (err) {
|
|
626
|
+
console.warn(`clean-jsdoc-theme: pagefind step skipped \u2014 ${err.message}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
630
|
+
0 && (module.exports = {
|
|
631
|
+
collectDocs,
|
|
632
|
+
computeRelPaths,
|
|
633
|
+
normalizeCopyPage,
|
|
634
|
+
normalizeDocGroups,
|
|
635
|
+
normalizeMenu,
|
|
636
|
+
normalizeSectionOrder,
|
|
637
|
+
outputSourceFilesEnabled,
|
|
638
|
+
publish,
|
|
639
|
+
sourceLinkToCommentEnabled
|
|
640
|
+
});
|
|
641
|
+
//# sourceMappingURL=publish.js.map
|