jsdoc-scribe 1.0.1 → 1.11.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/CHANGELOG.md +230 -0
- package/README.md +521 -110
- package/bin/cli.js +115 -115
- package/bin/gen-docs.js +299 -0
- package/lib/config.js +47 -0
- package/lib/docs.js +57 -0
- package/lib/extractor.js +468 -0
- package/lib/index.js +443 -427
- package/lib/renderer.js +831 -0
- package/package.json +56 -40
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `jsdoc-scribe` are documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
|
+
|
|
6
|
+
## [1.11.0] - 2026-06-30
|
|
7
|
+
|
|
8
|
+
### Changed — Code Quality (Phase D)
|
|
9
|
+
|
|
10
|
+
**`extractor.js` robustness**
|
|
11
|
+
- Added `sourceFile` null guard: if `ts.createSourceFile()` returns a falsy value the function logs to stderr and returns an empty-but-valid module object instead of throwing.
|
|
12
|
+
- Wrapped the entire `visit(node)` body in `try/catch`: a malformed or unexpected AST node now logs a warning (`jsdoc-scribe: skipped node in <file> — <message>`) and continues visiting sibling nodes instead of aborting the whole module.
|
|
13
|
+
|
|
14
|
+
**`renderer.js` refactor**
|
|
15
|
+
- Extracted `buildSymbolMap(modules)` from `buildSite()` — builds the `{name → {anchorId, modulePath}}` cross-reference map used by `{@link}` resolution.
|
|
16
|
+
- Extracted `buildIndexBody(modules)` — builds the module-grid HTML block for the index page (previously inlined in `buildSite()`).
|
|
17
|
+
- Extracted `buildModuleBody(mod, sourceUrl, symbolMap)` — builds the sections HTML for a single module page (previously inlined in `buildSite()`).
|
|
18
|
+
- `buildSite()` is now a slim coordinator (~25 lines) delegating to the three helpers above.
|
|
19
|
+
|
|
20
|
+
**`docs.js` async upgrade**
|
|
21
|
+
- `extractModules(files)` is now `async` and uses `Promise.allSettled`: all files are attempted in parallel; fulfilled results are collected, rejected ones are logged to stderr and skipped.
|
|
22
|
+
- `generateSite(inputPaths, options)` is now `async` accordingly.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## [1.10.0] - 2026-06-30
|
|
27
|
+
|
|
28
|
+
### Added — Test coverage (Phase C)
|
|
29
|
+
|
|
30
|
+
Expanded `npm test` from 7 tests to **25 tests** across three suites.
|
|
31
|
+
|
|
32
|
+
**`test/extractor.test.js` — 10 new tests** (exercises `lib/extractor.js`):
|
|
33
|
+
- Module-level `@module` description and `@since` extracted from top-of-file JSDoc
|
|
34
|
+
- `@param` type and description parsed from JSDoc block
|
|
35
|
+
- `@returns` type and description parsed
|
|
36
|
+
- `@since` and `@deprecated` on individual items
|
|
37
|
+
- `@throws` with type and description
|
|
38
|
+
- 1-based source line numbers on all functions (ordered)
|
|
39
|
+
- Class with constructor, methods, properties, and static members
|
|
40
|
+
- Interface with optional properties
|
|
41
|
+
- Enum members and their values
|
|
42
|
+
- Type alias and exported `const` variable
|
|
43
|
+
|
|
44
|
+
**`test/renderer.test.js` — 8 new tests** (exercises `lib/renderer.js` via mock module objects):
|
|
45
|
+
- `buildSite` returns exactly 3 shared assets + `index.html` + one page per module
|
|
46
|
+
- Search index contains every symbol (function, class) with root-relative URLs
|
|
47
|
+
- Module page includes right-side TOC with `data-anchor` attributes and "On this page" title
|
|
48
|
+
- `@deprecated` badge and notice rendered for deprecated items
|
|
49
|
+
- Source link contains GitHub URL and `#L42` line anchor when `sourceUrl` set
|
|
50
|
+
- `@example` blocks rendered with `tok-kw` syntax-highlighting spans
|
|
51
|
+
- Sidebar symbol tree includes `sym-rows` and kind pills for the active module
|
|
52
|
+
- `{@link Symbol}` in descriptions resolves to `<a class="link-ref">` with `href`
|
|
53
|
+
|
|
54
|
+
### Fixed — `@description` tag in JSDoc blocks
|
|
55
|
+
|
|
56
|
+
`parseJSDocBlock()` now recognises `@description <text>` as an alias for the plain-text
|
|
57
|
+
description that precedes the first `@tag`. Previously `@description` was silently discarded as
|
|
58
|
+
an unknown tag, leaving `mod.description === null` for any file that used it (including all
|
|
59
|
+
built-in sample files).
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## [1.9.0] - 2026-06-30
|
|
64
|
+
|
|
65
|
+
### Changed — Enterprise HTML Redesign (Phase B)
|
|
66
|
+
|
|
67
|
+
Complete visual overhaul of the generated documentation site.
|
|
68
|
+
|
|
69
|
+
**Three-column layout**
|
|
70
|
+
- Left sidebar (272 px) · Center content (flexible) · Right TOC (224 px)
|
|
71
|
+
- CSS Grid replaces the old flexbox layout: `.layout { grid-template-columns: 272px 1fr 224px }`
|
|
72
|
+
- Index page uses two-column grid (no right TOC); module pages use three columns automatically via the `has-toc` class
|
|
73
|
+
|
|
74
|
+
**Right-side "On this page" TOC**
|
|
75
|
+
- New `buildToc(mod)` function generates a per-section TOC (Functions, Classes, Interfaces, etc.) with every symbol as a clickable anchor
|
|
76
|
+
- `IntersectionObserver` scroll spy in `app.js` tracks which card is on screen and highlights the matching TOC item with an accent-colored left border
|
|
77
|
+
- TOC hides at ≤1280 px viewport width; three columns collapse to two
|
|
78
|
+
|
|
79
|
+
**Symbol tree in sidebar**
|
|
80
|
+
- Active module expands to show every symbol underneath its file link
|
|
81
|
+
- Each symbol is prefixed with a color-coded pill badge (`fn`, `cls`, `if`, `ty`, `en`, `$`) matching its kind
|
|
82
|
+
- New `.sym-rows`, `.sym-row`, `.sym-pill`, `.sym-link` CSS classes
|
|
83
|
+
|
|
84
|
+
**Color-coded cards**
|
|
85
|
+
- Each card now has a 3 px left accent border: green=function, blue=class, purple=interface, orange=enum, teal=type alias, gray=variable/const
|
|
86
|
+
- Added `card-fn`, `card-cls`, `card-iface`, `card-enum`, `card-type`, `card-var` CSS classes to all render functions
|
|
87
|
+
|
|
88
|
+
**Server-side syntax highlighting for `@example` blocks**
|
|
89
|
+
- New `highlightCode(raw)` function in `renderer.js` tokenizes JS/TS code at build time
|
|
90
|
+
- Handles line comments, block comments, strings (single/double/template), numbers, and 40+ keywords
|
|
91
|
+
- Produces `<span class="tok-kw|tok-str|tok-cmt|tok-num">` spans; colors adapt to dark/light theme via CSS vars
|
|
92
|
+
|
|
93
|
+
**Responsive layout**
|
|
94
|
+
- `@media (max-width: 1280px)`: right TOC hidden, grid collapses to two columns
|
|
95
|
+
- `@media (max-width: 860px)`: sidebar becomes a fixed overlay (off-screen by default), hamburger button appears in the top-left, main content uses mobile padding
|
|
96
|
+
- Hamburger toggle with animated open/close icon (three-bar → X)
|
|
97
|
+
|
|
98
|
+
**Print styles**
|
|
99
|
+
- `@media print`: sidebar, TOC, hamburger, copy buttons, theme toggle, and search box all hidden
|
|
100
|
+
- Cards get `break-inside: avoid` and a neutral border for clean PDF output
|
|
101
|
+
|
|
102
|
+
**Section counts**
|
|
103
|
+
- Section headings now show item count: `Functions (3)` using a `.section-count` monospace chip
|
|
104
|
+
|
|
105
|
+
**Other polish**
|
|
106
|
+
- `html { scroll-behavior: smooth }` for smooth anchor navigation
|
|
107
|
+
- Sidebar active link gets a 2 px accent left border instead of just a background change
|
|
108
|
+
- Card hover adds a subtle box-shadow
|
|
109
|
+
- All `section()` calls updated with count display
|
|
110
|
+
- CSS ~15 KB (up from ~9 KB), app.js ~4 KB (up from ~2.6 KB) — still cached after first load
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## [1.8.0] - 2026-06-30
|
|
115
|
+
|
|
116
|
+
### Changed — Performance: Shared Static Assets (Phase A)
|
|
117
|
+
|
|
118
|
+
Previously every generated HTML page inlined the same 9 KB CSS block, 3 KB client JS, and 34 KB search index. On a 9-page site that wasted 630+ KB of duplicate payload.
|
|
119
|
+
|
|
120
|
+
- **CSS extracted** to `assets/style.css` — written once per build, shared by all pages via `<link rel="stylesheet">`.
|
|
121
|
+
- **Client JS extracted** to `assets/app.js` — written once, shared via `<script src>`. Browsers cache it after the first page load.
|
|
122
|
+
- **Search index extracted** to `search-index.js` — written once as `window.__SEARCH_INDEX__=[...]`, loaded before `app.js` via `<script src>`. No more 34 KB inline JSON on every page.
|
|
123
|
+
- `app.js` auto-detects its location (`/modules/` in the path) and adjusts search result URLs at runtime, so a single shared index file works for both the index page and all module pages.
|
|
124
|
+
|
|
125
|
+
### Result
|
|
126
|
+
| Metric | Before | After |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| Total site size | 628 KB | 225 KB (−64%) |
|
|
129
|
+
| Per-page HTML (avg) | ~70 KB | ~20 KB |
|
|
130
|
+
| Cache benefit (2nd+ page) | ~70 KB reload | ~20 KB reload |
|
|
131
|
+
| Shared assets (loaded once) | — | 46 KB |
|
|
132
|
+
|
|
133
|
+
### Upgraded — `buildSite()` output
|
|
134
|
+
The return array now includes three additional entries: `{ path: 'assets/style.css', html: '...' }`, `{ path: 'assets/app.js', html: '...' }`, `{ path: 'search-index.js', html: '...' }`. The CLI handles these automatically. Programmatic API users should use `fs.mkdirSync(path.dirname(dest), { recursive: true })` before writing each file (the README example is updated).
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## [1.7.0] - 2026-06-29
|
|
139
|
+
|
|
140
|
+
### Added
|
|
141
|
+
- **Module-level JSDoc** (`@module` / `@description` at top of file): `extractModuleDoc()` in `extractor.js` reads the first `/** */` block before any declarations and extracts `description`, `moduleName`, and `@since`. Module pages now show a description paragraph below the file path; index cards show a 2-line truncated preview.
|
|
142
|
+
- **Per-module index stats**: each index card now shows a symbol breakdown (`fn · class · iface · enum · const`), `@since` version range across all items (e.g. `since v1.0.0–v1.1.0`), and a deprecated-item badge count when deprecations are present.
|
|
143
|
+
- **Full-text search** (`body` field in search index): search now matches against item descriptions, `@param` descriptions, `@returns` descriptions, and `@throws` descriptions — not just symbol names and module labels. Matched results display a one-line body preview in the search panel. E.g. searching `"rate limit"` surfaces `RateLimitError`.
|
|
144
|
+
- **`{@link Symbol}` cross-references**: `resolveLinks()` in `renderer.js` replaces `{@link ClassName}` and `{@link ClassName#method}` tags in JSDoc descriptions with `<a class="link-ref">` anchor links pointing to the target card, within the same module page or across module pages.
|
|
145
|
+
- `.link-ref` and `.module-desc` CSS for the above.
|
|
146
|
+
|
|
147
|
+
### Changed
|
|
148
|
+
- `section()` signature extended with an optional `symbolMap` argument, threaded into every item renderer so `descHtml()` can resolve cross-references.
|
|
149
|
+
- `buildSearchIndex()` now calls `buildBody(item)` to populate `body` on each entry; client-side `search()` and `render()` functions updated to match and display body previews.
|
|
150
|
+
- `buildSite()` now builds a `symbolMap` ({`name → {anchorId, modulePath}`}) before rendering any page.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## [1.6.0] - 2026-06-29
|
|
155
|
+
|
|
156
|
+
### Added
|
|
157
|
+
- **Config file support** (`lib/config.js`): `.jsdoc-scribe.json` in the project root stores `out`, `title`, `theme`, `json`, `readme`, `ignore` (array of globs), and `sourceUrl`. CLI flags always override config values. Custom path via `--config` / `-c`.
|
|
158
|
+
- **Ignore patterns** (`--ignore <glob>` / `-I`, repeatable): glob-like patterns (supports `**/` prefix and `*` wildcard) exclude files and directories from collection. Also reads the `ignore` array from the config file.
|
|
159
|
+
- **Source links** (`--source-url <url>` / `-s`): each documentation card shows the file path and line number. When a GitHub base URL is provided (e.g. `https://github.com/user/repo/blob/main`), links point directly to the source line on GitHub.
|
|
160
|
+
- **Enterprise sample modules** in `sample/`: `errors.ts` (full AppError hierarchy with 7 classes and 3 helpers), `events.ts` (typed async EventBus with priority, once(), bridgeEvent), `middleware.ts` (composable Pipeline class + 5 built-in middleware: logger, responseTime, timeout, cors, errorToResponse), `container.ts` (DI Container with singleton/transient/scoped lifetimes + ConsoleLogger + MemoryCache + buildRootContainer).
|
|
161
|
+
- Line numbers extracted for every documented symbol (`node.getLineAndCharacterOfPosition()` in extractor.js).
|
|
162
|
+
|
|
163
|
+
### Changed
|
|
164
|
+
- `collectFiles()` accepts a fourth `ignorePatterns` array argument.
|
|
165
|
+
- `buildSite()` accepts `sourceUrl` in the options object.
|
|
166
|
+
- All item renderers (`renderFunction`, `renderClass`, etc.) accept `filePath` and `sourceUrl` for source link generation.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## [1.5.0] - 2026-06-29
|
|
171
|
+
|
|
172
|
+
### Added
|
|
173
|
+
- **JSDoc tag extraction**: `@param`, `@returns`, `@throws`, `@since`, `@deprecated` parsed from `/** */` blocks and attached to every extracted item. `@param` descriptions enrich the parameter table; `@throws` renders a dedicated table; `@deprecated` shows a warning notice + badge; `@since` shows a version label.
|
|
174
|
+
- **README auto-generator** (`--readme` / `-r`): writes `README.md` to the output directory summarising all exported symbols grouped by module with markdown tables.
|
|
175
|
+
- **Multiple themes** (`--theme <name>` / `-T`): three built-in themes — `default` (dark sidebar, light/dark toggle), `minimal` (clean light, no toggle), `dark` (forced dark, no toggle).
|
|
176
|
+
- Deprecated badge and warning notice rendered for `@deprecated` items throughout all section types.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## [1.4.0] - 2026-06-29
|
|
181
|
+
|
|
182
|
+
### Added
|
|
183
|
+
- **Programmatic API** (`require('jsdoc-scribe/docs')`): `lib/docs.js` exports `collectFiles`, `extractModule`, `extractModules`, `buildSite`, `generateSite`, `moduleLabel`, `moduleHtmlPath`, and constants. `package.json` `exports` field maps `./docs` subpath.
|
|
184
|
+
- **JSON export** (`--json` / `-j`): `gen-docs` writes `docs.json` with title, version, `generatedAt` ISO timestamp, and full modules array alongside the HTML site.
|
|
185
|
+
- **GitHub Actions workflow** (`.github/workflows/docs.yml`): triggers on push to `main`, builds docs, deploys to GitHub Pages via `actions/deploy-pages`.
|
|
186
|
+
- **Collapsible sidebar module tree**: when modules share a directory prefix, the sidebar groups them under expandable `<details>` elements. Active group auto-opens.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## [1.3.0] - 2026-06-29
|
|
191
|
+
|
|
192
|
+
### Added
|
|
193
|
+
- **JSDoc description extraction**: `lib/extractor.js` parses `/** */` blocks, extracts description (text before first `@tag`) and `@example` content, attaches to every extracted symbol.
|
|
194
|
+
- **Dark mode toggle**: CSS custom properties (`--bg`, `--surface`, etc.) for light/dark theming; `data-theme` attribute on `<html>`; `localStorage` persistence; "Dark/Light" toggle button in sidebar.
|
|
195
|
+
- **Collapsible class sections**: Constructor, Properties, Methods, Accessors rendered as `<details><summary>` elements — open by default.
|
|
196
|
+
- **Watch mode** (`--watch` / `-W`): `fs.watch({ recursive: true })` with 150ms debounce, no extra dependencies.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## [1.2.0] - 2026-06-29
|
|
201
|
+
|
|
202
|
+
### Added
|
|
203
|
+
- **Client-side search** (Ctrl+K): embedded JSON index searched as-you-type; results panel with module context.
|
|
204
|
+
- **Anchor deep-links**: every card gets a stable `id` and a `#` link for sharing.
|
|
205
|
+
- **Copy-signature button**: one-click clipboard copy for function/method signatures.
|
|
206
|
+
- Rich sample files: `sample/utils.js` (16 functions + constants), `sample/models.ts` (4 classes, 3 interfaces, 2 enums, 5 type aliases), `sample/api.ts` (4 classes, 4 interfaces, 3 functions).
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## [1.1.0] - 2026-06-29
|
|
211
|
+
|
|
212
|
+
### Added
|
|
213
|
+
- **`gen-docs` CLI**: generates a multi-page HTML documentation site from JS/TS source.
|
|
214
|
+
- `lib/extractor.js`: TypeScript Compiler API AST → structured JSON module model.
|
|
215
|
+
- `lib/renderer.js`: JSON module model → multi-page HTML site.
|
|
216
|
+
- `bin/gen-docs.js`: CLI entry with `--out`, `--title`, `--help`, `--version` flags.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## [1.0.1] - 2026-06-29
|
|
221
|
+
|
|
222
|
+
### Fixed
|
|
223
|
+
- `@abstract` modifier never detected: `modifiersOf()` now uses `kinds.has(ts.SyntaxKind.AbstractKeyword)` (direct numeric comparison) instead of string reverse lookup which always returned `"FirstContextualKeyword"`.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## [1.0.0] - Initial release
|
|
228
|
+
|
|
229
|
+
### Added
|
|
230
|
+
- `gen-comments` CLI: AST-based JSDoc comment inserter for JavaScript and TypeScript. Adds `@param`, `@returns` (and `@class`, `@method`, etc.) stubs to undocumented functions and classes. Skip-existing and `--force` modes. Idempotent.
|