@tsdoctor/model 0.1.0 → 0.2.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/index.d.ts CHANGED
@@ -1,5 +1,139 @@
1
- import { ApiItem, ApiPackage, Excerpt } from "@microsoft/api-extractor-model";
1
+ import { ApiClass, ApiInterface, ApiItem, ApiModel, ApiNamespace, ApiPackage, Excerpt } from "@microsoft/api-extractor-model";
2
+ import { Effect, Schema } from "effect";
3
+ import { FlowContent, MarkdownNode } from "@effected/markdown";
4
+ import { PackageManifest } from "@effected/package-json";
2
5
  import { DocNode } from "@microsoft/tsdoc";
6
+ declare namespace EntryPoints_d_exports {
7
+ export { ResolvedEntryItem, entryPointName, resolve };
8
+ }
9
+ /**
10
+ * A resolved API item with entry point metadata for deduplication.
11
+ *
12
+ * @public
13
+ */
14
+ interface ResolvedEntryItem {
15
+ /** The API item from the model */
16
+ readonly item: ApiItem;
17
+ /** Which entry point defines this item (canonical owner) */
18
+ readonly definingEntryPoint: string;
19
+ /** All entry points that export this item (includes re-exports) */
20
+ readonly availableFrom: string[];
21
+ }
22
+ /**
23
+ * Derive an entry point name from its display name in the API model.
24
+ *
25
+ * - Empty string (main entry `.` in package.json) maps to `"default"`
26
+ * - Named entries (e.g. `"testing"`) keep their name
27
+ *
28
+ * @public
29
+ */
30
+ declare function entryPointName(displayName: string): string;
31
+ /**
32
+ * Resolve all entry points from an API package into a flat list of
33
+ * deduplicated items.
34
+ *
35
+ * - Re-exported items (same displayName + kind across entries) are
36
+ * deduplicated to a single entry with `availableFrom` listing all
37
+ * entry points. The defining entry point prefers `"default"`.
38
+ * - Items with different kinds but the same displayName (e.g. the
39
+ * Effect const + type companion pattern) remain as separate entries.
40
+ *
41
+ * @param apiPackage - The merged API package with 1+ entry points
42
+ * @returns Flat array of resolved items
43
+ *
44
+ * @public
45
+ */
46
+ declare function resolve(apiPackage: ApiPackage): ResolvedEntryItem[];
47
+ declare namespace ApiItems_d_exports {
48
+ export { CategorizedItems, CategorySpec, Inheritance, NamespaceMember, SourceLinkTarget, categorize, inheritance, namespaceMembers, sourceLink };
49
+ }
50
+ /**
51
+ * The category rules `categorize` reads — a structural subset of a consumer's
52
+ * richer category config (display names, sidebar options, …), so those configs
53
+ * assign directly.
54
+ *
55
+ * @public
56
+ */
57
+ interface CategorySpec {
58
+ /** API item kinds included in this category. */
59
+ readonly itemKinds?: ReadonlyArray<string> | undefined;
60
+ /** TSDoc modifier tag that marks items for this category (takes precedence). */
61
+ readonly tsdocModifier?: string | undefined;
62
+ }
63
+ /**
64
+ * The result of {@link categorize}: items grouped by category key, plus the
65
+ * items no category matched. Uncategorized items are returned as data — the
66
+ * caller decides whether to warn.
67
+ *
68
+ * @public
69
+ */
70
+ interface CategorizedItems {
71
+ readonly items: Record<string, ApiItem[]>;
72
+ readonly uncategorized: ReadonlyArray<ApiItem>;
73
+ }
74
+ /**
75
+ * A member of a namespace with its parent namespace context.
76
+ *
77
+ * @public
78
+ */
79
+ interface NamespaceMember {
80
+ /** The API item (class, interface, function, etc.) */
81
+ readonly item: ApiItem;
82
+ /** The parent namespace */
83
+ readonly namespace: ApiNamespace;
84
+ /** Qualified name including namespace prefix (e.g. `"MathUtils.Vector"`) */
85
+ readonly qualifiedName: string;
86
+ }
87
+ /**
88
+ * Inheritance information read off a class or interface declaration.
89
+ *
90
+ * @public
91
+ */
92
+ interface Inheritance {
93
+ readonly extends?: ReadonlyArray<string>;
94
+ readonly implements?: ReadonlyArray<string>;
95
+ }
96
+ /**
97
+ * Repository target for {@link sourceLink} — framework-neutral shape a
98
+ * consumer's source config assigns to structurally.
99
+ *
100
+ * @public
101
+ */
102
+ interface SourceLinkTarget {
103
+ /** Repository base URL, e.g. `"https://github.com/org/repo"`. */
104
+ readonly url: string;
105
+ /** Ref path segment appended to the URL. Defaults to `"blob/main"`. */
106
+ readonly ref?: string | undefined;
107
+ }
108
+ /**
109
+ * Group top-level API items into categories. A category's `tsdocModifier`
110
+ * takes precedence over its `itemKinds`; categories declaring a modifier are
111
+ * checked first. Items no category matches land in `uncategorized`.
112
+ *
113
+ * @public
114
+ */
115
+ declare function categorize(source: ApiPackage | ReadonlyArray<ResolvedEntryItem>, categories: Record<string, CategorySpec>): CategorizedItems;
116
+ /**
117
+ * Extract all members of top-level namespaces as a flat list with qualified
118
+ * names.
119
+ *
120
+ * @public
121
+ */
122
+ declare function namespaceMembers(source: ApiPackage | ReadonlyArray<ResolvedEntryItem>): NamespaceMember[];
123
+ /**
124
+ * Read extends/implements information from a class or interface declaration.
125
+ *
126
+ * @public
127
+ */
128
+ declare function inheritance(item: ApiClass | ApiInterface): Inheritance;
129
+ /**
130
+ * Build a source-code URL (with line number when available) for an API item,
131
+ * or `null` when no target or file path is known.
132
+ *
133
+ * @public
134
+ */
135
+ declare function sourceLink(item: ApiItem, target?: SourceLinkTarget): string | null;
136
+ //#endregion
3
137
  //#region src/types.d.ts
