@orkestrel/guide 0.0.5 → 0.0.7
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/dist/src/core/index.d.cts +904 -9
- package/dist/src/core/index.d.ts +904 -9
- package/package.json +18 -13
- package/dist/src/core/Guide.d.ts +0 -30
- package/dist/src/core/Source.d.ts +0 -35
- package/dist/src/core/constants.d.ts +0 -22
- package/dist/src/core/factories.d.ts +0 -86
- package/dist/src/core/helpers.d.ts +0 -196
- package/dist/src/core/parsers.d.ts +0 -218
- package/dist/src/core/shapers.d.ts +0 -54
- package/dist/src/core/types.d.ts +0 -148
- package/dist/src/core/validators.d.ts +0 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orkestrel/guide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Guides-parity test helpers — prove a package's guides are in bijection with the code they document: surface and methods bijection, link integrity, and non-vacuous extraction, built on @orkestrel/markdown. Part of the @orkestrel line.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bijection",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"url": "git+https://github.com/orkestrel/guide.git"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"dist",
|
|
23
|
+
"dist/src",
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"type": "module",
|
|
@@ -45,19 +45,20 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
-
"clean": "node -e \"
|
|
48
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
49
49
|
"copy": "node -e \"const fs=require('node:fs'),p=require('node:path'),a=process.argv[1],b=process.argv[2];fs.mkdirSync(p.dirname(b),{recursive:true});fs.cpSync(a,b,{force:true});console.log('Copied: '+a+' to '+b)\"",
|
|
50
|
-
"
|
|
51
|
-
"lint": "oxlint --config .oxlintrc.json --fix .",
|
|
50
|
+
"scaffold": "scaffold",
|
|
51
|
+
"lint": "oxlint --config .oxlintrc.json --fix --deny-warnings .",
|
|
52
52
|
"check": "tsc --noEmit --project tsconfig.json && npm run check:src",
|
|
53
53
|
"check:src": "npm run check:src:core",
|
|
54
54
|
"check:src:core": "tsc --noEmit -p configs/src/tsconfig.core.json",
|
|
55
55
|
"format": "oxfmt --config .oxfmtrc.json --write .",
|
|
56
56
|
"format:check": "oxfmt --config .oxfmtrc.json --check .",
|
|
57
|
-
"lint:check": "oxlint --config .oxlintrc.json .",
|
|
58
|
-
"test": "npm run test:src && npm run test:guides",
|
|
57
|
+
"lint:check": "oxlint --config .oxlintrc.json --deny-warnings .",
|
|
58
|
+
"test": "npm run test:src && npm run test:policy && npm run test:guides",
|
|
59
59
|
"test:src": "vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core",
|
|
60
60
|
"test:src:core": "vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core",
|
|
61
|
+
"test:policy": "vitest run --config vite.config.ts --no-cache --reporter=dot --project policy",
|
|
61
62
|
"test:guides": "vitest run --config vite.config.ts --reporter=dot --project guides",
|
|
62
63
|
"build": "npm run clean && npm run build:src",
|
|
63
64
|
"build:src": "npm run build:src:core",
|
|
@@ -65,19 +66,23 @@
|
|
|
65
66
|
"prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
|
-
"@orkestrel/contract": "^0.0.
|
|
69
|
-
"@orkestrel/markdown": "^0.0.
|
|
69
|
+
"@orkestrel/contract": "^0.0.8",
|
|
70
|
+
"@orkestrel/markdown": "^0.0.6"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
73
|
+
"@microsoft/api-extractor": "^7.58.12",
|
|
74
|
+
"@orkestrel/guide": "^0.0.6",
|
|
75
|
+
"@orkestrel/scaffold": "^0.0.6",
|
|
76
|
+
"@types/node": "^26.1.2",
|
|
77
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
78
|
+
"oxfmt": "^0.61.0",
|
|
79
|
+
"oxlint": "^1.76.0",
|
|
75
80
|
"typescript": "^6.0.3",
|
|
76
81
|
"vite": "^8.1.5",
|
|
77
82
|
"vite-plugin-dts": "^5.0.3",
|
|
78
83
|
"vitest": "^4.1.10"
|
|
79
84
|
},
|
|
80
85
|
"engines": {
|
|
81
|
-
"node": ">=22"
|
|
86
|
+
"node": ">=22.12.0"
|
|
82
87
|
}
|
|
83
88
|
}
|
package/dist/src/core/Guide.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { 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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { 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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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[];
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { ContractInterface } from '@orkestrel/contract';
|
|
2
|
-
import { 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>;
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { InlineNode, TableNode } from '@orkestrel/markdown';
|
|
2
|
-
import { 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;
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { BlockNode, MarkdownDocument } from '@orkestrel/markdown';
|
|
2
|
-
import { DeclarationHead, ManifestEntry, MethodGroup, SurfaceSymbol } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* The module-scope exports declared in one file's source text — matches
|
|
5
|
-
* `export (async)? (function(\*)?|class|const|interface|type) Name`, deduped
|
|
6
|
-
* by (kind, name). A generator export (`export function* walk`) scans as kind
|
|
7
|
-
* `function` — its trailing `*` is stripped before the {@link ExportKind} check.
|
|
8
|
-
*
|
|
9
|
-
* @param source - The file's source text
|
|
10
|
-
* @returns The file's exported symbols, in file order
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* exportsFrom('export class Markdown {}\n') // [{ name: 'Markdown', kind: 'class' }]
|
|
15
|
-
* exportsFrom('export function* walk() {}\n') // [{ name: 'walk', kind: 'function' }]
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function exportsFrom(source: string): readonly SurfaceSymbol[];
|
|
19
|
-
/**
|
|
20
|
-
* The module-scope declarations LACKING the `export` keyword in one file's
|
|
21
|
-
* source text — the mirror image of {@link exportsFrom}'s grammar, anchored
|
|
22
|
-
* the same way (column 0, so an indented inner declaration never matches).
|
|
23
|
-
* Scans only the five {@link ExportKind} keywords (`function` / `class` /
|
|
24
|
-
* `const` / `interface` / `type`) — a module-scope `let` or `var` is a
|
|
25
|
-
* different violation class (AGENTS §1 bans `var`; a bare `let` is not a
|
|
26
|
-
* declaration kind this scanner's five-kind grammar covers) and is out of
|
|
27
|
-
* this check's contract.
|
|
28
|
-
*
|
|
29
|
-
* @param source - The file's source text
|
|
30
|
-
* @returns The file's hidden (non-exported) symbols, in file order
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* hiddenFrom('function secretHelper() {}\n') // [{ name: 'secretHelper', kind: 'function' }]
|
|
35
|
-
* hiddenFrom('export class X {}\n') // []
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function hiddenFrom(source: string): readonly SurfaceSymbol[];
|
|
39
|
-
/**
|
|
40
|
-
* Join the declaration head starting at `start` into one space-separated
|
|
41
|
-
* line, consuming lines until the first that ends with `{`.
|
|
42
|
-
*
|
|
43
|
-
* @param lines - The file's source lines
|
|
44
|
-
* @param start - The index of the head's first line
|
|
45
|
-
* @returns The joined head, or `undefined` when no line opens a body
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* The body lines of the named `export class` / `export interface` declaration
|
|
55
|
-
* within one file's source text — everything between the head's opening `{`
|
|
56
|
-
* and the column-0 closing `}`.
|
|
57
|
-
*
|
|
58
|
-
* @param source - The file's source text to search
|
|
59
|
-
* @param keyword - Whether to look for a `class` or an `interface`
|
|
60
|
-
* @param name - The declaration's identifier
|
|
61
|
-
* @returns The declaration's body lines, or an empty array when `source` does not declare it
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* declarationBody('export interface X {\n\twalk(): void\n}\n', 'interface', 'X') // ['\twalk(): void']
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function declarationBody(source: string, keyword: 'class' | 'interface', name: string): readonly string[];
|
|
69
|
-
/**
|
|
70
|
-
* The member lines declaring a callable member: plain, `async`, generator
|
|
71
|
-
* (`*`), and optional (`records?(`) methods all count; getters, setters,
|
|
72
|
-
* `static` members, and `#` privates never do (their keyword or `#` breaks
|
|
73
|
-
* the `name(` shape).
|
|
74
|
-
*
|
|
75
|
-
* @param lines - A declaration's body lines
|
|
76
|
-
* @returns The declared method names, deduped and sorted
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
80
|
-
* memberMethods(['\tmap(): void', '\tfilter(): void']) // ['filter', 'map']
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export declare function memberMethods(lines: readonly string[]): readonly string[];
|
|
84
|
-
/**
|
|
85
|
-
* The block nodes under the named `##` heading, up to the next `##`-or-higher
|
|
86
|
-
* heading (or the document's end) — the section-scoping window `extractSurface` /
|
|
87
|
-
* `extractMethods` walk over.
|
|
88
|
-
*
|
|
89
|
-
* @param document - The parsed guide document
|
|
90
|
-
* @param heading - The `##` heading text to scope to (e.g. `Surface`)
|
|
91
|
-
* @returns The blocks belonging to that section, in document order
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* sectionBlocks(document, 'Surface') // the blocks between `## Surface` and the next `##`
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function sectionBlocks(document: MarkdownDocument, heading: string): readonly BlockNode[];
|
|
99
|
-
/**
|
|
100
|
-
* Every `## Surface` identifier the guide documents — each table row's column 0
|
|
101
|
-
* code span (the name) paired with its `Kind` column (located by header text)
|
|
102
|
-
* UNION every backticked H3 entity heading in the section
|
|
103
|
-
* (`{name: <codeSpan>, kind: 'class'}`), deduped by {@link symbolKey}. A row with
|
|
104
|
-
* no code-span name, or an unrecognized `Kind` text, is skipped.
|
|
105
|
-
*
|
|
106
|
-
* @param document - The parsed guide document
|
|
107
|
-
* @returns The documented surface, in encounter order
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* extractSurface(document) // [{ name: 'Markdown', kind: 'class' }, ...]
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
export declare function extractSurface(document: MarkdownDocument): readonly SurfaceSymbol[];
|
|
115
|
-
/**
|
|
116
|
-
* One {@link MethodGroup} per documented behavioral interface in `## Methods` —
|
|
117
|
-
* an H4 with a code span sets the current interface, and the table immediately
|
|
118
|
-
* following becomes its documented methods.
|
|
119
|
-
*
|
|
120
|
-
* @param document - The parsed guide document
|
|
121
|
-
* @returns The documented method groups, in document order
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```ts
|
|
125
|
-
* extractMethods(document) // [{ interface: 'MarkdownInterface', methods: ['walk', ...] }]
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
export declare function extractMethods(document: MarkdownDocument): readonly MethodGroup[];
|
|
129
|
-
/**
|
|
130
|
-
* Every link href in the guide document, including table cells — a full,
|
|
131
|
-
* depth-first walk of the whole AST.
|
|
132
|
-
*
|
|
133
|
-
* @param document - The parsed guide document
|
|
134
|
-
* @returns Every link's href, in walk order
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* extractLinks(document) // ['../../src/core/helpers.ts', 'https://example.com']
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export declare function extractLinks(document: MarkdownDocument): readonly string[];
|
|
142
|
-
/**
|
|
143
|
-
* The relative test links declared under `## Tests` — every link href found
|
|
144
|
-
* within that section only.
|
|
145
|
-
*
|
|
146
|
-
* @param document - The parsed guide document
|
|
147
|
-
* @returns The `## Tests` section's link hrefs, in walk order
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* extractTests(document) // ['../../tests/src/core/Markdown.test.ts', ...]
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
export declare function extractTests(document: MarkdownDocument): readonly string[];
|
|
155
|
-
/**
|
|
156
|
-
* The exported functions in one file's source text whose immediately preceding
|
|
157
|
-
* JSDoc block carries `@example` — walked line by line, tracking the current
|
|
158
|
-
* comment block; the block resets on any non-comment, non-export line so an
|
|
159
|
-
* `@example` never attaches to a declaration it does not directly precede.
|
|
160
|
-
*
|
|
161
|
-
* @param source - The file's source text
|
|
162
|
-
* @returns The exported function names with an `@example`, in file order
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```ts
|
|
166
|
-
* const block = ['/**', ' * @example', ' *' + '/', 'export function walk() {}', ''].join('\n')
|
|
167
|
-
* examplesFrom(block) // ['walk']
|
|
168
|
-
* examplesFrom('export function walk() {}\n') // []
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
export declare function examplesFrom(source: string): readonly string[];
|
|
172
|
-
/**
|
|
173
|
-
* The callable-member names in a declaration body (per {@link memberMethods}'
|
|
174
|
-
* grammar) whose immediately preceding JSDoc block, within the same body,
|
|
175
|
-
* carries `@example` — the member-level mirror of {@link examplesFrom}.
|
|
176
|
-
*
|
|
177
|
-
* @param lines - A declaration's body lines
|
|
178
|
-
* @returns The exemplified member names, deduped and sorted
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* exampleMethods(['\t/**', '\t * @example', '\t *' + '/', '\twalk(): void']) // ['walk']
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
export declare function exampleMethods(lines: readonly string[]): readonly string[];
|
|
186
|
-
/**
|
|
187
|
-
* Every ```ts fenced code block's body text anywhere in the guide document —
|
|
188
|
-
* a full AST walk so a fence nested inside a blockquote or list still counts.
|
|
189
|
-
*
|
|
190
|
-
* @param document - The parsed guide document
|
|
191
|
-
* @returns Every `ts`-lang fence's verbatim code, in walk order
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* extractPatterns(document) // ["import { X } from './x.js'\nX()"]
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
export declare function extractPatterns(document: MarkdownDocument): readonly string[];
|
|
199
|
-
/**
|
|
200
|
-
* Parse a `## By concept` manifest table into its {@link ManifestEntry} rows —
|
|
201
|
-
* each row's Concept cell (flattened text), Spec / Tests cells (a single link
|
|
202
|
-
* href, resolved against `base`), and Source cell (every link href, resolved
|
|
203
|
-
* against `base`; one directory collapses to a `string`, several become a
|
|
204
|
-
* `readonly string[]`). A row missing a concept, spec link, tests link, or
|
|
205
|
-
* source link is skipped as malformed.
|
|
206
|
-
*
|
|
207
|
-
* @param markdown - The manifest markdown source (e.g. `guides/README.md`'s content)
|
|
208
|
-
* @param base - A single directory name relative to the workspace root that the manifest's
|
|
209
|
-
* links are resolved against (e.g. `'guides'`) — {@link resolveLink}'s arithmetic supports
|
|
210
|
-
* only one path segment, so a deeper or nested base is not supported
|
|
211
|
-
* @returns The manifest's entries, in row order
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* parseManifest(readme, 'guides') // [{ concept: 'Markdown', spec: 'guides/src/markdown.md', ... }]
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
export declare function parseManifest(markdown: string, base: string): readonly ManifestEntry[];
|