@orkestrel/guide 0.0.1
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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/src/core/Guide.d.ts +30 -0
- package/dist/src/core/Source.d.ts +35 -0
- package/dist/src/core/constants.d.ts +22 -0
- package/dist/src/core/factories.d.ts +86 -0
- package/dist/src/core/helpers.d.ts +196 -0
- package/dist/src/core/index.d.ts +9 -0
- package/dist/src/core/index.js +1185 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/parsers.d.ts +218 -0
- package/dist/src/core/shapers.d.ts +53 -0
- package/dist/src/core/types.d.ts +148 -0
- package/dist/src/core/validators.d.ts +58 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Orkestrel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @orkestrel/guide
|
|
2
|
+
|
|
3
|
+
A guides-parity **test helper** for `@orkestrel` packages. Add it as a
|
|
4
|
+
devDependency, drop one short test file into `tests/guides/src/parity.test.ts`,
|
|
5
|
+
wire a vitest `guides` project, and thereafter every guide is proven —
|
|
6
|
+
mechanically, in CI, as ordinary vitest assertions — to be in **bijection**
|
|
7
|
+
with the code it documents: every documented export exists in source and
|
|
8
|
+
vice versa, every documented method matches the class, and every relative
|
|
9
|
+
link resolves. No CLI, no runner, no exit-code contract: it is a library of
|
|
10
|
+
extraction + reflection helpers your test suite calls. Built on
|
|
11
|
+
`@orkestrel/markdown`. Part of the `@orkestrel` line.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install -D @orkestrel/guide
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- Node.js >= 24
|
|
22
|
+
- ESM-only (no CommonJS build)
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
The entire consumer-side footprint is one short test file. An excerpt of the
|
|
27
|
+
drop-in pattern (`tests/guides/src/parity.test.ts`):
|
|
28
|
+
|
|
29
|
+
The consumer supplies the file inventory `Source` reflects over — gathered
|
|
30
|
+
with `node:fs` in a Node test file, or `import.meta.glob` under a browser
|
|
31
|
+
vitest project. This excerpt uses a Node `readFileSync`-backed inventory:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { readFileSync } from 'node:fs'
|
|
35
|
+
import { fileURLToPath } from 'node:url'
|
|
36
|
+
import { createGuide, createSource, missingSymbols, parseManifest } from '@orkestrel/guide'
|
|
37
|
+
|
|
38
|
+
const ROOT = fileURLToPath(new URL('../../../', import.meta.url))
|
|
39
|
+
const files: Record<string, string> = {/* root-relative path → file text */}
|
|
40
|
+
const readText = (relative: string) =>
|
|
41
|
+
files[relative] ?? readFileSync(new URL(relative, ROOT), 'utf8')
|
|
42
|
+
const manifest = parseManifest(readText('guides/README.md'), 'guides')
|
|
43
|
+
|
|
44
|
+
for (const entry of manifest) {
|
|
45
|
+
const guide = createGuide(readText(entry.spec))
|
|
46
|
+
const source = createSource({ files, module: entry.source })
|
|
47
|
+
|
|
48
|
+
it('documents every source export', () => {
|
|
49
|
+
expect(missingSymbols(source.exports(), guide.surface())).toEqual([])
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Every row added to the consumer's `guides/README.md` manifest auto-extends
|
|
55
|
+
coverage with zero test edits.
|
|
56
|
+
|
|
57
|
+
## Checks
|
|
58
|
+
|
|
59
|
+
- **Surface bijection** — every documented `## Surface` symbol (name + kind)
|
|
60
|
+
matches a real export, and vice versa.
|
|
61
|
+
- **Methods bijection + class-no-extra** — every documented `## Methods`
|
|
62
|
+
member matches the interface's implementer, and the implementing class
|
|
63
|
+
exposes no undocumented public method.
|
|
64
|
+
- **Link integrity** — every relative link in a guide resolves to a real
|
|
65
|
+
file.
|
|
66
|
+
- **Tests-link existence** — every `## Tests` link resolves to a real test
|
|
67
|
+
file.
|
|
68
|
+
- **Non-vacuousness guards** — the manifest, each guide's surface, and each
|
|
69
|
+
method group must extract non-empty, so a renamed heading fails loudly
|
|
70
|
+
instead of passing vacuously.
|
|
71
|
+
|
|
72
|
+
## API
|
|
73
|
+
|
|
74
|
+
- `createGuide(source)` — parses one guide's markdown into a structured,
|
|
75
|
+
cached view (`surface()`, `methods()`, `links()`, `tests()`).
|
|
76
|
+
- `createSource(options)` — reflects real exports/members/existence over a
|
|
77
|
+
consumer-supplied file inventory (`options.files`), for one or more source
|
|
78
|
+
directories.
|
|
79
|
+
- `parseManifest(markdown, base)` — extracts the `## By concept` rows from a
|
|
80
|
+
`guides/README.md` manifest.
|
|
81
|
+
- `missingSymbols(symbols, source)` — the `(name, kind)` set difference
|
|
82
|
+
driving surface bijection.
|
|
83
|
+
- `findMissing(names, source)` — the plain set difference driving methods
|
|
84
|
+
bijection and link/test checks.
|
|
85
|
+
- `isExternalLink(href)` — true for `http`/`https`/`mailto`/`tel`/`#` links.
|
|
86
|
+
- `resolveLink(from, target)` — resolves a guide-relative link against the
|
|
87
|
+
guide's own directory.
|
|
88
|
+
|
|
89
|
+
## Guide
|
|
90
|
+
|
|
91
|
+
For the full surface — the guide anatomy, the manifest format, and the check
|
|
92
|
+
catalog — see [`guides/src/guide.md`](guides/src/guide.md). For the design
|
|
93
|
+
rationale, see [`PROPOSAL.md`](./PROPOSAL.md). For the guide index, see
|
|
94
|
+
[`guides/`](./guides/).
|
|
95
|
+
|
|
96
|
+
## Package
|
|
97
|
+
|
|
98
|
+
Published as a single pure, typed entry point — `@orkestrel/guide` — per the
|
|
99
|
+
`exports` field in `package.json`. No filesystem or network access; the
|
|
100
|
+
consumer supplies the file inventory `Source` reflects over.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT © [Orkestrel](https://github.com/orkestrel) — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GuideInterface, MethodGroup, SurfaceSymbol } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A stateful, structured view over one parsed guide — the five documented
|
|
4
|
+
* projections (`sections` / `surface` / `methods` / `links` / `tests`) are
|
|
5
|
+
* extracted once at construction and cached.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Pure: parses `source` once via `@orkestrel/markdown` and never touches the
|
|
9
|
+
* filesystem — `Guide` has no notion of "where" the guide came from, only its
|
|
10
|
+
* markdown text. Every accessor returns the same cached, readonly array on
|
|
11
|
+
* every call.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Guide } from '@orkestrel/guide/core'
|
|
16
|
+
*
|
|
17
|
+
* const guide = new Guide('## Surface\n\n| Name | Kind |\n| --- | --- |\n| `X` | class |')
|
|
18
|
+
* guide.surface() // [{ name: 'X', kind: 'class' }]
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class Guide implements GuideInterface {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(source: string);
|
|
24
|
+
sections(): readonly string[];
|
|
25
|
+
surface(): readonly SurfaceSymbol[];
|
|
26
|
+
methods(): readonly MethodGroup[];
|
|
27
|
+
links(): readonly string[];
|
|
28
|
+
tests(): readonly string[];
|
|
29
|
+
patterns(): readonly string[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SourceInterface, SourceOptions, SurfaceSymbol } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A pure `SourceInterface` — reflects a module scope's exports and member
|
|
4
|
+
* methods over a consumer-supplied file inventory (AGENTS §22, `PROPOSAL.md`
|
|
5
|
+
* §7), using text-only line scanners rather than the TypeScript compiler API
|
|
6
|
+
* or the filesystem. `Source` never touches disk: the consumer gathers the
|
|
7
|
+
* inventory however their environment allows (`node:fs` in a Node script,
|
|
8
|
+
* `import.meta.glob` in a browser/vitest run) and passes it in as `files`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Source } from '@orkestrel/guide'
|
|
13
|
+
*
|
|
14
|
+
* const source = new Source({
|
|
15
|
+
* files: {
|
|
16
|
+
* 'src/core/Guide.ts': 'export class Guide {}\n',
|
|
17
|
+
* 'src/core/types.ts': 'export interface GuideInterface {\n\tsections(): void\n}\n',
|
|
18
|
+
* },
|
|
19
|
+
* module: 'src/core',
|
|
20
|
+
* })
|
|
21
|
+
* source.exports() // [{ name: 'Guide', kind: 'class' }, { name: 'GuideInterface', kind: 'interface' }]
|
|
22
|
+
* source.methods('GuideInterface') // ['sections']
|
|
23
|
+
* source.exists('src/core/Guide.ts') // true
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Source implements SourceInterface {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(options: SourceOptions);
|
|
29
|
+
exports(): readonly SurfaceSymbol[];
|
|
30
|
+
methods(name: string): readonly string[];
|
|
31
|
+
exists(relative: string): boolean;
|
|
32
|
+
hidden(): readonly SurfaceSymbol[];
|
|
33
|
+
examples(): readonly string[];
|
|
34
|
+
examples(name: string): readonly string[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `## Surface` heading text a guide's documented exports section is keyed on.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SURFACE: string;
|
|
5
|
+
/**
|
|
6
|
+
* The `## Methods` heading text a guide's documented interface-methods section is keyed on.
|
|
7
|
+
*/
|
|
8
|
+
export declare const METHODS: string;
|
|
9
|
+
/**
|
|
10
|
+
* The `## Tests` heading text a guide's documented test-link section is keyed on.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TESTS: string;
|
|
13
|
+
/**
|
|
14
|
+
* The `## By concept` heading text the manifest's run-map table is keyed on.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MANIFEST: string;
|
|
17
|
+
/**
|
|
18
|
+
* The link `href` schemes a guides-parity link check skips as external — a link
|
|
19
|
+
* with one of these prefixes (or a bare `#` anchor, handled separately in
|
|
20
|
+
* `isExternalLink`) is never resolved against the filesystem.
|
|
21
|
+
*/
|
|
22
|
+
export declare const EXTERNAL_SCHEMES: readonly string[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ContractInterface } from '@orkestrel/contract';
|
|
2
|
+
import type { GuideInterface, ManifestEntry, MethodGroup, SourceInterface, SourceOptions, SurfaceSymbol } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a structured {@link GuideInterface} view over one guide's markdown
|
|
5
|
+
* source — parses once and caches its `sections` / `surface` / `methods` /
|
|
6
|
+
* `links` / `tests` projections.
|
|
7
|
+
*
|
|
8
|
+
* @param source - The guide's markdown source text
|
|
9
|
+
* @returns A working {@link GuideInterface}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createGuide } from '@orkestrel/guide'
|
|
14
|
+
*
|
|
15
|
+
* const guide = createGuide('## Surface\n\n| Name | Kind |\n| --- | --- |\n| `X` | class |')
|
|
16
|
+
* guide.surface() // [{ name: 'X', kind: 'class' }]
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function createGuide(source: string): GuideInterface;
|
|
20
|
+
/**
|
|
21
|
+
* Create a pure {@link SourceInterface} over a consumer-supplied file
|
|
22
|
+
* inventory — see {@link Source}.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The file inventory and module scope to reflect
|
|
25
|
+
* @returns A `SourceInterface` reflecting the given module scope
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { createSource } from '@orkestrel/guide'
|
|
30
|
+
*
|
|
31
|
+
* const source = createSource({
|
|
32
|
+
* files: { 'src/core/Guide.ts': 'export class Guide {}\n' },
|
|
33
|
+
* module: 'src/core',
|
|
34
|
+
* })
|
|
35
|
+
* source.exports() // [{ name: 'Guide', kind: 'class' }]
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createSource(options: SourceOptions): SourceInterface;
|
|
39
|
+
/**
|
|
40
|
+
* Compile the {@link surfaceSymbolShape} into a {@link ContractInterface} for
|
|
41
|
+
* {@link SurfaceSymbol} — a guard, coercing parser, JSON Schema, and seeded
|
|
42
|
+
* generator from one shape declaration (AGENTS §14).
|
|
43
|
+
*
|
|
44
|
+
* @returns A `SurfaceSymbol` contract bundling `schema` / `is` / `parse` / `generate`
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { createSurfaceSymbolContract } from '@orkestrel/guide/core'
|
|
49
|
+
*
|
|
50
|
+
* const surfaceSymbol = createSurfaceSymbolContract()
|
|
51
|
+
* surfaceSymbol.is({ name: 'Markdown', kind: 'class' }) // true
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createSurfaceSymbolContract(): ContractInterface<SurfaceSymbol>;
|
|
55
|
+
/**
|
|
56
|
+
* Compile the {@link methodGroupShape} into a {@link ContractInterface} for
|
|
57
|
+
* {@link MethodGroup} — a guard, coercing parser, JSON Schema, and seeded
|
|
58
|
+
* generator from one shape declaration (AGENTS §14).
|
|
59
|
+
*
|
|
60
|
+
* @returns A `MethodGroup` contract bundling `schema` / `is` / `parse` / `generate`
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { createMethodGroupContract } from '@orkestrel/guide/core'
|
|
65
|
+
*
|
|
66
|
+
* const methodGroup = createMethodGroupContract()
|
|
67
|
+
* methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function createMethodGroupContract(): ContractInterface<MethodGroup>;
|
|
71
|
+
/**
|
|
72
|
+
* Compile the {@link manifestEntryShape} into a {@link ContractInterface} for
|
|
73
|
+
* {@link ManifestEntry} — a guard, coercing parser, JSON Schema, and seeded
|
|
74
|
+
* generator from one shape declaration (AGENTS §14).
|
|
75
|
+
*
|
|
76
|
+
* @returns A `ManifestEntry` contract bundling `schema` / `is` / `parse` / `generate`
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { createManifestEntryContract } from '@orkestrel/guide/core'
|
|
81
|
+
*
|
|
82
|
+
* const manifestEntry = createManifestEntryContract()
|
|
83
|
+
* manifestEntry.is({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function createManifestEntryContract(): ContractInterface<ManifestEntry>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { InlineNode, TableNode } from '@orkestrel/markdown';
|
|
2
|
+
import type { GuideModule, SurfaceSymbol } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A module scope normalized to its directory list — a single directory
|
|
5
|
+
* becomes a one-element list so every scanner walks the same shape.
|
|
6
|
+
*
|
|
7
|
+
* @param module - The module scope to normalize
|
|
8
|
+
* @returns The directory list `module` denotes
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* moduleDirs('src/core') // ['src/core']
|
|
13
|
+
* moduleDirs(['src/core', 'src/browser']) // ['src/core', 'src/browser']
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function moduleDirs(module: GuideModule): readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* The file inventory's keys belonging to a {@link GuideModule} scope, sorted —
|
|
19
|
+
* a key belongs when it starts with one of the scope's directories, ends in
|
|
20
|
+
* `.ts`, and is neither that directory's `index.ts` nor a `.test.ts` file.
|
|
21
|
+
*
|
|
22
|
+
* @param files - The workspace file inventory, root-relative path → file text
|
|
23
|
+
* @param module - The module scope to filter to
|
|
24
|
+
* @returns The scope's file keys, root-relative and sorted
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* moduleKeys({ 'src/core/Guide.ts': '', 'src/core/index.ts': '' }, 'src/core') // ['src/core/Guide.ts']
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function moduleKeys(files: Readonly<Record<string, string>>, module: GuideModule): readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* The bijection key for a surface symbol — its kind and name combined — so a
|
|
34
|
+
* symbol-set comparison diffs (name, kind) pairs rather than names alone.
|
|
35
|
+
*
|
|
36
|
+
* @param symbol - The symbol to key
|
|
37
|
+
* @returns The `${kind} ${name}` key
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* symbolKey({ name: 'Markdown', kind: 'class' }) // 'class Markdown'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function symbolKey(symbol: SurfaceSymbol): string;
|
|
45
|
+
/**
|
|
46
|
+
* The names present in `names` but absent from `source` — the set-difference
|
|
47
|
+
* behind a both-directions bijection assertion.
|
|
48
|
+
*
|
|
49
|
+
* @param names - The candidate names
|
|
50
|
+
* @param source - The names to compare against
|
|
51
|
+
* @returns The names in `names` that are not in `source`
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* findMissing(['a', 'b'], ['a']) // ['b']
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function findMissing(names: readonly string[], source: readonly string[]): readonly string[];
|
|
59
|
+
/**
|
|
60
|
+
* The symbol-key set-difference between two symbol lists — `symbols` present but
|
|
61
|
+
* absent from `source`, compared by {@link symbolKey} so a symbol can drift in
|
|
62
|
+
* neither name nor kind.
|
|
63
|
+
*
|
|
64
|
+
* @param symbols - The candidate symbols
|
|
65
|
+
* @param source - The symbols to compare against
|
|
66
|
+
* @returns The symbol keys in `symbols` that are not in `source`
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* missingSymbols([{ name: 'X', kind: 'class' }], []) // ['class X']
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function missingSymbols(symbols: readonly SurfaceSymbol[], source: readonly SurfaceSymbol[]): readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* The names in `names` that have no example — a fence containing the name at a
|
|
76
|
+
* word boundary in `fences`, or a membership in `examples`, both count as
|
|
77
|
+
* "has an example"; presence-only, fence and JSDoc content are never checked.
|
|
78
|
+
*
|
|
79
|
+
* @param names - The candidate symbol/member names to check
|
|
80
|
+
* @param fences - The guide's ```ts Patterns fence bodies to search
|
|
81
|
+
* @param examples - The names already known to carry an `@example` JSDoc block
|
|
82
|
+
* @returns The names in `names` with no fence mention and no `@example`
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* findUnexampled(['walk', 'fold'], ['walk()'], []) // ['fold']
|
|
87
|
+
* findUnexampled(['walk'], [], ['walk']) // []
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function findUnexampled(names: readonly string[], fences: readonly string[], examples: readonly string[]): readonly string[];
|
|
91
|
+
/**
|
|
92
|
+
* Parse a fence's `import` statements into per-specifier imported identifier
|
|
93
|
+
* names — handles `import type`, mixed multiline braces, and `x as y` aliases
|
|
94
|
+
* (resolved to the local name `x`... the ORIGINAL exported name, since it is
|
|
95
|
+
* the export that must exist in `source.exports()`).
|
|
96
|
+
*
|
|
97
|
+
* @param fence - A ```ts Patterns fence's verbatim body text
|
|
98
|
+
* @returns One entry per `import ... from 'specifier'` statement, in fence order
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* fenceImports("import { a, b as c } from 'x'\n") // [{ specifier: 'x', names: ['a', 'b'] }]
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function fenceImports(fence: string): readonly {
|
|
106
|
+
specifier: string;
|
|
107
|
+
names: readonly string[];
|
|
108
|
+
}[];
|
|
109
|
+
/**
|
|
110
|
+
* Whether a link `href` should be skipped by the guides-parity link checks — an
|
|
111
|
+
* external scheme ({@link EXTERNAL_SCHEMES}) or a bare in-document `#` anchor.
|
|
112
|
+
*
|
|
113
|
+
* @param href - The link destination
|
|
114
|
+
* @returns `true` when the link should not be resolved against the filesystem
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* isExternalLink('https://example.com') // true
|
|
119
|
+
* isExternalLink('../helpers.ts') // false
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function isExternalLink(href: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Resolve a relative link `target` against `from` and normalize the result — `from`
|
|
125
|
+
* is treated as a file (its directory is everything before the last `/`) when it
|
|
126
|
+
* carries a `/`, or as a bare directory itself when it does not; `.` segments drop
|
|
127
|
+
* and `..` segments pop the preceding component, purely (no `node:path`).
|
|
128
|
+
*
|
|
129
|
+
* @param from - The declaring guide path (a file) or manifest base (a directory)
|
|
130
|
+
* @param target - The relative link destination to resolve
|
|
131
|
+
* @returns The normalized, workspace-root-relative path
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* resolveLink('guides/src/markdown.md', '../../src/core/helpers.ts') // 'src/core/helpers.ts'
|
|
136
|
+
* resolveLink('guides', '../src/core') // 'src/core'
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveLink(from: string, target: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* The first code-span value found by descending an inline node list, following
|
|
142
|
+
* into `emphasis` / `link` children — the extraction rule behind a Surface or
|
|
143
|
+
* Methods table row's first-column identifier.
|
|
144
|
+
*
|
|
145
|
+
* @param nodes - The inline nodes to search
|
|
146
|
+
* @returns The first code span's literal text, or `undefined` when none is found
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* firstCode([{ element: 'codeSpan', value: 'Markdown' }]) // 'Markdown'
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function firstCode(nodes: readonly InlineNode[]): string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* The link hrefs found within one table cell's inline content.
|
|
156
|
+
*
|
|
157
|
+
* @param cell - The cell's inline nodes
|
|
158
|
+
* @returns The cell's link hrefs, in walk order
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* cellLinks([{ element: 'link', href: 'x.ts', children: [] }]) // ['x.ts']
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare function cellLinks(cell: readonly InlineNode[]): readonly string[];
|
|
166
|
+
/**
|
|
167
|
+
* The identifier prefix of a code-span text — everything before its first `<`,
|
|
168
|
+
* trimmed. Guide cells and headings may annotate a generic-parameterized name
|
|
169
|
+
* (`MarkdownHandler<TNode, T>`) for readability, but the bijection key is the
|
|
170
|
+
* bare identifier the source scanner captures, so both sides must normalize
|
|
171
|
+
* the same way.
|
|
172
|
+
*
|
|
173
|
+
* @param code - A code span's literal text
|
|
174
|
+
* @returns The identifier prefix, or an empty string when `code` is empty
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* identifierOf('MarkdownHandler<TNode, T>') // 'MarkdownHandler'
|
|
179
|
+
* identifierOf('fold') // 'fold'
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function identifierOf(code: string): string;
|
|
183
|
+
/**
|
|
184
|
+
* The index of a table's `Kind` column, found by its header text so it survives
|
|
185
|
+
* column reordering. The match is exact and case-sensitive (`'Kind'`) — a table
|
|
186
|
+
* without that exact header contributes no symbols to the surface it feeds.
|
|
187
|
+
*
|
|
188
|
+
* @param table - The table to inspect
|
|
189
|
+
* @returns The `Kind` column's index, or `undefined` when the table has no `Kind` header
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* kindIndex(table) // 1, or undefined
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export declare function kindIndex(table: TableNode): number | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from './types.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './helpers.js';
|
|
4
|
+
export * from './parsers.js';
|
|
5
|
+
export * from './shapers.js';
|
|
6
|
+
export * from './validators.js';
|
|
7
|
+
export * from './Guide.js';
|
|
8
|
+
export * from './Source.js';
|
|
9
|
+
export * from './factories.js';
|