4
138
  /**
5
139
  * URL-stable slug for an item kind, used in routes and generated doc paths.
@@ -48,7 +182,7 @@ interface RenderedDoc extends DocMeta {
48
182
  readonly markdown: string;
49
183
  }
50
184
  /**
51
- * Options for {@link renderPackage}: the package name plus the optional injected
185
+ * Options for `Render.docs`: the package name plus the optional injected
52
186
  * route, frontmatter, and filter services.
53
187
  *
54
188
  * @public
@@ -63,68 +197,115 @@ interface RenderPackageOptions {
63
197
  /**
64
198
  * Predicate deciding whether a top-level item is emitted (and registered as a
65
199
  * crosslink target). Returns `true` to keep the item. Omit → the default rule
66
- * {@link isEmittable} drops compiler-synthetic forgotten exports
67
- * (`isExported === false`). Providing a filter fully replaces the default; compose
68
- * with {@link isEmittable} to retain the forgotten-export drop.
200
+ * `Render.isEmittable` drops compiler-synthetic forgotten exports
201
+ * (`isExported === false`). Providing a filter fully replaces the default;
202
+ * compose with `Render.isEmittable` to retain the forgotten-export drop.
69
203
  */
70
204
  readonly filter?: (item: ApiItem) => boolean;
71
205
  }
72
206
  //#endregion
73
- //#region src/cross-linker.d.ts
207
+ //#region src/CrossLinker.d.ts
74
208
  /**
75
- * Links known API item names in prose to their docs, using an injected
76
- * {@link RouteFormatter} so each consumer supplies its own URL scheme.
209
+ * Links known API item names in prose to their documentation routes. Matching
210
+ * is longest-name-first with word boundaries, skipping code spans and existing
211
+ * links.
77
212
  *
78
213
  * @public
79
214
  */
