shelving 1.249.0 → 1.250.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.
|
@@ -12,6 +12,7 @@ import { FileExtractor } from "./FileExtractor.js";
|
|
|
12
12
|
* - Sets `title` on every `tree-documentation` child — `name()` for functions, `Class.name()` for methods, `Class.name` for properties, bare `name` for other kinds.
|
|
13
13
|
* - Records relational metadata as raw strings for render-time linking: `class` (owning class), `readonly`, `extends` / `implements` (full heritage type text including generic arguments, e.g. `AbstractStore<string>` or `Omit<StringSchemaOptions, "value">`), and `types` (the type names a `type` alias's body references, e.g. `OtherType` in `string | OtherType`).
|
|
14
14
|
* - Records a structured `properties` list for interfaces and object-literal `type` aliases — each member's name, type, optionality, `@default`, and description — so an options-bag parameter can be flattened into its fields at render time.
|
|
15
|
+
* - Names a destructured (binding-pattern) parameter for the Param column — which has no name of its own — from an explicit `@param`, else its rest element (`...options`), else a type-derived fallback (`props` / `options`). The signature still shows the full `{ … }`.
|
|
15
16
|
* - Pretty-prints object-literal signatures (interfaces and object-literal `type` aliases) as multi-line `{ … }` blocks, one member per line; other type bodies (`string | null`, mapped types, …) are emitted verbatim.
|
|
16
17
|
* - Members declared with the `override` or `declare` modifier are skipped — the base class already documents overrides, and `declare` members are ambient type-only re-declarations rather than new API.
|
|
17
18
|
* - Keys are the raw declared `name` (case-preserving) so case-distinct exports like `Collection` and `COLLECTION` stay separate.
|
|
@@ -13,6 +13,7 @@ import { extractMarkdownProps } from "./MarkupExtractor.js";
|
|
|
13
13
|
* - Sets `title` on every `tree-documentation` child — `name()` for functions, `Class.name()` for methods, `Class.name` for properties, bare `name` for other kinds.
|
|
14
14
|
* - Records relational metadata as raw strings for render-time linking: `class` (owning class), `readonly`, `extends` / `implements` (full heritage type text including generic arguments, e.g. `AbstractStore<string>` or `Omit<StringSchemaOptions, "value">`), and `types` (the type names a `type` alias's body references, e.g. `OtherType` in `string | OtherType`).
|
|
15
15
|
* - Records a structured `properties` list for interfaces and object-literal `type` aliases — each member's name, type, optionality, `@default`, and description — so an options-bag parameter can be flattened into its fields at render time.
|
|
16
|
+
* - Names a destructured (binding-pattern) parameter for the Param column — which has no name of its own — from an explicit `@param`, else its rest element (`...options`), else a type-derived fallback (`props` / `options`). The signature still shows the full `{ … }`.
|
|
16
17
|
* - Pretty-prints object-literal signatures (interfaces and object-literal `type` aliases) as multi-line `{ … }` blocks, one member per line; other type bodies (`string | null`, mapped types, …) are emitted verbatim.
|
|
17
18
|
* - Members declared with the `override` or `declare` modifier are skipped — the base class already documents overrides, and `declare` members are ambient type-only re-declarations rather than new API.
|
|
18
19
|
* - Keys are the raw declared `name` (case-preserving) so case-distinct exports like `Collection` and `COLLECTION` stay separate.
|
|
@@ -348,11 +349,23 @@ function _getParams(statement, source, jsDocParams) {
|
|
|
348
349
|
* - Multiple `@param name` tags for the same parameter each emit a row, so a single parameter can be documented as several typed variants.
|
|
349
350
|
* - A `@param name` with no `{Type}` only supplies the description; the inferred type stands.
|
|
350
351
|
* - `primaryJsDocParams` win over `fallbackJsDocParams` per name (used by constructors: the constructor's own `@param` beats the class-level `@param`).
|
|
352
|
+
* - A destructured (binding-pattern) param has no name of its own — its display name resolves as an "orphan" `@param` (one not matching any identifier param, in source order), else the rest element (`...options`), else a type-derived fallback (see `_getBindingName`). This keeps the Param column readable (`options`) while the signature still shows the full `{ … }`.
|
|
351
353
|
*/
|
|
352
354
|
function _buildParams(parameters, source, primaryJsDocParams, fallbackJsDocParams) {
|
|
353
355
|
const params = [];
|
|
356
|
+
// Identifier (non-destructured) parameter names — used to spot "orphan" `@param` tags that name a destructured bag.
|
|
357
|
+
const named = new Set();
|
|
358
|
+
for (const p of parameters)
|
|
359
|
+
if (ts.isIdentifier(p.name))
|
|
360
|
+
named.add(p.name.getText(source));
|
|
361
|
+
// Top-level `@param` names not matching any identifier parameter, in declared order (constructor's own first, then class-level), de-duplicated — these let an author name a destructured param (`@param options`). Sub-tags (`options.min`) are excluded.
|
|
362
|
+
const orphans = [];
|
|
363
|
+
for (const d of [...(primaryJsDocParams ?? []), ...(fallbackJsDocParams ?? [])])
|
|
364
|
+
if (!d.name.includes(".") && !named.has(d.name) && !orphans.includes(d.name))
|
|
365
|
+
orphans.push(d.name);
|
|
366
|
+
let orphan = 0;
|
|
354
367
|
for (const p of parameters) {
|
|
355
|
-
const name = p.name.getText(source);
|
|
368
|
+
const name = ts.isIdentifier(p.name) ? p.name.getText(source) : (orphans[orphan++] ?? _getBindingName(p, source));
|
|
356
369
|
const type = p.type?.getText(source);
|
|
357
370
|
const optional = !!p.questionToken || !!p.initializer;
|
|
358
371
|
const def = p.initializer?.getText(source);
|
|
@@ -371,6 +384,20 @@ function _buildParams(parameters, source, primaryJsDocParams, fallbackJsDocParam
|
|
|
371
384
|
}
|
|
372
385
|
return params;
|
|
373
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Derive a display name for a destructured (binding-pattern) parameter, which has no name of its own.
|
|
389
|
+
* - Prefers the rest element's name when present (`{ min, ...options }` → `options`), since that's already author-supplied and accurate.
|
|
390
|
+
* - Otherwise falls back to a generic name read from the type — `props` for a `*Props` type (component props), else `options`.
|
|
391
|
+
* - Callers resolve an explicit `@param` first (see `_buildParams`); this is only the fallback when none is given.
|
|
392
|
+
*/
|
|
393
|
+
function _getBindingName(p, source) {
|
|
394
|
+
const { name } = p;
|
|
395
|
+
if (ts.isObjectBindingPattern(name) || ts.isArrayBindingPattern(name))
|
|
396
|
+
for (const el of name.elements)
|
|
397
|
+
if (ts.isBindingElement(el) && el.dotDotDotToken && ts.isIdentifier(el.name))
|
|
398
|
+
return el.name.text;
|
|
399
|
+
return p.type?.getText(source).replace(/<.*/s, "").endsWith("Props") ? "props" : "options";
|
|
400
|
+
}
|
|
374
401
|
/**
|
|
375
402
|
* Extract a class's constructor parameters as `params`, mirroring the function shape.
|
|
376
403
|
* - Descriptions are sourced from the constructor's own `@param` first, falling back to the class-level `@param`.
|
package/markup/MarkupParser.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { Parser } from "./Parser.js";
|
|
|
16
16
|
export type MarkupOptions = {
|
|
17
17
|
/**
|
|
18
18
|
* The active list of parsing rules.
|
|
19
|
-
* @default MARKUP_RULES
|
|
19
|
+
* @default MARKUP_RULES
|
|
20
20
|
*/
|
|
21
21
|
readonly rules?: MarkupRules | undefined;
|
|
22
22
|
/**
|
package/package.json
CHANGED