clean-jsdoc-theme 5.0.0-alpha.1 → 5.0.0-alpha.3
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 -0
- package/README.md +64 -92
- package/dist/publish.d.mts +71 -2
- package/dist/publish.d.ts +71 -2
- package/dist/publish.js +238 -34
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +234 -34
- package/dist/publish.mjs.map +1 -1
- package/package.json +8 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ankit Kumar (अंकित कुमार)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,117 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<a href="https://ankdev.me/clean-jsdoc-theme">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ankitskvmdam/clean-jsdoc-theme/master/packages/clean-jsdoc-theme/media/clean-jsdoc-theme-dark.svg" />
|
|
6
|
+
<img src="https://raw.githubusercontent.com/ankitskvmdam/clean-jsdoc-theme/master/packages/clean-jsdoc-theme/media/clean-jsdoc-theme-light.svg" alt="clean-jsdoc-theme" width="340" />
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
|
|
10
|
+
A fast, modern, LLM-friendly documentation theme for **JSDoc** and **TypeDoc**.
|
|
11
|
+
|
|
12
|
+
[](https://www.npmjs.com/package/clean-jsdoc-theme)
|
|
13
|
+
[](https://www.npmjs.com/package/clean-jsdoc-theme)
|
|
14
|
+
[](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
|
|
15
|
+
[](https://ankdev.me/clean-jsdoc-theme)
|
|
16
|
+
[](https://ankdev.me/clean-jsdoc-theme/api-docs)
|
|
17
|
+
[](https://github.com/ankitskvmdam/clean-jsdoc-theme)
|
|
18
|
+
[](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork)
|
|
19
|
+
[](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues)
|
|
20
|
+
[](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors)
|
|
21
|
+
[](https://github.com/sponsors/ankitskvmdam)
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="https://raw.githubusercontent.com/ankitskvmdam/clean-jsdoc-theme/master/packages/clean-jsdoc-theme/media/screenshot.png" width="49%" alt="clean-jsdoc-theme — light theme" />
|
|
27
|
+
<img src="https://raw.githubusercontent.com/ankitskvmdam/clean-jsdoc-theme/master/packages/clean-jsdoc-theme/media/screenshot-dark.png" width="49%" alt="clean-jsdoc-theme — dark theme" />
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
Point it at your source comments — and, optionally, a folder of Markdown guides —
|
|
31
|
+
and it produces a static site: server-rendered HTML, lazily-hydrated interactive
|
|
32
|
+
islands, fuzzy + full-text search, light and dark themes, and a companion `.md`
|
|
33
|
+
of every page for LLMs. No CSS or build config required to get started.
|
|
34
|
+
|
|
35
|
+
## Highlights
|
|
36
|
+
|
|
37
|
+
- **JSDoc _and_ TypeDoc** — the same modern output from either toolchain.
|
|
38
|
+
- **Fast & framework-free** — server-rendered pages with lazily-hydrated Preact
|
|
39
|
+
islands; each page loads only the JS it actually uses.
|
|
40
|
+
- **Search built in** — a fuzzy command palette (`Ctrl K`) over titles,
|
|
41
|
+
descriptions, content, and per-member deep links, plus an optional
|
|
42
|
+
[Pagefind](https://pagefind.app/) full-text index.
|
|
43
|
+
- **Guides + API in one site** — hand-written Markdown guides and the
|
|
44
|
+
auto-generated reference share one sidebar and one search.
|
|
45
|
+
- **LLM-friendly** — every page ships a clean companion `.md`, plus a
|
|
46
|
+
copy-page button to hand any page to Claude / ChatGPT / Perplexity.
|
|
47
|
+
- **Polished by default** — light/dark OKLCH themes, Google Fonts, shiki syntax
|
|
48
|
+
highlighting, a Monaco source viewer, and `Source: file:line` links.
|
|
49
|
+
|
|
50
|
+
## Quick start
|
|
8
51
|
|
|
9
52
|
```sh
|
|
10
|
-
|
|
53
|
+
npm install --save-dev clean-jsdoc-theme jsdoc
|
|
11
54
|
```
|
|
12
55
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Add a `jsdoc.json` to your project:
|
|
56
|
+
Add a `jsdoc.json`:
|
|
16
57
|
|
|
17
58
|
```json
|
|
18
59
|
{
|
|
19
|
-
"source": {
|
|
20
|
-
"include": ["./src", "./README.md"]
|
|
21
|
-
},
|
|
60
|
+
"source": { "include": ["./src", "./README.md"] },
|
|
22
61
|
"plugins": ["plugins/markdown"],
|
|
23
62
|
"opts": {
|
|
24
|
-
"encoding": "utf8",
|
|
25
63
|
"destination": "dist",
|
|
26
64
|
"recurse": true,
|
|
27
|
-
"template": "
|
|
65
|
+
"template": "node_modules/clean-jsdoc-theme/dist"
|
|
28
66
|
}
|
|
29
67
|
}
|
|
30
68
|
```
|
|
31
69
|
|
|
32
|
-
|
|
70
|
+
Build, then serve over HTTP (Pagefind needs HTTP to load its index):
|
|
33
71
|
|
|
34
72
|
```sh
|
|
35
73
|
jsdoc -c jsdoc.json
|
|
74
|
+
npx serve dist
|
|
36
75
|
```
|
|
37
76
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
pnpm dlx serve dist
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## What gets generated
|
|
45
|
-
|
|
46
|
-
The theme emits a page per documented container (class / interface / mixin / module / namespace / typedef), one aggregated **Globals** page, the **README** as the home page, and **tutorials** as guide pages. For each page:
|
|
47
|
-
|
|
48
|
-
- `<slug>/index.html` — a server-rendered page with a pre-hydration theme script, layout chrome (header / sidebar / TOC / footer), island markers, and the lazy island loader.
|
|
49
|
-
- `<slug>/index.md` — the page's Markdown, written verbatim alongside the HTML, so LLMs (and the copy-page button) can fetch the source for any page. Source-viewer pages have none.
|
|
50
|
-
|
|
51
|
-
Plus, once per build:
|
|
52
|
-
|
|
53
|
-
- `_assets/styles.<buildId>.css` — combined theme-variable layer + static utility CSS, content-hashed for caching.
|
|
54
|
-
- `_assets/search-index.<buildId>.json` — the fuzzy search index the command palette (`Ctrl/⌘ K`) fetches on first open.
|
|
55
|
-
- `_islands/<name>.js` — one ESM chunk per island (`sidebar`, `mobile-nav`, `toc`, `toc-mobile`, `cmdk`, `code-tabs`, `copy-btn`, `copy-page`, `theme-toggle`, `settings`, `code-viewer`). Each page loads only the chunks whose markers are present.
|
|
56
|
-
- `pagefind/…` — an optional Pagefind full-text index, built against the on-disk HTML.
|
|
57
|
-
|
|
58
|
-
When `templates.default.outputSourceFiles` is on (default), every documented source file also becomes a read-only viewer page, with a flat **Source Files** index and a `Source: file:line` link on each member.
|
|
59
|
-
|
|
60
|
-
`opts.package` (the path to your `package.json` if you pass `--package`) flows into the manifest as `pkg.name` / `pkg.version` / `pkg.repository` / etc. for footer and `<meta>` tags. If not provided, the theme falls back to JSDoc's automatic `kind: 'package'` doclet, then to no metadata.
|
|
61
|
-
|
|
62
|
-
## Configuration
|
|
63
|
-
|
|
64
|
-
All keys go under `opts` in `jsdoc.json` (unless noted):
|
|
65
|
-
|
|
66
|
-
| Key | Type | Description |
|
|
67
|
-
| --------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
68
|
-
| `siteName` | `string` \| `{ default?, dark?, light?, alt? }` | Header/footer identity + `<title>` suffix. A string, or a per-theme logo set (local images are copied to `_assets/logo-*`). |
|
|
69
|
-
| `fonts` | `{ heading?, body?, mono? }` | Google Fonts family names for `heading`/`body`; `mono` is a CSS stack. |
|
|
70
|
-
| `sectionOrder` | `string[]` | Orders **and** filters the sidebar sections (e.g. `["Classes","Modules","Tutorials"]`). |
|
|
71
|
-
| `menu` | `{ id?, title?, link?/href?, icon? }[]` | Full sidebar top region (built-in `home`/`source` links + external links). Takes precedence over `sectionOrder`'s built-ins. |
|
|
72
|
-
| `clubSidebarItems` | `boolean` | Club related entries into collapsible `parent → children` groups by path prefix (e.g. all `queue/*` under `queue`). Off by default. |
|
|
73
|
-
| `aiPrompt` | `string` | Custom prompt for the copy-page "Open in …" actions. `{siteName}`, `{url}`, `{mdUrl}` are substituted; only the prompt + links are sent (the AI fetches `{mdUrl}`). |
|
|
74
|
-
| `copyPage` | `boolean` \| `{ enabled?, actions? }` | The copy-page button. `false` hides it; `actions` is an ordered subset of `["copy","view","claude","chatgpt","perplexity"]` (`[]` = primary button only). On by default. |
|
|
75
|
-
| `templates.default.outputSourceFiles` | `boolean` | Emit source-viewer pages + `Source:` links. On by default. |
|
|
76
|
-
| `templates.default.sourceLinkToComment` | `boolean` | Make `Source:` links land on the doc-comment line instead of the declaration. Off by default. |
|
|
77
|
-
|
|
78
|
-
The default theme uses a light/dark OKLCH palette, system fonts, and the [GitHub Light](https://github.com/shikijs/textmate-grammars-themes/blob/main/packages/tm-themes/themes/github-light.json) / [GitHub Dark](https://github.com/shikijs/textmate-grammars-themes/blob/main/packages/tm-themes/themes/github-dark.json) shiki themes. Full token + component overrides land before stable.
|
|
79
|
-
|
|
80
|
-
> **Pagefind is optional.** If `pagefind` isn't installed in the consuming project, the publish step warns and continues without the full-text index (the fuzzy palette still works).
|
|
81
|
-
|
|
82
|
-
## How it works
|
|
83
|
-
|
|
84
|
-
`publish.ts` is small by design — every non-trivial concern lives in one of the boundary packages:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
JSDoc 4 invokes publish(data, opts, tutorials)
|
|
88
|
-
│
|
|
89
|
-
├── setu.generateSite(data, { pkg, readme, tutorials, sources, … }) → SiteManifest
|
|
90
|
-
│ (one MDX page per container + globals + home + tutorials)
|
|
91
|
-
│
|
|
92
|
-
├── dwar.render(manifest, { theme, destination }) → RenderResult
|
|
93
|
-
│ (Preact SSR + esbuild island bundles + CSS)
|
|
94
|
-
│
|
|
95
|
-
├── writeOutputFiles(destination, result.files)
|
|
96
|
-
│ (mkdir -p + writeFile loop; Windows-safe via node:path)
|
|
97
|
-
│
|
|
98
|
-
└── dwar.runPagefindAgainstDir(destination)
|
|
99
|
-
(post-write search index; optional)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
The CJS bundle dynamic-`import()`s setu and dwar via `file://` URLs because both are ESM-only with `"type":"module"` while JSDoc 4 loads themes via `require()`. The bridge walks `node_modules` from its own location, so it works regardless of where JSDoc was invoked.
|
|
103
|
-
|
|
104
|
-
See the per-package READMEs for deeper detail:
|
|
105
|
-
|
|
106
|
-
- [`@clean-jsdoc-theme/utils`](../utils) — type contracts and slug rules
|
|
107
|
-
- [`@clean-jsdoc-theme/setu`](../setu) — JSDoc → SiteManifest
|
|
108
|
-
- [`@clean-jsdoc-theme/rang`](../rang) — Preact components + island registry
|
|
109
|
-
- [`@clean-jsdoc-theme/dwar`](../dwar) — SiteManifest → OutputFile[]
|
|
77
|
+
## Documentation
|
|
110
78
|
|
|
111
|
-
|
|
79
|
+
- **Guides & full reference** — [**ankdev.me/clean-jsdoc-theme**](https://ankdev.me/clean-jsdoc-theme): installation, TypeDoc usage, configuration, and theming.
|
|
80
|
+
- **FAQ & recipes** — [**ankdev.me/clean-jsdoc-theme/guides/faq**](https://ankdev.me/clean-jsdoc-theme/guides/faq): how to embed CodePen / YouTube / sites, write rich doc comments (callouts, steps), and common config tweaks.
|
|
81
|
+
- **Live demo** — [**ankdev.me/clean-jsdoc-theme/api-docs**](https://ankdev.me/clean-jsdoc-theme/api-docs): a real generated API reference, so you can see the output before installing.
|
|
112
82
|
|
|
113
|
-
|
|
83
|
+
> **v5 is in alpha.** To stay on v4, pin `"clean-jsdoc-theme": "^4"` in your
|
|
84
|
+
> `package.json`. Every past release is tagged, so you can check out the matching
|
|
85
|
+
> git tag to browse the v4 source.
|
|
114
86
|
|
|
115
87
|
## License
|
|
116
88
|
|
|
117
|
-
MIT.
|
|
89
|
+
[MIT](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE) © [Ankit Kumar](https://ankdev.me)
|
package/dist/publish.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopyPageConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
1
|
+
import { ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo, OutputFile } from '@clean-jsdoc-theme/dwar';
|
|
2
2
|
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
@@ -21,6 +21,19 @@ interface JSDocOpts {
|
|
|
21
21
|
body?: string;
|
|
22
22
|
mono?: string;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Light-mode color overrides from `jsdoc.json` (`"opts": { "colors": { ... } }`).
|
|
26
|
+
* Any subset of `bg`, `bgMuted`, `fg`, `fgMuted`, `accent`, `accentFg`, `border`;
|
|
27
|
+
* each value is any CSS color string (the theme ships oklch). Omitted keys keep
|
|
28
|
+
* the default palette.
|
|
29
|
+
*/
|
|
30
|
+
colors?: unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Dark-mode color overrides (`"opts": { "darkColors": { ... } }`). Same keys as
|
|
33
|
+
* {@link JSDocOpts.colors}; emitted under `[data-theme="dark"]`. Omitted keys
|
|
34
|
+
* keep the default dark palette.
|
|
35
|
+
*/
|
|
36
|
+
darkColors?: unknown;
|
|
24
37
|
/**
|
|
25
38
|
* Project README as HTML. JSDoc renders the Markdown README (`-R`/`opts.readme`
|
|
26
39
|
* or one found in the source paths) and replaces this with the resulting HTML
|
|
@@ -86,6 +99,13 @@ interface JSDocOpts {
|
|
|
86
99
|
* primary copy button). Defaults to enabled with all actions.
|
|
87
100
|
*/
|
|
88
101
|
copyPage?: unknown;
|
|
102
|
+
/**
|
|
103
|
+
* Previous/next page pager config (`jsdoc.json` `"opts": { "pageNav": … }`).
|
|
104
|
+
* Either a boolean (`false` hides the pager) or an object `{ enabled? }`. The
|
|
105
|
+
* pager links each content page to its neighbors in sidebar reading order.
|
|
106
|
+
* Defaults to enabled.
|
|
107
|
+
*/
|
|
108
|
+
pageNav?: unknown;
|
|
89
109
|
/**
|
|
90
110
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
91
111
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -118,6 +138,14 @@ interface JSDocOpts {
|
|
|
118
138
|
* Set `false` to copy with the original `<name>.css`/`.js` (no hash).
|
|
119
139
|
*/
|
|
120
140
|
hashCustomAssets?: unknown;
|
|
141
|
+
/**
|
|
142
|
+
* Build-stage progress output (`jsdoc.json` `"opts": { "progress": false }`).
|
|
143
|
+
* The setu→dwar pipeline does noticeably more than a bare jsdoc run (per-page
|
|
144
|
+
* MDX compile, per-island esbuild bundling, the Pagefind index), so by default
|
|
145
|
+
* the bridge narrates each stage with its elapsed time. Set `false` to silence
|
|
146
|
+
* the stage lines (the build report still prints).
|
|
147
|
+
*/
|
|
148
|
+
progress?: unknown;
|
|
121
149
|
/**
|
|
122
150
|
* JSDoc's default-template source options, read from `conf.templates.default`
|
|
123
151
|
* (or, as a fallback, nested under `opts.templates`):
|
|
@@ -155,6 +183,15 @@ declare function outputSourceFilesEnabled(opts: JSDocOpts): boolean;
|
|
|
155
183
|
* is exactly `=== true`; otherwise `false` (the default: links jump to code).
|
|
156
184
|
*/
|
|
157
185
|
declare function sourceLinkToCommentEnabled(opts: JSDocOpts): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Whether a JSDoc `conf.plugins` list enables the bundled `plugins/markdown`
|
|
188
|
+
* plugin. The theme relies on it: JSDoc runs `plugins/markdown` to convert the
|
|
189
|
+
* Markdown in doclet descriptions/tags to HTML *before* `publish` ever sees the
|
|
190
|
+
* doclets, so without it descriptions arrive as raw Markdown and render wrong.
|
|
191
|
+
* Pure + exported for testing — accepts the `plugins` array (module specifiers,
|
|
192
|
+
* e.g. `"plugins/markdown"`; tolerant of a `.js` suffix or path separators).
|
|
193
|
+
*/
|
|
194
|
+
declare function hasMarkdownPlugin(plugins: unknown): boolean;
|
|
158
195
|
/**
|
|
159
196
|
* Validate `opts.sectionOrder` into a clean `string[]`, or `undefined` to fall
|
|
160
197
|
* back to setu's default order. Accepts only an array; trims string entries and
|
|
@@ -177,6 +214,20 @@ declare function normalizeMenu(raw: unknown): MenuItem[] | undefined;
|
|
|
177
214
|
* only), which is meaningful and kept.
|
|
178
215
|
*/
|
|
179
216
|
declare function normalizeCopyPage(raw: unknown): CopyPageConfig | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Validate `opts.pageNav` into a {@link PageNavConfig}, or `undefined` to use the
|
|
219
|
+
* default (enabled). Accepts a boolean shorthand (`false` hides the pager) or an
|
|
220
|
+
* object whose `enabled` is read when boolean.
|
|
221
|
+
*/
|
|
222
|
+
declare function normalizePageNav(raw: unknown): PageNavConfig | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
|
|
225
|
+
* `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
|
|
226
|
+
* non-empty string, dropping everything else. Returns `undefined` when the input
|
|
227
|
+
* is not an object or yields no usable keys, so callers can fall back cleanly.
|
|
228
|
+
* Values are passed through verbatim (any CSS color is valid).
|
|
229
|
+
*/
|
|
230
|
+
declare function normalizeColors(raw: unknown): Partial<ThemeColors> | undefined;
|
|
180
231
|
/**
|
|
181
232
|
* Compute project-relative paths for a set of absolute source paths by stripping
|
|
182
233
|
* their longest common directory prefix. Returns a `Map<absPath, relPath>` with
|
|
@@ -207,6 +258,24 @@ declare function computeRelPaths(absPaths: readonly string[]): Map<string, strin
|
|
|
207
258
|
* the docs tree is read.
|
|
208
259
|
*/
|
|
209
260
|
declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
261
|
+
/**
|
|
262
|
+
* Resolve the local images a doc references and route them through the same
|
|
263
|
+
* content-hashed `_assets/` pipeline the logo and custom files use. For each
|
|
264
|
+
* `` whose `src` points to a file on disk, the file is copied to
|
|
265
|
+
* `_assets/<base>.<hash><ext>` (cache-busted, deduped across docs) and the `src`
|
|
266
|
+
* is rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
267
|
+
* `MdxImg` adds the base path, like it does for links). A `src` is resolved
|
|
268
|
+
* relative to the project root when it starts with `/`, else relative to the
|
|
269
|
+
* doc's own directory; absolute (`http(s):`, `data:`), `#`-anchor, and
|
|
270
|
+
* unreadable srcs are left untouched (the last with a warning). Returns the docs
|
|
271
|
+
* with rewritten content plus the asset files to write. The bridge is the I/O
|
|
272
|
+
* layer here, so setu/dwar only ever see the final `_assets/` paths.
|
|
273
|
+
*/
|
|
274
|
+
declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
|
|
275
|
+
docs: DocInput[];
|
|
276
|
+
files: OutputFile[];
|
|
277
|
+
inlineSvgs: Record<string, string>;
|
|
278
|
+
}>;
|
|
210
279
|
/**
|
|
211
280
|
* Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
|
|
212
281
|
* to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
|
|
@@ -215,4 +284,4 @@ declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
|
215
284
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
216
285
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
217
286
|
|
|
218
|
-
export { collectDocs, computeRelPaths, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeSectionOrder, outputSourceFilesEnabled, publish, sourceLinkToCommentEnabled };
|
|
287
|
+
export { collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, publish, resolveDocImages, sourceLinkToCommentEnabled };
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopyPageConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
1
|
+
import { ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo, OutputFile } from '@clean-jsdoc-theme/dwar';
|
|
2
2
|
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
@@ -21,6 +21,19 @@ interface JSDocOpts {
|
|
|
21
21
|
body?: string;
|
|
22
22
|
mono?: string;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Light-mode color overrides from `jsdoc.json` (`"opts": { "colors": { ... } }`).
|
|
26
|
+
* Any subset of `bg`, `bgMuted`, `fg`, `fgMuted`, `accent`, `accentFg`, `border`;
|
|
27
|
+
* each value is any CSS color string (the theme ships oklch). Omitted keys keep
|
|
28
|
+
* the default palette.
|
|
29
|
+
*/
|
|
30
|
+
colors?: unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Dark-mode color overrides (`"opts": { "darkColors": { ... } }`). Same keys as
|
|
33
|
+
* {@link JSDocOpts.colors}; emitted under `[data-theme="dark"]`. Omitted keys
|
|
34
|
+
* keep the default dark palette.
|
|
35
|
+
*/
|
|
36
|
+
darkColors?: unknown;
|
|
24
37
|
/**
|
|
25
38
|
* Project README as HTML. JSDoc renders the Markdown README (`-R`/`opts.readme`
|
|
26
39
|
* or one found in the source paths) and replaces this with the resulting HTML
|
|
@@ -86,6 +99,13 @@ interface JSDocOpts {
|
|
|
86
99
|
* primary copy button). Defaults to enabled with all actions.
|
|
87
100
|
*/
|
|
88
101
|
copyPage?: unknown;
|
|
102
|
+
/**
|
|
103
|
+
* Previous/next page pager config (`jsdoc.json` `"opts": { "pageNav": … }`).
|
|
104
|
+
* Either a boolean (`false` hides the pager) or an object `{ enabled? }`. The
|
|
105
|
+
* pager links each content page to its neighbors in sidebar reading order.
|
|
106
|
+
* Defaults to enabled.
|
|
107
|
+
*/
|
|
108
|
+
pageNav?: unknown;
|
|
89
109
|
/**
|
|
90
110
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
91
111
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -118,6 +138,14 @@ interface JSDocOpts {
|
|
|
118
138
|
* Set `false` to copy with the original `<name>.css`/`.js` (no hash).
|
|
119
139
|
*/
|
|
120
140
|
hashCustomAssets?: unknown;
|
|
141
|
+
/**
|
|
142
|
+
* Build-stage progress output (`jsdoc.json` `"opts": { "progress": false }`).
|
|
143
|
+
* The setu→dwar pipeline does noticeably more than a bare jsdoc run (per-page
|
|
144
|
+
* MDX compile, per-island esbuild bundling, the Pagefind index), so by default
|
|
145
|
+
* the bridge narrates each stage with its elapsed time. Set `false` to silence
|
|
146
|
+
* the stage lines (the build report still prints).
|
|
147
|
+
*/
|
|
148
|
+
progress?: unknown;
|
|
121
149
|
/**
|
|
122
150
|
* JSDoc's default-template source options, read from `conf.templates.default`
|
|
123
151
|
* (or, as a fallback, nested under `opts.templates`):
|
|
@@ -155,6 +183,15 @@ declare function outputSourceFilesEnabled(opts: JSDocOpts): boolean;
|
|
|
155
183
|
* is exactly `=== true`; otherwise `false` (the default: links jump to code).
|
|
156
184
|
*/
|
|
157
185
|
declare function sourceLinkToCommentEnabled(opts: JSDocOpts): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Whether a JSDoc `conf.plugins` list enables the bundled `plugins/markdown`
|
|
188
|
+
* plugin. The theme relies on it: JSDoc runs `plugins/markdown` to convert the
|
|
189
|
+
* Markdown in doclet descriptions/tags to HTML *before* `publish` ever sees the
|
|
190
|
+
* doclets, so without it descriptions arrive as raw Markdown and render wrong.
|
|
191
|
+
* Pure + exported for testing — accepts the `plugins` array (module specifiers,
|
|
192
|
+
* e.g. `"plugins/markdown"`; tolerant of a `.js` suffix or path separators).
|
|
193
|
+
*/
|
|
194
|
+
declare function hasMarkdownPlugin(plugins: unknown): boolean;
|
|
158
195
|
/**
|
|
159
196
|
* Validate `opts.sectionOrder` into a clean `string[]`, or `undefined` to fall
|
|
160
197
|
* back to setu's default order. Accepts only an array; trims string entries and
|
|
@@ -177,6 +214,20 @@ declare function normalizeMenu(raw: unknown): MenuItem[] | undefined;
|
|
|
177
214
|
* only), which is meaningful and kept.
|
|
178
215
|
*/
|
|
179
216
|
declare function normalizeCopyPage(raw: unknown): CopyPageConfig | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Validate `opts.pageNav` into a {@link PageNavConfig}, or `undefined` to use the
|
|
219
|
+
* default (enabled). Accepts a boolean shorthand (`false` hides the pager) or an
|
|
220
|
+
* object whose `enabled` is read when boolean.
|
|
221
|
+
*/
|
|
222
|
+
declare function normalizePageNav(raw: unknown): PageNavConfig | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
|
|
225
|
+
* `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
|
|
226
|
+
* non-empty string, dropping everything else. Returns `undefined` when the input
|
|
227
|
+
* is not an object or yields no usable keys, so callers can fall back cleanly.
|
|
228
|
+
* Values are passed through verbatim (any CSS color is valid).
|
|
229
|
+
*/
|
|
230
|
+
declare function normalizeColors(raw: unknown): Partial<ThemeColors> | undefined;
|
|
180
231
|
/**
|
|
181
232
|
* Compute project-relative paths for a set of absolute source paths by stripping
|
|
182
233
|
* their longest common directory prefix. Returns a `Map<absPath, relPath>` with
|
|
@@ -207,6 +258,24 @@ declare function computeRelPaths(absPaths: readonly string[]): Map<string, strin
|
|
|
207
258
|
* the docs tree is read.
|
|
208
259
|
*/
|
|
209
260
|
declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
261
|
+
/**
|
|
262
|
+
* Resolve the local images a doc references and route them through the same
|
|
263
|
+
* content-hashed `_assets/` pipeline the logo and custom files use. For each
|
|
264
|
+
* `` whose `src` points to a file on disk, the file is copied to
|
|
265
|
+
* `_assets/<base>.<hash><ext>` (cache-busted, deduped across docs) and the `src`
|
|
266
|
+
* is rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
|
|
267
|
+
* `MdxImg` adds the base path, like it does for links). A `src` is resolved
|
|
268
|
+
* relative to the project root when it starts with `/`, else relative to the
|
|
269
|
+
* doc's own directory; absolute (`http(s):`, `data:`), `#`-anchor, and
|
|
270
|
+
* unreadable srcs are left untouched (the last with a warning). Returns the docs
|
|
271
|
+
* with rewritten content plus the asset files to write. The bridge is the I/O
|
|
272
|
+
* layer here, so setu/dwar only ever see the final `_assets/` paths.
|
|
273
|
+
*/
|
|
274
|
+
declare function resolveDocImages(docs: DocInput[], docsDir: string): Promise<{
|
|
275
|
+
docs: DocInput[];
|
|
276
|
+
files: OutputFile[];
|
|
277
|
+
inlineSvgs: Record<string, string>;
|
|
278
|
+
}>;
|
|
210
279
|
/**
|
|
211
280
|
* Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
|
|
212
281
|
* to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
|
|
@@ -215,4 +284,4 @@ declare function collectDocs(dir: string): Promise<DocInput[]>;
|
|
|
215
284
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
216
285
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
217
286
|
|
|
218
|
-
export { collectDocs, computeRelPaths, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeSectionOrder, outputSourceFilesEnabled, publish, sourceLinkToCommentEnabled };
|
|
287
|
+
export { collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, publish, resolveDocImages, sourceLinkToCommentEnabled };
|