clean-jsdoc-theme 5.0.0-alpha.4 → 5.0.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 +36 -2
- package/dist/publish.d.ts +36 -2
- package/dist/publish.js +56 -1
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +54 -1
- package/dist/publish.mjs.map +1 -1
- package/package.json +6 -6
package/dist/publish.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputFile, ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
1
|
+
import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
2
|
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
@@ -106,6 +106,22 @@ interface JSDocOpts {
|
|
|
106
106
|
* Defaults to enabled.
|
|
107
107
|
*/
|
|
108
108
|
pageNav?: unknown;
|
|
109
|
+
/**
|
|
110
|
+
* Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
|
|
111
|
+
* inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
|
|
112
|
+
* disk by the bridge). Rendered into rang's footer slot in place of the
|
|
113
|
+
* default footer on every page; style it with `customCss`/`customCssFile`.
|
|
114
|
+
* Omit for the default footer.
|
|
115
|
+
*/
|
|
116
|
+
footer?: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
|
|
119
|
+
* array of attribute maps — each object's key/value pairs become one `<meta>`
|
|
120
|
+
* tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
|
|
121
|
+
* escapes values, drops invalid attribute names, and de-dupes against its own
|
|
122
|
+
* head defaults (an author `name: "description"` replaces the auto one).
|
|
123
|
+
*/
|
|
124
|
+
meta?: unknown;
|
|
109
125
|
/**
|
|
110
126
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
111
127
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -163,6 +179,24 @@ interface JSDocOpts {
|
|
|
163
179
|
};
|
|
164
180
|
[key: string]: unknown;
|
|
165
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
|
|
184
|
+
* `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
|
|
185
|
+
* bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
|
|
186
|
+
* string. A missing/unreadable file is warned about and dropped (resilient,
|
|
187
|
+
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
188
|
+
* the default footer renders. Exported for testing.
|
|
189
|
+
*/
|
|
190
|
+
declare function resolveFooter(raw: unknown): Promise<string | undefined>;
|
|
191
|
+
/**
|
|
192
|
+
* Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
|
|
193
|
+
* when there's nothing usable. Accepts only an array of objects; within each,
|
|
194
|
+
* keeps string→string pairs (trimming the value, coercing finite numbers to
|
|
195
|
+
* strings for convenience) and drops the rest. An entry with no recognized
|
|
196
|
+
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
197
|
+
* dropped with a warning — dwar does the final escaping + key validation.
|
|
198
|
+
*/
|
|
199
|
+
declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
|
|
166
200
|
/**
|
|
167
201
|
* Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
|
|
168
202
|
* `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
|
|
@@ -300,4 +334,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
300
334
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
301
335
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
302
336
|
|
|
303
|
-
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, sourceLinkToCommentEnabled };
|
|
337
|
+
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFooter, sourceLinkToCommentEnabled };
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputFile, ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
1
|
+
import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
2
|
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
@@ -106,6 +106,22 @@ interface JSDocOpts {
|
|
|
106
106
|
* Defaults to enabled.
|
|
107
107
|
*/
|
|
108
108
|
pageNav?: unknown;
|
|
109
|
+
/**
|
|
110
|
+
* Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
|
|
111
|
+
* inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
|
|
112
|
+
* disk by the bridge). Rendered into rang's footer slot in place of the
|
|
113
|
+
* default footer on every page; style it with `customCss`/`customCssFile`.
|
|
114
|
+
* Omit for the default footer.
|
|
115
|
+
*/
|
|
116
|
+
footer?: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
|
|
119
|
+
* array of attribute maps — each object's key/value pairs become one `<meta>`
|
|
120
|
+
* tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
|
|
121
|
+
* escapes values, drops invalid attribute names, and de-dupes against its own
|
|
122
|
+
* head defaults (an author `name: "description"` replaces the auto one).
|
|
123
|
+
*/
|
|
124
|
+
meta?: unknown;
|
|
109
125
|
/**
|
|
110
126
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
111
127
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -163,6 +179,24 @@ interface JSDocOpts {
|
|
|
163
179
|
};
|
|
164
180
|
[key: string]: unknown;
|
|
165
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
|
|
184
|
+
* `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
|
|
185
|
+
* bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
|
|
186
|
+
* string. A missing/unreadable file is warned about and dropped (resilient,
|
|
187
|
+
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
188
|
+
* the default footer renders. Exported for testing.
|
|
189
|
+
*/
|
|
190
|
+
declare function resolveFooter(raw: unknown): Promise<string | undefined>;
|
|
191
|
+
/**
|
|
192
|
+
* Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
|
|
193
|
+
* when there's nothing usable. Accepts only an array of objects; within each,
|
|
194
|
+
* keeps string→string pairs (trimming the value, coercing finite numbers to
|
|
195
|
+
* strings for convenience) and drops the rest. An entry with no recognized
|
|
196
|
+
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
197
|
+
* dropped with a warning — dwar does the final escaping + key validation.
|
|
198
|
+
*/
|
|
199
|
+
declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
|
|
166
200
|
/**
|
|
167
201
|
* Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
|
|
168
202
|
* `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
|
|
@@ -300,4 +334,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
300
334
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
301
335
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
302
336
|
|
|
303
|
-
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, sourceLinkToCommentEnabled };
|
|
337
|
+
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFooter, sourceLinkToCommentEnabled };
|
package/dist/publish.js
CHANGED
|
@@ -37,12 +37,14 @@ __export(publish_exports, {
|
|
|
37
37
|
normalizeCopyPage: () => normalizeCopyPage,
|
|
38
38
|
normalizeDocGroups: () => normalizeDocGroups,
|
|
39
39
|
normalizeMenu: () => normalizeMenu,
|
|
40
|
+
normalizeMeta: () => normalizeMeta,
|
|
40
41
|
normalizePageNav: () => normalizePageNav,
|
|
41
42
|
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
42
43
|
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
43
44
|
overlayDocs: () => overlayDocs,
|
|
44
45
|
publish: () => publish,
|
|
45
46
|
resolveDocImages: () => resolveDocImages,
|
|
47
|
+
resolveFooter: () => resolveFooter,
|
|
46
48
|
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled
|
|
47
49
|
});
|
|
48
50
|
module.exports = __toCommonJS(publish_exports);
|
|
@@ -289,6 +291,53 @@ async function resolveCustomAssets(opts, hrefForServed) {
|
|
|
289
291
|
files: [...cssAssets.files, ...jsAssets.files]
|
|
290
292
|
};
|
|
291
293
|
}
|
|
294
|
+
async function resolveFooter(raw) {
|
|
295
|
+
if (typeof raw === "string") {
|
|
296
|
+
const trimmed = raw.trim();
|
|
297
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
298
|
+
}
|
|
299
|
+
if (raw && typeof raw === "object" && typeof raw.file === "string") {
|
|
300
|
+
const file = raw.file.trim();
|
|
301
|
+
if (!file) return void 0;
|
|
302
|
+
try {
|
|
303
|
+
const html = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(file), "utf8");
|
|
304
|
+
return html.trim().length > 0 ? html : void 0;
|
|
305
|
+
} catch {
|
|
306
|
+
console.warn(
|
|
307
|
+
`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`
|
|
308
|
+
);
|
|
309
|
+
return void 0;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return void 0;
|
|
313
|
+
}
|
|
314
|
+
var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
|
|
315
|
+
function normalizeMeta(raw) {
|
|
316
|
+
if (!Array.isArray(raw)) return void 0;
|
|
317
|
+
const out = [];
|
|
318
|
+
for (const entry of raw) {
|
|
319
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
320
|
+
const o = entry;
|
|
321
|
+
const tag = {};
|
|
322
|
+
for (const [k, v] of Object.entries(o)) {
|
|
323
|
+
if (typeof v === "string") {
|
|
324
|
+
const t = v.trim();
|
|
325
|
+
if (t.length > 0) tag[k] = t;
|
|
326
|
+
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
327
|
+
tag[k] = String(v);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const hasIdentity = META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string");
|
|
331
|
+
if (!hasIdentity || Object.keys(tag).length === 0) {
|
|
332
|
+
console.warn(
|
|
333
|
+
`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
|
|
334
|
+
);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
out.push(tag);
|
|
338
|
+
}
|
|
339
|
+
return out.length > 0 ? out : void 0;
|
|
340
|
+
}
|
|
292
341
|
function isServableUrl(value) {
|
|
293
342
|
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
294
343
|
}
|
|
@@ -859,6 +908,8 @@ async function publish(data, opts, tutorials) {
|
|
|
859
908
|
fonts.locales = cleaned;
|
|
860
909
|
}
|
|
861
910
|
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
911
|
+
const footer = await resolveFooter(opts.footer);
|
|
912
|
+
const meta = normalizeMeta(opts.meta);
|
|
862
913
|
const absoluteDestination = (0, import_node_path2.resolve)(destination);
|
|
863
914
|
const islandCacheDir = (0, import_node_path2.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
864
915
|
const result = await progress.stage(
|
|
@@ -866,7 +917,9 @@ async function publish(data, opts, tutorials) {
|
|
|
866
917
|
() => render(manifest, {
|
|
867
918
|
theme: {
|
|
868
919
|
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
869
|
-
...customAssets.theme
|
|
920
|
+
...customAssets.theme,
|
|
921
|
+
...footer ? { footer } : {},
|
|
922
|
+
...meta ? { meta } : {}
|
|
870
923
|
},
|
|
871
924
|
destination: absoluteDestination,
|
|
872
925
|
islandCacheDir,
|
|
@@ -923,12 +976,14 @@ async function publish(data, opts, tutorials) {
|
|
|
923
976
|
normalizeCopyPage,
|
|
924
977
|
normalizeDocGroups,
|
|
925
978
|
normalizeMenu,
|
|
979
|
+
normalizeMeta,
|
|
926
980
|
normalizePageNav,
|
|
927
981
|
normalizeSectionOrder,
|
|
928
982
|
outputSourceFilesEnabled,
|
|
929
983
|
overlayDocs,
|
|
930
984
|
publish,
|
|
931
985
|
resolveDocImages,
|
|
986
|
+
resolveFooter,
|
|
932
987
|
sourceLinkToCommentEnabled
|
|
933
988
|
});
|
|
934
989
|
//# sourceMappingURL=publish.js.map
|