80
215
  declare class CrossLinker {
81
- private readonly byName;
82
- private readonly routeFor;
83
- constructor(refs: ReadonlyArray<ApiItemRef>, routeFor: RouteFormatter);
216
+ private readonly routesByName;
217
+ /** Names sorted longest-first so "HookEvent" matches before "Hook". */
218
+ private readonly orderedNames;
219
+ private constructor();
220
+ /**
221
+ * Build from a precomputed name → route map (member anchors and qualified
222
+ * names already baked into the routes). The primary pipeline path.
223
+ */
224
+ static fromRoutes(routes: ReadonlyMap<string, string>): CrossLinker;
225
+ /**
226
+ * Build from item refs plus an injected {@link RouteFormatter}, so each
227
+ * consumer supplies its own URL scheme. Routes are evaluated eagerly at
228
+ * construction.
229
+ */
230
+ static fromRefs(refs: ReadonlyArray<ApiItemRef>, routeFor: RouteFormatter): CrossLinker;
231
+ /** The identity cross-linker: `link(text)` returns `text` unchanged. */
232
+ static readonly empty: CrossLinker;
84
233
  /** Wrap known item names in markdown links, skipping code spans + existing links. */
85
- addLinks(text: string): string;
234
+ link(text: string): string;
235
+ /**
236
+ * Wrap known item names in HTML `<a>` anchors — for text rendered as HTML
237
+ * rather than markdown. Skips matches inside an open `<a>` tag.
238
+ */
239
+ linkHtml(text: string): string;
86
240
  }
87
- //#endregion
88
- //#region src/formatter.d.ts
241
+ declare namespace Model_d_exports {
242
+ export { EmptyModelError, ModelNotFoundError, ModelParseError, firstPackage, load };
243
+ }
244
+ declare const ModelNotFoundError_base: Schema.Class<ModelNotFoundError, Schema.TaggedStruct<"ModelNotFoundError", {
245
+ readonly modelPath: Schema.String;
246
+ }>, import("effect/Cause").YieldableError>;
89
247
  /**
90
- * Formats an API Extractor `Excerpt` into a clean, line-wrapped type signature string.
248
+ * The `.api.json` file does not exist at the resolved path.
91
249
  *
92
250
  * @public
93
251
  */
