clean-jsdoc-theme 5.0.4 → 5.0.5
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 +142 -14
- package/dist/publish.d.ts +142 -14
- package/dist/publish.js +351 -67
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +343 -67
- package/dist/publish.mjs.map +1 -1
- package/package.json +10 -6
package/dist/publish.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OutputFile, SiteLogo, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, ThemeConfig } from '@clean-jsdoc-theme/dwar';
|
|
2
|
-
import { DocInput, MenuItem, PlaygroundSiteConfig } from '@clean-jsdoc-theme/setu';
|
|
2
|
+
import { DocInput, MenuItem, PlaygroundSiteConfig, TutorialInput } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
5
5
|
destination?: string;
|
|
@@ -124,6 +124,14 @@ interface JSDocOpts {
|
|
|
124
124
|
* Omit for the default footer.
|
|
125
125
|
*/
|
|
126
126
|
footer?: unknown;
|
|
127
|
+
/**
|
|
128
|
+
* Site public base URL (`jsdoc.json` `"opts": { "siteUrl": "https://example.com" }`).
|
|
129
|
+
* When set, the build emits a `sitemap.xml` at the output root listing every
|
|
130
|
+
* non-hidden page's canonical URL. Only the URL's origin is used — the deploy
|
|
131
|
+
* sub-path comes from `basePath` — so a bare origin or a full URL whose path
|
|
132
|
+
* equals `basePath` both work. Omit it for no sitemap.
|
|
133
|
+
*/
|
|
134
|
+
siteUrl?: unknown;
|
|
127
135
|
/**
|
|
128
136
|
* Favicon (`jsdoc.json` `"opts": { "favicon": "./icon.svg" }`). A path to an
|
|
129
137
|
* image file (`.svg`/`.png`/`.ico`/…), relative to the working dir. The bridge
|
|
@@ -196,6 +204,15 @@ interface JSDocOpts {
|
|
|
196
204
|
outputSourceFiles?: unknown;
|
|
197
205
|
sourceLinkToComment?: unknown;
|
|
198
206
|
cleanOutputDir?: unknown;
|
|
207
|
+
/**
|
|
208
|
+
* JSDoc's standard static-file passthrough
|
|
209
|
+
* (`templates.default.staticFiles`): `{ include, exclude, includePattern,
|
|
210
|
+
* excludePattern }`. Files matched by `include` are copied verbatim into
|
|
211
|
+
* the output (an include dir's contents land at the output root, JSDoc's
|
|
212
|
+
* mapping) AND their dirs become fallback search roots for image
|
|
213
|
+
* resolution, so a bare/relative reference to a static image resolves.
|
|
214
|
+
*/
|
|
215
|
+
staticFiles?: unknown;
|
|
199
216
|
};
|
|
200
217
|
};
|
|
201
218
|
[key: string]: unknown;
|
|
@@ -350,23 +367,134 @@ declare function computeRelPaths(absPaths: readonly string[]): Map<string, strin
|
|
|
350
367
|
*/
|
|
351
368
|
declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
352
369
|
/**
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* `
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
370
|
+
* A reusable local-image asset pipeline shared by every prose source (docs,
|
|
371
|
+
* tutorials, README, doclet comments). `resolve(src, baseDir)` copies a local
|
|
372
|
+
* image to `_assets/<base>.<hash><ext>` (content-hashed → cache-busted, deduped
|
|
373
|
+
* across all sources via the shared caches) and returns the root-relative
|
|
374
|
+
* `/_assets/…` href. It accumulates each copied file on `files`, each SVG's
|
|
375
|
+
* markup on `inlineSvgs` (keyed by the rewritten href, so the renderer can inline
|
|
376
|
+
* it — its `[data-theme]` styles then track the toggle), and the absolute source
|
|
377
|
+
* path of every copied image on `consumed` (so the static-file passthrough can
|
|
378
|
+
* skip re-copying an image it already served from `_assets/`).
|
|
379
|
+
*
|
|
380
|
+
* Resolution tries, in order: the doc-relative path (or project root for a
|
|
381
|
+
* `/`-rooted src), then — for the JSDoc `staticFiles` convention — each
|
|
382
|
+
* `staticDirs` root joined with the reference's output-relative name. So a bare
|
|
383
|
+
* `` whose file lives in a declared `staticFiles` dir still
|
|
384
|
+
* resolves and is hashed. External (`http(s):`, `data:`), `#`-anchor, and
|
|
385
|
+
* fully-unresolvable srcs yield `null` (the last warned once) so callers leave
|
|
386
|
+
* them untouched.
|
|
387
|
+
*/
|
|
388
|
+
interface ImageCollector {
|
|
389
|
+
resolve(rawSrc: string, baseDir: string): Promise<string | null>;
|
|
390
|
+
readonly files: OutputFile[];
|
|
391
|
+
readonly inlineSvgs: Record<string, string>;
|
|
392
|
+
readonly consumed: Set<string>;
|
|
393
|
+
}
|
|
394
|
+
declare function createImageCollector(staticDirs?: readonly string[]): ImageCollector;
|
|
395
|
+
/**
|
|
396
|
+
* Resolve the local images a doc references and route them through the shared
|
|
397
|
+
* content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
|
|
398
|
+
* `` / `<img src>` whose `src` points to a file on disk is copied and
|
|
399
|
+
* its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
400
|
+
* `MdxImg` adds the base path, like it does for links), resolved relative to the
|
|
401
|
+
* project root when it starts with `/`, else relative to the doc's own directory.
|
|
402
|
+
* Returns the docs with rewritten content plus the asset files to write. The
|
|
403
|
+
* bridge is the I/O layer here, so setu/dwar only ever see the final `_assets/`
|
|
404
|
+
* paths.
|
|
364
405
|
*/
|
|
365
|
-
declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
|
|
406
|
+
declare function resolveDocImages(docs: DocInput[], docsDir: string, collector?: ImageCollector): Promise<{
|
|
366
407
|
docs: DocInput[];
|
|
367
408
|
files: OutputFile[];
|
|
368
409
|
inlineSvgs: Record<string, string>;
|
|
369
410
|
}>;
|
|
411
|
+
/**
|
|
412
|
+
* Resolve the local images referenced by tutorial content, routing them through
|
|
413
|
+
* the shared `collector` (the same content-hashed `_assets/` pipeline as docs).
|
|
414
|
+
* JSDoc reads every tutorial from a single directory, so each tutorial's relative
|
|
415
|
+
* srcs (``, `<img src>`) resolve against `tutorialsDir`. Walks
|
|
416
|
+
* the resolved tree (sub-tutorials included), rewriting each node's content —
|
|
417
|
+
* Markdown or HTML; the tree shape is preserved. Returns a new tree (the input is
|
|
418
|
+
* left untouched). Exported for testing.
|
|
419
|
+
*/
|
|
420
|
+
declare function resolveTutorialImages(tree: TutorialInput[], tutorialsDir: string, collector: ImageCollector): Promise<TutorialInput[]>;
|
|
421
|
+
/**
|
|
422
|
+
* Resolve the local images referenced inside JSDoc-comment prose (doclet
|
|
423
|
+
* descriptions, `@classdesc`, nested `@param`/`@property`/`@returns`
|
|
424
|
+
* descriptions, …) and route them through the shared `collector`. JSDoc's
|
|
425
|
+
* `plugins/markdown` has already turned a comment's `` into
|
|
426
|
+
* an HTML `<img src="../img/x.png">` by the time `publish` runs, so each src is
|
|
427
|
+
* resolved **relative to that doclet's own source file** (`meta.path` — the
|
|
428
|
+
* directory of the file the comment lives in). Doclets are mutated IN PLACE:
|
|
429
|
+
* salty's `get()` hands out live object references, so the rewrite is visible
|
|
430
|
+
* when setu later reads the same collection. Resilient — a non-collection `data`
|
|
431
|
+
* or unreadable image is skipped (the latter warned), never fatal.
|
|
432
|
+
*/
|
|
433
|
+
declare function resolveDocletImages(data: unknown, collector: ImageCollector): Promise<void>;
|
|
434
|
+
/** Normalized `templates.default.staticFiles` config. */
|
|
435
|
+
interface StaticFilesConfig {
|
|
436
|
+
/** Resolved-as-given include paths (dirs or files), trimmed, non-empty. */
|
|
437
|
+
include: string[];
|
|
438
|
+
/** Paths to exclude (a file equal to, or under, an excluded dir is dropped). */
|
|
439
|
+
exclude: string[];
|
|
440
|
+
/** Regex (source string) a file's POSIX abs path must match to be included. */
|
|
441
|
+
includePattern?: string;
|
|
442
|
+
/** Regex (source string) that drops a file when its POSIX abs path matches. */
|
|
443
|
+
excludePattern?: string;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Normalize a raw `staticFiles` block into a {@link StaticFilesConfig}, or
|
|
447
|
+
* `undefined` when there's nothing to include. `include`/`exclude` accept a
|
|
448
|
+
* string or string[]; patterns are kept as source strings (compiled later, so a
|
|
449
|
+
* bad pattern fails open rather than throwing). Pure + exported for testing.
|
|
450
|
+
*/
|
|
451
|
+
declare function normalizeStaticFilesConfig(raw: unknown): StaticFilesConfig | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* Read `templates.default.staticFiles` from JSDoc's canonical `jsdoc/env` conf
|
|
454
|
+
* (the only place the root-level `templates` block lives at runtime), falling
|
|
455
|
+
* back to a nested `opts.templates.default.staticFiles`. Mirrors the probe order
|
|
456
|
+
* of {@link outputSourceFilesEnabled}. Returns `undefined` when unset/unusable.
|
|
457
|
+
*/
|
|
458
|
+
declare function readStaticFilesConfig(opts: JSDocOpts): StaticFilesConfig | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Output-relative path (POSIX) for a static file under an include root: strip the
|
|
461
|
+
* resolved-root prefix so `<root>/img/sub/x.png` under root `<root>/img` →
|
|
462
|
+
* `sub/x.png` (JSDoc maps an include dir's contents to the output ROOT). When the
|
|
463
|
+
* include was a single FILE (`absFile === includeRootAbs`), the output name is its
|
|
464
|
+
* basename. Windows-aware: separators are normalized and the prefix match is
|
|
465
|
+
* case-insensitive (NTFS). Pure + exported for testing.
|
|
466
|
+
*/
|
|
467
|
+
declare function staticFileOutputName(absFile: string, includeRootAbs: string): string;
|
|
468
|
+
/**
|
|
469
|
+
* Whether a static file passes a config's filter — `includePattern` (must match),
|
|
470
|
+
* `excludePattern` (must not match), and `exclude` (file equal to, or nested
|
|
471
|
+
* under, an excluded path is dropped). Patterns are tested against the file's
|
|
472
|
+
* POSIX-normalized absolute path; a malformed pattern fails open (ignored). Pure
|
|
473
|
+
* + exported for testing.
|
|
474
|
+
*/
|
|
475
|
+
declare function staticFileIncluded(absFile: string, config: StaticFilesConfig): boolean;
|
|
476
|
+
/** One verbatim static-file copy entry. */
|
|
477
|
+
interface StaticFileEntry {
|
|
478
|
+
/** Output-relative POSIX path (where it lands under the destination). */
|
|
479
|
+
outputPath: string;
|
|
480
|
+
/** Absolute source path (matched against the image collector's `consumed`). */
|
|
481
|
+
absSource: string;
|
|
482
|
+
contents: Buffer;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Collect the files matched by a {@link StaticFilesConfig}: walk each include
|
|
486
|
+
* path (a directory recursively, or a single file), apply
|
|
487
|
+
* {@link staticFileIncluded}, and read each match. Returns the verbatim copy
|
|
488
|
+
* entries (output path = include-root-stripped, JSDoc's "contents → output root"
|
|
489
|
+
* mapping) plus the resolved `searchDirs` the image resolver uses as fallback
|
|
490
|
+
* roots (an include dir as-is; a file include's parent dir). Resilient: a missing
|
|
491
|
+
* include path / unreadable file is warned + skipped, never fatal. Exported for
|
|
492
|
+
* testing.
|
|
493
|
+
*/
|
|
494
|
+
declare function collectStaticFiles(config: StaticFilesConfig, warn?: (message: string) => void): Promise<{
|
|
495
|
+
files: StaticFileEntry[];
|
|
496
|
+
searchDirs: string[];
|
|
497
|
+
}>;
|
|
370
498
|
/** The output of {@link resolveDocImages}: resolved docs + their image assets. */
|
|
371
499
|
interface ResolvedDocs {
|
|
372
500
|
docs: DocInput[];
|
|
@@ -391,4 +519,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
391
519
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
392
520
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
393
521
|
|
|
394
|
-
export { type ResolvedDocs, cleanOutputDirEnabled, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFavicon, resolveFooter, sourceLinkToCommentEnabled };
|
|
522
|
+
export { type ImageCollector, type ResolvedDocs, type StaticFileEntry, type StaticFilesConfig, cleanOutputDirEnabled, collectDocs, collectStaticFiles, computeRelPaths, createImageCollector, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, normalizeStaticFilesConfig, outputSourceFilesEnabled, overlayDocs, publish, readStaticFilesConfig, resolveDocImages, resolveDocletImages, resolveFavicon, resolveFooter, resolveTutorialImages, sourceLinkToCommentEnabled, staticFileIncluded, staticFileOutputName };
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OutputFile, SiteLogo, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, ThemeConfig } from '@clean-jsdoc-theme/dwar';
|
|
2
|
-
import { DocInput, MenuItem, PlaygroundSiteConfig } from '@clean-jsdoc-theme/setu';
|
|
2
|
+
import { DocInput, MenuItem, PlaygroundSiteConfig, TutorialInput } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
5
5
|
destination?: string;
|
|
@@ -124,6 +124,14 @@ interface JSDocOpts {
|
|
|
124
124
|
* Omit for the default footer.
|
|
125
125
|
*/
|
|
126
126
|
footer?: unknown;
|
|
127
|
+
/**
|
|
128
|
+
* Site public base URL (`jsdoc.json` `"opts": { "siteUrl": "https://example.com" }`).
|
|
129
|
+
* When set, the build emits a `sitemap.xml` at the output root listing every
|
|
130
|
+
* non-hidden page's canonical URL. Only the URL's origin is used — the deploy
|
|
131
|
+
* sub-path comes from `basePath` — so a bare origin or a full URL whose path
|
|
132
|
+
* equals `basePath` both work. Omit it for no sitemap.
|
|
133
|
+
*/
|
|
134
|
+
siteUrl?: unknown;
|
|
127
135
|
/**
|
|
128
136
|
* Favicon (`jsdoc.json` `"opts": { "favicon": "./icon.svg" }`). A path to an
|
|
129
137
|
* image file (`.svg`/`.png`/`.ico`/…), relative to the working dir. The bridge
|
|
@@ -196,6 +204,15 @@ interface JSDocOpts {
|
|
|
196
204
|
outputSourceFiles?: unknown;
|
|
197
205
|
sourceLinkToComment?: unknown;
|
|
198
206
|
cleanOutputDir?: unknown;
|
|
207
|
+
/**
|
|
208
|
+
* JSDoc's standard static-file passthrough
|
|
209
|
+
* (`templates.default.staticFiles`): `{ include, exclude, includePattern,
|
|
210
|
+
* excludePattern }`. Files matched by `include` are copied verbatim into
|
|
211
|
+
* the output (an include dir's contents land at the output root, JSDoc's
|
|
212
|
+
* mapping) AND their dirs become fallback search roots for image
|
|
213
|
+
* resolution, so a bare/relative reference to a static image resolves.
|
|
214
|
+
*/
|
|
215
|
+
staticFiles?: unknown;
|
|
199
216
|
};
|
|
200
217
|
};
|
|
201
218
|
[key: string]: unknown;
|
|
@@ -350,23 +367,134 @@ declare function computeRelPaths(absPaths: readonly string[]): Map<string, strin
|
|
|
350
367
|
*/
|
|
351
368
|
declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
352
369
|
/**
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* `
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
370
|
+
* A reusable local-image asset pipeline shared by every prose source (docs,
|
|
371
|
+
* tutorials, README, doclet comments). `resolve(src, baseDir)` copies a local
|
|
372
|
+
* image to `_assets/<base>.<hash><ext>` (content-hashed → cache-busted, deduped
|
|
373
|
+
* across all sources via the shared caches) and returns the root-relative
|
|
374
|
+
* `/_assets/…` href. It accumulates each copied file on `files`, each SVG's
|
|
375
|
+
* markup on `inlineSvgs` (keyed by the rewritten href, so the renderer can inline
|
|
376
|
+
* it — its `[data-theme]` styles then track the toggle), and the absolute source
|
|
377
|
+
* path of every copied image on `consumed` (so the static-file passthrough can
|
|
378
|
+
* skip re-copying an image it already served from `_assets/`).
|
|
379
|
+
*
|
|
380
|
+
* Resolution tries, in order: the doc-relative path (or project root for a
|
|
381
|
+
* `/`-rooted src), then — for the JSDoc `staticFiles` convention — each
|
|
382
|
+
* `staticDirs` root joined with the reference's output-relative name. So a bare
|
|
383
|
+
* `` whose file lives in a declared `staticFiles` dir still
|
|
384
|
+
* resolves and is hashed. External (`http(s):`, `data:`), `#`-anchor, and
|
|
385
|
+
* fully-unresolvable srcs yield `null` (the last warned once) so callers leave
|
|
386
|
+
* them untouched.
|
|
387
|
+
*/
|
|
388
|
+
interface ImageCollector {
|
|
389
|
+
resolve(rawSrc: string, baseDir: string): Promise<string | null>;
|
|
390
|
+
readonly files: OutputFile[];
|
|
391
|
+
readonly inlineSvgs: Record<string, string>;
|
|
392
|
+
readonly consumed: Set<string>;
|
|
393
|
+
}
|
|
394
|
+
declare function createImageCollector(staticDirs?: readonly string[]): ImageCollector;
|
|
395
|
+
/**
|
|
396
|
+
* Resolve the local images a doc references and route them through the shared
|
|
397
|
+
* content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
|
|
398
|
+
* `` / `<img src>` whose `src` points to a file on disk is copied and
|
|
399
|
+
* its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
400
|
+
* `MdxImg` adds the base path, like it does for links), resolved relative to the
|
|
401
|
+
* project root when it starts with `/`, else relative to the doc's own directory.
|
|
402
|
+
* Returns the docs with rewritten content plus the asset files to write. The
|
|
403
|
+
* bridge is the I/O layer here, so setu/dwar only ever see the final `_assets/`
|
|
404
|
+
* paths.
|
|
364
405
|
*/
|
|
365
|
-
declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
|
|
406
|
+
declare function resolveDocImages(docs: DocInput[], docsDir: string, collector?: ImageCollector): Promise<{
|
|
366
407
|
docs: DocInput[];
|
|
367
408
|
files: OutputFile[];
|
|
368
409
|
inlineSvgs: Record<string, string>;
|
|
369
410
|
}>;
|
|
411
|
+
/**
|
|
412
|
+
* Resolve the local images referenced by tutorial content, routing them through
|
|
413
|
+
* the shared `collector` (the same content-hashed `_assets/` pipeline as docs).
|
|
414
|
+
* JSDoc reads every tutorial from a single directory, so each tutorial's relative
|
|
415
|
+
* srcs (``, `<img src>`) resolve against `tutorialsDir`. Walks
|
|
416
|
+
* the resolved tree (sub-tutorials included), rewriting each node's content —
|
|
417
|
+
* Markdown or HTML; the tree shape is preserved. Returns a new tree (the input is
|
|
418
|
+
* left untouched). Exported for testing.
|
|
419
|
+
*/
|
|
420
|
+
declare function resolveTutorialImages(tree: TutorialInput[], tutorialsDir: string, collector: ImageCollector): Promise<TutorialInput[]>;
|
|
421
|
+
/**
|
|
422
|
+
* Resolve the local images referenced inside JSDoc-comment prose (doclet
|
|
423
|
+
* descriptions, `@classdesc`, nested `@param`/`@property`/`@returns`
|
|
424
|
+
* descriptions, …) and route them through the shared `collector`. JSDoc's
|
|
425
|
+
* `plugins/markdown` has already turned a comment's `` into
|
|
426
|
+
* an HTML `<img src="../img/x.png">` by the time `publish` runs, so each src is
|
|
427
|
+
* resolved **relative to that doclet's own source file** (`meta.path` — the
|
|
428
|
+
* directory of the file the comment lives in). Doclets are mutated IN PLACE:
|
|
429
|
+
* salty's `get()` hands out live object references, so the rewrite is visible
|
|
430
|
+
* when setu later reads the same collection. Resilient — a non-collection `data`
|
|
431
|
+
* or unreadable image is skipped (the latter warned), never fatal.
|
|
432
|
+
*/
|
|
433
|
+
declare function resolveDocletImages(data: unknown, collector: ImageCollector): Promise<void>;
|
|
434
|
+
/** Normalized `templates.default.staticFiles` config. */
|
|
435
|
+
interface StaticFilesConfig {
|
|
436
|
+
/** Resolved-as-given include paths (dirs or files), trimmed, non-empty. */
|
|
437
|
+
include: string[];
|
|
438
|
+
/** Paths to exclude (a file equal to, or under, an excluded dir is dropped). */
|
|
439
|
+
exclude: string[];
|
|
440
|
+
/** Regex (source string) a file's POSIX abs path must match to be included. */
|
|
441
|
+
includePattern?: string;
|
|
442
|
+
/** Regex (source string) that drops a file when its POSIX abs path matches. */
|
|
443
|
+
excludePattern?: string;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Normalize a raw `staticFiles` block into a {@link StaticFilesConfig}, or
|
|
447
|
+
* `undefined` when there's nothing to include. `include`/`exclude` accept a
|
|
448
|
+
* string or string[]; patterns are kept as source strings (compiled later, so a
|
|
449
|
+
* bad pattern fails open rather than throwing). Pure + exported for testing.
|
|
450
|
+
*/
|
|
451
|
+
declare function normalizeStaticFilesConfig(raw: unknown): StaticFilesConfig | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* Read `templates.default.staticFiles` from JSDoc's canonical `jsdoc/env` conf
|
|
454
|
+
* (the only place the root-level `templates` block lives at runtime), falling
|
|
455
|
+
* back to a nested `opts.templates.default.staticFiles`. Mirrors the probe order
|
|
456
|
+
* of {@link outputSourceFilesEnabled}. Returns `undefined` when unset/unusable.
|
|
457
|
+
*/
|
|
458
|
+
declare function readStaticFilesConfig(opts: JSDocOpts): StaticFilesConfig | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Output-relative path (POSIX) for a static file under an include root: strip the
|
|
461
|
+
* resolved-root prefix so `<root>/img/sub/x.png` under root `<root>/img` →
|
|
462
|
+
* `sub/x.png` (JSDoc maps an include dir's contents to the output ROOT). When the
|
|
463
|
+
* include was a single FILE (`absFile === includeRootAbs`), the output name is its
|
|
464
|
+
* basename. Windows-aware: separators are normalized and the prefix match is
|
|
465
|
+
* case-insensitive (NTFS). Pure + exported for testing.
|
|
466
|
+
*/
|
|
467
|
+
declare function staticFileOutputName(absFile: string, includeRootAbs: string): string;
|
|
468
|
+
/**
|
|
469
|
+
* Whether a static file passes a config's filter — `includePattern` (must match),
|
|
470
|
+
* `excludePattern` (must not match), and `exclude` (file equal to, or nested
|
|
471
|
+
* under, an excluded path is dropped). Patterns are tested against the file's
|
|
472
|
+
* POSIX-normalized absolute path; a malformed pattern fails open (ignored). Pure
|
|
473
|
+
* + exported for testing.
|
|
474
|
+
*/
|
|
475
|
+
declare function staticFileIncluded(absFile: string, config: StaticFilesConfig): boolean;
|
|
476
|
+
/** One verbatim static-file copy entry. */
|
|
477
|
+
interface StaticFileEntry {
|
|
478
|
+
/** Output-relative POSIX path (where it lands under the destination). */
|
|
479
|
+
outputPath: string;
|
|
480
|
+
/** Absolute source path (matched against the image collector's `consumed`). */
|
|
481
|
+
absSource: string;
|
|
482
|
+
contents: Buffer;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Collect the files matched by a {@link StaticFilesConfig}: walk each include
|
|
486
|
+
* path (a directory recursively, or a single file), apply
|
|
487
|
+
* {@link staticFileIncluded}, and read each match. Returns the verbatim copy
|
|
488
|
+
* entries (output path = include-root-stripped, JSDoc's "contents → output root"
|
|
489
|
+
* mapping) plus the resolved `searchDirs` the image resolver uses as fallback
|
|
490
|
+
* roots (an include dir as-is; a file include's parent dir). Resilient: a missing
|
|
491
|
+
* include path / unreadable file is warned + skipped, never fatal. Exported for
|
|
492
|
+
* testing.
|
|
493
|
+
*/
|
|
494
|
+
declare function collectStaticFiles(config: StaticFilesConfig, warn?: (message: string) => void): Promise<{
|
|
495
|
+
files: StaticFileEntry[];
|
|
496
|
+
searchDirs: string[];
|
|
497
|
+
}>;
|
|
370
498
|
/** The output of {@link resolveDocImages}: resolved docs + their image assets. */
|
|
371
499
|
interface ResolvedDocs {
|
|
372
500
|
docs: DocInput[];
|
|
@@ -391,4 +519,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
391
519
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
392
520
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
393
521
|
|
|
394
|
-
export { type ResolvedDocs, cleanOutputDirEnabled, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFavicon, resolveFooter, sourceLinkToCommentEnabled };
|
|
522
|
+
export { type ImageCollector, type ResolvedDocs, type StaticFileEntry, type StaticFilesConfig, cleanOutputDirEnabled, collectDocs, collectStaticFiles, computeRelPaths, createImageCollector, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, normalizeStaticFilesConfig, outputSourceFilesEnabled, overlayDocs, publish, readStaticFilesConfig, resolveDocImages, resolveDocletImages, resolveFavicon, resolveFooter, resolveTutorialImages, sourceLinkToCommentEnabled, staticFileIncluded, staticFileOutputName };
|