@orkestrel/guide 0.0.14 → 0.0.16
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 +12 -12
- package/dist/src/core/index.cjs +323 -229
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +528 -351
- package/dist/src/core/index.d.ts +528 -351
- package/dist/src/core/index.js +306 -214
- package/dist/src/core/index.js.map +1 -1
- package/package.json +10 -11
package/dist/src/core/index.d.ts
CHANGED
|
@@ -11,20 +11,37 @@ import { TableNode } from '@orkestrel/markdown';
|
|
|
11
11
|
import { UnionShape } from '@orkestrel/contract';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Computes the stable cache key for a {@link GuideModule}. Directories normalize before
|
|
15
|
+
* joining, so equivalent module spellings share one key. The NUL separator
|
|
16
|
+
* cannot occur in filesystem-backed canonical-segment inventory keys, so no
|
|
17
|
+
* directory boundary can collide with directory text.
|
|
15
18
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns The
|
|
19
|
+
* @param module - The module scope to key
|
|
20
|
+
* @returns The normalized directories joined by NUL
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* computeModuleKey(['src/core', 'src/browser']) // 'src/core\0src/browser'
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function computeModuleKey(module: GuideModule): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the bijection key for a surface symbol — its keyword and name combined — so a
|
|
31
|
+
* symbol-set comparison diffs (name, keyword) pairs rather than names alone.
|
|
32
|
+
*
|
|
33
|
+
* @param symbol - The symbol to key
|
|
34
|
+
* @returns The `${keyword} ${name}` key
|
|
18
35
|
*
|
|
19
36
|
* @example
|
|
20
37
|
* ```ts
|
|
21
|
-
*
|
|
38
|
+
* computeSymbolKey({ name: 'Markdown', keyword: 'class' }) // 'class Markdown'
|
|
22
39
|
* ```
|
|
23
40
|
*/
|
|
24
|
-
export declare function
|
|
41
|
+
export declare function computeSymbolKey(symbol: SurfaceSymbol): string;
|
|
25
42
|
|
|
26
43
|
/**
|
|
27
|
-
*
|
|
44
|
+
* Creates a structured {@link GuideInterface} view over one guide's markdown
|
|
28
45
|
* source — parses once and caches its `sections` / `surface` / `methods` /
|
|
29
46
|
* `links` / `tests` / `fences` projections.
|
|
30
47
|
*
|
|
@@ -36,15 +53,15 @@ export declare function cellLinks(cell: readonly InlineNode[]): readonly string[
|
|
|
36
53
|
* import { createGuide } from '@orkestrel/guide'
|
|
37
54
|
*
|
|
38
55
|
* const guide = createGuide('## Surface\n\n| Name | Kind |\n| --- | --- |\n| `X` | class |')
|
|
39
|
-
* guide.surface() // [{ name: 'X',
|
|
56
|
+
* guide.surface() // [{ name: 'X', keyword: 'class' }]
|
|
40
57
|
* ```
|
|
41
58
|
*/
|
|
42
59
|
export declare function createGuide(source: string): GuideInterface;
|
|
43
60
|
|
|
44
61
|
/**
|
|
45
|
-
*
|
|
62
|
+
* Compiles the {@link manifestEntryShape} into a {@link ContractInterface} for
|
|
46
63
|
* {@link ManifestEntry} — a guard, coercing parser, JSON Schema, and seeded
|
|
47
|
-
* generator from one shape declaration (AGENTS §
|
|
64
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
48
65
|
*
|
|
49
66
|
* @returns A `ManifestEntry` contract bundling `schema` / `is` / `parse` / `generate`
|
|
50
67
|
*
|
|
@@ -59,9 +76,9 @@ export declare function createGuide(source: string): GuideInterface;
|
|
|
59
76
|
export declare function createManifestEntryContract(): ContractInterface<ManifestEntry>;
|
|
60
77
|
|
|
61
78
|
/**
|
|
62
|
-
*
|
|
79
|
+
* Compiles the {@link methodGroupShape} into a {@link ContractInterface} for
|
|
63
80
|
* {@link MethodGroup} — a guard, coercing parser, JSON Schema, and seeded
|
|
64
|
-
* generator from one shape declaration (AGENTS §
|
|
81
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
65
82
|
*
|
|
66
83
|
* @returns A `MethodGroup` contract bundling `schema` / `is` / `parse` / `generate`
|
|
67
84
|
*
|
|
@@ -76,7 +93,7 @@ export declare function createManifestEntryContract(): ContractInterface<Manifes
|
|
|
76
93
|
export declare function createMethodGroupContract(): ContractInterface<MethodGroup>;
|
|
77
94
|
|
|
78
95
|
/**
|
|
79
|
-
*
|
|
96
|
+
* Creates a pure {@link SourceInterface} over a consumer-supplied file
|
|
80
97
|
* inventory — see {@link Source}.
|
|
81
98
|
*
|
|
82
99
|
* @param options - The file inventory and module scope to reflect
|
|
@@ -90,13 +107,13 @@ export declare function createMethodGroupContract(): ContractInterface<MethodGro
|
|
|
90
107
|
* files: { 'src/core/Guide.ts': 'export class Guide {}\n' },
|
|
91
108
|
* module: 'src/core',
|
|
92
109
|
* })
|
|
93
|
-
* source.exports() // [{ name: 'Guide',
|
|
110
|
+
* source.exports() // [{ name: 'Guide', keyword: 'class' }]
|
|
94
111
|
* ```
|
|
95
112
|
*/
|
|
96
113
|
export declare function createSource(options: SourceOptions): SourceInterface;
|
|
97
114
|
|
|
98
115
|
/**
|
|
99
|
-
*
|
|
116
|
+
* Creates a {@link SourceManagerInterface} that resolves the consumer's local
|
|
100
117
|
* import specifiers and shares one source view per module.
|
|
101
118
|
*
|
|
102
119
|
* @param options - The shared file inventory and specifier-to-module policy
|
|
@@ -116,9 +133,9 @@ export declare function createSource(options: SourceOptions): SourceInterface;
|
|
|
116
133
|
export declare function createSourceManager(options: SourceManagerOptions): SourceManagerInterface;
|
|
117
134
|
|
|
118
135
|
/**
|
|
119
|
-
*
|
|
136
|
+
* Compiles the {@link surfaceSymbolShape} into a {@link ContractInterface} for
|
|
120
137
|
* {@link SurfaceSymbol} — a guard, coercing parser, JSON Schema, and seeded
|
|
121
|
-
* generator from one shape declaration (AGENTS §
|
|
138
|
+
* generator from one shape declaration (AGENTS.md § Design laws).
|
|
122
139
|
*
|
|
123
140
|
* @returns A `SurfaceSymbol` contract bundling `schema` / `is` / `parse` / `generate`
|
|
124
141
|
*
|
|
@@ -127,43 +144,163 @@ export declare function createSourceManager(options: SourceManagerOptions): Sour
|
|
|
127
144
|
* import { createSurfaceSymbolContract } from '@orkestrel/guide'
|
|
128
145
|
*
|
|
129
146
|
* const surfaceSymbol = createSurfaceSymbolContract()
|
|
130
|
-
* surfaceSymbol.is({ name: 'Markdown',
|
|
147
|
+
* surfaceSymbol.is({ name: 'Markdown', keyword: 'class' }) // true
|
|
131
148
|
* ```
|
|
132
149
|
*/
|
|
133
150
|
export declare function createSurfaceSymbolContract(): ContractInterface<SurfaceSymbol>;
|
|
134
151
|
|
|
135
152
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
153
|
+
* Represents one located `export class` / `export interface` declaration — the body lines
|
|
154
|
+
* and the base identifiers read from the same head, so a consumer never pairs
|
|
155
|
+
* one declaration's body with another declaration's heritage (see
|
|
156
|
+
* {@link extractDeclaration}).
|
|
157
|
+
*/
|
|
158
|
+
export declare interface Declaration {
|
|
159
|
+
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}`. */
|
|
160
|
+
readonly body: readonly string[];
|
|
161
|
+
/** Lists the base identifiers its head extends, in head order. */
|
|
162
|
+
readonly bases: readonly string[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Pairs a declaration head joined into a single line with the index of the line
|
|
167
|
+
* carrying its opening `{` — how a head that oxfmt wrapped across lines
|
|
168
|
+
* (printWidth 100) is matched as if it were written on one.
|
|
169
|
+
*/
|
|
170
|
+
export declare interface DeclarationHead {
|
|
171
|
+
/** Holds the joined, space-separated head text. */
|
|
172
|
+
readonly text: string;
|
|
173
|
+
/** Holds the index (within the source `lines`) of the line ending in `{`. */
|
|
174
|
+
readonly end: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Represents which declaration head {@link extractDeclaration} and {@link Source} locate —
|
|
179
|
+
* a `class` or an `interface`. That pair is the subset of {@link ExportKeyword}
|
|
180
|
+
* carrying a body whose members a guide's `## Methods` table documents.
|
|
181
|
+
*/
|
|
182
|
+
export declare type DeclarationKeyword = 'class' | 'interface';
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Escapes every regex metacharacter in a literal string so it reads as text
|
|
186
|
+
* inside a larger `RegExp` source rather than as syntax.
|
|
187
|
+
*
|
|
188
|
+
* @remarks
|
|
189
|
+
* Every caller-supplied name reaches a `RegExp` through this: {@link
|
|
190
|
+
* extractDeclaration} splices it into the head grammar and {@link
|
|
191
|
+
* findUnexampled} into a word-boundary search, so a name carrying `$`, `(`,
|
|
192
|
+
* `[`, or `.` matches that character literally instead of throwing or matching
|
|
193
|
+
* text it does not name. Pure and total; never throws.
|
|
194
|
+
*
|
|
195
|
+
* @param value - The literal string to escape
|
|
196
|
+
* @returns `value` with every regex metacharacter backslash-escaped
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* escapeRegExp('A.B') // 'A\\.B'
|
|
201
|
+
* new RegExp(`^${escapeRegExp('A.B')}$`).test('AxB') // false
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function escapeRegExp(value: string): string;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Lists the declaration keywords a documented or exported symbol carries, in
|
|
208
|
+
* the order the reflection grammar names them.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* One frozen list feeds the `ExportKeyword` type, the `isExportKeyword` guard, and
|
|
212
|
+
* `surfaceSymbolShape`, so a keyword cannot be admitted by one and refused by
|
|
213
|
+
* another. Comment and template payload is excluded before reflection, and
|
|
214
|
+
* `enum` is outside this population rather than forbidden by general package
|
|
215
|
+
* policy.
|
|
216
|
+
*/
|
|
217
|
+
export declare const EXPORT_KEYWORDS: readonly ["type", "interface", "const", "function", "class"];
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Represents the declaration keyword a documented / exported symbol carries — the reflected
|
|
221
|
+
* `type`, `interface`, `const`, `function`, and `class` heads, derived from
|
|
222
|
+
* {@link EXPORT_KEYWORDS} so the type, the guard, and the shape name one
|
|
223
|
+
* population. Comment/template payload is excluded before reflection.
|
|
224
|
+
* `enum` is outside this population, not forbidden by general package policy.
|
|
225
|
+
*/
|
|
226
|
+
export declare type ExportKeyword = (typeof EXPORT_KEYWORDS)[number];
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Lists the link `href` schemes a guides-parity link check skips as external — a link
|
|
230
|
+
* with one of these prefixes (or a bare `#` anchor, handled separately in
|
|
231
|
+
* `isExternalLink`) is never resolved against the filesystem.
|
|
232
|
+
*/
|
|
233
|
+
export declare const EXTERNAL_SCHEMES: readonly string[];
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Extracts the link hrefs within one table cell's inline content.
|
|
237
|
+
*
|
|
238
|
+
* @param cell - The cell's inline nodes
|
|
239
|
+
* @returns The cell's link hrefs, in walk order
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* extractCellLinks([{ element: 'link', href: 'x.ts', children: [] }]) // ['x.ts']
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function extractCellLinks(cell: readonly InlineNode[]): readonly string[];
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Locates the named `export class` / `export interface` declaration in one
|
|
250
|
+
* file's source text and returns its body lines and its base identifiers read
|
|
251
|
+
* from that one head, so a body and a heritage clause always come from the same
|
|
252
|
+
* declaration.
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* The head is matched on projected lines (column 0, an oxfmt-wrapped signature
|
|
256
|
+
* joined through {@link joinHead}), with an optional generic parameter list and
|
|
257
|
+
* an optional heritage clause between the identifier and the opening `{`; the
|
|
258
|
+
* identifier matches exactly and is escaped through {@link escapeRegExp}, so a
|
|
259
|
+
* metacharacter in `name` is literal text. The returned body lines are the raw
|
|
260
|
+
* source between that head and the first projected column-zero `}`, keeping
|
|
261
|
+
* JSDoc evidence intact. Every balanced `<...>` span is removed from the head
|
|
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.
|
|
140
267
|
*
|
|
141
268
|
* @param source - The file's source text to search
|
|
142
269
|
* @param keyword - Whether to look for a `class` or an `interface`
|
|
143
270
|
* @param name - The declaration's identifier
|
|
144
|
-
* @returns
|
|
271
|
+
* @returns Its body and bases, or `undefined` when `source` declares no such head
|
|
145
272
|
*
|
|
146
273
|
* @example
|
|
147
274
|
* ```ts
|
|
148
|
-
*
|
|
275
|
+
* extractDeclaration('export interface X extends Y {\n\twalk(): void\n}\n', 'interface', 'X')
|
|
276
|
+
* // { body: ['\twalk(): void'], bases: ['Y'] }
|
|
149
277
|
* ```
|
|
150
278
|
*/
|
|
151
|
-
export declare function
|
|
279
|
+
export declare function extractDeclaration(source: string, keyword: DeclarationKeyword, name: string): Declaration | undefined;
|
|
152
280
|
|
|
153
281
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
282
|
+
* Selects the next physical record after an eligible genuine JSDoc whose final
|
|
283
|
+
* authoritative span carries an exact block-position `@example` tag. Title
|
|
284
|
+
* text is allowed. A leading whitespace-separated span chain is last-span
|
|
285
|
+
* authoritative; intervening source material severs association, while a
|
|
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.
|
|
290
|
+
*
|
|
291
|
+
* @param lines - Aligned physical source-line records
|
|
292
|
+
* @returns The immediately following candidate lines, in source order
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* extractExampleLines(extractSourceLines('/** @example *' + '/\nexport function walk() {}'))
|
|
297
|
+
* // the `export function walk() {}` SourceLine
|
|
298
|
+
* ```
|
|
157
299
|
*/
|
|
158
|
-
export declare
|
|
159
|
-
/** The joined, space-separated head text. */
|
|
160
|
-
readonly text: string;
|
|
161
|
-
/** The index (within the source `lines`) of the line ending in `{`. */
|
|
162
|
-
readonly end: number;
|
|
163
|
-
}
|
|
300
|
+
export declare function extractExampleLines(lines: readonly SourceLine[]): readonly SourceLine[];
|
|
164
301
|
|
|
165
302
|
/**
|
|
166
|
-
*
|
|
303
|
+
* Extracts the callable-member names in a declaration body (per {@link extractMemberMethods}'
|
|
167
304
|
* grammar) whose immediately preceding eligible genuine JSDoc block, within
|
|
168
305
|
* the same body, carries `@example`. Shared adjacency comes from
|
|
169
306
|
* {@link extractExampleLines}; member membership is matched against aligned
|
|
@@ -174,13 +311,13 @@ export declare interface DeclarationHead {
|
|
|
174
311
|
*
|
|
175
312
|
* @example
|
|
176
313
|
* ```ts
|
|
177
|
-
*
|
|
314
|
+
* extractExampleMethods(['\t/**', '\t * @example', '\t *' + '/', '\twalk(): void']) // ['walk']
|
|
178
315
|
* ```
|
|
179
316
|
*/
|
|
180
|
-
export declare function
|
|
317
|
+
export declare function extractExampleMethods(lines: readonly string[]): readonly string[];
|
|
181
318
|
|
|
182
319
|
/**
|
|
183
|
-
*
|
|
320
|
+
* Extracts the exported functions in one file's source text whose immediately preceding
|
|
184
321
|
* eligible genuine JSDoc block carries `@example`. Shared adjacency comes from
|
|
185
322
|
* {@link extractExampleLines}; exported-function membership is matched against
|
|
186
323
|
* the aligned code projection, so comment and template payload cannot qualify.
|
|
@@ -191,25 +328,18 @@ export declare function exampleMethods(lines: readonly string[]): readonly strin
|
|
|
191
328
|
* @example
|
|
192
329
|
* ```ts
|
|
193
330
|
* const block = ['/**', ' * @example', ' *' + '/', 'export function walk() {}', ''].join('\n')
|
|
194
|
-
*
|
|
195
|
-
*
|
|
331
|
+
* extractExamples(block) // ['walk']
|
|
332
|
+
* extractExamples('export function walk() {}\n') // []
|
|
196
333
|
* ```
|
|
197
334
|
*/
|
|
198
|
-
export declare function
|
|
335
|
+
export declare function extractExamples(source: string): readonly string[];
|
|
199
336
|
|
|
200
337
|
/**
|
|
201
|
-
*
|
|
202
|
-
* five reflected `type`, `interface`, `const`, `function`, and `class` heads.
|
|
203
|
-
* Comment/template payload is excluded before reflection. `enum` is outside
|
|
204
|
-
* this population, not forbidden by general package policy.
|
|
205
|
-
*/
|
|
206
|
-
export declare type ExportKind = 'type' | 'interface' | 'const' | 'function' | 'class';
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* The module-scope exports declared in one file's source text — matches
|
|
338
|
+
* Extracts the module-scope exports declared in one file's source text — matches
|
|
210
339
|
* `export (async)? (function(\*)?|class|const|interface|type) Name`, deduped
|
|
211
|
-
* by (
|
|
212
|
-
* `function` — its trailing `*` is stripped before the
|
|
340
|
+
* by (keyword, name). A generator export (`export function* walk`) scans as the
|
|
341
|
+
* `function` keyword — its trailing `*` is stripped before the
|
|
342
|
+
* {@link ExportKeyword} check.
|
|
213
343
|
* Scanning uses {@link extractSourceLines}, so comment and template payload is
|
|
214
344
|
* excluded while its uninterrupted column-zero head remains required; preserved
|
|
215
345
|
* columns do not grant membership to leading/interrupted comment forms. The population is
|
|
@@ -221,42 +351,30 @@ export declare type ExportKind = 'type' | 'interface' | 'const' | 'function' | '
|
|
|
221
351
|
*
|
|
222
352
|
* @example
|
|
223
353
|
* ```ts
|
|
224
|
-
*
|
|
225
|
-
*
|
|
354
|
+
* extractExports('export class Markdown {}\n') // [{ name: 'Markdown', keyword: 'class' }]
|
|
355
|
+
* extractExports('export function* walk() {}\n') // [{ name: 'walk', keyword: 'function' }]
|
|
226
356
|
* ```
|
|
227
357
|
*/
|
|
228
|
-
export declare function
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* The link `href` schemes a guides-parity link check skips as external — a link
|
|
232
|
-
* with one of these prefixes (or a bare `#` anchor, handled separately in
|
|
233
|
-
* `isExternalLink`) is never resolved against the filesystem.
|
|
234
|
-
*/
|
|
235
|
-
export declare const EXTERNAL_SCHEMES: readonly string[];
|
|
358
|
+
export declare function extractExports(source: string): readonly SurfaceSymbol[];
|
|
236
359
|
|
|
237
360
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* leading JSDoc on the next record replaces pending state. Any other next
|
|
243
|
-
* physical record is returned once and consumes it. This parser walks aligned
|
|
244
|
-
* records without rescanning source syntax or applying declaration/member
|
|
245
|
-
* grammar.
|
|
361
|
+
* Parses a fence's `import` statements into per-specifier imported identifier
|
|
362
|
+
* names — handles `import type`, mixed multiline braces, and `x as y` aliases,
|
|
363
|
+
* resolving each alias to the exported name `x` because that is the name the
|
|
364
|
+
* checked barrel surface must hold.
|
|
246
365
|
*
|
|
247
|
-
* @param
|
|
248
|
-
* @returns
|
|
366
|
+
* @param fence - A ```ts Patterns fence's verbatim body text
|
|
367
|
+
* @returns One entry per `import ... from 'specifier'` statement, in fence order
|
|
249
368
|
*
|
|
250
369
|
* @example
|
|
251
370
|
* ```ts
|
|
252
|
-
*
|
|
253
|
-
* // the `export function walk() {}` SourceLine
|
|
371
|
+
* extractFenceImports("import { a, b as c } from 'x'\n") // [{ specifier: 'x', names: ['a', 'b'] }]
|
|
254
372
|
* ```
|
|
255
373
|
*/
|
|
256
|
-
export declare function
|
|
374
|
+
export declare function extractFenceImports(fence: string): readonly FenceImport[];
|
|
257
375
|
|
|
258
376
|
/**
|
|
259
|
-
*
|
|
377
|
+
* Extracts every fenced code block anywhere in the guide document. A full AST walk
|
|
260
378
|
* includes fences nested inside blockquotes and lists.
|
|
261
379
|
*
|
|
262
380
|
* @param document - The parsed guide document
|
|
@@ -270,7 +388,30 @@ export declare function extractExampleLines(lines: readonly SourceLine[]): reado
|
|
|
270
388
|
export declare function extractFences(document: MarkdownDocument): readonly GuideFence[];
|
|
271
389
|
|
|
272
390
|
/**
|
|
273
|
-
*
|
|
391
|
+
* Extracts the module-scope declarations lacking the `export` keyword in one file's
|
|
392
|
+
* source text — the mirror image of {@link extractExports}'s grammar, anchored
|
|
393
|
+
* the same way (column 0, so an indented inner declaration never matches).
|
|
394
|
+
* Scans only the {@link ExportKeyword} keywords (`function` / `class` /
|
|
395
|
+
* `const` / `interface` / `type`) — a module-scope `let` or `var` is outside
|
|
396
|
+
* this scanner's declaration-keyword grammar and out of this check's contract.
|
|
397
|
+
* Scanning uses {@link extractSourceLines}, so comment
|
|
398
|
+
* and template payload is excluded while its uninterrupted column-zero head
|
|
399
|
+
* remains required; preserved columns do not widen membership. `enum` is likewise outside this reflection population, not
|
|
400
|
+
* forbidden by general package policy.
|
|
401
|
+
*
|
|
402
|
+
* @param source - The file's source text
|
|
403
|
+
* @returns The file's hidden (non-exported) symbols, in file order
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* extractHidden('function secretHelper() {}\n') // [{ name: 'secretHelper', keyword: 'function' }]
|
|
408
|
+
* extractHidden('export class X {}\n') // []
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
export declare function extractHidden(source: string): readonly SurfaceSymbol[];
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Extracts every link href in the guide document, including table cells — a full,
|
|
274
415
|
* depth-first walk of the whole AST.
|
|
275
416
|
*
|
|
276
417
|
* @param document - The parsed guide document
|
|
@@ -284,7 +425,24 @@ export declare function extractFences(document: MarkdownDocument): readonly Guid
|
|
|
284
425
|
export declare function extractLinks(document: MarkdownDocument): readonly string[];
|
|
285
426
|
|
|
286
427
|
/**
|
|
287
|
-
*
|
|
428
|
+
* Selects the member lines declaring a callable member: plain, `async`, generator
|
|
429
|
+
* (`*`), and optional (`records?(`) methods all count; getters, setters,
|
|
430
|
+
* `static` members, and `#` privates never do (their keyword or `#` breaks
|
|
431
|
+
* the `name(` shape). Matching runs once over projected lines so commented
|
|
432
|
+
* method-like payload never becomes eligible.
|
|
433
|
+
*
|
|
434
|
+
* @param lines - A declaration's body lines
|
|
435
|
+
* @returns The declared method names, deduped and sorted
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* extractMemberMethods(['\tmap(): void', '\tfilter(): void']) // ['filter', 'map']
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
export declare function extractMemberMethods(lines: readonly string[]): readonly string[];
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Extracts one {@link MethodGroup} per documented behavioral interface in `## Methods` —
|
|
288
446
|
* an H4 with a code span sets the current interface, and the table immediately
|
|
289
447
|
* following becomes its documented methods.
|
|
290
448
|
*
|
|
@@ -299,7 +457,7 @@ export declare function extractLinks(document: MarkdownDocument): readonly strin
|
|
|
299
457
|
export declare function extractMethods(document: MarkdownDocument): readonly MethodGroup[];
|
|
300
458
|
|
|
301
459
|
/**
|
|
302
|
-
*
|
|
460
|
+
* Extracts aligned physical source-line records in one character traversal.
|
|
303
461
|
* Real line and block comments and complete template tokens become spaces in
|
|
304
462
|
* {@link SourceLine.code}, while ordinary code, quoted strings, and recognized
|
|
305
463
|
* regex literals retain their columns. Genuine JSDoc opened from reflection
|
|
@@ -329,10 +487,10 @@ export declare function extractMethods(document: MarkdownDocument): readonly Met
|
|
|
329
487
|
export declare function extractSourceLines(source: string): readonly SourceLine[];
|
|
330
488
|
|
|
331
489
|
/**
|
|
332
|
-
*
|
|
490
|
+
* Extracts every `## Surface` identifier the guide documents — each table row's column 0
|
|
333
491
|
* code span (the name) paired with its `Kind` column (located by header text)
|
|
334
|
-
*
|
|
335
|
-
* (`{name: <codeSpan>,
|
|
492
|
+
* unioned with every backticked H3 entity heading in the section
|
|
493
|
+
* (`{name: <codeSpan>, keyword: 'class'}`), deduped by {@link computeSymbolKey}. A row with
|
|
336
494
|
* no code-span name, or an unrecognized `Kind` text, is skipped.
|
|
337
495
|
*
|
|
338
496
|
* @param document - The parsed guide document
|
|
@@ -340,13 +498,13 @@ export declare function extractSourceLines(source: string): readonly SourceLine[
|
|
|
340
498
|
*
|
|
341
499
|
* @example
|
|
342
500
|
* ```ts
|
|
343
|
-
* extractSurface(document) // [{ name: 'Markdown',
|
|
501
|
+
* extractSurface(document) // [{ name: 'Markdown', keyword: 'class' }, ...]
|
|
344
502
|
* ```
|
|
345
503
|
*/
|
|
346
504
|
export declare function extractSurface(document: MarkdownDocument): readonly SurfaceSymbol[];
|
|
347
505
|
|
|
348
506
|
/**
|
|
349
|
-
*
|
|
507
|
+
* Extracts the relative test links declared under `## Tests` — every link href found
|
|
350
508
|
* within that section only.
|
|
351
509
|
*
|
|
352
510
|
* @param document - The parsed guide document
|
|
@@ -360,26 +518,48 @@ export declare function extractSurface(document: MarkdownDocument): readonly Sur
|
|
|
360
518
|
export declare function extractTests(document: MarkdownDocument): readonly string[];
|
|
361
519
|
|
|
362
520
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
|
|
366
|
-
|
|
521
|
+
* Represents one brace `import` statement projected from a guide fence — its specifier
|
|
522
|
+
* paired with the exported names it binds.
|
|
523
|
+
*/
|
|
524
|
+
export declare interface FenceImport {
|
|
525
|
+
/** Names the module specifier the statement imports from. */
|
|
526
|
+
readonly specifier: string;
|
|
527
|
+
/** Lists the imported names, each alias resolved to the original exported name. */
|
|
528
|
+
readonly names: readonly string[];
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Finds the first code-span value by descending an inline node list, following
|
|
533
|
+
* into `emphasis` / `link` / `image` children — the extraction rule behind a
|
|
534
|
+
* Surface or Methods table row's first-column identifier.
|
|
367
535
|
*
|
|
368
|
-
* @param
|
|
369
|
-
* @returns
|
|
536
|
+
* @param nodes - The inline nodes to search
|
|
537
|
+
* @returns The first code span's literal text, or `undefined` when none is found
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* findFirstCode([{ element: 'codeSpan', value: 'Markdown' }]) // 'Markdown'
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
export declare function findFirstCode(nodes: readonly InlineNode[]): string | undefined;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Finds the index of a table's `Kind` column by its header text so it survives
|
|
548
|
+
* column reordering. The match is exact and case-sensitive (`'Kind'`) — a table
|
|
549
|
+
* without that exact header contributes no symbols to the surface it feeds.
|
|
550
|
+
*
|
|
551
|
+
* @param table - The table to inspect
|
|
552
|
+
* @returns The `Kind` column's index, or `undefined` when the table has no `Kind` header
|
|
370
553
|
*
|
|
371
554
|
* @example
|
|
372
555
|
* ```ts
|
|
373
|
-
*
|
|
556
|
+
* findKindIndex(table) // 1, or undefined
|
|
374
557
|
* ```
|
|
375
558
|
*/
|
|
376
|
-
export declare function
|
|
377
|
-
specifier: string;
|
|
378
|
-
names: readonly string[];
|
|
379
|
-
}>;
|
|
559
|
+
export declare function findKindIndex(table: TableNode): number | undefined;
|
|
380
560
|
|
|
381
561
|
/**
|
|
382
|
-
*
|
|
562
|
+
* Finds the names present in `names` but absent from `source` — the set-difference
|
|
383
563
|
* behind a both-directions bijection assertion.
|
|
384
564
|
*
|
|
385
565
|
* @param names - The candidate names
|
|
@@ -394,7 +574,23 @@ export declare function fenceImports(fence: string): ReadonlyArray<{
|
|
|
394
574
|
export declare function findMissing(names: readonly string[], source: readonly string[]): readonly string[];
|
|
395
575
|
|
|
396
576
|
/**
|
|
397
|
-
*
|
|
577
|
+
* Finds the symbol-key set-difference between two symbol lists — `symbols` present but
|
|
578
|
+
* absent from `source`, compared by {@link computeSymbolKey} so a symbol can drift in
|
|
579
|
+
* neither name nor keyword.
|
|
580
|
+
*
|
|
581
|
+
* @param symbols - The candidate symbols
|
|
582
|
+
* @param source - The symbols to compare against
|
|
583
|
+
* @returns The symbol keys in `symbols` that are not in `source`
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* findMissingSymbols([{ name: 'X', keyword: 'class' }], []) // ['class X']
|
|
588
|
+
* ```
|
|
589
|
+
*/
|
|
590
|
+
export declare function findMissingSymbols(symbols: readonly SurfaceSymbol[], source: readonly SurfaceSymbol[]): readonly string[];
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Finds the names in `names` that have no example — a fence containing the name at a
|
|
398
594
|
* word boundary in `fences`, or a membership in `examples`, both count as
|
|
399
595
|
* "has an example"; presence-only, fence and JSDoc content are never checked.
|
|
400
596
|
*
|
|
@@ -412,7 +608,7 @@ export declare function findMissing(names: readonly string[], source: readonly s
|
|
|
412
608
|
export declare function findUnexampled(names: readonly string[], fences: readonly string[], examples: readonly string[]): readonly string[];
|
|
413
609
|
|
|
414
610
|
/**
|
|
415
|
-
*
|
|
611
|
+
* Finds the fences whose language is absent from the caller's listed languages.
|
|
416
612
|
* Untagged fences are always returned because they have no language to list.
|
|
417
613
|
*
|
|
418
614
|
* @param fences - The guide fences to check
|
|
@@ -428,37 +624,22 @@ export declare function findUnexampled(names: readonly string[], fences: readonl
|
|
|
428
624
|
export declare function findUnlisted(fences: readonly GuideFence[], languages: readonly string[]): readonly GuideFence[];
|
|
429
625
|
|
|
430
626
|
/**
|
|
431
|
-
*
|
|
432
|
-
* into `emphasis` / `link` / `image` children — the extraction rule behind a
|
|
433
|
-
* Surface or Methods table row's first-column identifier.
|
|
434
|
-
*
|
|
435
|
-
* @param nodes - The inline nodes to search
|
|
436
|
-
* @returns The first code span's literal text, or `undefined` when none is found
|
|
437
|
-
*
|
|
438
|
-
* @example
|
|
439
|
-
* ```ts
|
|
440
|
-
* firstCode([{ element: 'codeSpan', value: 'Markdown' }]) // 'Markdown'
|
|
441
|
-
* ```
|
|
442
|
-
*/
|
|
443
|
-
export declare function firstCode(nodes: readonly InlineNode[]): string | undefined;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* A stateful, structured view over one parsed guide — the six documented
|
|
627
|
+
* Presents a pure, structured view over one parsed guide — the documented
|
|
447
628
|
* projections (`sections` / `surface` / `methods` / `links` / `tests` /
|
|
448
629
|
* `fences`) are extracted once at construction and cached.
|
|
449
630
|
*
|
|
450
631
|
* @remarks
|
|
451
|
-
*
|
|
452
|
-
* filesystem — `Guide`
|
|
453
|
-
*
|
|
454
|
-
* every call.
|
|
632
|
+
* Parses `source` once through `@orkestrel/markdown` and never touches the
|
|
633
|
+
* filesystem — `Guide` reads only the markdown text it is given and records
|
|
634
|
+
* nothing about where the guide came from. Every accessor returns the same
|
|
635
|
+
* cached, readonly array on every call.
|
|
455
636
|
*
|
|
456
637
|
* @example
|
|
457
638
|
* ```ts
|
|
458
639
|
* import { Guide } from '@orkestrel/guide'
|
|
459
640
|
*
|
|
460
641
|
* const guide = new Guide('## Surface\n\n| Name | Kind |\n| --- | --- |\n| `X` | class |')
|
|
461
|
-
* guide.surface() // [{ name: 'X',
|
|
642
|
+
* guide.surface() // [{ name: 'X', keyword: 'class' }]
|
|
462
643
|
* ```
|
|
463
644
|
*/
|
|
464
645
|
export declare class Guide implements GuideInterface {
|
|
@@ -472,27 +653,42 @@ export declare class Guide implements GuideInterface {
|
|
|
472
653
|
fences(): readonly GuideFence[];
|
|
473
654
|
}
|
|
474
655
|
|
|
475
|
-
/**
|
|
656
|
+
/** Represents one fenced code block projected from a guide document. */
|
|
476
657
|
export declare interface GuideFence {
|
|
477
|
-
/**
|
|
658
|
+
/** Holds the info-string language tag, or `undefined` when the fence is untagged. */
|
|
478
659
|
readonly language: string | undefined;
|
|
479
|
-
/**
|
|
660
|
+
/** Holds the fence's verbatim code body. */
|
|
480
661
|
readonly code: string;
|
|
481
662
|
}
|
|
482
663
|
|
|
483
664
|
/**
|
|
484
|
-
*
|
|
665
|
+
* Represents the structured, pure view of one parsed guide — every projection extracted and
|
|
485
666
|
* cached once at construction (see {@link createGuide}).
|
|
486
667
|
*/
|
|
487
668
|
export declare interface GuideInterface {
|
|
488
|
-
/**
|
|
669
|
+
/**
|
|
670
|
+
* Lists the `##` heading names, in document order — the non-vacuousness guard for
|
|
671
|
+
* section presence.
|
|
672
|
+
*
|
|
673
|
+
* @returns The document's `##` heading names, in document order
|
|
674
|
+
*/
|
|
489
675
|
sections(): readonly string[];
|
|
490
|
-
/**
|
|
676
|
+
/**
|
|
677
|
+
* Lists every `## Surface` identifier + keyword — table rows union backticked entity headings.
|
|
678
|
+
*
|
|
679
|
+
* @returns The documented surface symbols, in encounter order
|
|
680
|
+
*/
|
|
491
681
|
surface(): readonly SurfaceSymbol[];
|
|
492
|
-
/**
|
|
682
|
+
/**
|
|
683
|
+
* Returns one {@link MethodGroup} per documented behavioral interface in `## Methods`.
|
|
684
|
+
*
|
|
685
|
+
* @returns One group per documented behavioral interface, in document order
|
|
686
|
+
*/
|
|
493
687
|
methods(): readonly MethodGroup[];
|
|
494
688
|
/**
|
|
495
|
-
*
|
|
689
|
+
* Lists every link href in the guide, including table cells.
|
|
690
|
+
*
|
|
691
|
+
* @returns Every link href in the guide, in walk order
|
|
496
692
|
*
|
|
497
693
|
* @example
|
|
498
694
|
* ```ts
|
|
@@ -501,7 +697,9 @@ export declare interface GuideInterface {
|
|
|
501
697
|
*/
|
|
502
698
|
links(): readonly string[];
|
|
503
699
|
/**
|
|
504
|
-
*
|
|
700
|
+
* Lists the relative test links declared under `## Tests`.
|
|
701
|
+
*
|
|
702
|
+
* @returns The `## Tests` section's link hrefs, in walk order
|
|
505
703
|
*
|
|
506
704
|
* @example
|
|
507
705
|
* ```ts
|
|
@@ -510,9 +708,11 @@ export declare interface GuideInterface {
|
|
|
510
708
|
*/
|
|
511
709
|
tests(): readonly string[];
|
|
512
710
|
/**
|
|
513
|
-
*
|
|
711
|
+
* Lists every fenced code block in the whole document, in document order — no
|
|
514
712
|
* language filter, so a consumer decides which languages its checks read.
|
|
515
713
|
*
|
|
714
|
+
* @returns Every fence's language and verbatim code, in document order
|
|
715
|
+
*
|
|
516
716
|
* @example
|
|
517
717
|
* ```ts
|
|
518
718
|
* guide.fences() // [{ language: 'ts', code: "import { createGuide } from '@orkestrel/guide'" }]
|
|
@@ -522,7 +722,7 @@ export declare interface GuideInterface {
|
|
|
522
722
|
}
|
|
523
723
|
|
|
524
724
|
/**
|
|
525
|
-
*
|
|
725
|
+
* Represents the source scope a guide's manifest entry covers — one module directory, or
|
|
526
726
|
* several when a layer guide spans multiple source directories (a core module
|
|
527
727
|
* plus its backend implementations). `'.'` is the canonical workspace-root
|
|
528
728
|
* directory; empty, trailing-slash, and dot-segment spellings canonicalize to
|
|
@@ -531,12 +731,12 @@ export declare interface GuideInterface {
|
|
|
531
731
|
export declare type GuideModule = string | readonly string[];
|
|
532
732
|
|
|
533
733
|
/**
|
|
534
|
-
*
|
|
734
|
+
* Checks whether an opaque inventory key contains only canonical slash-separated
|
|
535
735
|
* segments. Empty, `.` and `..` segments are rejected without rewriting the
|
|
536
736
|
* key; ordinary dotfile segments remain valid.
|
|
537
737
|
*
|
|
538
738
|
* @param key - The opaque inventory key to inspect
|
|
539
|
-
* @returns
|
|
739
|
+
* @returns True if every segment is canonical; false otherwise
|
|
540
740
|
*
|
|
541
741
|
* @example
|
|
542
742
|
* ```ts
|
|
@@ -547,68 +747,27 @@ export declare type GuideModule = string | readonly string[];
|
|
|
547
747
|
export declare function hasCanonicalSegments(key: string): boolean;
|
|
548
748
|
|
|
549
749
|
/**
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
* Scans only the five {@link ExportKind} keywords (`function` / `class` /
|
|
554
|
-
* `const` / `interface` / `type`) — a module-scope `let` or `var` is a
|
|
555
|
-
* different violation class (AGENTS §1 bans `var`; a bare `let` is not a
|
|
556
|
-
* declaration kind this scanner's five-kind grammar covers) and is out of
|
|
557
|
-
* this check's contract. Scanning uses {@link extractSourceLines}, so comment
|
|
558
|
-
* and template payload is excluded while its uninterrupted column-zero head
|
|
559
|
-
* remains required; preserved columns do not widen membership. `enum` is likewise outside this reflection population, not
|
|
560
|
-
* forbidden by general package policy.
|
|
561
|
-
*
|
|
562
|
-
* @param source - The file's source text
|
|
563
|
-
* @returns The file's hidden (non-exported) symbols, in file order
|
|
564
|
-
*
|
|
565
|
-
* @example
|
|
566
|
-
* ```ts
|
|
567
|
-
* hiddenFrom('function secretHelper() {}\n') // [{ name: 'secretHelper', kind: 'function' }]
|
|
568
|
-
* hiddenFrom('export class X {}\n') // []
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
export declare function hiddenFrom(source: string): readonly SurfaceSymbol[];
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* The identifier prefix of a code-span text — everything before its first `<`,
|
|
575
|
-
* trimmed. Guide cells and headings may annotate a generic-parameterized name
|
|
576
|
-
* (`MarkdownHandler<TNode, T>`) for readability, but the bijection key is the
|
|
577
|
-
* bare identifier the source scanner captures, so both sides must normalize
|
|
578
|
-
* the same way.
|
|
579
|
-
*
|
|
580
|
-
* @param code - A code span's literal text
|
|
581
|
-
* @returns The identifier prefix, or an empty string when `code` is empty
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```ts
|
|
585
|
-
* identifierOf('MarkdownHandler<TNode, T>') // 'MarkdownHandler'
|
|
586
|
-
* identifierOf('fold') // 'fold'
|
|
587
|
-
* ```
|
|
588
|
-
*/
|
|
589
|
-
export declare function identifierOf(code: string): string;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Whether `value` is one of the five documented {@link ExportKind} literals — the
|
|
593
|
-
* guard behind extracting a Surface table's `Kind` cell into a typed symbol.
|
|
750
|
+
* Checks whether `value` is one of the documented {@link ExportKeyword}
|
|
751
|
+
* literals — the guard behind extracting a Surface table's `Kind` cell into a
|
|
752
|
+
* typed symbol.
|
|
594
753
|
*
|
|
595
754
|
* @param value - The candidate value
|
|
596
|
-
* @returns
|
|
755
|
+
* @returns True if `value` is a valid {@link ExportKeyword}; false otherwise
|
|
597
756
|
*
|
|
598
757
|
* @example
|
|
599
758
|
* ```ts
|
|
600
|
-
*
|
|
601
|
-
*
|
|
759
|
+
* isExportKeyword('class') // true
|
|
760
|
+
* isExportKeyword('enum') // false
|
|
602
761
|
* ```
|
|
603
762
|
*/
|
|
604
|
-
export declare const
|
|
763
|
+
export declare const isExportKeyword: Guard<ExportKeyword>;
|
|
605
764
|
|
|
606
765
|
/**
|
|
607
|
-
*
|
|
608
|
-
*
|
|
766
|
+
* Checks whether a guides-parity link check skips a link `href` — an external
|
|
767
|
+
* scheme ({@link EXTERNAL_SCHEMES}) or a bare in-document `#` anchor.
|
|
609
768
|
*
|
|
610
769
|
* @param href - The link destination
|
|
611
|
-
* @returns
|
|
770
|
+
* @returns True if a link check leaves the href unresolved against the filesystem; false otherwise
|
|
612
771
|
*
|
|
613
772
|
* @example
|
|
614
773
|
* ```ts
|
|
@@ -619,11 +778,12 @@ export declare const isExportKind: Guard<ExportKind>;
|
|
|
619
778
|
export declare function isExternalLink(href: string): boolean;
|
|
620
779
|
|
|
621
780
|
/**
|
|
622
|
-
*
|
|
623
|
-
* manifest row, its `source` accepting either a single directory
|
|
781
|
+
* Checks whether `value` is a well-formed {@link ManifestEntry} — a
|
|
782
|
+
* `## By concept` manifest row, its `source` accepting either a single directory
|
|
783
|
+
* or several.
|
|
624
784
|
*
|
|
625
785
|
* @param value - The value to test
|
|
626
|
-
* @returns
|
|
786
|
+
* @returns True if `value` is a well-formed {@link ManifestEntry}; false otherwise
|
|
627
787
|
*
|
|
628
788
|
* @example
|
|
629
789
|
* ```ts
|
|
@@ -634,11 +794,11 @@ export declare function isExternalLink(href: string): boolean;
|
|
|
634
794
|
export declare const isManifestEntry: Guard<ManifestEntry>;
|
|
635
795
|
|
|
636
796
|
/**
|
|
637
|
-
*
|
|
797
|
+
* Checks whether `value` is a well-formed {@link MethodGroup} — a backticked
|
|
638
798
|
* `interface` name paired with its documented `methods`.
|
|
639
799
|
*
|
|
640
800
|
* @param value - The value to test
|
|
641
|
-
* @returns
|
|
801
|
+
* @returns True if `value` is a well-formed {@link MethodGroup}; false otherwise
|
|
642
802
|
*
|
|
643
803
|
* @example
|
|
644
804
|
* ```ts
|
|
@@ -649,22 +809,22 @@ export declare const isManifestEntry: Guard<ManifestEntry>;
|
|
|
649
809
|
export declare const isMethodGroup: Guard<MethodGroup>;
|
|
650
810
|
|
|
651
811
|
/**
|
|
652
|
-
*
|
|
653
|
-
* paired with a valid {@link
|
|
812
|
+
* Checks whether `value` is a well-formed {@link SurfaceSymbol} — a `name`
|
|
813
|
+
* string paired with a valid {@link ExportKeyword}.
|
|
654
814
|
*
|
|
655
815
|
* @param value - The value to test
|
|
656
|
-
* @returns
|
|
816
|
+
* @returns True if `value` is a well-formed {@link SurfaceSymbol}; false otherwise
|
|
657
817
|
*
|
|
658
818
|
* @example
|
|
659
819
|
* ```ts
|
|
660
|
-
* isSurfaceSymbol({ name: 'Markdown',
|
|
661
|
-
* isSurfaceSymbol({ name: 'Markdown',
|
|
820
|
+
* isSurfaceSymbol({ name: 'Markdown', keyword: 'class' }) // true
|
|
821
|
+
* isSurfaceSymbol({ name: 'Markdown', keyword: 'enum' }) // false
|
|
662
822
|
* ```
|
|
663
823
|
*/
|
|
664
824
|
export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
665
825
|
|
|
666
826
|
/**
|
|
667
|
-
*
|
|
827
|
+
* Joins the declaration head starting at `start` into one space-separated
|
|
668
828
|
* line, consuming lines until the first that ends with `{`.
|
|
669
829
|
*
|
|
670
830
|
* @param lines - The file's source lines
|
|
@@ -679,43 +839,28 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
679
839
|
export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
|
|
680
840
|
|
|
681
841
|
/**
|
|
682
|
-
*
|
|
683
|
-
* column reordering. The match is exact and case-sensitive (`'Kind'`) — a table
|
|
684
|
-
* without that exact header contributes no symbols to the surface it feeds.
|
|
685
|
-
*
|
|
686
|
-
* @param table - The table to inspect
|
|
687
|
-
* @returns The `Kind` column's index, or `undefined` when the table has no `Kind` header
|
|
688
|
-
*
|
|
689
|
-
* @example
|
|
690
|
-
* ```ts
|
|
691
|
-
* kindIndex(table) // 1, or undefined
|
|
692
|
-
* ```
|
|
693
|
-
*/
|
|
694
|
-
export declare function kindIndex(table: TableNode): number | undefined;
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* The `## By concept` heading text the manifest's run-map table is keyed on.
|
|
842
|
+
* Names the `## By concept` heading text the manifest's run-map table is keyed on.
|
|
698
843
|
*/
|
|
699
844
|
export declare const MANIFEST: string;
|
|
700
845
|
|
|
701
846
|
/**
|
|
702
|
-
*
|
|
847
|
+
* Represents one `## By concept` manifest row — a single guides-parity check target, paths
|
|
703
848
|
* normalized to workspace root.
|
|
704
849
|
*/
|
|
705
850
|
export declare interface ManifestEntry {
|
|
706
|
-
/**
|
|
851
|
+
/** Holds the concept name — the row's first cell, flattened. */
|
|
707
852
|
readonly concept: string;
|
|
708
|
-
/**
|
|
853
|
+
/** Names the guide `.md` this entry documents, root-relative. */
|
|
709
854
|
readonly spec: string;
|
|
710
|
-
/**
|
|
855
|
+
/** Names the source directory (or directories) the guide documents. */
|
|
711
856
|
readonly source: GuideModule;
|
|
712
|
-
/**
|
|
857
|
+
/** Names the tests directory the guide's `## Tests` links resolve against. */
|
|
713
858
|
readonly tests: string;
|
|
714
859
|
}
|
|
715
860
|
|
|
716
861
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
862
|
+
* Shapes a {@link ManifestEntry} — one `## By concept` manifest row, `source`
|
|
863
|
+
* accepting either a single directory or several.
|
|
719
864
|
*
|
|
720
865
|
* @example
|
|
721
866
|
* ```ts
|
|
@@ -734,36 +879,19 @@ export declare const manifestEntryShape: ObjectShape<{
|
|
|
734
879
|
}, false>;
|
|
735
880
|
|
|
736
881
|
/**
|
|
737
|
-
*
|
|
738
|
-
* (`*`), and optional (`records?(`) methods all count; getters, setters,
|
|
739
|
-
* `static` members, and `#` privates never do (their keyword or `#` breaks
|
|
740
|
-
* the `name(` shape). Matching runs once over projected lines so commented
|
|
741
|
-
* method-like payload never becomes eligible.
|
|
742
|
-
*
|
|
743
|
-
* @param lines - A declaration's body lines
|
|
744
|
-
* @returns The declared method names, deduped and sorted
|
|
745
|
-
*
|
|
746
|
-
* @example
|
|
747
|
-
* ```ts
|
|
748
|
-
* memberMethods(['\tmap(): void', '\tfilter(): void']) // ['filter', 'map']
|
|
749
|
-
* ```
|
|
750
|
-
*/
|
|
751
|
-
export declare function memberMethods(lines: readonly string[]): readonly string[];
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* One `#### \`Interface\`` block in a guide's `## Methods` section — the
|
|
882
|
+
* Represents one `#### \`Interface\`` block in a guide's `## Methods` section — the
|
|
755
883
|
* documented member names of one behavioral interface.
|
|
756
884
|
*/
|
|
757
885
|
export declare interface MethodGroup {
|
|
758
|
-
/**
|
|
886
|
+
/** Holds the backticked interface name. */
|
|
759
887
|
readonly interface: string;
|
|
760
|
-
/**
|
|
888
|
+
/** Lists the group's documented Method-cell identifiers, in table order. */
|
|
761
889
|
readonly methods: readonly string[];
|
|
762
890
|
}
|
|
763
891
|
|
|
764
892
|
/**
|
|
765
|
-
*
|
|
766
|
-
*
|
|
893
|
+
* Shapes a {@link MethodGroup} — a backticked `interface` name paired with
|
|
894
|
+
* its documented `methods`.
|
|
767
895
|
*
|
|
768
896
|
* @example
|
|
769
897
|
* ```ts
|
|
@@ -780,60 +908,46 @@ export declare const methodGroupShape: ObjectShape<{
|
|
|
780
908
|
}, false>;
|
|
781
909
|
|
|
782
910
|
/**
|
|
783
|
-
*
|
|
911
|
+
* Names the `## Methods` heading text a guide's documented interface-methods section is keyed on.
|
|
784
912
|
*/
|
|
785
913
|
export declare const METHODS: string;
|
|
786
914
|
|
|
787
915
|
/**
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
* @param symbols - The candidate symbols
|
|
793
|
-
* @param source - The symbols to compare against
|
|
794
|
-
* @returns The symbol keys in `symbols` that are not in `source`
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```ts
|
|
798
|
-
* missingSymbols([{ name: 'X', kind: 'class' }], []) // ['class X']
|
|
799
|
-
* ```
|
|
800
|
-
*/
|
|
801
|
-
export declare function missingSymbols(symbols: readonly SurfaceSymbol[], source: readonly SurfaceSymbol[]): readonly string[];
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* The stable cache key for a {@link GuideModule}. Directories normalize before
|
|
805
|
-
* joining, so equivalent module spellings share one key. The NUL separator
|
|
806
|
-
* cannot occur in filesystem-backed canonical-segment inventory keys, so no
|
|
807
|
-
* directory boundary can collide with directory text.
|
|
916
|
+
* Normalizes a module scope to its canonical directory list. `'.'` represents
|
|
917
|
+
* workspace root; empty, trailing, and dot-segment spellings reduce through
|
|
918
|
+
* {@link resolvePath}, and duplicates are removed in first-seen order.
|
|
808
919
|
*
|
|
809
|
-
* @param module - The module scope to
|
|
810
|
-
* @returns The
|
|
920
|
+
* @param module - The module scope to normalize
|
|
921
|
+
* @returns The directory list `module` denotes
|
|
811
922
|
*
|
|
812
923
|
* @example
|
|
813
924
|
* ```ts
|
|
814
|
-
*
|
|
925
|
+
* normalizeDirectories('src/core') // ['src/core']
|
|
926
|
+
* normalizeDirectories(['src/core', 'src/browser']) // ['src/core', 'src/browser']
|
|
815
927
|
* ```
|
|
816
928
|
*/
|
|
817
|
-
export declare function
|
|
929
|
+
export declare function normalizeDirectories(module: GuideModule): readonly string[];
|
|
818
930
|
|
|
819
931
|
/**
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
932
|
+
* Returns the identifier prefix of a code-span text — everything before its first `<`,
|
|
933
|
+
* trimmed. Guide cells and headings may annotate a generic-parameterized name
|
|
934
|
+
* (`MarkdownHandler<TNode, T>`) for readability, but the bijection key is the
|
|
935
|
+
* bare identifier the source scanner captures, so both sides must normalize
|
|
936
|
+
* the same way.
|
|
823
937
|
*
|
|
824
|
-
* @param
|
|
825
|
-
* @returns The
|
|
938
|
+
* @param code - A code span's literal text
|
|
939
|
+
* @returns The identifier prefix, or an empty string when `code` is empty
|
|
826
940
|
*
|
|
827
941
|
* @example
|
|
828
942
|
* ```ts
|
|
829
|
-
*
|
|
830
|
-
*
|
|
943
|
+
* normalizeIdentifier('MarkdownHandler<TNode, T>') // 'MarkdownHandler'
|
|
944
|
+
* normalizeIdentifier('fold') // 'fold'
|
|
831
945
|
* ```
|
|
832
946
|
*/
|
|
833
|
-
export declare function
|
|
947
|
+
export declare function normalizeIdentifier(code: string): string;
|
|
834
948
|
|
|
835
949
|
/**
|
|
836
|
-
*
|
|
950
|
+
* Parses a `## By concept` manifest table into its {@link ManifestEntry} rows —
|
|
837
951
|
* each row's Concept cell (flattened text), Spec / Tests cells (a single link
|
|
838
952
|
* href, resolved against `directory`), and Source cell (every link href,
|
|
839
953
|
* resolved against `directory`; Source links canonicalize through
|
|
@@ -841,7 +955,7 @@ export declare function normalizeDirectories(module: GuideModule): readonly stri
|
|
|
841
955
|
* a `readonly string[]`). A row missing a concept, spec link, tests link, or
|
|
842
956
|
* source link is skipped as malformed.
|
|
843
957
|
*
|
|
844
|
-
* @param markdown - The manifest markdown source
|
|
958
|
+
* @param markdown - The manifest markdown source, for example the content of `guides/README.md`
|
|
845
959
|
* @param directory - The root-relative directory containing the manifest
|
|
846
960
|
* @returns The manifest's entries, in row order
|
|
847
961
|
*
|
|
@@ -853,7 +967,7 @@ export declare function normalizeDirectories(module: GuideModule): readonly stri
|
|
|
853
967
|
export declare function parseManifest(markdown: string, directory: string): readonly ManifestEntry[];
|
|
854
968
|
|
|
855
969
|
/**
|
|
856
|
-
*
|
|
970
|
+
* Resolves a relative `target` from the directory containing a root-relative
|
|
857
971
|
* declaring `file`. A slashless file belongs to the workspace root; path
|
|
858
972
|
* reduction is delegated to {@link resolvePath}.
|
|
859
973
|
*
|
|
@@ -870,7 +984,7 @@ export declare function parseManifest(markdown: string, directory: string): read
|
|
|
870
984
|
export declare function resolveLink(file: string, target: string): string;
|
|
871
985
|
|
|
872
986
|
/**
|
|
873
|
-
*
|
|
987
|
+
* Resolves a relative `target` from a root-relative `directory`, normalizing
|
|
874
988
|
* forward-slash dot segments without filesystem or extension inference. A
|
|
875
989
|
* parent pops only a retained real component; every excess leading parent is
|
|
876
990
|
* preserved.
|
|
@@ -888,23 +1002,7 @@ export declare function resolveLink(file: string, target: string): string;
|
|
|
888
1002
|
export declare function resolvePath(directory: string, target: string): string;
|
|
889
1003
|
|
|
890
1004
|
/**
|
|
891
|
-
*
|
|
892
|
-
* heading (or the document's end) — the section-scoping window `extractSurface` /
|
|
893
|
-
* `extractMethods` walk over.
|
|
894
|
-
*
|
|
895
|
-
* @param document - The parsed guide document
|
|
896
|
-
* @param heading - The `##` heading text to scope to (e.g. `Surface`)
|
|
897
|
-
* @returns The blocks belonging to that section, in document order
|
|
898
|
-
*
|
|
899
|
-
* @example
|
|
900
|
-
* ```ts
|
|
901
|
-
* sectionBlocks(document, 'Surface') // the blocks between `## Surface` and the next `##`
|
|
902
|
-
* ```
|
|
903
|
-
*/
|
|
904
|
-
export declare function sectionBlocks(document: MarkdownDocument, heading: string): readonly BlockNode[];
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* The exact opaque file-inventory keys belonging under any canonical
|
|
1005
|
+
* Selects the exact opaque file-inventory keys belonging under any canonical
|
|
908
1006
|
* {@link GuideModule} directory, sorted. `'.'` selects canonical root-relative
|
|
909
1007
|
* keys without accepting `/`, `./`, or `../` aliases. Every selected exact
|
|
910
1008
|
* `index.ts` and every `.test.ts` key is excluded independent of scope order.
|
|
@@ -921,10 +1019,26 @@ export declare function sectionBlocks(document: MarkdownDocument, heading: strin
|
|
|
921
1019
|
export declare function selectModuleKeys(files: Readonly<Record<string, string>>, module: GuideModule): readonly string[];
|
|
922
1020
|
|
|
923
1021
|
/**
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
*
|
|
1022
|
+
* Selects the block nodes under the named `##` heading, up to the next `##`-or-higher
|
|
1023
|
+
* heading (or the document's end) — the section-scoping window `extractSurface` /
|
|
1024
|
+
* `extractMethods` walk over.
|
|
1025
|
+
*
|
|
1026
|
+
* @param document - The parsed guide document
|
|
1027
|
+
* @param heading - The `##` heading text to scope to, for example `Surface`
|
|
1028
|
+
* @returns The blocks belonging to that section, in document order
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* selectSectionBlocks(document, 'Surface') // the blocks between `## Surface` and the next `##`
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
export declare function selectSectionBlocks(document: MarkdownDocument, heading: string): readonly BlockNode[];
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Reflects, as a pure `SourceInterface`, a module scope's intentional direct declarations,
|
|
1039
|
+
* conventional barrel-reachable surface, and member methods over a consumer-supplied file
|
|
1040
|
+
* inventory, using text-only line scanners rather than the TypeScript compiler API or the
|
|
1041
|
+
* filesystem. `Source` never touches disk:
|
|
928
1042
|
* the consumer gathers the inventory however their environment allows
|
|
929
1043
|
* (`node:fs` in a Node script, `import.meta.glob` in a browser/vitest run) and
|
|
930
1044
|
* passes it in as `files`. Conventional barrel traversal recurses through both
|
|
@@ -933,7 +1047,12 @@ export declare function selectModuleKeys(files: Readonly<Record<string, string>>
|
|
|
933
1047
|
* construction, and exact opaque inventory keys are never rewritten; keys with
|
|
934
1048
|
* empty, `.` or `..` segments stay outside both initial and resolved barrel
|
|
935
1049
|
* inventory entrances after relative-row reduction; canonical parent hops
|
|
936
|
-
* remain valid.
|
|
1050
|
+
* remain valid. `methods` resolves a declaration's members through its
|
|
1051
|
+
* `extends` chain within the same module scope, keeping the keyword it started
|
|
1052
|
+
* from; a base the scope does not declare contributes nothing. One declaration
|
|
1053
|
+
* answers for a name: the first file in sorted key order that declares the head
|
|
1054
|
+
* supplies its members and its bases, and a second file declaring the same name
|
|
1055
|
+
* adds nothing. Source projection preserves columns without widening
|
|
937
1056
|
* direct/hidden column-zero heads. Literal ECMAScript Unicode identifiers
|
|
938
1057
|
* participate in bounded slash-state recognition without escape decoding.
|
|
939
1058
|
* Regex recognition is bounded: slash after bare `}` is division, so a
|
|
@@ -953,8 +1072,8 @@ export declare function selectModuleKeys(files: Readonly<Record<string, string>>
|
|
|
953
1072
|
* },
|
|
954
1073
|
* module: 'src/core',
|
|
955
1074
|
* })
|
|
956
|
-
* source.exports() // [{ name: 'Guide',
|
|
957
|
-
* source.surface() // [{ name: 'Guide',
|
|
1075
|
+
* source.exports() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
1076
|
+
* source.surface() // [{ name: 'Guide', keyword: 'class' }, { name: 'GuideInterface', keyword: 'interface' }]
|
|
958
1077
|
* source.methods('GuideInterface') // ['sections']
|
|
959
1078
|
* source.exists('src/core/Guide.ts') // true
|
|
960
1079
|
* ```
|
|
@@ -972,26 +1091,28 @@ export declare class Source implements SourceInterface {
|
|
|
972
1091
|
}
|
|
973
1092
|
|
|
974
1093
|
/**
|
|
975
|
-
*
|
|
1094
|
+
* Represents the reflected source truth a guide's documented surface is checked against —
|
|
976
1095
|
* a pure view over a consumer-supplied file inventory (see {@link Source}).
|
|
977
1096
|
*/
|
|
978
1097
|
export declare interface SourceInterface {
|
|
979
1098
|
/**
|
|
980
|
-
*
|
|
1099
|
+
* Lists every direct declaration in the selected module keys matching
|
|
981
1100
|
* `export (async )?(function*?|class|const|interface|type) Name`, by
|
|
982
|
-
* (name,
|
|
1101
|
+
* (name, keyword). Module keys are `.ts` inventory keys under the selected
|
|
983
1102
|
* directories, excluding each directory's exact root `index.ts` and every
|
|
984
1103
|
* `*.test.ts` key. Inventory keys are exact opaque workspace-relative keys,
|
|
985
1104
|
* must contain no empty, `.` or `..` segment, and are never normalized.
|
|
986
1105
|
* Comment/template payload is excluded through a
|
|
987
1106
|
* length-preserving projection, but membership still follows this consumer's
|
|
988
1107
|
* uninterrupted column-zero declaration-head grammar. `enum`
|
|
989
|
-
* and other TypeScript export forms are outside this
|
|
990
|
-
* population, not forbidden by general package policy.
|
|
1108
|
+
* and other TypeScript export forms are outside this declaration-keyword
|
|
1109
|
+
* reflection population, not forbidden by general package policy.
|
|
1110
|
+
*
|
|
1111
|
+
* @returns The selected modules' direct declarations, deduplicated and sorted by name
|
|
991
1112
|
*/
|
|
992
1113
|
exports(): readonly SurfaceSymbol[];
|
|
993
1114
|
/**
|
|
994
|
-
*
|
|
1115
|
+
* Lists every declaration reachable from each selected module's conventional root
|
|
995
1116
|
* `index.ts` through complete relative `.js` `export *` rows. Unlike
|
|
996
1117
|
* {@link exports}, this inventories barrel reachability rather than all
|
|
997
1118
|
* intentional direct declarations under the selected directories.
|
|
@@ -1015,33 +1136,64 @@ export declare interface SourceInterface {
|
|
|
1015
1136
|
* reduce to canonical keys remain valid. Exact workspace-root `index.ts` and
|
|
1016
1137
|
* nested targets ending `/index.ts` recurse as barrels, with a
|
|
1017
1138
|
* per-computation visited set terminating cycles; other targets contribute
|
|
1018
|
-
* direct declarations from `
|
|
1139
|
+
* direct declarations from `extractExports()`. Missing roots, missing targets, and
|
|
1019
1140
|
* unsupported export forms contribute no symbols while valid siblings continue.
|
|
1020
1141
|
* Repository policy, typechecking, and builds own validation; this is not
|
|
1021
1142
|
* filesystem or TypeScript resolution. The result is deduplicated by
|
|
1022
|
-
* `
|
|
1143
|
+
* `computeSymbolKey()`, retains same-name/different-keyword symbols, sorts by name,
|
|
1023
1144
|
* computes lazily, and caches the same readonly array instance.
|
|
1024
1145
|
*
|
|
1025
1146
|
* @returns The conventional barrel-reachable surface
|
|
1026
1147
|
*
|
|
1027
1148
|
* @example
|
|
1028
1149
|
* ```ts
|
|
1029
|
-
* source.surface() // [{ name: 'Guide',
|
|
1150
|
+
* source.surface() // [{ name: 'Guide', keyword: 'class' }]
|
|
1030
1151
|
* ```
|
|
1031
1152
|
*/
|
|
1032
1153
|
surface(): readonly SurfaceSymbol[];
|
|
1033
|
-
/**
|
|
1154
|
+
/**
|
|
1155
|
+
* Returns the call-signature members of the `class` / `interface` named `name`,
|
|
1156
|
+
* unioned with the members of every declaration it extends.
|
|
1157
|
+
*
|
|
1158
|
+
* @remarks
|
|
1159
|
+
* One declaration answers for `name`: the module scope's files are read in
|
|
1160
|
+
* sorted key order and the first one whose located head has a body or has
|
|
1161
|
+
* bases supplies both the members and the bases, so a second file
|
|
1162
|
+
* declaring the same name adds nothing; a head with neither a body nor
|
|
1163
|
+
* bases does not count as declared, so an empty `export interface X {}`
|
|
1164
|
+
* is skipped and resolution continues to a later file or falls through to
|
|
1165
|
+
* a same-named class. Resolution reads that head's `extends` clause and follows it
|
|
1166
|
+
* through this same module scope, keeping the keyword it started from: an
|
|
1167
|
+
* `interface` chain resolves through interfaces and a `class` chain through
|
|
1168
|
+
* classes, so a class's `implements` clause is outside the walk. A base the
|
|
1169
|
+
* scope does not declare — imported from another package, written as a
|
|
1170
|
+
* qualified name, or declared outside the selected directories —
|
|
1171
|
+
* contributes no members and is not an error. One visited set per call
|
|
1172
|
+
* collapses a cycle and a diamond to a single visit.
|
|
1173
|
+
*
|
|
1174
|
+
* @param name - The declaration's identifier
|
|
1175
|
+
* @returns Its declared and inherited method names, deduplicated and sorted, a class `constructor` excluded
|
|
1176
|
+
*/
|
|
1034
1177
|
methods(name: string): readonly string[];
|
|
1035
|
-
/**
|
|
1178
|
+
/**
|
|
1179
|
+
* Checks whether a workspace-root-relative path names a file or a directory present
|
|
1180
|
+
* in the inventory.
|
|
1181
|
+
*
|
|
1182
|
+
* @param relative - The workspace-root-relative path to look up
|
|
1183
|
+
* @returns True if the inventory holds that exact key or any key beneath it; false otherwise
|
|
1184
|
+
*/
|
|
1036
1185
|
exists(relative: string): boolean;
|
|
1037
1186
|
/**
|
|
1038
|
-
*
|
|
1039
|
-
* export-discipline reflection
|
|
1040
|
-
*
|
|
1187
|
+
* Lists every module-scope declaration lacking the `export` keyword — the
|
|
1188
|
+
* export-discipline reflection `.claude/rules/architecture.md` § Barrel exports
|
|
1189
|
+
* states — across the same projected physical code lines and declaration
|
|
1190
|
+
* keywords as {@link exports}. Comment/template payload and
|
|
1041
1191
|
* `enum` are outside this population; projection preserves physical columns
|
|
1042
1192
|
* but does not widen the uninterrupted column-zero declaration-head grammar.
|
|
1043
1193
|
* This does not forbid enums by general package policy. Empty on a conforming module.
|
|
1044
1194
|
*
|
|
1195
|
+
* @returns The module scope's non-exported declarations, deduplicated and sorted by name
|
|
1196
|
+
*
|
|
1045
1197
|
* @example
|
|
1046
1198
|
* ```ts
|
|
1047
1199
|
* source.hidden() // []
|
|
@@ -1049,11 +1201,13 @@ export declare interface SourceInterface {
|
|
|
1049
1201
|
*/
|
|
1050
1202
|
hidden(): readonly SurfaceSymbol[];
|
|
1051
1203
|
/**
|
|
1052
|
-
*
|
|
1204
|
+
* Lists the names of every exported function whose next-physical-record eligible
|
|
1053
1205
|
* genuine JSDoc chain ends in a span carrying an exact block-position
|
|
1054
1206
|
* `@example` tag. Title text is allowed; intervening material severs
|
|
1055
1207
|
* association.
|
|
1056
1208
|
*
|
|
1209
|
+
* @returns The exported function names carrying an `@example`, in first-seen order
|
|
1210
|
+
*
|
|
1057
1211
|
* @example
|
|
1058
1212
|
* ```ts
|
|
1059
1213
|
* source.examples() // ['createGuide', 'createSource']
|
|
@@ -1061,13 +1215,22 @@ export declare interface SourceInterface {
|
|
|
1061
1215
|
*/
|
|
1062
1216
|
examples(): readonly string[];
|
|
1063
1217
|
/**
|
|
1064
|
-
*
|
|
1218
|
+
* Lists the members of the `class` / `interface` named `name` whose immediately
|
|
1065
1219
|
* preceding eligible genuine JSDoc chain, within the declaration body, ends
|
|
1066
1220
|
* in a span carrying an exact block-position `@example` tag. Title text is
|
|
1067
1221
|
* allowed; intervening material severs association. Declaration and callable
|
|
1068
1222
|
* member eligibility comes from aligned projected code while genuine JSDoc
|
|
1069
1223
|
* evidence retains its source columns.
|
|
1070
1224
|
*
|
|
1225
|
+
* @remarks
|
|
1226
|
+
* This overload reads only the named declaration's own body, in the first
|
|
1227
|
+
* file that declares it, under each keyword. Unlike {@link methods}, the
|
|
1228
|
+
* overload follows no `extends` clause, so an inherited member's `@example`
|
|
1229
|
+
* belongs to the base that declares it.
|
|
1230
|
+
*
|
|
1231
|
+
* @param name - The declaration's identifier
|
|
1232
|
+
* @returns Its own members carrying an `@example`, deduplicated and sorted
|
|
1233
|
+
*
|
|
1071
1234
|
* @example
|
|
1072
1235
|
* ```ts
|
|
1073
1236
|
* source.examples('GuideInterface') // ['fences', 'links', 'tests']
|
|
@@ -1077,17 +1240,17 @@ export declare interface SourceInterface {
|
|
|
1077
1240
|
}
|
|
1078
1241
|
|
|
1079
1242
|
/**
|
|
1080
|
-
*
|
|
1243
|
+
* Represents one terminator-free physical source line and its aligned reflection
|
|
1081
1244
|
* projections. Every projection has the same length as {@link source}, and
|
|
1082
1245
|
* every genuine JSDoc span retains its physical opener column; the final
|
|
1083
1246
|
* physical line is present even when it is empty.
|
|
1084
1247
|
*/
|
|
1085
1248
|
export declare interface SourceLine {
|
|
1086
|
-
/**
|
|
1249
|
+
/** Holds the exact source characters, excluding the LF or CRLF terminator. */
|
|
1087
1250
|
readonly source: string;
|
|
1088
|
-
/**
|
|
1251
|
+
/** Holds source code with comment and template spans replaced by aligned spaces. */
|
|
1089
1252
|
readonly code: string;
|
|
1090
|
-
/**
|
|
1253
|
+
/** Holds every genuine JSDoc span at its exact source columns, or `undefined` when absent. */
|
|
1091
1254
|
readonly jsdoc: string | undefined;
|
|
1092
1255
|
}
|
|
1093
1256
|
|
|
@@ -1095,6 +1258,8 @@ export declare interface SourceLine {
|
|
|
1095
1258
|
* Resolves a consumer-owned import-specifier policy into pure source views and
|
|
1096
1259
|
* caches those views by module, so aliases for one module share one entity.
|
|
1097
1260
|
* Unmapped specifiers remain foreign to the consumer and return `undefined`.
|
|
1261
|
+
* `sources()` enumerates the same shared views, one per distinct module the
|
|
1262
|
+
* policy maps.
|
|
1098
1263
|
*
|
|
1099
1264
|
* @example
|
|
1100
1265
|
* ```ts
|
|
@@ -1105,68 +1270,94 @@ export declare interface SourceLine {
|
|
|
1105
1270
|
* modules: { '@scope/package': 'src/core' },
|
|
1106
1271
|
* })
|
|
1107
1272
|
* sources.source('@scope/package')?.surface()
|
|
1273
|
+
* sources.sources() // [the same shared view]
|
|
1108
1274
|
* ```
|
|
1109
1275
|
*/
|
|
1110
1276
|
export declare class SourceManager implements SourceManagerInterface {
|
|
1111
1277
|
#private;
|
|
1112
1278
|
constructor(options: SourceManagerOptions);
|
|
1113
1279
|
source(specifier: string): SourceInterface | undefined;
|
|
1280
|
+
sources(): readonly SourceInterface[];
|
|
1114
1281
|
}
|
|
1115
1282
|
|
|
1116
|
-
/**
|
|
1283
|
+
/** Represents a specifier resolver that shares one {@link SourceInterface} per module. */
|
|
1117
1284
|
export declare interface SourceManagerInterface {
|
|
1118
1285
|
/**
|
|
1119
|
-
*
|
|
1286
|
+
* Resolves a mapped specifier to its shared source view.
|
|
1120
1287
|
*
|
|
1121
1288
|
* @param specifier - The import specifier to resolve
|
|
1122
1289
|
* @returns Its source view, or `undefined` when the specifier is not mapped
|
|
1290
|
+
*
|
|
1291
|
+
* @example
|
|
1292
|
+
* ```ts
|
|
1293
|
+
* sources.source('@scope/package')?.surface() // [{ name: 'Guide', keyword: 'class' }]
|
|
1294
|
+
* ```
|
|
1123
1295
|
*/
|
|
1124
1296
|
source(specifier: string): SourceInterface | undefined;
|
|
1297
|
+
/**
|
|
1298
|
+
* Lists every source view the policy maps, sharing the same per-module entities
|
|
1299
|
+
* {@link source} returns.
|
|
1300
|
+
*
|
|
1301
|
+
* @returns One shared source view per distinct module the policy maps, in first-seen specifier order
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* ```ts
|
|
1305
|
+
* const [core] = sources.sources()
|
|
1306
|
+
* core === sources.source('@scope/package') // true
|
|
1307
|
+
* ```
|
|
1308
|
+
*/
|
|
1309
|
+
sources(): readonly SourceInterface[];
|
|
1125
1310
|
}
|
|
1126
1311
|
|
|
1127
1312
|
/**
|
|
1128
|
-
*
|
|
1313
|
+
* Represents the construction input for a {@link SourceManager}: one shared file inventory
|
|
1129
1314
|
* plus the consumer's specifier-to-module policy.
|
|
1130
1315
|
*/
|
|
1131
1316
|
export declare interface SourceManagerOptions {
|
|
1132
|
-
/**
|
|
1317
|
+
/**
|
|
1318
|
+
* Holds the workspace's exact canonical-segment opaque inventory keys, root-relative path
|
|
1319
|
+
* → text.
|
|
1320
|
+
*/
|
|
1133
1321
|
readonly files: Readonly<Record<string, string>>;
|
|
1134
|
-
/**
|
|
1322
|
+
/** Maps each local import specifier to the source module it exposes. */
|
|
1135
1323
|
readonly modules: Readonly<Record<string, GuideModule>>;
|
|
1136
1324
|
}
|
|
1137
1325
|
|
|
1138
1326
|
/**
|
|
1139
|
-
*
|
|
1327
|
+
* Represents the construction input for a {@link Source} — a consumer-supplied file
|
|
1140
1328
|
* inventory (root-relative path → file text) plus the module scope to
|
|
1141
1329
|
* reflect. The consumer gathers `files` however their environment allows
|
|
1142
1330
|
* (`node:fs` in a Node script, `import.meta.glob` in a browser/vitest run) —
|
|
1143
1331
|
* `Source` itself never touches disk.
|
|
1144
1332
|
*/
|
|
1145
1333
|
export declare interface SourceOptions {
|
|
1146
|
-
/**
|
|
1334
|
+
/**
|
|
1335
|
+
* Holds the workspace's exact canonical-segment opaque inventory keys, root-relative path
|
|
1336
|
+
* → text.
|
|
1337
|
+
*/
|
|
1147
1338
|
readonly files: Readonly<Record<string, string>>;
|
|
1148
|
-
/**
|
|
1339
|
+
/** Names the source directory (or directories) this guide documents; `'.'` is workspace root. */
|
|
1149
1340
|
readonly module: GuideModule;
|
|
1150
1341
|
}
|
|
1151
1342
|
|
|
1152
1343
|
/**
|
|
1153
|
-
*
|
|
1344
|
+
* Names the `## Surface` heading text a guide's documented exports section is keyed on.
|
|
1154
1345
|
*/
|
|
1155
1346
|
export declare const SURFACE: string;
|
|
1156
1347
|
|
|
1157
1348
|
/**
|
|
1158
|
-
*
|
|
1349
|
+
* Represents one documented / exported symbol — its identifier plus its declaration keyword.
|
|
1159
1350
|
*/
|
|
1160
1351
|
export declare interface SurfaceSymbol {
|
|
1161
|
-
/**
|
|
1352
|
+
/** Holds the symbol's identifier. */
|
|
1162
1353
|
readonly name: string;
|
|
1163
|
-
/**
|
|
1164
|
-
readonly
|
|
1354
|
+
/** Holds the symbol's declaration keyword — half of the bijection key alongside {@link name}. */
|
|
1355
|
+
readonly keyword: ExportKeyword;
|
|
1165
1356
|
}
|
|
1166
1357
|
|
|
1167
1358
|
/**
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1359
|
+
* Shapes a {@link SurfaceSymbol} — a documented / exported symbol's `name`
|
|
1360
|
+
* paired with its {@link ExportKeyword}.
|
|
1170
1361
|
*
|
|
1171
1362
|
* @example
|
|
1172
1363
|
* ```ts
|
|
@@ -1174,30 +1365,16 @@ export declare interface SurfaceSymbol {
|
|
|
1174
1365
|
* import { surfaceSymbolShape } from '@orkestrel/guide'
|
|
1175
1366
|
*
|
|
1176
1367
|
* const surfaceSymbol = createContract(surfaceSymbolShape)
|
|
1177
|
-
* surfaceSymbol.is({ name: 'Markdown',
|
|
1368
|
+
* surfaceSymbol.is({ name: 'Markdown', keyword: 'class' }) // true
|
|
1178
1369
|
* ```
|
|
1179
1370
|
*/
|
|
1180
1371
|
export declare const surfaceSymbolShape: ObjectShape<{
|
|
1181
1372
|
name: StringShape;
|
|
1182
|
-
|
|
1373
|
+
keyword: LiteralShape<readonly ["type", "interface", "const", "function", "class"]>;
|
|
1183
1374
|
}, false>;
|
|
1184
1375
|
|
|
1185
1376
|
/**
|
|
1186
|
-
*
|
|
1187
|
-
* symbol-set comparison diffs (name, kind) pairs rather than names alone.
|
|
1188
|
-
*
|
|
1189
|
-
* @param symbol - The symbol to key
|
|
1190
|
-
* @returns The `${kind} ${name}` key
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```ts
|
|
1194
|
-
* symbolKey({ name: 'Markdown', kind: 'class' }) // 'class Markdown'
|
|
1195
|
-
* ```
|
|
1196
|
-
*/
|
|
1197
|
-
export declare function symbolKey(symbol: SurfaceSymbol): string;
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* The `## Tests` heading text a guide's documented test-link section is keyed on.
|
|
1377
|
+
* Names the `## Tests` heading text a guide's documented test-link section is keyed on.
|
|
1201
1378
|
*/
|
|
1202
1379
|
export declare const TESTS: string;
|
|
1203
1380
|
|