@orkestrel/guide 0.0.16 → 0.0.18
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/README.md +40 -20
- package/dist/src/core/index.cjs +2400 -264
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1616 -203
- package/dist/src/core/index.d.ts +1616 -203
- package/dist/src/core/index.js +2351 -269
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +3867 -0
- package/dist/src/server/index.cjs.map +1 -0
- package/dist/src/server/index.d.cts +686 -0
- package/dist/src/server/index.d.ts +686 -0
- package/dist/src/server/index.js +3833 -0
- package/dist/src/server/index.js.map +1 -0
- package/package.json +29 -17
|
@@ -1,15 +1,281 @@
|
|
|
1
1
|
import { ArrayShape } from '@orkestrel/contract';
|
|
2
|
-
import { BlockNode } from '@orkestrel/markdown';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { BlockNode } from '@orkestrel/markdown';
|
|
3
|
+
import type { CodeBlockNode } from '@orkestrel/markdown';
|
|
4
|
+
import type { ContractInterface } from '@orkestrel/contract';
|
|
5
|
+
import type { Guard } from '@orkestrel/contract';
|
|
6
|
+
import type { InlineNode } from '@orkestrel/markdown';
|
|
6
7
|
import { LiteralShape } from '@orkestrel/contract';
|
|
7
|
-
import { MarkdownDocument } from '@orkestrel/markdown';
|
|
8
|
+
import type { MarkdownDocument } from '@orkestrel/markdown';
|
|
9
|
+
import type { MarkdownSpan } from '@orkestrel/markdown';
|
|
8
10
|
import { ObjectShape } from '@orkestrel/contract';
|
|
11
|
+
import { OptionalShape } from '@orkestrel/contract';
|
|
9
12
|
import { StringShape } from '@orkestrel/contract';
|
|
10
|
-
import { TableNode } from '@orkestrel/markdown';
|
|
13
|
+
import type { TableNode } from '@orkestrel/markdown';
|
|
11
14
|
import { UnionShape } from '@orkestrel/contract';
|
|
12
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Builds one table cell's inline content from its compared text — the inverse of
|
|
18
|
+
* {@link extractCellText}. A single-backtick run whose text carries no inner backtick and
|
|
19
|
+
* neither a leading nor a trailing space becomes a code span; every other character, a backtick
|
|
20
|
+
* included, becomes literal text, which `renderMarkdown` escapes so the rendered cell parses back
|
|
21
|
+
* to the text this function was given.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* The compared form spells every code span with one backtick per side, because
|
|
25
|
+
* {@link extractCellText} emits `` `${value}` `` whatever delimiter the source used. A run this
|
|
26
|
+
* function refuses is therefore a run no parsed cell produced, and emitting it as text is what
|
|
27
|
+
* keeps the projection total: reading the rendered cell back through {@link extractCellText}
|
|
28
|
+
* returns the text, so a rendered row and a hand-written row compare the same. A code span whose
|
|
29
|
+
* own text carries a backtick or a boundary space is outside the compared form's fidelity in
|
|
30
|
+
* either direction, and this function writes it as text rather than guessing a delimiter.
|
|
31
|
+
*
|
|
32
|
+
* @param text - The cell's compared text, as {@link extractCellText} returns it
|
|
33
|
+
* @returns The cell's inline nodes, in text order
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* buildCell('Holds a `Widget`.')
|
|
38
|
+
* // [{ element: 'text', value: 'Holds a ' }, { element: 'codeSpan', value: 'Widget' }, { element: 'text', value: '.' }]
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildCell(text: string): readonly InlineNode[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Builds one genuine JSDoc span from its content lines — the inverse of {@link unwrapComment}.
|
|
45
|
+
* Each line is emitted at `indent` behind a continuation marker, an empty line as the bare
|
|
46
|
+
* marker so no line carries trailing whitespace, and the leading and trailing empty lines are
|
|
47
|
+
* dropped because the opener and the closer take those physical lines.
|
|
48
|
+
*
|
|
49
|
+
* @param lines - The span's content lines, as {@link unwrapComment} returns them
|
|
50
|
+
* @param indent - The whitespace the span opens at
|
|
51
|
+
* @returns The span's raw text, opener and closer included
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* buildComment(['Walks.'], '') // '/**\n * Walks.\n *' + '/'
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildComment(lines: readonly string[], indent: string): string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Builds the fenced code block one `@example` block renders as — its code inside a fence
|
|
62
|
+
* carrying its language, and an untagged fence when the block names none.
|
|
63
|
+
*
|
|
64
|
+
* @param example - The block to render
|
|
65
|
+
* @returns The fence node
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* buildFence({ name: 'walk', code: 'walk()', language: 'ts' }) // { element: 'codeBlock', code: 'walk()', lang: 'ts' }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildFence(example: SourceExample): CodeBlockNode;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Builds a copy of `table` with one cell's inline content rebuilt from `text` through
|
|
76
|
+
* {@link buildCell}. Every other cell keeps its own nodes, so a rewrite touches the one cell it
|
|
77
|
+
* names and the header and the alignment row travel unchanged.
|
|
78
|
+
*
|
|
79
|
+
* @param table - The table to copy
|
|
80
|
+
* @param row - The index of the row to rewrite within {@link TableNode.rows}
|
|
81
|
+
* @param column - The index of the cell to rewrite within that row
|
|
82
|
+
* @param text - The cell's new compared text
|
|
83
|
+
* @returns The rewritten table
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* buildTable(table, 0, 2, 'Walks the tree.').rows[0]?.[2] // [{ element: 'text', value: 'Walks the tree.' }]
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildTable(table: TableNode, row: number, column: number, text: string): TableNode;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Collects every `export class` / `export interface` declaration one file's source text declares,
|
|
94
|
+
* each keyed `${keyword} ${name}` and carrying the body lines and the base identifiers read from
|
|
95
|
+
* its own head, so a body and a heritage clause always come from the same declaration.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* The whole file is projected once through {@link extractSourceLines} and every head is read from
|
|
99
|
+
* that one projection, so a scope resolving many names reads each file once rather than once per
|
|
100
|
+
* name. A head is a column-zero `export class` / `export interface` line, an oxfmt-wrapped
|
|
101
|
+
* signature joined through {@link joinHead}, with an optional generic parameter list and an
|
|
102
|
+
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
103
|
+
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
104
|
+
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
105
|
+
* keeping JSDoc evidence intact. Every balanced `<...>` span is removed from the head before its
|
|
106
|
+
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
107
|
+
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
108
|
+
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
109
|
+
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
110
|
+
* head of a key already collected adds nothing.
|
|
111
|
+
*
|
|
112
|
+
* @param source - The file's source text to read
|
|
113
|
+
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* collectDeclarations('export interface X extends Y {\n\twalk(): void\n}\n').get('interface X')
|
|
118
|
+
* // { body: ['\twalk(): void'], bases: ['Y'] }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function collectDeclarations(source: string): ReadonlyMap<string, Declaration>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Collects the `@example` blocks one doc block's unwrapped text carries, each named for the
|
|
125
|
+
* declaration or member the block documents. The text after the tag becomes the block's
|
|
126
|
+
* `title`; a body opening with a fence contributes that fence's language and its verbatim
|
|
127
|
+
* body, and a body with no fence contributes its own trimmed text as the code.
|
|
128
|
+
*
|
|
129
|
+
* @param comment - One doc block's unwrapped text, as {@link normalizeComment} returns it
|
|
130
|
+
* @param name - The declaration or member the block documents
|
|
131
|
+
* @returns The block's `@example` entries, in block order
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* collectExamples('@example Walking\n```ts\nwalk()\n```', 'walk')
|
|
136
|
+
* // [{ name: 'walk', title: 'Walking', code: 'walk()', language: 'ts' }]
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function collectExamples(comment: string, name: string): readonly SourceExample[];
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Collects each fenced code block keyed by its own node, paired with the {@link GuideFence}
|
|
143
|
+
* {@link extractFences} reports for it — the node-addressed form a rewrite needs, so a caller
|
|
144
|
+
* that located a fence by title can read that node's source region back from the parser. The map
|
|
145
|
+
* iterates in document order and a node keys itself, so a repeated identical fence keeps its own
|
|
146
|
+
* entry.
|
|
147
|
+
*
|
|
148
|
+
* @param document - The parsed guide document
|
|
149
|
+
* @returns One entry per fenced code block, in document order
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* Array.from(collectFences(document).values()) // [{ language: 'ts', code: 'walk()' }]
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function collectFences(document: MarkdownDocument): ReadonlyMap<CodeBlockNode, GuideFence>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Collects each `## Methods` table keyed to the interface its `####` heading names — an H4
|
|
160
|
+
* carrying a code span sets the current interface and the table immediately following claims it,
|
|
161
|
+
* so a heading with no table and a table with no heading before it contribute nothing. The map
|
|
162
|
+
* iterates in document order and a node keys itself, so a repeated identical table keeps its own
|
|
163
|
+
* entry.
|
|
164
|
+
*
|
|
165
|
+
* @param document - The parsed guide document
|
|
166
|
+
* @returns One entry per documented `## Methods` table, in document order
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* collectGroups(document).values().next().value // 'GuideInterface'
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function collectGroups(document: MarkdownDocument): ReadonlyMap<TableNode, string>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Collects the compared key of every physical record a key names — a {@link computeSymbolKey}
|
|
177
|
+
* symbol key for a column-zero `export` declaration head, an `Owner.member` key for a one-tab
|
|
178
|
+
* callable member inside one — keyed by the record itself. The owner closes at the first
|
|
179
|
+
* column-zero `}` or at a column-zero `export` declaration carrying another keyword, and a
|
|
180
|
+
* record no key names contributes no entry.
|
|
181
|
+
*
|
|
182
|
+
* @remarks
|
|
183
|
+
* This is the package's one key grammar, and each keyed reader projects its own part back out of
|
|
184
|
+
* it: {@link extractExports} splits a declaration key at its one space,
|
|
185
|
+
* {@link extractMemberMethods} and {@link extractExampleMethods} split a member key at its dot,
|
|
186
|
+
* and {@link locateComment} matches a caller's key against the whole map. A change to the head
|
|
187
|
+
* shape or to the member shape reaches every one of them at once.
|
|
188
|
+
*
|
|
189
|
+
* An owner opens at a column-zero `export class` or `export interface` head and closes at the
|
|
190
|
+
* first column-zero `}`, so a member declared past that brace keys nothing. A column-zero `export` declaration carrying any other keyword closes the owner it follows,
|
|
191
|
+
* because a member belongs to the head enclosing it. Reading runs over {@link extractSourceLines}'s
|
|
192
|
+
* projection, so a head or
|
|
193
|
+
* a member written inside a comment or a template literal keys nothing.
|
|
194
|
+
*
|
|
195
|
+
* @param lines - Aligned physical source-line records
|
|
196
|
+
* @returns One entry per record a key names, in file order
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const keys = collectKeys(extractSourceLines('export class Widget {\n\twalk(): void\n}'))
|
|
201
|
+
* Array.from(keys.values()) // ['class Widget', 'Widget.walk']
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function collectKeys(lines: readonly SourceLine[]): ReadonlyMap<SourceLine, string>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Collects the description paragraph of every documented physical record — a doc block's
|
|
208
|
+
* text before its first block tag, in {@link normalizeSummary}'s compared form — keyed by the
|
|
209
|
+
* record it documents. A record whose block carries no description contributes no entry, so
|
|
210
|
+
* an absent summary stays absent rather than becoming an empty string.
|
|
211
|
+
*
|
|
212
|
+
* @param lines - Aligned physical source-line records
|
|
213
|
+
* @returns One entry per documented record carrying a description paragraph
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* collectSummaries(extractSourceLines('/**' + ' Walks. *' + '/\nexport function walk() {}')).size // 1
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare function collectSummaries(lines: readonly SourceLine[]): ReadonlyMap<SourceLine, string>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Collects the titled `@example` blocks a guide's documented surface reaches — the module's
|
|
224
|
+
* exported declaration heads, plus the own members of every documented `class` and `interface` —
|
|
225
|
+
* keyed by title, the first block of a title answering for it.
|
|
226
|
+
*
|
|
227
|
+
* @param guide - The parsed guide naming the documented declarations
|
|
228
|
+
* @param source - The reflected source to read the blocks from
|
|
229
|
+
* @returns One entry per distinct `@example` title
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* collectTitles(guide, source).get('Walk a tree') // { name: 'walk', title: 'Walk a tree', code: 'walk()' }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export declare function collectTitles(guide: GuideInterface, source: SourceInterface): ReadonlyMap<string, SourceExample>;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Compares documented and declared membership exactly after sorting copies, preserving duplicates.
|
|
240
|
+
*
|
|
241
|
+
* @param spec - The guide inventory key the finding belongs to
|
|
242
|
+
* @param name - The declaration whose membership is compared
|
|
243
|
+
* @param documented - The documented member names
|
|
244
|
+
* @param declared - The declared member names
|
|
245
|
+
* @returns The membership finding, or `undefined` when the sorted populations match
|
|
246
|
+
*
|
|
247
|
+
* @example Compare declaration membership
|
|
248
|
+
* ```ts
|
|
249
|
+
* import { compareMembership } from '@orkestrel/guide'
|
|
250
|
+
*
|
|
251
|
+
* compareMembership('guides/widget.md', 'WidgetInterface', ['open'], ['open']) // undefined
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export declare function compareMembership(spec: string, name: string, documented: readonly string[], declared: readonly string[]): ParityFinding | undefined;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Computes the drift between one compared key's guide text and source text. A pair agrees
|
|
258
|
+
* only when both sides carry the same text, and every other state is a drift: guide text
|
|
259
|
+
* alone reports the guide's side, source text alone reports the source's, and neither side
|
|
260
|
+
* carrying text reports the key by itself. A side carrying no text is absent from the result,
|
|
261
|
+
* so a documented symbol with no doc block reports as a drift naming the guide's text alone,
|
|
262
|
+
* and a row a table has no `Summary` column for against a declaration with no doc block
|
|
263
|
+
* reports as `{ key }`.
|
|
264
|
+
*
|
|
265
|
+
* @param key - The compared pair's key
|
|
266
|
+
* @param category - The compared site the drift came from
|
|
267
|
+
* @param guide - The guide's text there, or `undefined` when it carries none
|
|
268
|
+
* @param source - The source's text there, or `undefined` when it carries none
|
|
269
|
+
* @returns The drift, or `undefined` when both sides carry the same text
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* computeDrift('function walk', 'summary', 'Walks the tree.', 'Walks a tree.')
|
|
274
|
+
* // { key: 'function walk', category: 'summary', guide: 'Walks the tree.', source: 'Walks a tree.' }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export declare function computeDrift(key: string, category: Drift['category'], guide: string | undefined, source: string | undefined): Drift | undefined;
|
|
278
|
+
|
|
13
279
|
/**
|
|
14
280
|
* Computes the stable cache key for a {@link GuideModule}. Directories normalize before
|
|
15
281
|
* joining, so equivalent module spellings share one key. The NUL separator
|
|
@@ -27,8 +293,8 @@ import { UnionShape } from '@orkestrel/contract';
|
|
|
27
293
|
export declare function computeModuleKey(module: GuideModule): string;
|
|
28
294
|
|
|
29
295
|
/**
|
|
30
|
-
* Computes the bijection key for a surface symbol —
|
|
31
|
-
*
|
|
296
|
+
* Computes the bijection key for a surface symbol — `${keyword} ${name}` — so a symbol-set
|
|
297
|
+
* comparison diffs (name, keyword) pairs rather than names alone.
|
|
32
298
|
*
|
|
33
299
|
* @param symbol - The symbol to key
|
|
34
300
|
* @returns The `${keyword} ${name}` key
|
|
@@ -40,6 +306,23 @@ export declare function computeModuleKey(module: GuideModule): string;
|
|
|
40
306
|
*/
|
|
41
307
|
export declare function computeSymbolKey(symbol: SurfaceSymbol): string;
|
|
42
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Compiles the {@link driftShape} into a {@link ContractInterface} for
|
|
311
|
+
* {@link Drift} — a guard, coercing parser, JSON Schema, and seeded
|
|
312
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
313
|
+
*
|
|
314
|
+
* @returns A `Drift` contract bundling `schema` / `is` / `parse` / `generate`
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
318
|
+
* import { createDriftContract } from '@orkestrel/guide'
|
|
319
|
+
*
|
|
320
|
+
* const drift = createDriftContract()
|
|
321
|
+
* drift.is({ key: 'class Widget', category: 'summary', guide: 'A widget.' }) // true
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export declare function createDriftContract(): ContractInterface<Drift>;
|
|
325
|
+
|
|
43
326
|
/**
|
|
44
327
|
* Creates a structured {@link GuideInterface} view over one guide's markdown
|
|
45
328
|
* source — parses once and caches its `sections` / `surface` / `methods` /
|
|
@@ -48,12 +331,13 @@ export declare function computeSymbolKey(symbol: SurfaceSymbol): string;
|
|
|
48
331
|
* @param source - The guide's markdown source text
|
|
49
332
|
* @returns A working {@link GuideInterface}
|
|
50
333
|
*
|
|
51
|
-
* @example
|
|
334
|
+
* @example Construct a Guide from markdown text
|
|
52
335
|
* ```ts
|
|
53
336
|
* import { createGuide } from '@orkestrel/guide'
|
|
54
337
|
*
|
|
55
338
|
* const guide = createGuide('## Surface\n\n| Name | Kind |\n| --- | --- |\n| `X` | class |')
|
|
56
339
|
* guide.surface() // [{ name: 'X', keyword: 'class' }]
|
|
340
|
+
* guide.sections() // ['Surface']
|
|
57
341
|
* ```
|
|
58
342
|
*/
|
|
59
343
|
export declare function createGuide(source: string): GuideInterface;
|
|
@@ -75,6 +359,23 @@ export declare function createGuide(source: string): GuideInterface;
|
|
|
75
359
|
*/
|
|
76
360
|
export declare function createManifestEntryContract(): ContractInterface<ManifestEntry>;
|
|
77
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Compiles the {@link methodEntryShape} into a {@link ContractInterface} for
|
|
364
|
+
* {@link MethodEntry} — a guard, coercing parser, JSON Schema, and seeded
|
|
365
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
366
|
+
*
|
|
367
|
+
* @returns A `MethodEntry` contract bundling `schema` / `is` / `parse` / `generate`
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```ts
|
|
371
|
+
* import { createMethodEntryContract } from '@orkestrel/guide'
|
|
372
|
+
*
|
|
373
|
+
* const methodEntry = createMethodEntryContract()
|
|
374
|
+
* methodEntry.is({ name: 'walk' }) // true
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
export declare function createMethodEntryContract(): ContractInterface<MethodEntry>;
|
|
378
|
+
|
|
78
379
|
/**
|
|
79
380
|
* Compiles the {@link methodGroupShape} into a {@link ContractInterface} for
|
|
80
381
|
* {@link MethodGroup} — a guard, coercing parser, JSON Schema, and seeded
|
|
@@ -87,7 +388,7 @@ export declare function createManifestEntryContract(): ContractInterface<Manifes
|
|
|
87
388
|
* import { createMethodGroupContract } from '@orkestrel/guide'
|
|
88
389
|
*
|
|
89
390
|
* const methodGroup = createMethodGroupContract()
|
|
90
|
-
* methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
|
|
391
|
+
* methodGroup.is({ interface: 'MarkdownInterface', methods: [{ name: 'walk' }] }) // true
|
|
91
392
|
* ```
|
|
92
393
|
*/
|
|
93
394
|
export declare function createMethodGroupContract(): ContractInterface<MethodGroup>;
|
|
@@ -99,19 +400,44 @@ export declare function createMethodGroupContract(): ContractInterface<MethodGro
|
|
|
99
400
|
* @param options - The file inventory and module scope to reflect
|
|
100
401
|
* @returns A `SourceInterface` reflecting the given module scope
|
|
101
402
|
*
|
|
102
|
-
* @example
|
|
403
|
+
* @example Construct a Source from an inline files record
|
|
103
404
|
* ```ts
|
|
104
405
|
* import { createSource } from '@orkestrel/guide'
|
|
105
406
|
*
|
|
106
407
|
* const source = createSource({
|
|
107
|
-
* files: {
|
|
408
|
+
* files: {
|
|
409
|
+
* 'src/core/index.ts': "export * from './Guide.js'\nexport * from './types.js'\n",
|
|
410
|
+
* 'src/core/Guide.ts': 'export class Guide {}\n',
|
|
411
|
+
* 'src/core/types.ts': 'export interface GuideInterface {\n\tsections(): void\n}\n',
|
|
412
|
+
* },
|
|
108
413
|
* module: 'src/core',
|
|
109
414
|
* })
|
|
110
|
-
* source.exports() // [{ name: 'Guide', keyword: 'class' }]
|
|
415
|
+
* source.exports() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
416
|
+
* source.surface() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
417
|
+
* source.methods('GuideInterface') // [{ name: 'sections' }]
|
|
418
|
+
* source.exists('src/core/Guide.ts') // true
|
|
419
|
+
* source.exists('src/core') // true — a directory any inventory key sits beneath
|
|
111
420
|
* ```
|
|
112
421
|
*/
|
|
113
422
|
export declare function createSource(options: SourceOptions): SourceInterface;
|
|
114
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Compiles the {@link sourceExampleShape} into a {@link ContractInterface} for
|
|
426
|
+
* {@link SourceExample} — a guard, coercing parser, JSON Schema, and seeded
|
|
427
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
428
|
+
*
|
|
429
|
+
* @returns A `SourceExample` contract bundling `schema` / `is` / `parse` / `generate`
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* import { createSourceExampleContract } from '@orkestrel/guide'
|
|
434
|
+
*
|
|
435
|
+
* const sourceExample = createSourceExampleContract()
|
|
436
|
+
* sourceExample.is({ name: 'walk', code: 'walk()' }) // true
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
export declare function createSourceExampleContract(): ContractInterface<SourceExample>;
|
|
440
|
+
|
|
115
441
|
/**
|
|
116
442
|
* Creates a {@link SourceManagerInterface} that resolves the consumer's local
|
|
117
443
|
* import specifiers and shares one source view per module.
|
|
@@ -119,15 +445,22 @@ export declare function createSource(options: SourceOptions): SourceInterface;
|
|
|
119
445
|
* @param options - The shared file inventory and specifier-to-module policy
|
|
120
446
|
* @returns A source manager over the supplied policy
|
|
121
447
|
*
|
|
122
|
-
* @example
|
|
448
|
+
* @example Resolve a fence's import specifier to the right Source
|
|
123
449
|
* ```ts
|
|
124
450
|
* import { createSourceManager } from '@orkestrel/guide'
|
|
125
451
|
*
|
|
126
452
|
* const sources = createSourceManager({
|
|
127
|
-
* files: {
|
|
128
|
-
*
|
|
453
|
+
* files: {
|
|
454
|
+
* 'src/core/index.ts': "export * from './Guide.js'\n",
|
|
455
|
+
* 'src/core/Guide.ts': 'export class Guide {}\n',
|
|
456
|
+
* },
|
|
457
|
+
* modules: { '@scope/package': 'src/core', '@scope/package/core': 'src/core' },
|
|
129
458
|
* })
|
|
130
|
-
*
|
|
459
|
+
*
|
|
460
|
+
* sources.source('@scope/package')?.surface() // [{ name: 'Guide', keyword: 'class' }]
|
|
461
|
+
* sources.source('node:fs') // undefined — a foreign import, which a fence check skips
|
|
462
|
+
* sources.source('@scope/package') === sources.source('@scope/package/core') // true
|
|
463
|
+
* sources.sources() // [the one shared view both specifiers name]
|
|
131
464
|
* ```
|
|
132
465
|
*/
|
|
133
466
|
export declare function createSourceManager(options: SourceManagerOptions): SourceManagerInterface;
|
|
@@ -153,7 +486,7 @@ export declare function createSurfaceSymbolContract(): ContractInterface<Surface
|
|
|
153
486
|
* Represents one located `export class` / `export interface` declaration — the body lines
|
|
154
487
|
* and the base identifiers read from the same head, so a consumer never pairs
|
|
155
488
|
* one declaration's body with another declaration's heritage (see
|
|
156
|
-
* {@link
|
|
489
|
+
* {@link collectDeclarations}).
|
|
157
490
|
*/
|
|
158
491
|
export declare interface Declaration {
|
|
159
492
|
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}`. */
|
|
@@ -175,22 +508,69 @@ export declare interface DeclarationHead {
|
|
|
175
508
|
}
|
|
176
509
|
|
|
177
510
|
/**
|
|
178
|
-
* Represents which declaration head {@link
|
|
511
|
+
* Represents which declaration head {@link collectDeclarations} and {@link Source} locate —
|
|
179
512
|
* a `class` or an `interface`. That pair is the subset of {@link ExportKeyword}
|
|
180
513
|
* carrying a body whose members a guide's `## Methods` table documents.
|
|
181
514
|
*/
|
|
182
515
|
export declare type DeclarationKeyword = 'class' | 'interface';
|
|
183
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Represents one disagreement between a guide and the source it documents — the compared key
|
|
519
|
+
* with the text each side carries there, the side carrying no text omitted.
|
|
520
|
+
*/
|
|
521
|
+
export declare interface Drift {
|
|
522
|
+
/** Names whether the disagreement belongs to a summary or a titled example. */
|
|
523
|
+
readonly category: DriftCategory;
|
|
524
|
+
/**
|
|
525
|
+
* Names the compared pair: a {@link computeSymbolKey} symbol key for a `## Surface` row, an
|
|
526
|
+
* `Owner.member` key for a `## Methods` row, or the shared title for an example.
|
|
527
|
+
*/
|
|
528
|
+
readonly key: string;
|
|
529
|
+
/** Holds the guide's text, or is absent when the guide carries none there. */
|
|
530
|
+
readonly guide?: string;
|
|
531
|
+
/** Holds the source's text, or is absent when the source carries none there. */
|
|
532
|
+
readonly source?: string;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Lists the compared sites a {@link Drift} can describe.
|
|
537
|
+
*/
|
|
538
|
+
export declare const DRIFT_CATEGORIES: readonly ("summary" | "example")[];
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Represents the compared site one disagreement came from.
|
|
542
|
+
*/
|
|
543
|
+
export declare type DriftCategory = (typeof DRIFT_CATEGORIES)[number];
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Shapes a {@link Drift} — one disagreement's compared `key` with the optional text each
|
|
547
|
+
* side carries there.
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```ts
|
|
551
|
+
* import { createContract } from '@orkestrel/contract'
|
|
552
|
+
* import { driftShape } from '@orkestrel/guide'
|
|
553
|
+
*
|
|
554
|
+
* const drift = createContract(driftShape)
|
|
555
|
+
* drift.is({ key: 'class Widget', category: 'summary', guide: 'A widget.' }) // true
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
export declare const driftShape: ObjectShape< {
|
|
559
|
+
key: StringShape;
|
|
560
|
+
category: LiteralShape<readonly ("summary" | "example")[]>;
|
|
561
|
+
guide: OptionalShape<StringShape>;
|
|
562
|
+
source: OptionalShape<StringShape>;
|
|
563
|
+
}, false>;
|
|
564
|
+
|
|
184
565
|
/**
|
|
185
566
|
* Escapes every regex metacharacter in a literal string so it reads as text
|
|
186
567
|
* inside a larger `RegExp` source rather than as syntax.
|
|
187
568
|
*
|
|
188
569
|
* @remarks
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* text it does not name. Pure and total; never throws.
|
|
570
|
+
* A caller-supplied name reaches a `RegExp` through this: {@link
|
|
571
|
+
* findUnexampled} splices it into a word-boundary search, so a name carrying
|
|
572
|
+
* `$`, `(`, `[`, or `.` matches that character literally instead of throwing or
|
|
573
|
+
* matching text it does not name. Pure and total; never throws.
|
|
194
574
|
*
|
|
195
575
|
* @param value - The literal string to escape
|
|
196
576
|
* @returns `value` with every regex metacharacter backslash-escaped
|
|
@@ -204,17 +584,16 @@ export declare type DeclarationKeyword = 'class' | 'interface';
|
|
|
204
584
|
export declare function escapeRegExp(value: string): string;
|
|
205
585
|
|
|
206
586
|
/**
|
|
207
|
-
* Lists the declaration keywords a documented or exported symbol carries, in
|
|
208
|
-
*
|
|
587
|
+
* Lists the declaration keywords a documented or exported symbol carries, in the order the
|
|
588
|
+
* reflection grammar names them — the frozen population `ExportKeyword`, `isExportKeyword`, and
|
|
589
|
+
* `surfaceSymbolShape` all derive from.
|
|
209
590
|
*
|
|
210
591
|
* @remarks
|
|
211
|
-
* One frozen list feeds the
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* `enum` is outside this population rather than forbidden by general package
|
|
215
|
-
* policy.
|
|
592
|
+
* One frozen list feeds the type, the guard, and the shape, so a keyword cannot be admitted by one
|
|
593
|
+
* and refused by another. Comment and template payload is excluded before reflection, and `enum`
|
|
594
|
+
* is outside this population rather than forbidden by general package policy.
|
|
216
595
|
*/
|
|
217
|
-
export declare const EXPORT_KEYWORDS: readonly
|
|
596
|
+
export declare const EXPORT_KEYWORDS: readonly ("function" | "type" | "interface" | "const" | "class")[];
|
|
218
597
|
|
|
219
598
|
/**
|
|
220
599
|
* Represents the declaration keyword a documented / exported symbol carries — the reflected
|
|
@@ -233,7 +612,30 @@ export declare type ExportKeyword = (typeof EXPORT_KEYWORDS)[number];
|
|
|
233
612
|
export declare const EXTERNAL_SCHEMES: readonly string[];
|
|
234
613
|
|
|
235
614
|
/**
|
|
236
|
-
* Extracts the
|
|
615
|
+
* Extracts the aligned physical records of a declaration's body, read inside an owner head this
|
|
616
|
+
* function supplies, so a callable member in the body carries the `Owner.member` key
|
|
617
|
+
* {@link collectKeys} reports for it, and that head's own record opens the projection. A body
|
|
618
|
+
* read on its own carries no head, and the member grammar attaches a member to the head
|
|
619
|
+
* enclosing it.
|
|
620
|
+
*
|
|
621
|
+
* @remarks
|
|
622
|
+
* The supplied head is an `export interface` line, so the projection opens with that head's own
|
|
623
|
+
* record and every body line follows it in order. A column-zero `}` among the body lines closes
|
|
624
|
+
* the supplied head and leaves every later member unkeyed; a body {@link extractDeclaration}
|
|
625
|
+
* returns carries none, because that reader ends a body at the first one.
|
|
626
|
+
*
|
|
627
|
+
* @param lines - A declaration's body lines
|
|
628
|
+
* @returns The supplied head's record, then one record per body line
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* ```ts
|
|
632
|
+
* extractBodyLines(['\twalk(): void'])[1]?.code // '\twalk(): void'
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
export declare function extractBodyLines(lines: readonly string[]): readonly SourceLine[];
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Extracts the link hrefs within one table cell's inline content, in walk order.
|
|
237
639
|
*
|
|
238
640
|
* @param cell - The cell's inline nodes
|
|
239
641
|
* @returns The cell's link hrefs, in walk order
|
|
@@ -246,24 +648,35 @@ export declare const EXTERNAL_SCHEMES: readonly string[];
|
|
|
246
648
|
export declare function extractCellLinks(cell: readonly InlineNode[]): readonly string[];
|
|
247
649
|
|
|
248
650
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
651
|
+
* Extracts compared inline content — the text of a table cell or candidate entity heading
|
|
652
|
+
* flattened with every code span kept as a code span, so `` `Widget` `` reads the same wherever
|
|
653
|
+
* the parity reader compares it. Emphasis drops to its text, a link drops to its text, an image
|
|
654
|
+
* drops to its alternative text, and the markdown parser has already unescaped `\|`.
|
|
655
|
+
*
|
|
656
|
+
* @param cell - The inline nodes to flatten
|
|
657
|
+
* @returns The compared text, code spans included
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```ts
|
|
661
|
+
* extractCellText([{ element: 'codeSpan', value: 'Widget' }]) // '`Widget`'
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
export declare function extractCellText(cell: readonly InlineNode[]): string;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Locates the named `export class` / `export interface` declaration in one file's source text
|
|
668
|
+
* and returns its body lines and its base identifiers read from that one head, so a body and a
|
|
669
|
+
* heritage clause always come from the same declaration, or `undefined` when the file declares
|
|
670
|
+
* no such head.
|
|
253
671
|
*
|
|
254
672
|
* @remarks
|
|
255
|
-
* The
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* before its `extends` clause is read, so a `T extends Base` type parameter is
|
|
263
|
-
* never a base and `Base<T>` reads as `Base`; a class's `implements` clause and
|
|
264
|
-
* everything after it is excluded, and a qualified base such as
|
|
265
|
-
* `namespace.Base` is returned verbatim. A head that opens no column-zero close
|
|
266
|
-
* is skipped and the scan continues, so a later real declaration still answers.
|
|
673
|
+
* The one named lookup over {@link collectDeclarations}, which owns the head grammar, the body
|
|
674
|
+
* window, and the base reading. This lookup spells the map's `${keyword} ${name}` key for its
|
|
675
|
+
* caller, so a consumer reading one name never writes that convention itself. `name` is compared
|
|
676
|
+
* as literal text against the identifier the head itself carries, so a metacharacter in `name`
|
|
677
|
+
* names that character rather than matching text it does not name. Every call collects the whole
|
|
678
|
+
* file afresh: a consumer reading many names from one file calls {@link collectDeclarations} once
|
|
679
|
+
* and reads the map, and {@link Source} holds one such map per module scope.
|
|
267
680
|
*
|
|
268
681
|
* @param source - The file's source text to search
|
|
269
682
|
* @param keyword - Whether to look for a `class` or an `interface`
|
|
@@ -280,71 +693,74 @@ export declare function extractDeclaration(source: string, keyword: DeclarationK
|
|
|
280
693
|
|
|
281
694
|
/**
|
|
282
695
|
* Selects the next physical record after an eligible genuine JSDoc whose final
|
|
283
|
-
* authoritative span carries an
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* leading JSDoc on the next record replaces pending state. Any other next
|
|
287
|
-
* physical record is returned once and consumes it. This parser walks aligned
|
|
288
|
-
* records without rescanning source syntax or applying declaration/member
|
|
289
|
-
* grammar.
|
|
696
|
+
* authoritative span carries an `@example` tag opening a line at its first non-blank column —
|
|
697
|
+
* the {@link extractSourceComments} walk filtered to the blocks that carry one. Title
|
|
698
|
+
* text is allowed, and {@link maskFences} keeps a fenced body's own lines out of the search.
|
|
290
699
|
*
|
|
291
700
|
* @param lines - Aligned physical source-line records
|
|
292
701
|
* @returns The immediately following candidate lines, in source order
|
|
293
702
|
*
|
|
294
703
|
* @example
|
|
295
704
|
* ```ts
|
|
296
|
-
* extractExampleLines(extractSourceLines('/** @example *' + '/\nexport function walk() {}'))
|
|
705
|
+
* extractExampleLines(extractSourceLines('/**' + ' @example *' + '/\nexport function walk() {}'))
|
|
297
706
|
* // the `export function walk() {}` SourceLine
|
|
298
707
|
* ```
|
|
299
708
|
*/
|
|
300
709
|
export declare function extractExampleLines(lines: readonly SourceLine[]): readonly SourceLine[];
|
|
301
710
|
|
|
302
711
|
/**
|
|
303
|
-
* Extracts the callable
|
|
304
|
-
* grammar
|
|
305
|
-
* the
|
|
306
|
-
* {@link
|
|
307
|
-
*
|
|
712
|
+
* Extracts the `@example` blocks carried by the callable members of a declaration body (per
|
|
713
|
+
* {@link collectKeys}' grammar, the same one {@link extractMemberMethods} reads), each named for
|
|
714
|
+
* the member its block documents. Shared adjacency comes from {@link extractSourceComments} and
|
|
715
|
+
* each block is read by {@link collectExamples}; member membership is the key
|
|
716
|
+
* {@link extractBodyLines}'s projection gives the documented record.
|
|
308
717
|
*
|
|
309
718
|
* @param lines - A declaration's body lines
|
|
310
|
-
* @returns The
|
|
719
|
+
* @returns The members' `@example` blocks, deduplicated by name and title and sorted by name
|
|
311
720
|
*
|
|
312
721
|
* @example
|
|
313
722
|
* ```ts
|
|
314
|
-
* extractExampleMethods(['\t/**', '\t * @example', '\t *' + '/', '\twalk(): void'])
|
|
723
|
+
* extractExampleMethods(['\t/**', '\t * @example', '\t * walk()', '\t *' + '/', '\twalk(): void'])
|
|
724
|
+
* // [{ name: 'walk', code: 'walk()' }]
|
|
315
725
|
* ```
|
|
316
726
|
*/
|
|
317
|
-
export declare function extractExampleMethods(lines: readonly string[]): readonly
|
|
727
|
+
export declare function extractExampleMethods(lines: readonly string[]): readonly SourceExample[];
|
|
318
728
|
|
|
319
729
|
/**
|
|
320
|
-
* Extracts the exported
|
|
321
|
-
*
|
|
322
|
-
* {@link
|
|
323
|
-
* the
|
|
730
|
+
* Extracts the `@example` blocks carried by the exported declaration heads in one file's source
|
|
731
|
+
* text, each named for the declaration its block documents. Shared adjacency comes from
|
|
732
|
+
* {@link extractSourceComments} and each block is read by {@link collectExamples}; head
|
|
733
|
+
* membership is the {@link collectKeys} key of the documented record under every keyword that
|
|
734
|
+
* grammar admits at column zero, so comment and template payload cannot qualify and the head
|
|
735
|
+
* grammar stays the one every reader here shares. A member key carries a dot and a head key
|
|
736
|
+
* does not, so a member's block belongs to {@link extractExampleMethods} instead. A head
|
|
737
|
+
* carrying several blocks contributes each.
|
|
324
738
|
*
|
|
325
739
|
* @param source - The file's source text
|
|
326
|
-
* @returns The exported
|
|
740
|
+
* @returns The exported declaration heads' `@example` blocks, in file order, deduplicated by name and title
|
|
327
741
|
*
|
|
328
742
|
* @example
|
|
329
743
|
* ```ts
|
|
330
|
-
* const block = ['/**', ' * @example', ' *' + '/', 'export
|
|
331
|
-
* extractExamples(block) // ['
|
|
332
|
-
* extractExamples('export
|
|
744
|
+
* const block = ['/**', ' * @example', ' * new Widget()', ' *' + '/', 'export class Widget {}', ''].join('\n')
|
|
745
|
+
* extractExamples(block) // [{ name: 'Widget', code: 'new Widget()' }]
|
|
746
|
+
* extractExamples('export class Widget {}\n') // []
|
|
333
747
|
* ```
|
|
334
748
|
*/
|
|
335
|
-
export declare function extractExamples(source: string): readonly
|
|
749
|
+
export declare function extractExamples(source: string): readonly SourceExample[];
|
|
336
750
|
|
|
337
751
|
/**
|
|
338
|
-
* Extracts the module-scope exports declared in one file's source text —
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
752
|
+
* Extracts the module-scope exports declared in one file's source text — the declaration keys
|
|
753
|
+
* {@link collectKeys} reports, each split back into the keyword and name that built it, deduped by
|
|
754
|
+
* (keyword, name).
|
|
755
|
+
*
|
|
756
|
+
* @remarks
|
|
757
|
+
* That one grammar matches `export (async)? (function(\*)?|class|const|interface|type) Name`; a
|
|
758
|
+
* generator export (`export function* walk`) keys as the `function` keyword, its trailing `*`
|
|
759
|
+
* stripped before the {@link ExportKeyword} check. Scanning uses {@link extractSourceLines}, so
|
|
760
|
+
* comment and template payload is excluded while its uninterrupted column-zero head remains
|
|
761
|
+
* required; preserved columns do not grant membership to leading/interrupted comment forms. The
|
|
762
|
+
* population is exactly `type`, `interface`, `const`, `function`, and `class`; `enum` is outside
|
|
763
|
+
* this reflection contract, not forbidden by general package policy.
|
|
348
764
|
*
|
|
349
765
|
* @param source - The file's source text
|
|
350
766
|
* @returns The file's exported symbols, in file order
|
|
@@ -358,10 +774,11 @@ export declare function extractExamples(source: string): readonly string[];
|
|
|
358
774
|
export declare function extractExports(source: string): readonly SurfaceSymbol[];
|
|
359
775
|
|
|
360
776
|
/**
|
|
361
|
-
* Parses a fence's `import` statements into per-specifier imported identifier
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
777
|
+
* Parses a fence's brace `import` statements into per-specifier imported identifier names —
|
|
778
|
+
* `import type`, mixed multiline braces, and `x as y` aliases all count, each alias resolved to
|
|
779
|
+
* the exported name `x` because that is the name the checked barrel surface must hold. Brace
|
|
780
|
+
* bindings only: a default, namespace, side-effect, or mixed `import Default, { named }`
|
|
781
|
+
* statement is not surfaced.
|
|
365
782
|
*
|
|
366
783
|
* @param fence - A ```ts Patterns fence's verbatim body text
|
|
367
784
|
* @returns One entry per `import ... from 'specifier'` statement, in fence order
|
|
@@ -375,10 +792,13 @@ export declare function extractFenceImports(fence: string): readonly FenceImport
|
|
|
375
792
|
|
|
376
793
|
/**
|
|
377
794
|
* Extracts every fenced code block anywhere in the guide document. A full AST walk
|
|
378
|
-
* includes fences nested inside blockquotes and lists
|
|
795
|
+
* includes fences nested inside blockquotes and lists, and the same walk carries each
|
|
796
|
+
* fence's nearest preceding heading as its `title` — the key an `@example` block pairs on.
|
|
797
|
+
* A heading's text is flattened, so a title written with a code span pairs with a plain
|
|
798
|
+
* `@example` title.
|
|
379
799
|
*
|
|
380
800
|
* @param document - The parsed guide document
|
|
381
|
-
* @returns Every fence's language
|
|
801
|
+
* @returns Every fence's language, verbatim code, and title, in document order
|
|
382
802
|
*
|
|
383
803
|
* @example
|
|
384
804
|
* ```ts
|
|
@@ -388,16 +808,17 @@ export declare function extractFenceImports(fence: string): readonly FenceImport
|
|
|
388
808
|
export declare function extractFences(document: MarkdownDocument): readonly GuideFence[];
|
|
389
809
|
|
|
390
810
|
/**
|
|
391
|
-
* Extracts the module-scope declarations lacking the `export` keyword in one file's
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* and
|
|
399
|
-
*
|
|
400
|
-
*
|
|
811
|
+
* Extracts the module-scope declarations lacking the `export` keyword in one file's source text —
|
|
812
|
+
* the mirror image of {@link extractExports}'s grammar, anchored the same way (column 0, so an
|
|
813
|
+
* indented inner declaration never matches).
|
|
814
|
+
*
|
|
815
|
+
* @remarks
|
|
816
|
+
* Scans only the {@link ExportKeyword} keywords (`function` / `class` / `const` / `interface` /
|
|
817
|
+
* `type`) — a module-scope `let` or `var` is outside this scanner's declaration-keyword grammar
|
|
818
|
+
* and out of this check's contract. Scanning uses {@link extractSourceLines}, so comment and
|
|
819
|
+
* template payload is excluded while its uninterrupted column-zero head remains required;
|
|
820
|
+
* preserved columns do not widen membership. `enum` is likewise outside this reflection
|
|
821
|
+
* population, not forbidden by general package policy.
|
|
401
822
|
*
|
|
402
823
|
* @param source - The file's source text
|
|
403
824
|
* @returns The file's hidden (non-exported) symbols, in file order
|
|
@@ -428,34 +849,112 @@ export declare function extractLinks(document: MarkdownDocument): readonly strin
|
|
|
428
849
|
* Selects the member lines declaring a callable member: plain, `async`, generator
|
|
429
850
|
* (`*`), and optional (`records?(`) methods all count; getters, setters,
|
|
430
851
|
* `static` members, and `#` privates never do (their keyword or `#` breaks
|
|
431
|
-
* the `name(` shape).
|
|
432
|
-
* method-like payload never
|
|
852
|
+
* the `name(` shape). The grammar is {@link collectKeys}'s, read once over
|
|
853
|
+
* {@link extractBodyLines}'s projection of the body, so commented method-like payload never
|
|
854
|
+
* becomes eligible and each member keys to the owner head that projection supplies. Each member
|
|
855
|
+
* carries its own doc block's description paragraph, read through {@link collectSummaries}; the
|
|
856
|
+
* first declaration of a name answers for it.
|
|
433
857
|
*
|
|
434
858
|
* @param lines - A declaration's body lines
|
|
435
|
-
* @returns The declared
|
|
859
|
+
* @returns The declared members, deduplicated by name and sorted by name
|
|
436
860
|
*
|
|
437
861
|
* @example
|
|
438
862
|
* ```ts
|
|
439
|
-
* extractMemberMethods(['\tmap(): void', '\tfilter(): void']) // ['filter', 'map']
|
|
863
|
+
* extractMemberMethods(['\tmap(): void', '\tfilter(): void']) // [{ name: 'filter' }, { name: 'map' }]
|
|
440
864
|
* ```
|
|
441
865
|
*/
|
|
442
|
-
export declare function extractMemberMethods(lines: readonly string[]): readonly
|
|
866
|
+
export declare function extractMemberMethods(lines: readonly string[]): readonly MethodEntry[];
|
|
443
867
|
|
|
444
868
|
/**
|
|
445
869
|
* Extracts one {@link MethodGroup} per documented behavioral interface in `## Methods` —
|
|
446
870
|
* an H4 with a code span sets the current interface, and the table immediately
|
|
447
|
-
* following becomes its documented methods.
|
|
871
|
+
* following becomes its documented methods. A row with no code-span name has no name to key a
|
|
872
|
+
* member on, so this reader skips it and {@link extractUnnamed} reports it. Each row carries its
|
|
873
|
+
* {@link SUMMARY} column's compared text when the table has that column.
|
|
448
874
|
*
|
|
449
875
|
* @param document - The parsed guide document
|
|
450
876
|
* @returns The documented method groups, in document order
|
|
451
877
|
*
|
|
452
878
|
* @example
|
|
453
879
|
* ```ts
|
|
454
|
-
* extractMethods(document) // [{ interface: 'MarkdownInterface', methods: ['walk'
|
|
880
|
+
* extractMethods(document) // [{ interface: 'MarkdownInterface', methods: [{ name: 'walk' }] }]
|
|
455
881
|
* ```
|
|
456
882
|
*/
|
|
457
883
|
export declare function extractMethods(document: MarkdownDocument): readonly MethodGroup[];
|
|
458
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Extracts one `## Methods` table row's entry — its column 0 code span as the name and its
|
|
887
|
+
* {@link SUMMARY} column as the compared summary when the table has that column. A row with no
|
|
888
|
+
* code-span name has no member to key, so it returns `undefined`.
|
|
889
|
+
*
|
|
890
|
+
* @param table - The table to read
|
|
891
|
+
* @param row - The index of the row within {@link TableNode.rows}
|
|
892
|
+
* @returns The row's entry, or `undefined` when the row keys none
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```ts
|
|
896
|
+
* extractRowEntry(table, 0) // { name: 'walk', summary: 'Walks the tree.' }
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
export declare function extractRowEntry(table: TableNode, row: number): MethodEntry | undefined;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Extracts one row's compared summary — its {@link SUMMARY} column read through
|
|
903
|
+
* {@link extractCellText} and {@link normalizeSummary}. A table with no such column and a row
|
|
904
|
+
* whose cell is empty each carry no summary and return `undefined` rather than an empty string,
|
|
905
|
+
* so {@link findDrift} reports the absence.
|
|
906
|
+
*
|
|
907
|
+
* @param table - The table to read
|
|
908
|
+
* @param row - The index of the row within {@link TableNode.rows}
|
|
909
|
+
* @returns The row's compared summary, or `undefined` when it carries none
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```ts
|
|
913
|
+
* extractRowSummary(table, 0) // 'Walks the tree.'
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
export declare function extractRowSummary(table: TableNode, row: number): string | undefined;
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Extracts one `## Surface` table row's symbol — its column 0 code span as the name, its
|
|
920
|
+
* {@link KIND} column as the keyword, and its {@link SUMMARY} column as the compared summary
|
|
921
|
+
* when the table has that column. A row with no code-span name and a row whose `Kind` text is
|
|
922
|
+
* no {@link ExportKeyword} have no symbol to key, so each returns `undefined`.
|
|
923
|
+
*
|
|
924
|
+
* @param table - The table to read
|
|
925
|
+
* @param row - The index of the row within {@link TableNode.rows}
|
|
926
|
+
* @returns The row's symbol, or `undefined` when the row keys none
|
|
927
|
+
*
|
|
928
|
+
* @example
|
|
929
|
+
* ```ts
|
|
930
|
+
* extractRowSymbol(table, 0) // { name: 'walk', keyword: 'function', summary: 'Walks the tree.' }
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
export declare function extractRowSymbol(table: TableNode, row: number): SurfaceSymbol | undefined;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Extracts every eligible genuine JSDoc block paired with the physical record it documents.
|
|
937
|
+
*
|
|
938
|
+
* @remarks
|
|
939
|
+
* An opener is eligible only when it is the first non-whitespace source material of its record; a
|
|
940
|
+
* leading whitespace-separated span chain is last-span authoritative; intervening source material
|
|
941
|
+
* severs association, while a leading JSDoc on the next record replaces pending state. Any other
|
|
942
|
+
* next physical record is returned once and consumes it. This parser walks aligned records without
|
|
943
|
+
* rescanning source syntax or applying declaration/member grammar, and every reader of a doc
|
|
944
|
+
* block's text — the description paragraph, the `@example` blocks, the member summaries — reads it
|
|
945
|
+
* through this one walk.
|
|
946
|
+
*
|
|
947
|
+
* @param lines - Aligned physical source-line records
|
|
948
|
+
* @returns One record per documented physical line, in source order
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```ts
|
|
952
|
+
* extractSourceComments(extractSourceLines('/**' + ' Walks. *' + '/\nexport function walk() {}'))
|
|
953
|
+
* // [{ text: 'Walks.', line: the `export function walk() {}` SourceLine }]
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
export declare function extractSourceComments(lines: readonly SourceLine[]): readonly SourceComment[];
|
|
957
|
+
|
|
459
958
|
/**
|
|
460
959
|
* Extracts aligned physical source-line records in one character traversal.
|
|
461
960
|
* Real line and block comments and complete template tokens become spaces in
|
|
@@ -478,20 +977,34 @@ export declare function extractMethods(document: MarkdownDocument): readonly Met
|
|
|
478
977
|
* @param source - The TypeScript source text to project
|
|
479
978
|
* @returns One aligned terminator-free record per LF or CRLF physical line, including the final line
|
|
480
979
|
*
|
|
481
|
-
* @example
|
|
980
|
+
* @example Project source into physical code lines
|
|
482
981
|
* ```ts
|
|
982
|
+
* import { extractSourceLines } from '@orkestrel/guide'
|
|
983
|
+
*
|
|
483
984
|
* extractSourceLines('export const visible = true // note\n')
|
|
484
|
-
* // [{ source: 'export const visible = true // note', code: 'export const visible = true ', jsdoc: undefined }
|
|
985
|
+
* // [{ source: 'export const visible = true // note', code: 'export const visible = true ', jsdoc: undefined }]
|
|
986
|
+
* // … one record per remaining line
|
|
485
987
|
* ```
|
|
486
988
|
*/
|
|
487
989
|
export declare function extractSourceLines(source: string): readonly SourceLine[];
|
|
488
990
|
|
|
489
991
|
/**
|
|
490
992
|
* Extracts every `## Surface` identifier the guide documents — each table row's column 0
|
|
491
|
-
* code span (the name) paired with its `Kind` column (located by header text)
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
993
|
+
* code span (the name) paired with its `Kind` column (located by header text), unioned with every
|
|
994
|
+
* H3 entity heading whose trimmed compared inline content is exactly its backticked code-span
|
|
995
|
+
* name, deduped by {@link computeSymbolKey}. A row with no code-span name has no name to key a
|
|
996
|
+
* symbol on, so this reader skips it and {@link extractUnnamed} reports it; a row with an
|
|
997
|
+
* unrecognized `Kind` text is skipped. A row also carries its {@link SUMMARY} column's compared
|
|
998
|
+
* text when the table has that column; a table without it leaves every row's summary absent,
|
|
999
|
+
* which {@link findDrift} reports.
|
|
1000
|
+
*
|
|
1001
|
+
* @remarks
|
|
1002
|
+
* The heading boundary compares {@link extractCellText} with the raw value from
|
|
1003
|
+
* {@link findFirstCode} before {@link normalizeIdentifier} strips a generic annotation.
|
|
1004
|
+
* Surrounding spaces, emphasis, and links preserve that identity. This reader refuses a heading
|
|
1005
|
+
* carrying any other visible text or an additional code span. Entries retain encounter order, and
|
|
1006
|
+
* the first-seen name + keyword wins: a genuine heading before its table row keeps the heading's
|
|
1007
|
+
* summary-less class entry, while a table row before that heading keeps its `Summary`.
|
|
495
1008
|
*
|
|
496
1009
|
* @param document - The parsed guide document
|
|
497
1010
|
* @returns The documented surface, in encounter order
|
|
@@ -503,6 +1016,21 @@ export declare function extractSourceLines(source: string): readonly SourceLine[
|
|
|
503
1016
|
*/
|
|
504
1017
|
export declare function extractSurface(document: MarkdownDocument): readonly SurfaceSymbol[];
|
|
505
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* Extracts the guide's tagline — the text of the blockquote following the document's H1,
|
|
1021
|
+
* with every code span kept as a code span and whitespace collapsed. A heading before the
|
|
1022
|
+
* blockquote ends the window, so a blockquote elsewhere in the document is not the tagline.
|
|
1023
|
+
*
|
|
1024
|
+
* @param document - The parsed guide document
|
|
1025
|
+
* @returns The tagline, or `undefined` when no blockquote follows an H1 before the next heading
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```ts
|
|
1029
|
+
* extractTagline(document) // 'A pure, I/O-free guides-parity toolkit'
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
export declare function extractTagline(document: MarkdownDocument): string | undefined;
|
|
1033
|
+
|
|
506
1034
|
/**
|
|
507
1035
|
* Extracts the relative test links declared under `## Tests` — every link href found
|
|
508
1036
|
* within that section only.
|
|
@@ -517,6 +1045,24 @@ export declare function extractSurface(document: MarkdownDocument): readonly Sur
|
|
|
517
1045
|
*/
|
|
518
1046
|
export declare function extractTests(document: MarkdownDocument): readonly string[];
|
|
519
1047
|
|
|
1048
|
+
/**
|
|
1049
|
+
* Extracts every `## Surface` or `## Methods` table row whose first cell carries no code span.
|
|
1050
|
+
* {@link extractSurface} and {@link extractMethods} skip such a row, because a row with no
|
|
1051
|
+
* name gives them nothing to key a symbol or a member on, and this projection is what reports
|
|
1052
|
+
* the skip. Each entry is the row's cells read through {@link extractCellText} and joined
|
|
1053
|
+
* by ` | `, so a reader can locate the row in the guide; the `## Surface` rows come first,
|
|
1054
|
+
* then the `## Methods` rows, each in document order. {@link GuideInterface.unnamed} caches it.
|
|
1055
|
+
*
|
|
1056
|
+
* @param document - The parsed guide document
|
|
1057
|
+
* @returns One entry per row carrying no code-span name
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```ts
|
|
1061
|
+
* extractUnnamed(document) // ['Widget | class | Represents a widget.']
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
export declare function extractUnnamed(document: MarkdownDocument): readonly string[];
|
|
1065
|
+
|
|
520
1066
|
/**
|
|
521
1067
|
* Represents one brace `import` statement projected from a guide fence — its specifier
|
|
522
1068
|
* paired with the exported names it binds.
|
|
@@ -529,34 +1075,64 @@ export declare interface FenceImport {
|
|
|
529
1075
|
}
|
|
530
1076
|
|
|
531
1077
|
/**
|
|
532
|
-
* Finds the
|
|
533
|
-
*
|
|
534
|
-
*
|
|
1078
|
+
* Finds the index of the column whose header text is `header` so a table's columns survive
|
|
1079
|
+
* reordering. The match is exact and case-sensitive — a table without that exact header
|
|
1080
|
+
* contributes nothing to the projection reading it, so a `## Surface` table with no
|
|
1081
|
+
* {@link SUMMARY} column leaves every row's summary absent and {@link findDrift} reports each
|
|
1082
|
+
* of those rows, never agreement.
|
|
535
1083
|
*
|
|
536
|
-
* @param
|
|
537
|
-
* @
|
|
1084
|
+
* @param table - The table to inspect
|
|
1085
|
+
* @param header - The exact header text to locate, for example `Kind`
|
|
1086
|
+
* @returns The column's index, or `undefined` when the table has no such header
|
|
538
1087
|
*
|
|
539
1088
|
* @example
|
|
540
1089
|
* ```ts
|
|
541
|
-
*
|
|
1090
|
+
* findColumnIndex(table, 'Kind') // 1, or undefined
|
|
542
1091
|
* ```
|
|
543
1092
|
*/
|
|
544
|
-
export declare function
|
|
1093
|
+
export declare function findColumnIndex(table: TableNode, header: string): number | undefined;
|
|
545
1094
|
|
|
546
1095
|
/**
|
|
547
|
-
* Finds
|
|
548
|
-
*
|
|
549
|
-
*
|
|
1096
|
+
* Finds every disagreement between a guide and the source it documents, naming both sites:
|
|
1097
|
+
* each `## Surface` row against its declaration's description paragraph, each `## Methods`
|
|
1098
|
+
* row against its member's, and the first titled guide fence of a heading against the
|
|
1099
|
+
* `@example` block of the same title. An example's compared text is its language on the first
|
|
1100
|
+
* line and its body beneath, so a fence that names another language drifts on its own.
|
|
550
1101
|
*
|
|
551
|
-
* @
|
|
552
|
-
*
|
|
1102
|
+
* @remarks
|
|
1103
|
+
* Only a pair present on both sides is compared, so a symbol, a member, or a title one side
|
|
1104
|
+
* lacks entirely is left to the bijection checks that own it and is never reported twice.
|
|
1105
|
+
* {@link computeDrift} rules each compared pair, so a pair whose sides carry different text, a
|
|
1106
|
+
* pair where one side carries none, and a pair where neither side carries text are all drift.
|
|
1107
|
+
* The pairing is per title across the whole document, not per heading: the first fence a title
|
|
1108
|
+
* reaches is the compared one, and every later fence of that title is outside the comparison,
|
|
1109
|
+
* whether it sits under the same heading or under a second heading of the same text.
|
|
1110
|
+
*
|
|
1111
|
+
* @param guide - The parsed guide
|
|
1112
|
+
* @param source - The reflected source the guide documents
|
|
1113
|
+
* @returns One entry per disagreement: Surface rows, then Methods rows, then examples
|
|
553
1114
|
*
|
|
554
1115
|
* @example
|
|
555
1116
|
* ```ts
|
|
556
|
-
*
|
|
1117
|
+
* findDrift(guide, source) // [{ key: 'function walk', category: 'summary', guide: 'Walks.', source: 'Walks a tree.' }]
|
|
557
1118
|
* ```
|
|
558
1119
|
*/
|
|
559
|
-
export declare function
|
|
1120
|
+
export declare function findDrift(guide: GuideInterface, source: SourceInterface): readonly Drift[];
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Finds the first code-span value by descending an inline node list, following
|
|
1124
|
+
* into `emphasis` / `link` / `image` children — the extraction rule behind a
|
|
1125
|
+
* Surface or Methods table row's first-column identifier.
|
|
1126
|
+
*
|
|
1127
|
+
* @param nodes - The inline nodes to search
|
|
1128
|
+
* @returns The first code span's literal text, or `undefined` when none is found
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```ts
|
|
1132
|
+
* findFirstCode([{ element: 'codeSpan', value: 'Markdown' }]) // 'Markdown'
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
export declare function findFirstCode(nodes: readonly InlineNode[]): string | undefined;
|
|
560
1136
|
|
|
561
1137
|
/**
|
|
562
1138
|
* Finds the names present in `names` but absent from `source` — the set-difference
|
|
@@ -623,10 +1199,42 @@ export declare function findUnexampled(names: readonly string[], fences: readonl
|
|
|
623
1199
|
*/
|
|
624
1200
|
export declare function findUnlisted(fences: readonly GuideFence[], languages: readonly string[]): readonly GuideFence[];
|
|
625
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Formats a categorized drift with its guide and source sides.
|
|
1204
|
+
*
|
|
1205
|
+
* @param drift - The categorized disagreement to format
|
|
1206
|
+
* @returns The complete developer-facing drift text
|
|
1207
|
+
*
|
|
1208
|
+
* @example Format categorized drift
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* import { formatDrift } from '@orkestrel/guide'
|
|
1211
|
+
*
|
|
1212
|
+
* formatDrift({ category: 'summary', key: 'function walk', guide: 'Walks.', source: 'Walks a tree.' })
|
|
1213
|
+
* // 'summary function walk: guide "Walks." source "Walks a tree."'
|
|
1214
|
+
* ```
|
|
1215
|
+
*/
|
|
1216
|
+
export declare function formatDrift(drift: Drift): string;
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Formats present parity text as a JSON string and absent text as `absent`.
|
|
1220
|
+
*
|
|
1221
|
+
* @param value - The compared side's text, or `undefined` when absent
|
|
1222
|
+
* @returns The developer-facing side text
|
|
1223
|
+
*
|
|
1224
|
+
* @example Format a parity side
|
|
1225
|
+
* ```ts
|
|
1226
|
+
* import { formatSide } from '@orkestrel/guide'
|
|
1227
|
+
*
|
|
1228
|
+
* formatSide('Walks.') // '"Walks."'
|
|
1229
|
+
* formatSide(undefined) // 'absent'
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
export declare function formatSide(value: string | undefined): string;
|
|
1233
|
+
|
|
626
1234
|
/**
|
|
627
1235
|
* Presents a pure, structured view over one parsed guide — the documented
|
|
628
|
-
* projections (`sections` / `surface` / `methods` / `
|
|
629
|
-
* `fences`) are extracted once at construction and cached.
|
|
1236
|
+
* projections (`sections` / `tagline` / `surface` / `methods` / `unnamed` / `links` /
|
|
1237
|
+
* `tests` / `fences`) are extracted once at construction and cached.
|
|
630
1238
|
*
|
|
631
1239
|
* @remarks
|
|
632
1240
|
* Parses `source` once through `@orkestrel/markdown` and never touches the
|
|
@@ -646,19 +1254,30 @@ export declare class Guide implements GuideInterface {
|
|
|
646
1254
|
#private;
|
|
647
1255
|
constructor(source: string);
|
|
648
1256
|
sections(): readonly string[];
|
|
1257
|
+
tagline(): string | undefined;
|
|
649
1258
|
surface(): readonly SurfaceSymbol[];
|
|
650
1259
|
methods(): readonly MethodGroup[];
|
|
1260
|
+
unnamed(): readonly string[];
|
|
651
1261
|
links(): readonly string[];
|
|
652
1262
|
tests(): readonly string[];
|
|
653
1263
|
fences(): readonly GuideFence[];
|
|
654
1264
|
}
|
|
655
1265
|
|
|
656
|
-
/**
|
|
1266
|
+
/**
|
|
1267
|
+
* Represents one fenced code block projected from a guide document — its `language` is the
|
|
1268
|
+
* fence's info-string tag and is absent when the fence is untagged, and its `title` is the
|
|
1269
|
+
* flattened text of its nearest preceding heading.
|
|
1270
|
+
*/
|
|
657
1271
|
export declare interface GuideFence {
|
|
658
1272
|
/** Holds the info-string language tag, or `undefined` when the fence is untagged. */
|
|
659
1273
|
readonly language: string | undefined;
|
|
660
1274
|
/** Holds the fence's verbatim code body. */
|
|
661
1275
|
readonly code: string;
|
|
1276
|
+
/**
|
|
1277
|
+
* Holds the flattened text of the fence's nearest preceding heading, which pairs the fence
|
|
1278
|
+
* with the `@example` block carrying that title; absent when no heading precedes it.
|
|
1279
|
+
*/
|
|
1280
|
+
readonly title?: string;
|
|
662
1281
|
}
|
|
663
1282
|
|
|
664
1283
|
/**
|
|
@@ -674,17 +1293,55 @@ export declare interface GuideInterface {
|
|
|
674
1293
|
*/
|
|
675
1294
|
sections(): readonly string[];
|
|
676
1295
|
/**
|
|
677
|
-
*
|
|
1296
|
+
* Returns the text of the blockquote following the document's H1 — the guide's tagline, or
|
|
1297
|
+
* `undefined` when a heading intervenes first.
|
|
1298
|
+
*
|
|
1299
|
+
* @returns The tagline, or `undefined` when no blockquote follows an H1 before the next heading
|
|
1300
|
+
*
|
|
1301
|
+
* @example Read a guide's tagline
|
|
1302
|
+
* ```ts
|
|
1303
|
+
* import { createGuide } from '@orkestrel/guide'
|
|
1304
|
+
*
|
|
1305
|
+
* const guide = createGuide('# Widget\n\n> A widget toolkit.\n\n## Surface\n')
|
|
1306
|
+
* guide.tagline() // 'A widget toolkit.'
|
|
1307
|
+
* ```
|
|
1308
|
+
*/
|
|
1309
|
+
tagline(): string | undefined;
|
|
1310
|
+
/**
|
|
1311
|
+
* Lists every `## Surface` identifier + keyword — table rows union H3 entity headings whose
|
|
1312
|
+
* trimmed compared inline content is exactly their backticked code-span name. Each row carries
|
|
1313
|
+
* its `Summary` cell, located by header text, when the table has that column.
|
|
1314
|
+
*
|
|
1315
|
+
* @remarks
|
|
1316
|
+
* Entries retain encounter order, and the first-seen name + keyword wins. A genuine entity
|
|
1317
|
+
* heading before its matching class row keeps the heading's summary-less entry; a table row
|
|
1318
|
+
* before that heading keeps its `Summary`.
|
|
678
1319
|
*
|
|
679
1320
|
* @returns The documented surface symbols, in encounter order
|
|
680
1321
|
*/
|
|
681
1322
|
surface(): readonly SurfaceSymbol[];
|
|
682
1323
|
/**
|
|
683
|
-
* Returns one {@link MethodGroup} per documented behavioral interface in `## Methods
|
|
1324
|
+
* Returns one {@link MethodGroup} per documented behavioral interface in `## Methods`, each
|
|
1325
|
+
* row carrying its `Summary` cell.
|
|
684
1326
|
*
|
|
685
1327
|
* @returns One group per documented behavioral interface, in document order
|
|
686
1328
|
*/
|
|
687
1329
|
methods(): readonly MethodGroup[];
|
|
1330
|
+
/**
|
|
1331
|
+
* Lists every `## Surface` or `## Methods` row whose first cell carries no code span — the
|
|
1332
|
+
* rows {@link surface} and {@link methods} skip for want of a name, each entry being the
|
|
1333
|
+
* row's cells joined by ` | `. Such a row reaches neither projection, so no bijection check
|
|
1334
|
+
* can report it and this one names it instead. The `## Surface` rows come first, then the
|
|
1335
|
+
* `## Methods` rows, each in document order.
|
|
1336
|
+
*
|
|
1337
|
+
* @returns One entry per row carrying no code-span name, in document order
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```ts
|
|
1341
|
+
* guide.unnamed() // ['Widget | class | Represents a widget.']
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
unnamed(): readonly string[];
|
|
688
1345
|
/**
|
|
689
1346
|
* Lists every link href in the guide, including table cells.
|
|
690
1347
|
*
|
|
@@ -708,10 +1365,11 @@ export declare interface GuideInterface {
|
|
|
708
1365
|
*/
|
|
709
1366
|
tests(): readonly string[];
|
|
710
1367
|
/**
|
|
711
|
-
* Lists every fenced code block in the whole document,
|
|
712
|
-
* language filter, so a consumer decides which
|
|
1368
|
+
* Lists every fenced code block in the whole document, tagged or not, each carrying its
|
|
1369
|
+
* nearest preceding heading as `title` — no language filter, so a consumer decides which
|
|
1370
|
+
* languages its checks read.
|
|
713
1371
|
*
|
|
714
|
-
* @returns Every fence's language
|
|
1372
|
+
* @returns Every fence's language, verbatim code, and nearest preceding heading title, in document order
|
|
715
1373
|
*
|
|
716
1374
|
* @example
|
|
717
1375
|
* ```ts
|
|
@@ -746,6 +1404,41 @@ export declare type GuideModule = string | readonly string[];
|
|
|
746
1404
|
*/
|
|
747
1405
|
export declare function hasCanonicalSegments(key: string): boolean;
|
|
748
1406
|
|
|
1407
|
+
/**
|
|
1408
|
+
* Computes a category-separated identity for a guide finding.
|
|
1409
|
+
*
|
|
1410
|
+
* @param spec - The guide inventory key the drift belongs to
|
|
1411
|
+
* @param drift - The categorized disagreement
|
|
1412
|
+
* @returns The inventory key, category, and compared key separated by line feeds
|
|
1413
|
+
*
|
|
1414
|
+
* @example Identify categorized drift
|
|
1415
|
+
* ```ts
|
|
1416
|
+
* import { identifyDrift } from '@orkestrel/guide'
|
|
1417
|
+
*
|
|
1418
|
+
* identifyDrift('guides/widget.md', { category: 'summary', key: 'function open' })
|
|
1419
|
+
* // 'guides/widget.md\nsummary\nfunction open'
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
export declare function identifyDrift(spec: string, drift: Drift): string;
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* Checks whether `value` is a well-formed {@link Drift} — a compared `key` with an optional
|
|
1426
|
+
* `guide` and `source` text.
|
|
1427
|
+
*
|
|
1428
|
+
* @param value - The value to test
|
|
1429
|
+
* @returns True if `value` is a well-formed {@link Drift}; false otherwise
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* isDrift({ key: 'class Widget', category: 'summary', guide: 'A widget.' }) // true
|
|
1434
|
+
* isDrift({ guide: 'A widget.' }) // false
|
|
1435
|
+
* ```
|
|
1436
|
+
*/
|
|
1437
|
+
export declare const isDrift: Guard<Drift>;
|
|
1438
|
+
|
|
1439
|
+
/** Checks whether `value` names a supported drift category. */
|
|
1440
|
+
export declare const isDriftCategory: Guard<DriftCategory>;
|
|
1441
|
+
|
|
749
1442
|
/**
|
|
750
1443
|
* Checks whether `value` is one of the documented {@link ExportKeyword}
|
|
751
1444
|
* literals — the guard behind extracting a Surface table's `Kind` cell into a
|
|
@@ -783,34 +1476,64 @@ export declare function isExternalLink(href: string): boolean;
|
|
|
783
1476
|
* or several.
|
|
784
1477
|
*
|
|
785
1478
|
* @param value - The value to test
|
|
786
|
-
* @returns True if `value` is a well-formed {@link ManifestEntry}; false otherwise
|
|
1479
|
+
* @returns True if `value` is a well-formed {@link ManifestEntry}; false otherwise
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```ts
|
|
1483
|
+
* isManifestEntry({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
|
|
1484
|
+
* isManifestEntry({ concept: 1 }) // false
|
|
1485
|
+
* ```
|
|
1486
|
+
*/
|
|
1487
|
+
export declare const isManifestEntry: Guard<ManifestEntry>;
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Checks whether `value` is a well-formed {@link MethodEntry} — a `name` string with an
|
|
1491
|
+
* optional `summary`.
|
|
1492
|
+
*
|
|
1493
|
+
* @param value - The value to test
|
|
1494
|
+
* @returns True if `value` is a well-formed {@link MethodEntry}; false otherwise
|
|
787
1495
|
*
|
|
788
1496
|
* @example
|
|
789
1497
|
* ```ts
|
|
790
|
-
*
|
|
791
|
-
*
|
|
1498
|
+
* isMethodEntry({ name: 'walk' }) // true
|
|
1499
|
+
* isMethodEntry({ name: 1 }) // false
|
|
792
1500
|
* ```
|
|
793
1501
|
*/
|
|
794
|
-
export declare const
|
|
1502
|
+
export declare const isMethodEntry: Guard<MethodEntry>;
|
|
795
1503
|
|
|
796
1504
|
/**
|
|
797
1505
|
* Checks whether `value` is a well-formed {@link MethodGroup} — a backticked
|
|
798
|
-
* `interface` name paired with its documented
|
|
1506
|
+
* `interface` name paired with its documented {@link MethodEntry} rows.
|
|
799
1507
|
*
|
|
800
1508
|
* @param value - The value to test
|
|
801
1509
|
* @returns True if `value` is a well-formed {@link MethodGroup}; false otherwise
|
|
802
1510
|
*
|
|
803
1511
|
* @example
|
|
804
1512
|
* ```ts
|
|
805
|
-
* isMethodGroup({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
|
|
806
|
-
* isMethodGroup({ interface: 'MarkdownInterface', methods: [1] })
|
|
1513
|
+
* isMethodGroup({ interface: 'MarkdownInterface', methods: [{ name: 'walk' }] }) // true
|
|
1514
|
+
* isMethodGroup({ interface: 'MarkdownInterface', methods: [1] }) // false
|
|
807
1515
|
* ```
|
|
808
1516
|
*/
|
|
809
1517
|
export declare const isMethodGroup: Guard<MethodGroup>;
|
|
810
1518
|
|
|
1519
|
+
/**
|
|
1520
|
+
* Checks whether `value` is a well-formed {@link SourceExample} — a `name` and `code`
|
|
1521
|
+
* string with an optional `title` and `language`.
|
|
1522
|
+
*
|
|
1523
|
+
* @param value - The value to test
|
|
1524
|
+
* @returns True if `value` is a well-formed {@link SourceExample}; false otherwise
|
|
1525
|
+
*
|
|
1526
|
+
* @example
|
|
1527
|
+
* ```ts
|
|
1528
|
+
* isSourceExample({ name: 'walk', code: 'walk()' }) // true
|
|
1529
|
+
* isSourceExample({ name: 'walk' }) // false
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
export declare const isSourceExample: Guard<SourceExample>;
|
|
1533
|
+
|
|
811
1534
|
/**
|
|
812
1535
|
* Checks whether `value` is a well-formed {@link SurfaceSymbol} — a `name`
|
|
813
|
-
* string paired with a valid {@link ExportKeyword}
|
|
1536
|
+
* string paired with a valid {@link ExportKeyword}, and an optional `summary`.
|
|
814
1537
|
*
|
|
815
1538
|
* @param value - The value to test
|
|
816
1539
|
* @returns True if `value` is a well-formed {@link SurfaceSymbol}; false otherwise
|
|
@@ -838,6 +1561,55 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
838
1561
|
*/
|
|
839
1562
|
export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
|
|
840
1563
|
|
|
1564
|
+
/**
|
|
1565
|
+
* Names the header text of the column a `## Surface` table's declaration keyword is read from.
|
|
1566
|
+
*/
|
|
1567
|
+
export declare const KIND: string;
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Locates the doc block a compared key attaches to inside one file's text and returns the block's
|
|
1571
|
+
* own character region, so a caller can `slice` the block, rewrite it through
|
|
1572
|
+
* {@link replaceSummary} or {@link replaceExample}, and write the result back through
|
|
1573
|
+
* {@link spliceSpan}. `key` names the pair the way {@link findDrift} names it — a
|
|
1574
|
+
* {@link computeSymbolKey} key for a declaration, an `Owner.member` key for an interface or class
|
|
1575
|
+
* member; the region covers the block's own indentation, and no block carrying the key returns
|
|
1576
|
+
* `undefined`.
|
|
1577
|
+
*
|
|
1578
|
+
* @remarks
|
|
1579
|
+
* Attachment is {@link extractSourceComments}'s, not a second reading of the file: that walk
|
|
1580
|
+
* pairs each eligible block with the physical record it documents, and this function keeps the
|
|
1581
|
+
* record {@link collectKeys} gives `key`. The keys are that one grammar's — the map
|
|
1582
|
+
* {@link extractExports} and {@link extractMemberMethods} each read their own part out of — so
|
|
1583
|
+
* this function runs no head pattern, no member pattern, and no owner-close rule of its own, and
|
|
1584
|
+
* a change to any of them reaches the locator too. Every block {@link collectSummaries} reports
|
|
1585
|
+
* a summary for is reachable by its key, and a block carrying only block tags is reachable too although it carries no summary.
|
|
1586
|
+
* A block it misses is one the comparison never had: a block a blank line separates from its
|
|
1587
|
+
* declaration attaches to the blank line, and a block written inside a template literal or a
|
|
1588
|
+
* string is no genuine span at all. The first block whose record carries the key answers for it,
|
|
1589
|
+
* as the first declaration of a name does everywhere else.
|
|
1590
|
+
*
|
|
1591
|
+
* The region runs from the start of the opener's line, the block's indentation included, to the
|
|
1592
|
+
* character past its closing marker — the raw text {@link replaceSummary} and
|
|
1593
|
+
* {@link replaceExample} each document as the span "as it sits in the file", so a caller slices,
|
|
1594
|
+
* rewrites, and splices with no adjustment and the rewrite keeps the indentation it found. A
|
|
1595
|
+
* block that source material precedes on its own line starts at the opener instead. The region
|
|
1596
|
+
* is read off the aligned JSDoc projection rather than searched for in the text, so an opener
|
|
1597
|
+
* written inside a string never yields one, and line offsets come from
|
|
1598
|
+
* {@link extractSourceLines}'s own records under its stated LF-or-CRLF terminator rule, so a
|
|
1599
|
+
* CRLF file reports the offsets its own bytes carry.
|
|
1600
|
+
*
|
|
1601
|
+
* @param text - One file's whole source text
|
|
1602
|
+
* @param key - The compared key naming the declaration or the member
|
|
1603
|
+
* @returns The block's half-open character region, or `undefined` when no block carries the key
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```ts
|
|
1607
|
+
* const text = '/**' + ' Walks. *' + '/\nexport function walk(): void {}\n'
|
|
1608
|
+
* locateComment(text, 'function walk') // { start: 0, end: 13 }
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
export declare function locateComment(text: string, key: string): MarkdownSpan | undefined;
|
|
1612
|
+
|
|
841
1613
|
/**
|
|
842
1614
|
* Names the `## By concept` heading text the manifest's run-map table is keyed on.
|
|
843
1615
|
*/
|
|
@@ -871,22 +1643,69 @@ export declare interface ManifestEntry {
|
|
|
871
1643
|
* manifestEntry.is({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
|
|
872
1644
|
* ```
|
|
873
1645
|
*/
|
|
874
|
-
export declare const manifestEntryShape: ObjectShape<{
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1646
|
+
export declare const manifestEntryShape: ObjectShape< {
|
|
1647
|
+
concept: StringShape;
|
|
1648
|
+
spec: StringShape;
|
|
1649
|
+
source: UnionShape<readonly [StringShape, ArrayShape<StringShape>]>;
|
|
1650
|
+
tests: StringShape;
|
|
1651
|
+
}, false>;
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Returns one doc block's unwrapped text with every fenced body replaced by aligned spaces,
|
|
1655
|
+
* so a tag search reads the block's structure and never its example code. A line opening with
|
|
1656
|
+
* three or more backticks or tildes opens a body, the first line opening with a run of the same
|
|
1657
|
+
* character at least as long closes it, an unclosed body runs to the end, and the marker lines
|
|
1658
|
+
* themselves stay. The projection preserves every line and every column, so an index found in
|
|
1659
|
+
* it addresses the same character of the text it was built from.
|
|
1660
|
+
*
|
|
1661
|
+
* @param text - One doc block's unwrapped text, as {@link normalizeComment} returns it
|
|
1662
|
+
* @returns The same text with each fenced body's characters replaced by spaces
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* maskFences('@example\n~~~\n@decorator()\n~~~').split('\n')[2] // ' '
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
export declare function maskFences(text: string): string;
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* Represents one documented method — its identifier plus the description paragraph the guide's
|
|
1673
|
+
* `Summary` cell and the member's doc block are compared on.
|
|
1674
|
+
*/
|
|
1675
|
+
export declare interface MethodEntry {
|
|
1676
|
+
/** Holds the method's identifier. */
|
|
1677
|
+
readonly name: string;
|
|
1678
|
+
/** Holds the normalized description paragraph this side carries, or is absent when it carries none. */
|
|
1679
|
+
readonly summary?: string;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Shapes a {@link MethodEntry} — one documented method's `name` paired with its optional
|
|
1684
|
+
* compared `summary`.
|
|
1685
|
+
*
|
|
1686
|
+
* @example
|
|
1687
|
+
* ```ts
|
|
1688
|
+
* import { createContract } from '@orkestrel/contract'
|
|
1689
|
+
* import { methodEntryShape } from '@orkestrel/guide'
|
|
1690
|
+
*
|
|
1691
|
+
* const methodEntry = createContract(methodEntryShape)
|
|
1692
|
+
* methodEntry.is({ name: 'walk' }) // true
|
|
1693
|
+
* ```
|
|
1694
|
+
*/
|
|
1695
|
+
export declare const methodEntryShape: ObjectShape< {
|
|
1696
|
+
name: StringShape;
|
|
1697
|
+
summary: OptionalShape<StringShape>;
|
|
879
1698
|
}, false>;
|
|
880
1699
|
|
|
881
1700
|
/**
|
|
882
|
-
* Represents one
|
|
883
|
-
*
|
|
1701
|
+
* Represents one behavioral interface a guide's `## Methods` section documents — the H4
|
|
1702
|
+
* heading naming that interface as a code span, and the member entries its table lists.
|
|
884
1703
|
*/
|
|
885
1704
|
export declare interface MethodGroup {
|
|
886
1705
|
/** Holds the backticked interface name. */
|
|
887
1706
|
readonly interface: string;
|
|
888
|
-
/** Lists the group's documented Method-cell
|
|
889
|
-
readonly methods: readonly
|
|
1707
|
+
/** Lists the group's documented Method-cell entries, in table order. */
|
|
1708
|
+
readonly methods: readonly MethodEntry[];
|
|
890
1709
|
}
|
|
891
1710
|
|
|
892
1711
|
/**
|
|
@@ -902,9 +1721,12 @@ export declare interface MethodGroup {
|
|
|
902
1721
|
* methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
|
|
903
1722
|
* ```
|
|
904
1723
|
*/
|
|
905
|
-
export declare const methodGroupShape: ObjectShape<{
|
|
906
|
-
|
|
907
|
-
|
|
1724
|
+
export declare const methodGroupShape: ObjectShape< {
|
|
1725
|
+
interface: StringShape;
|
|
1726
|
+
methods: ArrayShape<ObjectShape< {
|
|
1727
|
+
name: StringShape;
|
|
1728
|
+
summary: OptionalShape<StringShape>;
|
|
1729
|
+
}, false>>;
|
|
908
1730
|
}, false>;
|
|
909
1731
|
|
|
910
1732
|
/**
|
|
@@ -912,6 +1734,23 @@ export declare const methodGroupShape: ObjectShape<{
|
|
|
912
1734
|
*/
|
|
913
1735
|
export declare const METHODS: string;
|
|
914
1736
|
|
|
1737
|
+
/**
|
|
1738
|
+
* Returns the canonical body of one genuine JSDoc span — the `/**` opener, the closing
|
|
1739
|
+
* marker, each line's continuation marker, and the block's leading indentation removed,
|
|
1740
|
+
* with per-line trailing whitespace trimmed and the surrounding blank lines dropped. A
|
|
1741
|
+
* line's own indentation beyond the marker is kept, so an `@example` fence body keeps the
|
|
1742
|
+
* shape it was written in.
|
|
1743
|
+
*
|
|
1744
|
+
* @param comment - One complete genuine JSDoc span's raw text
|
|
1745
|
+
* @returns The span's unwrapped body
|
|
1746
|
+
*
|
|
1747
|
+
* @example
|
|
1748
|
+
* ```ts
|
|
1749
|
+
* normalizeComment('/**' + ' Creates a widget. *' + '/') // 'Creates a widget.'
|
|
1750
|
+
* ```
|
|
1751
|
+
*/
|
|
1752
|
+
export declare function normalizeComment(comment: string): string;
|
|
1753
|
+
|
|
915
1754
|
/**
|
|
916
1755
|
* Normalizes a module scope to its canonical directory list. `'.'` represents
|
|
917
1756
|
* workspace root; empty, trailing, and dot-segment spellings reduce through
|
|
@@ -946,6 +1785,220 @@ export declare function normalizeDirectories(module: GuideModule): readonly stri
|
|
|
946
1785
|
*/
|
|
947
1786
|
export declare function normalizeIdentifier(code: string): string;
|
|
948
1787
|
|
|
1788
|
+
/**
|
|
1789
|
+
* Returns the canonical compared form of a description paragraph. `{@link Target}` and
|
|
1790
|
+
* `{@link Target | label}` become the code token of the target text, or of the label where one is
|
|
1791
|
+
* written; a target's module part — the inline import form `import('./module.js').` and TSDoc's
|
|
1792
|
+
* package-qualified form `@scope/pkg#` — is dropped first. Every run of whitespace, including a
|
|
1793
|
+
* collapsed continuation marker and a line break, becomes one space, the ends trim, and a code
|
|
1794
|
+
* span keeps its delimiters while its own boundary whitespace goes. The guide's side and the
|
|
1795
|
+
* source's side read through this one form.
|
|
1796
|
+
*
|
|
1797
|
+
* @remarks
|
|
1798
|
+
* The clauses land in a fixed order, because each one decides what the next one sees. Every
|
|
1799
|
+
* single-backtick code span — one backtick per side, no inner backtick, no adjacent backtick —
|
|
1800
|
+
* is located first, so a delimiter the `{@link}` expansion inserts afterwards is never mistaken
|
|
1801
|
+
* for an authored one. The expansion then runs outside those spans
|
|
1802
|
+
* only, so a `{@link}` written inside a code span stays literal on both sides. Whitespace
|
|
1803
|
+
* collapses next, which is what makes a span wrapped across two physical lines comparable at
|
|
1804
|
+
* all. The boundary trim runs last, inside each located span: the markdown parser strips one
|
|
1805
|
+
* space from each end of a code span it reads, and this trim is the symmetric rule that meets
|
|
1806
|
+
* it, so `` ` | ` ``, `` ` |` ``, and `` `|` `` all reach `` `|` `` from either side. A span
|
|
1807
|
+
* whose content is all whitespace keeps one space, because a parser strips nothing from that
|
|
1808
|
+
* one.
|
|
1809
|
+
*
|
|
1810
|
+
* A target's module part is the inline import form `import('./module.js').` or TSDoc's
|
|
1811
|
+
* package-qualified form `@scope/pkg#`, and the expansion drops it, so a cross-file link and the
|
|
1812
|
+
* code token a guide cell documents it with reach the same text. A package qualifier carries `@`
|
|
1813
|
+
* or `/`; text before a `#` carrying neither is JSDoc's member reference, so `{@link Owner#member}`
|
|
1814
|
+
* and `{@link #member}` travel whole and a guide cell documents each as written. An unscoped
|
|
1815
|
+
* package name is spelled like an owner, so `{@link pkg#Name}` travels whole too — write the
|
|
1816
|
+
* scoped or the path form where a cell must drop the package. Everything after a module part
|
|
1817
|
+
* travels: `Owner.member` keeps its owner, and a dotted target no module part precedes is
|
|
1818
|
+
* untouched. A label is text rather than a target, so `{@link Target | label}` renders its label
|
|
1819
|
+
* whole.
|
|
1820
|
+
*
|
|
1821
|
+
* A code span delimited by more than one backtick is outside the compared form's representable
|
|
1822
|
+
* set and travels untouched, as does a code span whose own text carries a backtick: the form
|
|
1823
|
+
* spells every span with one backtick per side, so neither can be written back. A summary that
|
|
1824
|
+
* needs one of those constructs takes another shape: name the construct in prose rather than
|
|
1825
|
+
* expecting the comparison to converge it.
|
|
1826
|
+
*
|
|
1827
|
+
* @param text - A doc block's description paragraph, or a guide cell's flattened text
|
|
1828
|
+
* @returns The compared form of that text
|
|
1829
|
+
*
|
|
1830
|
+
* @example
|
|
1831
|
+
* ```ts
|
|
1832
|
+
* normalizeSummary('Creates a\n{@link Widget}.') // 'Creates a `Widget`.'
|
|
1833
|
+
* normalizeSummary("Reads {@link import('./widgets.js').Widget}.") // 'Reads `Widget`.'
|
|
1834
|
+
* normalizeSummary('Reads {@link @scope/widgets#Widget}.') // 'Reads `Widget`.'
|
|
1835
|
+
* normalizeSummary('Reads {@link Widget#render}.') // 'Reads `Widget#render`.'
|
|
1836
|
+
* normalizeSummary('cells joined by ` | `.') // 'cells joined by `|`.'
|
|
1837
|
+
* ```
|
|
1838
|
+
*/
|
|
1839
|
+
export declare function normalizeSummary(text: string): string;
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* Composes generic guide-parity inspection and explicit in-memory rewrites over a caller inventory.
|
|
1843
|
+
*/
|
|
1844
|
+
export declare class Parity implements ParityInterface {
|
|
1845
|
+
#private;
|
|
1846
|
+
constructor(options: ParityOptions);
|
|
1847
|
+
rows(): readonly ParityRow[];
|
|
1848
|
+
inspect(): ParityResult;
|
|
1849
|
+
document(): ParityRewriteResult;
|
|
1850
|
+
annotate(): ParityRewriteResult;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* Represents a changed inventory text returned by a parity rewrite.
|
|
1855
|
+
*/
|
|
1856
|
+
export declare interface ParityChange {
|
|
1857
|
+
/** Names the changed root-relative inventory path. */
|
|
1858
|
+
readonly path: string;
|
|
1859
|
+
/** Holds the accumulated replacement text for the path. */
|
|
1860
|
+
readonly content: string;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Represents the destination an explicit parity rewrite updates.
|
|
1865
|
+
*/
|
|
1866
|
+
export declare type ParityDirection = 'guide' | 'source';
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* Groups executable-example findings by their independent evidence populations.
|
|
1870
|
+
*/
|
|
1871
|
+
export declare interface ParityExampleResult {
|
|
1872
|
+
/** Lists findings for absence of a fence in the configured example language. */
|
|
1873
|
+
readonly fences: readonly ParityFinding[];
|
|
1874
|
+
/** Lists documented functions without example evidence. */
|
|
1875
|
+
readonly functions: readonly ParityFinding[];
|
|
1876
|
+
/** Lists documented methods without example evidence. */
|
|
1877
|
+
readonly methods: readonly ParityFinding[];
|
|
1878
|
+
/** Lists missing top-level guide/source title intersections. */
|
|
1879
|
+
readonly titles: readonly ParityFinding[];
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Represents a preformatted guides-parity finding.
|
|
1884
|
+
*/
|
|
1885
|
+
export declare interface ParityFinding {
|
|
1886
|
+
/** Names the guide or inventory key the finding belongs to. */
|
|
1887
|
+
readonly spec?: string;
|
|
1888
|
+
/** Holds the complete developer-facing finding text. */
|
|
1889
|
+
readonly text: string;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
/**
|
|
1893
|
+
* Represents a pure guides-parity composition over caller-supplied inventory.
|
|
1894
|
+
*/
|
|
1895
|
+
export declare interface ParityInterface {
|
|
1896
|
+
/**
|
|
1897
|
+
* Lists the manifest rows whose guide text is present, joined to parsed guide and source views.
|
|
1898
|
+
*
|
|
1899
|
+
* @returns The shared readonly row views
|
|
1900
|
+
*/
|
|
1901
|
+
rows(): readonly ParityRow[];
|
|
1902
|
+
/**
|
|
1903
|
+
* Inspects the configured inventory and groups generic parity findings.
|
|
1904
|
+
*
|
|
1905
|
+
* @returns The grouped parity report
|
|
1906
|
+
*/
|
|
1907
|
+
inspect(): ParityResult;
|
|
1908
|
+
/**
|
|
1909
|
+
* Updates guide summaries and titled examples from source authority without touching disk.
|
|
1910
|
+
*
|
|
1911
|
+
* @returns The changed texts and unresolved requested rewrites
|
|
1912
|
+
*/
|
|
1913
|
+
document(): ParityRewriteResult;
|
|
1914
|
+
/**
|
|
1915
|
+
* Updates source doc-block summaries and examples from guide authority without touching disk.
|
|
1916
|
+
*
|
|
1917
|
+
* @returns The changed texts and unresolved requested rewrites
|
|
1918
|
+
*/
|
|
1919
|
+
annotate(): ParityRewriteResult;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
/**
|
|
1923
|
+
* Represents the pure inputs that configure a guides-parity composition.
|
|
1924
|
+
*/
|
|
1925
|
+
export declare interface ParityOptions {
|
|
1926
|
+
/** Holds the workspace's root-relative path-to-text inventory. */
|
|
1927
|
+
readonly files: Readonly<Record<string, string>>;
|
|
1928
|
+
/** Lists the concept-manifest rows to inspect. */
|
|
1929
|
+
readonly entries: readonly ManifestEntry[];
|
|
1930
|
+
/** Maps each self import specifier to the source scope it exposes. */
|
|
1931
|
+
readonly modules: Readonly<Record<string, GuideModule>>;
|
|
1932
|
+
/** Lists every fence language the package admits. */
|
|
1933
|
+
readonly languages: readonly string[];
|
|
1934
|
+
/** Names the fence language inspected for examples and self imports. */
|
|
1935
|
+
readonly language: string;
|
|
1936
|
+
/** Names the optional README and guide tagline pair. */
|
|
1937
|
+
readonly pitch?: ParityPitch;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Names the inventory keys paired for README pitch parity.
|
|
1942
|
+
*/
|
|
1943
|
+
export declare interface ParityPitch {
|
|
1944
|
+
/** Names the README inventory key. */
|
|
1945
|
+
readonly readme: string;
|
|
1946
|
+
/** Names the guide inventory key whose tagline the README pitch must match. */
|
|
1947
|
+
readonly spec: string;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* Groups independently assertable guides-parity findings by subject.
|
|
1952
|
+
*/
|
|
1953
|
+
export declare interface ParityResult {
|
|
1954
|
+
/** Lists missing or unusable manifest inputs. */
|
|
1955
|
+
readonly input: readonly ParityFinding[];
|
|
1956
|
+
/** Lists required-section and documented method-group population findings. */
|
|
1957
|
+
readonly sections: readonly ParityFinding[];
|
|
1958
|
+
/** Lists documented-surface and barrel-surface findings. */
|
|
1959
|
+
readonly surface: readonly ParityFinding[];
|
|
1960
|
+
/** Lists behavioral-interface and implementing-class findings. */
|
|
1961
|
+
readonly methods: readonly ParityFinding[];
|
|
1962
|
+
/** Lists documented-group and source-driven behavioral declaration findings. */
|
|
1963
|
+
readonly declarations: readonly ParityFinding[];
|
|
1964
|
+
/** Lists unresolved relative guide links. */
|
|
1965
|
+
readonly links: readonly ParityFinding[];
|
|
1966
|
+
/** Lists missing or vacant documented test links. */
|
|
1967
|
+
readonly tests: readonly ParityFinding[];
|
|
1968
|
+
/** Lists unadmitted fence languages. */
|
|
1969
|
+
readonly fences: readonly ParityFinding[];
|
|
1970
|
+
/** Groups executable-example findings by evidence population. */
|
|
1971
|
+
readonly examples: ParityExampleResult;
|
|
1972
|
+
/** Lists mapped self imports that do not resolve to public exports. */
|
|
1973
|
+
readonly imports: readonly ParityFinding[];
|
|
1974
|
+
/** Lists categorized summary and titled-example disagreements. */
|
|
1975
|
+
readonly drift: readonly ParityFinding[];
|
|
1976
|
+
/** Lists README pitch and guide-tagline disagreements. */
|
|
1977
|
+
readonly pitch: readonly ParityFinding[];
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* Represents the changed texts and unresolved findings from an explicit rewrite.
|
|
1982
|
+
*/
|
|
1983
|
+
export declare interface ParityRewriteResult {
|
|
1984
|
+
/** Lists only texts that differ from the input inventory. */
|
|
1985
|
+
readonly changes: readonly ParityChange[];
|
|
1986
|
+
/** Lists requested rewrites that remain unresolved after accumulation. */
|
|
1987
|
+
readonly findings: readonly ParityFinding[];
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* Represents a manifest row joined to its parsed guide and reflected source.
|
|
1992
|
+
*/
|
|
1993
|
+
export declare interface ParityRow {
|
|
1994
|
+
/** Holds the manifest row. */
|
|
1995
|
+
readonly entry: ManifestEntry;
|
|
1996
|
+
/** Holds the parsed guide view. */
|
|
1997
|
+
readonly guide: GuideInterface;
|
|
1998
|
+
/** Holds the reflected source view. */
|
|
1999
|
+
readonly source: SourceInterface;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
949
2002
|
/**
|
|
950
2003
|
* Parses a `## By concept` manifest table into its {@link ManifestEntry} rows —
|
|
951
2004
|
* each row's Concept cell (flattened text), Spec / Tests cells (a single link
|
|
@@ -966,6 +2019,213 @@ export declare function normalizeIdentifier(code: string): string;
|
|
|
966
2019
|
*/
|
|
967
2020
|
export declare function parseManifest(markdown: string, directory: string): readonly ManifestEntry[];
|
|
968
2021
|
|
|
2022
|
+
/**
|
|
2023
|
+
* Renders one `@example` block as the guide fence it pairs with — an H3 heading carrying the
|
|
2024
|
+
* block's title, then a fence carrying its language and its code. An untitled block renders the
|
|
2025
|
+
* fence alone, because a fence pairs on its nearest preceding heading and an untitled block
|
|
2026
|
+
* claims none.
|
|
2027
|
+
*
|
|
2028
|
+
* @remarks
|
|
2029
|
+
* The title renders as literal text rather than markdown, so a title carrying backticks or
|
|
2030
|
+
* emphasis reads back through {@link extractFences} as the text the `@example` tag carried.
|
|
2031
|
+
* The heading level is 3 because a guide documents its examples one level under a `##` section;
|
|
2032
|
+
* {@link extractFences} pairs on the nearest preceding heading of any level, so the level is
|
|
2033
|
+
* presentation rather than pairing.
|
|
2034
|
+
*
|
|
2035
|
+
* @param example - The block to render
|
|
2036
|
+
* @returns The heading and fence's markdown source, with no trailing newline
|
|
2037
|
+
*
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```ts
|
|
2040
|
+
* renderExample({ name: 'walk', title: 'Walk a tree', code: 'walk()', language: 'ts' })
|
|
2041
|
+
* // an H3 heading of 'Walk a tree', then a fence tagged `ts` carrying `walk()`
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
export declare function renderExample(example: SourceExample): string;
|
|
2045
|
+
|
|
2046
|
+
/**
|
|
2047
|
+
* Renders one `## Methods` group — the `####` heading naming the interface as a code span, then
|
|
2048
|
+
* a `Name` and {@link SUMMARY} table with one row per documented member. A member carrying no
|
|
2049
|
+
* summary renders an empty cell, which {@link extractMethods} reads back as an absent summary.
|
|
2050
|
+
*
|
|
2051
|
+
* @remarks
|
|
2052
|
+
* The render carries no `## Methods` heading, for the reason {@link renderSurface} states:
|
|
2053
|
+
* a guide documents one group per interface under that one section heading.
|
|
2054
|
+
*
|
|
2055
|
+
* @param group - The interface and its members
|
|
2056
|
+
* @returns The heading and table's markdown source, with no trailing newline
|
|
2057
|
+
*
|
|
2058
|
+
* @example
|
|
2059
|
+
* ```ts
|
|
2060
|
+
* renderMethods({ interface: 'WidgetInterface', methods: [{ name: 'walk', summary: 'Walks.' }] })
|
|
2061
|
+
* // '#### `WidgetInterface`\n\n| Name | Summary |\n| --- | --- |\n| `walk` | Walks. |'
|
|
2062
|
+
* ```
|
|
2063
|
+
*/
|
|
2064
|
+
export declare function renderMethods(group: MethodGroup): string;
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Renders a `## Surface` table from the symbols a source declares — a `Name`, {@link KIND}, and
|
|
2068
|
+
* {@link SUMMARY} table with one row per symbol, the name as a code span, the keyword as its
|
|
2069
|
+
* text, and the summary through {@link buildCell}. A symbol carrying no summary renders an empty
|
|
2070
|
+
* cell, which {@link extractSurface} reads back as an absent summary.
|
|
2071
|
+
*
|
|
2072
|
+
* @remarks
|
|
2073
|
+
* The render carries no `## Surface` heading, because a guide documents its surface in several
|
|
2074
|
+
* tables under their own sub-headings and one of them is what this function produces. Reading the
|
|
2075
|
+
* render back therefore parses it under that heading. `renderMarkdown` pads every cell to one
|
|
2076
|
+
* space, so the render is not the committed column-aligned bytes; the checkout's formatter
|
|
2077
|
+
* re-aligns the table and the reader compares parsed entries rather than bytes.
|
|
2078
|
+
*
|
|
2079
|
+
* @param symbols - The symbols to document, in row order
|
|
2080
|
+
* @returns The table's markdown source, with no trailing newline
|
|
2081
|
+
*
|
|
2082
|
+
* @example
|
|
2083
|
+
* ```ts
|
|
2084
|
+
* renderSurface([{ name: 'walk', keyword: 'function', summary: 'Walks the tree.' }])
|
|
2085
|
+
* // '| Name | Kind | Summary |\n| --- | --- | --- |\n| `walk` | function | Walks the tree. |'
|
|
2086
|
+
* ```
|
|
2087
|
+
*/
|
|
2088
|
+
export declare function renderSurface(symbols: readonly SurfaceSymbol[]): string;
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Replaces one compared cell in a guide's text and returns the whole guide back. `key` names the
|
|
2092
|
+
* row the way {@link findDrift} names it — a {@link computeSymbolKey} key for a `## Surface` row,
|
|
2093
|
+
* an `Owner.member` key for a `## Methods` row — and the row's {@link SUMMARY} cell becomes
|
|
2094
|
+
* `summary`. Only the table's own source region is rewritten, so every byte outside it travels
|
|
2095
|
+
* unchanged; a key reaching no cell returns `undefined`, and a row already carrying the summary
|
|
2096
|
+
* returns the guide byte for byte.
|
|
2097
|
+
*
|
|
2098
|
+
* @remarks
|
|
2099
|
+
* A row the key does not reach, a table carrying no {@link SUMMARY} column, and a document whose
|
|
2100
|
+
* parse recorded no region for the table are each a miss, and a miss returns `undefined` rather
|
|
2101
|
+
* than throwing, so a caller reports the key it could not place — the one meaning `undefined`
|
|
2102
|
+
* carries in every replacer here. A row already carrying `summary` returns the guide byte for
|
|
2103
|
+
* byte, because a rewrite would re-pad the whole table for no change; that identity reads both
|
|
2104
|
+
* sides through {@link normalizeSummary}, so a caller passing text the compared form still moves
|
|
2105
|
+
* is a fixed point on the second run rather than a row rewritten forever. The rewritten table
|
|
2106
|
+
* renders one-space padded whatever padding it carried, so the checkout's formatter re-aligns it.
|
|
2107
|
+
*
|
|
2108
|
+
* @param guide - The guide's markdown source
|
|
2109
|
+
* @param key - The compared key naming the row
|
|
2110
|
+
* @param summary - The row's new compared text
|
|
2111
|
+
* @returns The guide's text with that cell replaced, or `undefined` when the key reaches no cell
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```ts
|
|
2115
|
+
* replaceCell('## Surface\n\n| Name | Kind | Summary |\n| --- | --- | --- |\n| `walk` | function | Walks. |', 'function walk', 'Walks a tree.')
|
|
2116
|
+
* // '## Surface\n\n| Name | Kind | Summary |\n| --- | --- | --- |\n| `walk` | function | Walks a tree. |'
|
|
2117
|
+
* ```
|
|
2118
|
+
*/
|
|
2119
|
+
export declare function replaceCell(guide: string, key: string, summary: string): string | undefined;
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* Replaces the body of one titled `@example` tag in a doc block's raw text and returns the whole
|
|
2123
|
+
* block back. The tag carrying `example`'s title takes a fence of its language and its code;
|
|
2124
|
+
* every other tag, the description paragraph, the block's indentation, and its continuation
|
|
2125
|
+
* markers all survive. A text that is no doc block, a title no tag carries, and a language or
|
|
2126
|
+
* code the emitted three-backtick fence cannot enclose or the doc block cannot hold each return
|
|
2127
|
+
* `undefined`.
|
|
2128
|
+
*
|
|
2129
|
+
* @remarks
|
|
2130
|
+
* A miss returns `undefined`, the one meaning `undefined` carries in every replacer here, so a
|
|
2131
|
+
* caller reports the block it could not rewrite. Text that opens with no
|
|
2132
|
+
* `/**` is no doc block, for the reason {@link replaceSummary} states. A block carrying no
|
|
2133
|
+
* `@example` tag of that title has nowhere to write, so an untitled tag and a tag carrying
|
|
2134
|
+
* another title are each left alone, and an `example` naming no title misses a block whose tags
|
|
2135
|
+
* all carry one. Code carrying a run of three or more backticks is a body the emitted fence
|
|
2136
|
+
* cannot enclose: the fence is three backticks, {@link maskFences} ends a body at the first line
|
|
2137
|
+
* opening a run at least as long, and {@link collectExamples} reads to the first such run
|
|
2138
|
+
* whatever column it sits at, so writing that body would truncate it and turn a following
|
|
2139
|
+
* `@`-line into a tag. A language or code carrying the doc-comment terminator is a body the
|
|
2140
|
+
* block itself cannot hold: the terminator closes the block where it lands and the file stops
|
|
2141
|
+
* parsing there. Refusing keeps the rewrite total over the bodies it can spell.
|
|
2142
|
+
*
|
|
2143
|
+
* A tag already carrying that language and code returns byte for byte. {@link maskFences} keeps
|
|
2144
|
+
* the current body's own lines out of the tag search, so a fenced body carrying a tag-shaped line
|
|
2145
|
+
* does not end the body early. The body ends at its last line carrying text, so the blank line
|
|
2146
|
+
* separating it from the next tag survives.
|
|
2147
|
+
*
|
|
2148
|
+
* @param comment - One complete genuine JSDoc span's raw text, as it sits in the file
|
|
2149
|
+
* @param example - The block whose language and code the tag's body takes
|
|
2150
|
+
* @returns The block's raw text with that body replaced, or `undefined` for a text that is no
|
|
2151
|
+
* doc block, for a title no `@example` tag carries, and for a language or code the emitted
|
|
2152
|
+
* fence cannot enclose or the doc block cannot hold — a body carrying the doc-comment terminator
|
|
2153
|
+
*
|
|
2154
|
+
* @example
|
|
2155
|
+
* ```ts
|
|
2156
|
+
* replaceExample('/**' + '\n * @example Walk\n * old()\n *' + '/', { name: 'walk', title: 'Walk', code: 'walk()', language: 'ts' })
|
|
2157
|
+
* // the same block, its `@example Walk` body now a fence tagged `ts` carrying `walk()`
|
|
2158
|
+
* ```
|
|
2159
|
+
*/
|
|
2160
|
+
export declare function replaceExample(comment: string, example: SourceExample): string | undefined;
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* Replaces one titled fence in a guide's text and returns the whole guide back. The first fence
|
|
2164
|
+
* carrying `title` — the pairing {@link findDrift} compares on — takes `example`'s language and
|
|
2165
|
+
* code. Only the fence's own source region is rewritten, so every byte outside it travels
|
|
2166
|
+
* unchanged; a title no fence carries returns `undefined`, and a fence already carrying that
|
|
2167
|
+
* body returns the guide byte for byte.
|
|
2168
|
+
*
|
|
2169
|
+
* @remarks
|
|
2170
|
+
* A title no fence carries and a document whose parse recorded no region for the fence are each a
|
|
2171
|
+
* miss, and a miss returns `undefined` rather than throwing — the one meaning `undefined` carries
|
|
2172
|
+
* in every replacer here. A fence already carrying that language and code returns the guide
|
|
2173
|
+
* byte for byte. A later fence of the same title is outside the pairing and is never rewritten,
|
|
2174
|
+
* which is the rule {@link findDrift} compares under.
|
|
2175
|
+
*
|
|
2176
|
+
* @param guide - The guide's markdown source
|
|
2177
|
+
* @param title - The heading text the fence pairs on
|
|
2178
|
+
* @param example - The block whose language and code the fence takes
|
|
2179
|
+
* @returns The guide's text with that fence replaced, or `undefined` when no fence carries the title
|
|
2180
|
+
*
|
|
2181
|
+
* @example
|
|
2182
|
+
* ```ts
|
|
2183
|
+
* replaceFence(guide, 'Walk', { name: 'walk', title: 'Walk', code: 'walk()', language: 'ts' })
|
|
2184
|
+
* // the guide's text with the fence under its `### Walk` heading carrying `walk()`
|
|
2185
|
+
* ```
|
|
2186
|
+
*/
|
|
2187
|
+
export declare function replaceFence(guide: string, title: string, example: SourceExample): string | undefined;
|
|
2188
|
+
|
|
2189
|
+
/**
|
|
2190
|
+
* Replaces one doc block's description paragraph with `summary` and returns the whole block back.
|
|
2191
|
+
* The paragraph is the block's text before its first block tag, and it re-wraps inside `width`;
|
|
2192
|
+
* the blank line before the first tag, every tag line, the block's indentation, and its
|
|
2193
|
+
* continuation markers all survive. A block already carrying the summary returns byte for byte,
|
|
2194
|
+
* and a text that is no doc block and a summary carrying no word each return `undefined`.
|
|
2195
|
+
*
|
|
2196
|
+
* @remarks
|
|
2197
|
+
* A miss returns `undefined`, the one meaning `undefined` carries in every replacer here, so a
|
|
2198
|
+
* caller reports the block it could not rewrite. Text that opens with no
|
|
2199
|
+
* `/**` is no doc block: a single-star `/*` comment reaches this function only by a caller's
|
|
2200
|
+
* mistake, and reshaping it into a doc block would be a silent edit. A `summary` carrying no word
|
|
2201
|
+
* names no paragraph to write, and deleting the block's description on that argument would erase
|
|
2202
|
+
* documentation on the strength of an absent value — a caller with nothing to write writes
|
|
2203
|
+
* nothing.
|
|
2204
|
+
*
|
|
2205
|
+
* A block already carrying `summary` returns byte for byte, which is what keeps a propagation
|
|
2206
|
+
* that finds no drift from rewriting the file: a doc block's own wrapping is not recoverable from
|
|
2207
|
+
* its text, so re-wrapping an unchanged paragraph would move most blocks this package's source
|
|
2208
|
+
* carries. That identity reads both sides through {@link normalizeSummary}, and it holds for a
|
|
2209
|
+
* block carrying no tag as much as for a block carrying several. A block written on one physical
|
|
2210
|
+
* line stays on one line while `summary` still fits inside `width`, and expands otherwise.
|
|
2211
|
+
*
|
|
2212
|
+
* `width` counts characters from the line's first, a tab counting as one, so a wrapped line reads
|
|
2213
|
+
* `${indent} * ${text}` and never passes that count. A caller whose formatter measures a tab as
|
|
2214
|
+
* more than one column passes a smaller width rather than taking the default.
|
|
2215
|
+
*
|
|
2216
|
+
* @param comment - One complete genuine JSDoc span's raw text, as it sits in the file
|
|
2217
|
+
* @param summary - The block's new description paragraph
|
|
2218
|
+
* @param width - The character budget a re-wrapped line stays inside. Default: {@link WRAP_WIDTH}
|
|
2219
|
+
* @returns The block's raw text with that paragraph replaced, or `undefined` for a text that is
|
|
2220
|
+
* no doc block and for a `summary` carrying no word
|
|
2221
|
+
*
|
|
2222
|
+
* @example
|
|
2223
|
+
* ```ts
|
|
2224
|
+
* replaceSummary('/**' + ' Walks. *' + '/', 'Walks a tree.') // '/**' + ' Walks a tree. *' + '/'
|
|
2225
|
+
* ```
|
|
2226
|
+
*/
|
|
2227
|
+
export declare function replaceSummary(comment: string, summary: string, width?: number): string | undefined;
|
|
2228
|
+
|
|
969
2229
|
/**
|
|
970
2230
|
* Resolves a relative `target` from the directory containing a root-relative
|
|
971
2231
|
* declaring `file`. A slashless file belongs to the workspace root; path
|
|
@@ -1041,7 +2301,10 @@ export declare function selectSectionBlocks(document: MarkdownDocument, heading:
|
|
|
1041
2301
|
* filesystem. `Source` never touches disk:
|
|
1042
2302
|
* the consumer gathers the inventory however their environment allows
|
|
1043
2303
|
* (`node:fs` in a Node script, `import.meta.glob` in a browser/vitest run) and
|
|
1044
|
-
* passes it in as `files`.
|
|
2304
|
+
* passes it in as `files`.
|
|
2305
|
+
*
|
|
2306
|
+
* @remarks
|
|
2307
|
+
* Conventional barrel traversal recurses through both
|
|
1045
2308
|
* exact workspace-root `index.ts` and nested `/index.ts` targets. `'.'` is the
|
|
1046
2309
|
* canonical workspace-root module, module spellings normalize once at
|
|
1047
2310
|
* construction, and exact opaque inventory keys are never rewritten; keys with
|
|
@@ -1052,11 +2315,16 @@ export declare function selectSectionBlocks(document: MarkdownDocument, heading:
|
|
|
1052
2315
|
* from; a base the scope does not declare contributes nothing. One declaration
|
|
1053
2316
|
* answers for a name: the first file in sorted key order that declares the head
|
|
1054
2317
|
* supplies its members and its bases, and a second file declaring the same name
|
|
1055
|
-
* adds nothing.
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
2318
|
+
* adds nothing. Every reading derives once per instance from the immutable
|
|
2319
|
+
* inventory and is reused — the scope's declaration map on the first `methods`
|
|
2320
|
+
* or `examples` lookup, then each name's members and each example collection
|
|
2321
|
+
* under the name asked for — so a reader asking twice reads the files once and
|
|
2322
|
+
* receives the same records, and a second instance over the same inventory
|
|
2323
|
+
* derives the same readings of its own. Source projection preserves columns
|
|
2324
|
+
* without widening direct/hidden column-zero heads. Literal ECMAScript Unicode
|
|
2325
|
+
* identifiers participate in bounded slash-state recognition without escape
|
|
2326
|
+
* decoding. Regex recognition is bounded: slash after bare `}` is division, so
|
|
2327
|
+
* a post-brace regex statement requires an explicit `;`. General semicolonless
|
|
1060
2328
|
* declaration/ASI classification is also outside the finite projector, so a
|
|
1061
2329
|
* slash-leading statement after such a declaration requires an explicit `;`.
|
|
1062
2330
|
*
|
|
@@ -1074,7 +2342,7 @@ export declare function selectSectionBlocks(document: MarkdownDocument, heading:
|
|
|
1074
2342
|
* })
|
|
1075
2343
|
* source.exports() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
1076
2344
|
* source.surface() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
1077
|
-
* source.methods('GuideInterface') // ['sections']
|
|
2345
|
+
* source.methods('GuideInterface') // [{ name: 'sections' }]
|
|
1078
2346
|
* source.exists('src/core/Guide.ts') // true
|
|
1079
2347
|
* ```
|
|
1080
2348
|
*/
|
|
@@ -1083,13 +2351,63 @@ export declare class Source implements SourceInterface {
|
|
|
1083
2351
|
constructor(options: SourceOptions);
|
|
1084
2352
|
exports(): readonly SurfaceSymbol[];
|
|
1085
2353
|
surface(): readonly SurfaceSymbol[];
|
|
1086
|
-
methods(name: string): readonly
|
|
2354
|
+
methods(name: string): readonly MethodEntry[];
|
|
1087
2355
|
exists(relative: string): boolean;
|
|
1088
2356
|
hidden(): readonly SurfaceSymbol[];
|
|
1089
|
-
examples(): readonly
|
|
1090
|
-
examples(name: string): readonly
|
|
2357
|
+
examples(): readonly SourceExample[];
|
|
2358
|
+
examples(name: string): readonly SourceExample[];
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* Represents one eligible genuine JSDoc block paired with the physical record it documents —
|
|
2363
|
+
* the block's unwrapped body and the {@link SourceLine} that follows its chain.
|
|
2364
|
+
*/
|
|
2365
|
+
export declare interface SourceComment {
|
|
2366
|
+
/**
|
|
2367
|
+
* Holds the authoritative span's unwrapped body: the `/**` opener, the closing marker, each
|
|
2368
|
+
* line's continuation marker, and the block's leading indentation removed, with per-line
|
|
2369
|
+
* trailing whitespace trimmed.
|
|
2370
|
+
*/
|
|
2371
|
+
readonly text: string;
|
|
2372
|
+
/** Holds the physical record the block documents — the next record after its chain. */
|
|
2373
|
+
readonly line: SourceLine;
|
|
1091
2374
|
}
|
|
1092
2375
|
|
|
2376
|
+
/**
|
|
2377
|
+
* Represents one `@example` block read from a doc comment — the declaration it documents, its
|
|
2378
|
+
* pairing title, its code, and its fence language.
|
|
2379
|
+
*/
|
|
2380
|
+
export declare interface SourceExample {
|
|
2381
|
+
/** Names the declaration or member whose doc block carries the block. */
|
|
2382
|
+
readonly name: string;
|
|
2383
|
+
/** Holds the text after the `@example` tag, which pairs the block with the guide fence under the heading of that text; absent when the tag carries none. */
|
|
2384
|
+
readonly title?: string;
|
|
2385
|
+
/** Holds the block's code — the body of its fence, or the whole block when it carries no fence. */
|
|
2386
|
+
readonly code: string;
|
|
2387
|
+
/** Holds the info-string language of the block's fence, or is absent when the block carries no fence. */
|
|
2388
|
+
readonly language?: string;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
/**
|
|
2392
|
+
* Shapes a {@link SourceExample} — one `@example` block's `name`, its optional pairing
|
|
2393
|
+
* `title`, its `code`, and its optional fence `language`.
|
|
2394
|
+
*
|
|
2395
|
+
* @example
|
|
2396
|
+
* ```ts
|
|
2397
|
+
* import { createContract } from '@orkestrel/contract'
|
|
2398
|
+
* import { sourceExampleShape } from '@orkestrel/guide'
|
|
2399
|
+
*
|
|
2400
|
+
* const sourceExample = createContract(sourceExampleShape)
|
|
2401
|
+
* sourceExample.is({ name: 'walk', code: 'walk()' }) // true
|
|
2402
|
+
* ```
|
|
2403
|
+
*/
|
|
2404
|
+
export declare const sourceExampleShape: ObjectShape< {
|
|
2405
|
+
name: StringShape;
|
|
2406
|
+
title: OptionalShape<StringShape>;
|
|
2407
|
+
code: StringShape;
|
|
2408
|
+
language: OptionalShape<StringShape>;
|
|
2409
|
+
}, false>;
|
|
2410
|
+
|
|
1093
2411
|
/**
|
|
1094
2412
|
* Represents the reflected source truth a guide's documented surface is checked against —
|
|
1095
2413
|
* a pure view over a consumer-supplied file inventory (see {@link Source}).
|
|
@@ -1097,16 +2415,16 @@ export declare class Source implements SourceInterface {
|
|
|
1097
2415
|
export declare interface SourceInterface {
|
|
1098
2416
|
/**
|
|
1099
2417
|
* Lists every direct declaration in the selected module keys matching
|
|
1100
|
-
* `export (async )?(function*?|class|const|interface|type) Name`, by
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1106
|
-
* length-preserving projection, but membership
|
|
1107
|
-
* uninterrupted column-zero declaration-head grammar. `enum`
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
2418
|
+
* `export (async )?(function*?|class|const|interface|type) Name`, by (name, keyword).
|
|
2419
|
+
*
|
|
2420
|
+
* @remarks
|
|
2421
|
+
* Module keys are `.ts` inventory keys under the selected directories, excluding each directory's
|
|
2422
|
+
* exact root `index.ts` and every `*.test.ts` key. Inventory keys are exact opaque
|
|
2423
|
+
* workspace-relative keys, must contain no empty, `.` or `..` segment, and are never normalized.
|
|
2424
|
+
* Comment/template payload is excluded through a length-preserving projection, but membership
|
|
2425
|
+
* still follows this consumer's uninterrupted column-zero declaration-head grammar. `enum` and
|
|
2426
|
+
* other TypeScript export forms are outside this declaration-keyword reflection population, not
|
|
2427
|
+
* forbidden by general package policy.
|
|
1110
2428
|
*
|
|
1111
2429
|
* @returns The selected modules' direct declarations, deduplicated and sorted by name
|
|
1112
2430
|
*/
|
|
@@ -1152,8 +2470,9 @@ export declare interface SourceInterface {
|
|
|
1152
2470
|
*/
|
|
1153
2471
|
surface(): readonly SurfaceSymbol[];
|
|
1154
2472
|
/**
|
|
1155
|
-
* Returns the call-signature members of the `class` / `interface` named `name`,
|
|
1156
|
-
*
|
|
2473
|
+
* Returns the call-signature members of the `class` / `interface` named `name`, unioned with
|
|
2474
|
+
* those of every declaration it extends within the module scope, each with its own doc
|
|
2475
|
+
* block's description paragraph. The first file declaring the name answers for it.
|
|
1157
2476
|
*
|
|
1158
2477
|
* @remarks
|
|
1159
2478
|
* One declaration answers for `name`: the module scope's files are read in
|
|
@@ -1172,13 +2491,16 @@ export declare interface SourceInterface {
|
|
|
1172
2491
|
* collapses a cycle and a diamond to a single visit.
|
|
1173
2492
|
*
|
|
1174
2493
|
* @param name - The declaration's identifier
|
|
1175
|
-
* @returns Its declared and inherited
|
|
2494
|
+
* @returns Its declared and inherited members, each with its doc block's description paragraph, deduplicated by name and sorted, a class `constructor` excluded
|
|
1176
2495
|
*/
|
|
1177
|
-
methods(name: string): readonly
|
|
2496
|
+
methods(name: string): readonly MethodEntry[];
|
|
1178
2497
|
/**
|
|
1179
2498
|
* Checks whether a workspace-root-relative path names a file or a directory present
|
|
1180
2499
|
* in the inventory.
|
|
1181
2500
|
*
|
|
2501
|
+
* @remarks
|
|
2502
|
+
* A directory counts so a guide's link to a directory resolves.
|
|
2503
|
+
*
|
|
1182
2504
|
* @param relative - The workspace-root-relative path to look up
|
|
1183
2505
|
* @returns True if the inventory holds that exact key or any key beneath it; false otherwise
|
|
1184
2506
|
*/
|
|
@@ -1201,26 +2523,30 @@ export declare interface SourceInterface {
|
|
|
1201
2523
|
*/
|
|
1202
2524
|
hidden(): readonly SurfaceSymbol[];
|
|
1203
2525
|
/**
|
|
1204
|
-
* Lists
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
2526
|
+
* Lists every `@example` block carried by an exported declaration head — a `type`,
|
|
2527
|
+
* `interface`, `const`, `function`, or `class` head at column zero — whose
|
|
2528
|
+
* next-physical-record eligible genuine JSDoc chain ends in a span holding an `@example` tag
|
|
2529
|
+
* opening a line at its first non-blank column. Each block carries its title, its fence
|
|
2530
|
+
* language, and its code; intervening material severs association. A member's block belongs
|
|
2531
|
+
* to the `name` overload instead.
|
|
1208
2532
|
*
|
|
1209
|
-
* @returns The exported
|
|
2533
|
+
* @returns The exported declaration heads' `@example` blocks, in first-seen order
|
|
1210
2534
|
*
|
|
1211
2535
|
* @example
|
|
1212
2536
|
* ```ts
|
|
1213
|
-
* source.examples() // ['createGuide', '
|
|
2537
|
+
* source.examples() // [{ name: 'createGuide', code: "createGuide('# Guide')" }]
|
|
1214
2538
|
* ```
|
|
1215
2539
|
*/
|
|
1216
|
-
examples(): readonly
|
|
2540
|
+
examples(): readonly SourceExample[];
|
|
1217
2541
|
/**
|
|
1218
|
-
* Lists
|
|
1219
|
-
* preceding eligible genuine JSDoc chain, within the declaration
|
|
1220
|
-
* in a span
|
|
1221
|
-
*
|
|
2542
|
+
* Lists every `@example` block carried by a member of the `class` / `interface` named
|
|
2543
|
+
* `name` whose immediately preceding eligible genuine JSDoc chain, within the declaration
|
|
2544
|
+
* body, ends in a span holding an `@example` tag opening a line at its first non-blank column.
|
|
2545
|
+
* Each block carries its title, its fence language, and its code; intervening material severs
|
|
2546
|
+
* association. Declaration and callable
|
|
1222
2547
|
* member eligibility comes from aligned projected code while genuine JSDoc
|
|
1223
|
-
* evidence retains its source columns.
|
|
2548
|
+
* evidence retains its source columns. The head's own block belongs to the
|
|
2549
|
+
* no-argument overload instead.
|
|
1224
2550
|
*
|
|
1225
2551
|
* @remarks
|
|
1226
2552
|
* This overload reads only the named declaration's own body, in the first
|
|
@@ -1229,14 +2555,14 @@ export declare interface SourceInterface {
|
|
|
1229
2555
|
* belongs to the base that declares it.
|
|
1230
2556
|
*
|
|
1231
2557
|
* @param name - The declaration's identifier
|
|
1232
|
-
* @returns Its own members
|
|
2558
|
+
* @returns Its own members' `@example` blocks, deduplicated by name and title and sorted by name
|
|
1233
2559
|
*
|
|
1234
2560
|
* @example
|
|
1235
2561
|
* ```ts
|
|
1236
|
-
* source.examples('GuideInterface') // ['fences', '
|
|
2562
|
+
* source.examples('GuideInterface') // [{ name: 'fences', code: 'guide.fences()' }]
|
|
1237
2563
|
* ```
|
|
1238
2564
|
*/
|
|
1239
|
-
examples(name: string): readonly
|
|
2565
|
+
examples(name: string): readonly SourceExample[];
|
|
1240
2566
|
}
|
|
1241
2567
|
|
|
1242
2568
|
/**
|
|
@@ -1280,10 +2606,14 @@ export declare class SourceManager implements SourceManagerInterface {
|
|
|
1280
2606
|
sources(): readonly SourceInterface[];
|
|
1281
2607
|
}
|
|
1282
2608
|
|
|
1283
|
-
/**
|
|
2609
|
+
/**
|
|
2610
|
+
* Represents a specifier resolver that shares one {@link SourceInterface} per module and
|
|
2611
|
+
* enumerates those views.
|
|
2612
|
+
*/
|
|
1284
2613
|
export declare interface SourceManagerInterface {
|
|
1285
2614
|
/**
|
|
1286
|
-
* Resolves a mapped specifier to
|
|
2615
|
+
* Resolves a mapped specifier to the shared source view of the module it names, and returns
|
|
2616
|
+
* `undefined` when the policy does not map it — a foreign import.
|
|
1287
2617
|
*
|
|
1288
2618
|
* @param specifier - The import specifier to resolve
|
|
1289
2619
|
* @returns Its source view, or `undefined` when the specifier is not mapped
|
|
@@ -1295,8 +2625,8 @@ export declare interface SourceManagerInterface {
|
|
|
1295
2625
|
*/
|
|
1296
2626
|
source(specifier: string): SourceInterface | undefined;
|
|
1297
2627
|
/**
|
|
1298
|
-
* Lists
|
|
1299
|
-
* {@link source} returns.
|
|
2628
|
+
* Lists one shared source view per distinct module the policy maps, in first-seen specifier
|
|
2629
|
+
* order, sharing the same per-module entities {@link source} returns.
|
|
1300
2630
|
*
|
|
1301
2631
|
* @returns One shared source view per distinct module the policy maps, in first-seen specifier order
|
|
1302
2632
|
*
|
|
@@ -1340,24 +2670,56 @@ export declare interface SourceOptions {
|
|
|
1340
2670
|
readonly module: GuideModule;
|
|
1341
2671
|
}
|
|
1342
2672
|
|
|
2673
|
+
/**
|
|
2674
|
+
* Splices `replacement` into `source` over the region `span` addresses, and returns the result.
|
|
2675
|
+
* The text before the region and the text after it travel byte for byte, so a rewrite that
|
|
2676
|
+
* addresses one node's region changes nothing else in the document.
|
|
2677
|
+
*
|
|
2678
|
+
* @param source - The text to rewrite
|
|
2679
|
+
* @param span - The half-open region to replace: the region `MarkdownInterface.span` reports
|
|
2680
|
+
* for a markdown node, or the one {@link locateComment} reports for a doc block
|
|
2681
|
+
* @param replacement - The text to write over that region
|
|
2682
|
+
* @returns The rewritten text
|
|
2683
|
+
*
|
|
2684
|
+
* @example
|
|
2685
|
+
* ```ts
|
|
2686
|
+
* spliceSpan('one two three', { start: 4, end: 7 }, 'TWO') // 'one TWO three'
|
|
2687
|
+
* ```
|
|
2688
|
+
*/
|
|
2689
|
+
export declare function spliceSpan(source: string, span: MarkdownSpan, replacement: string): string;
|
|
2690
|
+
|
|
2691
|
+
/**
|
|
2692
|
+
* Names the header text of the column a `## Surface` or `## Methods` table's compared
|
|
2693
|
+
* description paragraph is read from.
|
|
2694
|
+
*/
|
|
2695
|
+
export declare const SUMMARY: string;
|
|
2696
|
+
|
|
1343
2697
|
/**
|
|
1344
2698
|
* Names the `## Surface` heading text a guide's documented exports section is keyed on.
|
|
1345
2699
|
*/
|
|
1346
2700
|
export declare const SURFACE: string;
|
|
1347
2701
|
|
|
1348
2702
|
/**
|
|
1349
|
-
* Represents one documented / exported symbol — its identifier
|
|
2703
|
+
* Represents one documented / exported symbol — its identifier, its declaration keyword, and
|
|
2704
|
+
* the description paragraph the guide and the doc block are compared on.
|
|
1350
2705
|
*/
|
|
1351
2706
|
export declare interface SurfaceSymbol {
|
|
1352
2707
|
/** Holds the symbol's identifier. */
|
|
1353
2708
|
readonly name: string;
|
|
1354
2709
|
/** Holds the symbol's declaration keyword — half of the bijection key alongside {@link name}. */
|
|
1355
2710
|
readonly keyword: ExportKeyword;
|
|
2711
|
+
/**
|
|
2712
|
+
* Holds the normalized description paragraph this side carries — a guide table's `Summary`
|
|
2713
|
+
* cell, or a doc block's text before its first block tag — and is absent when this side
|
|
2714
|
+
* carries none. Optional, so a hand-built symbol stays valid; {@link computeSymbolKey} never
|
|
2715
|
+
* reads it.
|
|
2716
|
+
*/
|
|
2717
|
+
readonly summary?: string;
|
|
1356
2718
|
}
|
|
1357
2719
|
|
|
1358
2720
|
/**
|
|
1359
2721
|
* Shapes a {@link SurfaceSymbol} — a documented / exported symbol's `name`
|
|
1360
|
-
* paired with its {@link ExportKeyword}
|
|
2722
|
+
* paired with its {@link ExportKeyword} and its optional compared `summary`.
|
|
1361
2723
|
*
|
|
1362
2724
|
* @example
|
|
1363
2725
|
* ```ts
|
|
@@ -1368,9 +2730,10 @@ export declare interface SurfaceSymbol {
|
|
|
1368
2730
|
* surfaceSymbol.is({ name: 'Markdown', keyword: 'class' }) // true
|
|
1369
2731
|
* ```
|
|
1370
2732
|
*/
|
|
1371
|
-
export declare const surfaceSymbolShape: ObjectShape<{
|
|
1372
|
-
|
|
1373
|
-
|
|
2733
|
+
export declare const surfaceSymbolShape: ObjectShape< {
|
|
2734
|
+
name: StringShape;
|
|
2735
|
+
keyword: LiteralShape<readonly ("function" | "type" | "interface" | "const" | "class")[]>;
|
|
2736
|
+
summary: OptionalShape<StringShape>;
|
|
1374
2737
|
}, false>;
|
|
1375
2738
|
|
|
1376
2739
|
/**
|
|
@@ -1378,4 +2741,54 @@ export declare const surfaceSymbolShape: ObjectShape<{
|
|
|
1378
2741
|
*/
|
|
1379
2742
|
export declare const TESTS: string;
|
|
1380
2743
|
|
|
2744
|
+
/**
|
|
2745
|
+
* Unwraps one genuine JSDoc span into one content line per physical line — the `/**` opener,
|
|
2746
|
+
* the closing marker, each line's continuation marker, and per-line trailing whitespace removed,
|
|
2747
|
+
* with a line's own indentation past the marker kept. The result is aligned with
|
|
2748
|
+
* `comment.split('\n')`, so an index found in it addresses the same physical line of the span it
|
|
2749
|
+
* was built from, which is what lets a rewrite keep every line it does not replace.
|
|
2750
|
+
* {@link normalizeComment} is this projection joined and trimmed at its ends.
|
|
2751
|
+
*
|
|
2752
|
+
* @param comment - One complete genuine JSDoc span's raw text
|
|
2753
|
+
* @returns One content line per physical line of the span
|
|
2754
|
+
*
|
|
2755
|
+
* @example
|
|
2756
|
+
* ```ts
|
|
2757
|
+
* unwrapComment('/**' + '\n * Walks.\n *' + '/') // ['', 'Walks.', '']
|
|
2758
|
+
* ```
|
|
2759
|
+
*/
|
|
2760
|
+
export declare function unwrapComment(comment: string): readonly string[];
|
|
2761
|
+
|
|
2762
|
+
/**
|
|
2763
|
+
* Holds the default character budget a rewritten doc block's description paragraph wraps
|
|
2764
|
+
* inside — the greatest number of characters a re-wrapped line may carry, counted from the
|
|
2765
|
+
* line's first character with a tab counting as one, so a wrapped line reads
|
|
2766
|
+
* `${indent} * ${text}` and never passes that count.
|
|
2767
|
+
*
|
|
2768
|
+
* @remarks
|
|
2769
|
+
* The budget counts characters, not rendered columns. A block indented with tabs therefore
|
|
2770
|
+
* measures each tab as one character, and a formatter that renders a tab wider reads the same
|
|
2771
|
+
* line as longer; a caller whose formatter measures differently passes its own width instead of
|
|
2772
|
+
* taking this default. A doc block's own wrapping is not recoverable from its text either — the
|
|
2773
|
+
* blocks this package's own source carries are hand-wrapped, and no single greedy width
|
|
2774
|
+
* reproduces them — so a rewrite cannot infer a per-block width and falls back to this budget.
|
|
2775
|
+
*/
|
|
2776
|
+
export declare const WRAP_WIDTH: number;
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* Wraps one paragraph into greedy lines no longer than `width` characters. Every run of
|
|
2780
|
+
* whitespace separates words, and a word longer than `width` takes its own line rather than
|
|
2781
|
+
* being split, so a long code token or URL survives the wrap intact.
|
|
2782
|
+
*
|
|
2783
|
+
* @param text - The paragraph to wrap
|
|
2784
|
+
* @param width - The greatest length a returned line may reach
|
|
2785
|
+
* @returns The wrapped lines, in order, or an empty list when `text` carries no word
|
|
2786
|
+
*
|
|
2787
|
+
* @example
|
|
2788
|
+
* ```ts
|
|
2789
|
+
* wrapText('one two three', 8) // ['one two', 'three']
|
|
2790
|
+
* ```
|
|
2791
|
+
*/
|
|
2792
|
+
export declare function wrapText(text: string, width: number): readonly string[];
|
|
2793
|
+
|
|
1381
2794
|
export { }
|