94
- declare class TypeSignatureFormatter {
95
- private readonly maxLineLength;
96
- private readonly indent;
97
- constructor(opts?: {
98
- maxLineLength?: number;
99
- indent?: string;
100
- });
101
- format(excerpt: Excerpt): string;
102
- private stripExportDeclare;
103
- private needsSpaceBefore;
252
+ declare class ModelNotFoundError extends ModelNotFoundError_base {
253
+ get message(): string;
104
254
  }
105
- //#endregion
106
- //#region src/model-loader.d.ts
255
+ declare const ModelParseError_base: Schema.Class<ModelParseError, Schema.TaggedStruct<"ModelParseError", {
256
+ readonly modelPath: Schema.String;
257
+ readonly reason: Schema.String;
258
+ }>, import("effect/Cause").YieldableError>;
107
259
  /**
108
- * Load a `.api.json` model file and return its first (only) package.
260
+ * The `.api.json` file exists but could not be deserialized (malformed JSON,
261
+ * unsupported schema version, …). `reason` carries the deserializer's message.
109
262
  *
110
263
  * @public
111
264
  */
112
- declare function loadApiModel(modelPath: string): Promise<ApiPackage>;
113
- //#endregion
114
- //#region src/render.d.ts
265
+ declare class ModelParseError extends ModelParseError_base {
266
+ get message(): string;
267
+ }
268
+ declare const EmptyModelError_base: Schema.Class<EmptyModelError, Schema.TaggedStruct<"EmptyModelError", {
269
+ readonly reason: Schema.String;
270
+ }>, import("effect/Cause").YieldableError>;
115
271
  /**
116
- * The default emit rule for {@link renderPackage}: drop compiler-synthetic
117
- * forgotten exports — items the model retains only because API Extractor ran with
118
- * `includeForgottenExports: true` (e.g. the `*_base` classes TypeScript hoists for
119
- * Effect class mixins). Those carry `isExported === false` on `ApiExportedMixin`.
120
- * Every other item, including any lacking the flag, is kept.
272
+ * An in-memory `ApiModel` carries no packages (or is otherwise unusable).
273
+ *
274
+ * @public
275
+ */
276
+ declare class EmptyModelError extends EmptyModelError_base {
277
+ get message(): string;
278
+ }
279
+ /**
280
+ * Load a `.api.json` model file and return its single `ApiPackage`.
281
+ *
282
+ * @public
283
+ */
284
+ declare const load: (modelPath: string) => Effect.Effect<ApiPackage, ModelNotFoundError | ModelParseError>;
285
+ /**
286
+ * Extract the first (only) package from an already-constructed `ApiModel` —
287
+ * the user-supplied-loader path, where the caller obtained the model itself.
288
+ *
289
+ * @public
290
+ */
291
+ declare const firstPackage: (model: ApiModel) => Effect.Effect<ApiPackage, EmptyModelError>;
292
+ declare namespace Render_d_exports {
293
+ export { RenderItemOptions, docs, isEmittable, item, tree };
294
+ }
295
+ /**
296
+ * The default emit rule for {@link docs}: drop compiler-synthetic forgotten
297
+ * exports — items the model retains only because API Extractor ran with
298
+ * `includeForgottenExports: true` (e.g. the `*_base` classes TypeScript hoists
299
+ * for Effect class mixins). Those carry `isExported === false` on
300
+ * `ApiExportedMixin`. Every other item, including any lacking the flag, is
301
+ * kept.
121
302
  *
122
303
  * @public
123
304
  */
124
305
  declare const isEmittable: (item: ApiItem) => boolean;
125
306
  /**
126
- * Options for {@link renderItem}: the package name used in fallbacks and an
127
- * optional crosslinker applied to the rendered prose.
307
+ * Options for {@link item} and {@link tree}: the package name used in
308
+ * fallbacks and an optional crosslinker applied to the rendered prose.
128
309
  *
129
310
  * @public
130
311
  */
@@ -134,78 +315,308 @@ interface RenderItemOptions {
134
315
  readonly crossLinker?: CrossLinker;
135
316
  }
136
317
  /**
137
- * Render one API item to a markdown body (no frontmatter).
318
+ * Render one API item's markdown body as flow nodes — the pre-serialization
319
+ * form of {@link item}.
320
+ *
321
+ * @alpha
322
+ */
323
+ declare function tree(apiItem: ApiItem, opts: RenderItemOptions): ReadonlyArray<FlowContent>;
324
+ /**
325
+ * Render one API item to a markdown body string (no frontmatter).
138
326
  *
139
327
  * @public
140
328
  */
141
- declare function renderItem(item: ApiItem, opts: RenderItemOptions): string;
329
+ declare function item(apiItem: ApiItem, opts: RenderItemOptions): string;
142
330
  /**
143
- * Walk a package's first entry point and assemble one RenderedDoc per top-level member.
331
+ * Walk a package's first entry point and assemble one RenderedDoc per
332
+ * top-level member.
144
333
  *
145
334
  * @public
146
335
  */
147
- declare function renderPackage(apiPackage: ApiPackage, opts: RenderPackageOptions): RenderedDoc[];
148
- //#endregion
149
- //#region src/tsdoc.d.ts
336
+ declare function docs(apiPackage: ApiPackage, opts: RenderPackageOptions): RenderedDoc[];
337
+ declare namespace Routes_d_exports {
338
+ export { RouteCandidate, RouteCollision, RouteCollisionError, detectCollisions, sanitizeId };
339
+ }
340
+ declare const RouteCandidate_base: Schema.Class<RouteCandidate, Schema.Struct<{
341
+ /** Stable identity (e.g. `"displayName::kind"` or a namespace qualified name). */
342
+ readonly id: Schema.String;
343
+ /** Human-readable name for error messages (original, non-lowercased). */
344
+ readonly displayName: Schema.String;
345
+ /** Category folder name, e.g. `"variable"`. */
346
+ readonly folder: Schema.String;
347
+ /** Lowercased sanitized last path segment, e.g. `"foo"` — the value used in the route. */
348
+ readonly baseName: Schema.String;
349
+ /** API item kind string, e.g. `"Variable"`. */
350
+ readonly kind: Schema.String;
351
+ /** canonicalReference string, used for deterministic ordering. */
352
+ readonly canonicalRef: Schema.String;
353
+ }>, {}>;
354
+ /**
355
+ * A candidate output route for collision detection. All-string and
356
+ * serializable — candidates cross the error boundary inside
357
+ * {@link RouteCollisionError} and may be persisted by consumer diagnostics.
358
+ *
359
+ * @public
360
+ */
361
+ declare class RouteCandidate extends RouteCandidate_base {}
150
362
  /**
151
- * Recursively flatten a TSDoc DocNode tree to plain text (code spans → backticks).
363
+ * A set of distinct items that resolve to the same output route.
152
364
  *
153
365
  * @public
154
366
  */
155
- declare function extractPlainText(node: DocNode): string;
367
+ interface RouteCollision {
368
+ /** The shared route key: `${folder}/${baseName}`. */
369
+ readonly route: string;
370
+ /** The distinct candidates that resolve to it (two or more). */
371
+ readonly items: ReadonlyArray<RouteCandidate>;
372
+ }
373
+ /**
374
+ * Group candidates by their final route (`${folder}/${baseName}`) and return
375
+ * the groups with more than one distinct item. The route key is the lowercased
376
+ * path the file is written to, so detection matches generation (and what a
377
+ * case-insensitive filesystem would merge). Companion pairs (same name,
378
+ * different folders) land under different keys and are never collisions.
379
+ *
380
+ * Output is deterministic: collisions ordered by route, items within a
381
+ * collision ordered by canonicalReference.
382
+ *
383
+ * @public
384
+ */
385
+ declare function detectCollisions(candidates: ReadonlyArray<RouteCandidate>): RouteCollision[];
386
+ declare const RouteCollisionError_base: Schema.Class<RouteCollisionError, Schema.TaggedStruct<"RouteCollisionError", {
387
+ readonly baseRoute: Schema.String;
388
+ readonly collisions: Schema.$Array<Schema.Struct<{
389
+ readonly route: Schema.String;
390
+ readonly items: Schema.$Array<typeof RouteCandidate>;
391
+ }>>;
392
+ }>, import("effect/Cause").YieldableError>;
393
+ /**
394
+ * Two or more distinct API items resolve to the same documentation route — a
395
+ * naming or category-configuration problem the build must fail on. The
396
+ * `message` names every colliding item with its kind and canonical reference,
397
+ * plus remediation guidance.
398
+ *
399
+ * @public
400
+ */
401
+ declare class RouteCollisionError extends RouteCollisionError_base {
402
+ get message(): string;
403
+ }
404
+ /**
405
+ * Sanitize a display name into a valid HTML anchor id: lowercase,
406
+ * spaces/underscores → hyphens, other specials stripped, optional prefix for
407
+ * disambiguation. The ONE canonical implementation — anchor generation and
408
+ * cross-link routes must agree on it by construction.
409
+ *
410
+ * @public
411
+ */
412
+ declare function sanitizeId(displayName: string, prefix?: string): string;
413
+ declare namespace Signature_d_exports {
414
+ export { FormatOptions, format, linkReferences, stripExportDeclare };
415
+ }
416
+ /**
417
+ * Options for {@link format}.
418
+ *
419
+ * @public
420
+ */
421
+ interface FormatOptions {
422
+ /** Wrap long union/intersection lines beyond this length. Default 80. */
423
+ readonly maxLineLength?: number;
424
+ /** Continuation-line indent. Default two spaces. */
425
+ readonly indent?: string;
426
+ }
427
+ /**
428
+ * Strip `export` / `declare` modifiers from a declaration text.
429
+ *
430
+ * @public
431
+ */
432
+ declare function stripExportDeclare(text: string): string;
433
+ /**
434
+ * Format an API Extractor `Excerpt` into a clean type signature string,
435
+ * wrapping long top-level unions/intersections.
436
+ *
437
+ * @public
438
+ */
439
+ declare function format(excerpt: Excerpt, options?: FormatOptions): string;
440
+ /**
441
+ * Inject markdown cross-links into already-formatted signature text. Reference
442
+ * tokens in the excerpt whose canonical reference appears in
443
+ * `routesByCanonicalRef` have their display text wrapped in a markdown link.
444
+ *
445
+ * @public
446
+ */
447
+ declare function linkReferences(text: string, excerpt: Excerpt, routesByCanonicalRef: ReadonlyMap<string, string>): string;
448
+ declare namespace StructuredData_d_exports {
449
+ export { StructuredDataGraph, derive };
450
+ }
451
+ /**
452
+ * A schema.org JSON-LD graph.
453
+ *
454
+ * @alpha
455
+ */
456
+ interface StructuredDataGraph {
457
+ readonly "@context": "https://schema.org";
458
+ readonly "@graph": ReadonlyArray<Record<string, unknown>>;
459
+ }
460
+ /**
461
+ * Derive schema.org structured data for a documented package.
462
+ *
463
+ * @remarks
464
+ * Not implemented yet — this is the phase-4 seam. Calling it throws.
465
+ *
466
+ * @alpha
467
+ */
468
+ declare function derive(_apiPackage: ApiPackage, _manifest: PackageManifest): StructuredDataGraph;
469
+ declare namespace SyntheticBases_d_exports {
470
+ export { BASE_CLASS_ANCHOR, SyntheticBase, SyntheticBaseDetection, detect };
471
+ }
472
+ /**
473
+ * Anchor id of the inline "Base Class" section rendered on the owner class
474
+ * page. Must match the slug RSPress derives from the `## Base Class` heading
475
+ * emitted by the owner-class page.
476
+ *
477
+ * @public
478
+ */
479
+ declare const BASE_CLASS_ANCHOR = "base-class";
156
480
  /**
157
- * The TSDoc `@summary` section as a single cleaned line.
481
+ * A synthetic base declaration: an unexported item that API Extractor hoisted
482
+ * into the model (via `includeForgottenExports`) because an exported class's
483
+ * extends clause references it.
484
+ *
485
+ * TypeScript emits these for classes extending a call expression — e.g. the
486
+ * Effect `Schema.Class`/`Data.TaggedError` patterns or mixin factories — as
487
+ * `declare const Foo_base: ...; class Foo extends Foo_base {}`.
488
+ *
489
+ * @public
490
+ */
491
+ interface SyntheticBase {
492
+ /** The unexported supporting declaration (usually a Variable). */
493
+ readonly baseItem: ApiItem;
494
+ /** Classes whose extends clause references this declaration, in model order. */
495
+ readonly ownerClasses: readonly ApiClass[];
496
+ }
497
+ /**
498
+ * The result of {@link detect}.
499
+ *
500
+ * @public
501
+ */
502
+ interface SyntheticBaseDetection {
503
+ /** Detected base declarations, keyed by the base ApiItem (identity). */
504
+ readonly bases: ReadonlyMap<ApiItem, SyntheticBase>;
505
+ /** Owner class -> its synthetic base declaration (identity keys). */
506
+ readonly baseByOwner: ReadonlyMap<ApiItem, ApiItem>;
507
+ }
508
+ /**
509
+ * Detect synthetic base declarations among top-level API items.
510
+ *
511
+ * An item qualifies when it is unexported (hoisted into the model only because
512
+ * something references it) AND at least one class's extends clause references
513
+ * its canonical symbol. Unexported items with no class referencing them
514
+ * (genuine forgotten exports) are left alone, as are extends references whose
515
+ * target is absent from the model.
158
516
  *
159
517
  * @public
160
518
  */
161
- declare function getSummary(item: ApiItem): string;
519
+ declare function detect(items: readonly ApiItem[]): SyntheticBaseDetection;
520
+ declare namespace Tsdoc_d_exports {
521
+ export { DocExample, DocParam, ReleaseTagName, deprecation, examples, hasModifier, params, plainText, releaseTag, returns, seeReferences, summary, toMarkdown };
522
+ }
523
+ /**
524
+ * One documented parameter: the `@param` block merged with the declared type.
525
+ *
526
+ * @public
527
+ */
528
+ interface DocParam {
529
+ readonly name: string;
530
+ readonly type?: string;
531
+ readonly description: string;
532
+ }
533
+ /**
534
+ * One `@example` block's code (language defaults to `typescript`).
535
+ *
536
+ * @public
537
+ */
538
+ interface DocExample {
539
+ readonly language: string;
540
+ readonly code: string;
541
+ }
542
+ /**
543
+ * TSDoc release tag names, with `"Public"` as the absent-tag default.
544
+ *
545
+ * @public
546
+ */
547
+ type ReleaseTagName = "Public" | "Beta" | "Alpha" | "Internal";
548
+ /**
549
+ * Recursively flatten a TSDoc DocNode tree to plain text (code spans →
550
+ * backticks, `{@link}` → display text, code fences dropped).
551
+ *
552
+ * @public
553
+ */
554
+ declare function plainText(node: DocNode): string;
555
+ /**
556
+ * Convert a TSDoc DocNode tree to markdown nodes, preserving structure the
557
+ * plain-text flattener drops: code spans become {@link InlineCode}, url
558
+ * `{@link}` tags become {@link Link} nodes, fenced code becomes {@link Code}
559
+ * blocks. Code-destination `{@link}` tags (declaration references) flatten to
560
+ * their display text — resolving them to URLs is the caller's cross-linking
561
+ * concern, not this layer's.
562
+ *
563
+ * @public
564
+ */
565
+ declare function toMarkdown(node: DocNode): ReadonlyArray<MarkdownNode>;
566
+ /**
567
+ * The TSDoc summary section as a single cleaned line.
568
+ *
569
+ * @public
570
+ */
571
+ declare function summary(item: ApiItem): string;
162
572
  /**
163
573
  * `@param` blocks merged with parameter types from the declaration excerpt.
164
574
  *
165
575
  * @public
166
576
  */
167
- declare function getParams(item: ApiItem): Array<{
168
- name: string;
169
- type?: string;
170
- description: string;
171
- }>;
577
+ declare function params(item: ApiItem): ReadonlyArray<DocParam>;
172
578
  /**
173
579
  * The `@returns` block description, if present.
174
580
  *
175
581
  * @public
176
582
  */
177
- declare function getReturns(item: ApiItem): {
178
- description: string;
583
+ declare function returns(item: ApiItem): {
584
+ readonly description: string;
179
585
  } | null;
180
586
  /**
181
587
  * All `@example` fenced-code blocks (falls back to plain text).
182
588
  *
183
589
  * @public
184
590
  */
185
- declare function getExamples(item: ApiItem): Array<{
186
- language: string;
187
- code: string;
188
- }>;
591
+ declare function examples(item: ApiItem): ReadonlyArray<DocExample>;
189
592
  /**
190
- * Reads the deprecation-block message from an ApiItem, if one is present.
593
+ * The deprecation-block message, if one is present.
191
594
  *
192
595
  * @public
193
596
  */
194
- declare function getDeprecation(item: ApiItem): {
195
- message: string;
597
+ declare function deprecation(item: ApiItem): {
598
+ readonly message: string;
196
599
  } | null;
197
600
  /**
198
- * The release tag (Public/Beta/Alpha/Internal) or "Public" when absent.
601
+ * The release tag (Public/Beta/Alpha/Internal), `"Public"` when absent.
199
602
  *
200
603
  * @public
201
604
  */
202
- declare function getReleaseTag(item: ApiItem): string;
605
+ declare function releaseTag(item: ApiItem): ReleaseTagName;
203
606
  /**
204
607
  * True when the item carries the given TSDoc modifier tag (without the `@`).
205
608
  *
206
609
  * @public
207
610
  */
208
- declare function hasModifierTag(item: ApiItem, tagName: string): boolean;
611
+ declare function hasModifier(item: ApiItem, tagName: string): boolean;
612
+ /**
613
+ * `@see` block contents, flattened to prose (whitespace-normalized).
614
+ *
615
+ * @public
616
+ */
617
+ declare function seeReferences(item: ApiItem): ReadonlyArray<{
618
+ readonly text: string;
619
+ }>;
209
620
  //#endregion
210
- export { type ApiItemRef, CrossLinker, type DocMeta, type FrontmatterRenderer, type ItemKindSlug, type RenderItemOptions, type RenderPackageOptions, type RenderedDoc, type RouteFormatter, TypeSignatureFormatter, extractPlainText, getDeprecation, getExamples, getParams, getReleaseTag, getReturns, getSummary, hasModifierTag, isEmittable, loadApiModel, renderItem, renderPackage };
621
+ export { type ApiItemRef, ApiItems_d_exports as ApiItems, CrossLinker, type DocMeta, EntryPoints_d_exports as EntryPoints, type FrontmatterRenderer, type ItemKindSlug, Model_d_exports as Model, Render_d_exports as Render, type RenderPackageOptions, type RenderedDoc, type RouteFormatter, Routes_d_exports as Routes, Signature_d_exports as Signature, StructuredData_d_exports as StructuredData, SyntheticBases_d_exports as SyntheticBases, Tsdoc_d_exports as Tsdoc };
211
622
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,7 +1,12 @@
1
- import { CrossLinker } from "./cross-linker.js";
2
- import { TypeSignatureFormatter } from "./formatter.js";
3
- import { loadApiModel } from "./model-loader.js";
4
- import { extractPlainText, getDeprecation, getExamples, getParams, getReleaseTag, getReturns, getSummary, hasModifierTag } from "./tsdoc.js";
5
- import { isEmittable, renderItem, renderPackage } from "./render.js";
1
+ import { Tsdoc_exports } from "./Tsdoc.js";
2
+ import { ApiItems_exports } from "./ApiItems.js";
3
+ import { CrossLinker } from "./CrossLinker.js";
4
+ import { EntryPoints_exports } from "./EntryPoints.js";
5
+ import { Model_exports } from "./Model.js";
6
+ import { Signature_exports } from "./Signature.js";
7
+ import { Render_exports } from "./Render.js";
8
+ import { Routes_exports } from "./Routes.js";
9
+ import { StructuredData_exports } from "./StructuredData.js";
10
+ import { SyntheticBases_exports } from "./SyntheticBases.js";
6
11
 
7
- export { CrossLinker, TypeSignatureFormatter, extractPlainText, getDeprecation, getExamples, getParams, getReleaseTag, getReturns, getSummary, hasModifierTag, isEmittable, loadApiModel, renderItem, renderPackage };
12
+ export { ApiItems_exports as ApiItems, CrossLinker, EntryPoints_exports as EntryPoints, Model_exports as Model, Render_exports as Render, Routes_exports as Routes, Signature_exports as Signature, StructuredData_exports as StructuredData, SyntheticBases_exports as SyntheticBases, Tsdoc_exports as Tsdoc };
@@ -0,0 +1,20 @@
1
+ import { Markdown, Paragraph, Text } from "@effected/markdown";
2
+ import { Result } from "effect";
3
+
4
+ //#region src/internal/prose.ts
5
+ /**
6
+ * Parse a single-line markdown prose string into phrasing nodes. Multiple
7
+ * paragraphs collapse into one phrasing run (prose from TSDoc extraction is
8
+ * whitespace-normalized single-line text). Falls back to a literal Text node
9
+ * when the string does not parse.
10
+ */
11
+ const phrasingFromMarkdown = (prose) => {
12
+ const parsed = Markdown.parseResult(prose);
13
+ if (Result.isFailure(parsed)) return [new Text({ value: prose })];
14
+ const phrasing = [];
15
+ for (const child of parsed.success.children) if (child instanceof Paragraph) phrasing.push(...child.children);
16
+ return phrasing.length > 0 ? phrasing : [new Text({ value: prose })];
17
+ };
18
+
19
+ //#endregion
20
+ export { phrasingFromMarkdown };