@driftsys/markspec 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -8
- package/esm/compiler/inverses.d.ts +22 -0
- package/esm/compiler/inverses.d.ts.map +1 -0
- package/esm/compiler/inverses.js +147 -0
- package/esm/compiler/link_target.d.ts +19 -0
- package/esm/compiler/link_target.d.ts.map +1 -0
- package/esm/compiler/link_target.js +66 -0
- package/esm/compiler/mod.d.ts +7 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +61 -14
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +20 -1
- package/esm/config/markspec.d.ts +51 -0
- package/esm/config/markspec.d.ts.map +1 -0
- package/esm/config/markspec.js +216 -0
- package/esm/config/mod.d.ts +4 -0
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +27 -16
- package/esm/formatter/mod.d.ts +19 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +139 -29
- package/esm/mod.d.ts +11 -7
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +6 -3
- package/esm/model/attributes.d.ts +47 -0
- package/esm/model/attributes.d.ts.map +1 -0
- package/esm/model/attributes.js +97 -0
- package/esm/model/mod.d.ts +257 -26
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +28 -1
- package/esm/model/palette.d.ts +18 -0
- package/esm/model/palette.d.ts.map +1 -0
- package/esm/model/palette.js +23 -0
- package/esm/model/profile.d.ts +189 -0
- package/esm/model/profile.d.ts.map +1 -0
- package/esm/model/profile.js +31 -0
- package/esm/parser/attributes.d.ts +13 -1
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +47 -0
- package/esm/parser/frontmatter.d.ts +53 -0
- package/esm/parser/frontmatter.d.ts.map +1 -0
- package/esm/parser/frontmatter.js +185 -0
- package/esm/parser/grammars.js +11 -2
- package/esm/parser/markdown.d.ts +21 -7
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +101 -40
- package/esm/parser/mod.d.ts +26 -10
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +40 -10
- package/esm/parser/source.d.ts +12 -8
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +21 -14
- package/esm/profile/cache.d.ts +29 -0
- package/esm/profile/cache.d.ts.map +1 -0
- package/esm/profile/cache.js +45 -0
- package/esm/profile/chain.d.ts +42 -0
- package/esm/profile/chain.d.ts.map +1 -0
- package/esm/profile/chain.js +193 -0
- package/esm/profile/colors.d.ts +26 -0
- package/esm/profile/colors.d.ts.map +1 -0
- package/esm/profile/colors.js +46 -0
- package/esm/profile/git-cache.d.ts +73 -0
- package/esm/profile/git-cache.d.ts.map +1 -0
- package/esm/profile/git-cache.js +96 -0
- package/esm/profile/load.d.ts +28 -0
- package/esm/profile/load.d.ts.map +1 -0
- package/esm/profile/load.js +50 -0
- package/esm/profile/manifest.d.ts +21 -0
- package/esm/profile/manifest.d.ts.map +1 -0
- package/esm/profile/manifest.js +815 -0
- package/esm/profile/merge.d.ts +26 -0
- package/esm/profile/merge.d.ts.map +1 -0
- package/esm/profile/merge.js +518 -0
- package/esm/profile/mod.d.ts +24 -0
- package/esm/profile/mod.d.ts.map +1 -0
- package/esm/profile/mod.js +15 -0
- package/esm/profile/npm.d.ts +51 -0
- package/esm/profile/npm.d.ts.map +1 -0
- package/esm/profile/npm.js +186 -0
- package/esm/profile/resolver.d.ts +60 -0
- package/esm/profile/resolver.d.ts.map +1 -0
- package/esm/profile/resolver.js +132 -0
- package/esm/reporter/mod.js +14 -27
- package/esm/validator/attributes.d.ts +43 -0
- package/esm/validator/attributes.d.ts.map +1 -0
- package/esm/validator/attributes.js +169 -0
- package/esm/validator/mod.d.ts +27 -6
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +132 -124
- package/esm/validator/normalize.d.ts +21 -0
- package/esm/validator/normalize.d.ts.map +1 -0
- package/esm/validator/normalize.js +58 -0
- package/esm/validator/pattern.d.ts +23 -0
- package/esm/validator/pattern.d.ts.map +1 -0
- package/esm/validator/pattern.js +44 -0
- package/esm/validator/pipeline.d.ts +30 -0
- package/esm/validator/pipeline.d.ts.map +1 -0
- package/esm/validator/pipeline.js +115 -0
- package/esm/validator/traceability.d.ts +48 -0
- package/esm/validator/traceability.d.ts.map +1 -0
- package/esm/validator/traceability.js +141 -0
- package/esm/validator/types.d.ts +48 -0
- package/esm/validator/types.d.ts.map +1 -0
- package/esm/validator/types.js +140 -0
- package/esm/validator/value_types.d.ts +20 -0
- package/esm/validator/value_types.d.ts.map +1 -0
- package/esm/validator/value_types.js +126 -0
- package/package.json +1 -1
- package/script/compiler/inverses.d.ts +22 -0
- package/script/compiler/inverses.d.ts.map +1 -0
- package/script/compiler/inverses.js +150 -0
- package/script/compiler/link_target.d.ts +19 -0
- package/script/compiler/link_target.d.ts.map +1 -0
- package/script/compiler/link_target.js +69 -0
- package/script/compiler/mod.d.ts +7 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +62 -14
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +20 -1
- package/script/config/markspec.d.ts +51 -0
- package/script/config/markspec.d.ts.map +1 -0
- package/script/config/markspec.js +222 -0
- package/script/config/mod.d.ts +4 -0
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +28 -16
- package/script/formatter/mod.d.ts +19 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +140 -29
- package/script/mod.d.ts +11 -7
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +50 -19
- package/script/model/attributes.d.ts +47 -0
- package/script/model/attributes.d.ts.map +1 -0
- package/script/model/attributes.js +101 -0
- package/script/model/mod.d.ts +257 -26
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +37 -2
- package/script/model/palette.d.ts +18 -0
- package/script/model/palette.d.ts.map +1 -0
- package/script/model/palette.js +26 -0
- package/script/model/profile.d.ts +189 -0
- package/script/model/profile.d.ts.map +1 -0
- package/script/model/profile.js +34 -0
- package/script/parser/attributes.d.ts +13 -1
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +48 -0
- package/script/parser/frontmatter.d.ts +53 -0
- package/script/parser/frontmatter.d.ts.map +1 -0
- package/script/parser/frontmatter.js +188 -0
- package/script/parser/grammars.js +11 -2
- package/script/parser/markdown.d.ts +21 -7
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +100 -39
- package/script/parser/mod.d.ts +26 -10
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +42 -11
- package/script/parser/source.d.ts +12 -8
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +21 -14
- package/script/profile/cache.d.ts +29 -0
- package/script/profile/cache.d.ts.map +1 -0
- package/script/profile/cache.js +48 -0
- package/script/profile/chain.d.ts +42 -0
- package/script/profile/chain.d.ts.map +1 -0
- package/script/profile/chain.js +229 -0
- package/script/profile/colors.d.ts +26 -0
- package/script/profile/colors.d.ts.map +1 -0
- package/script/profile/colors.js +49 -0
- package/script/profile/git-cache.d.ts +73 -0
- package/script/profile/git-cache.d.ts.map +1 -0
- package/script/profile/git-cache.js +104 -0
- package/script/profile/load.d.ts +28 -0
- package/script/profile/load.d.ts.map +1 -0
- package/script/profile/load.js +53 -0
- package/script/profile/manifest.d.ts +21 -0
- package/script/profile/manifest.d.ts.map +1 -0
- package/script/profile/manifest.js +818 -0
- package/script/profile/merge.d.ts +26 -0
- package/script/profile/merge.d.ts.map +1 -0
- package/script/profile/merge.js +521 -0
- package/script/profile/mod.d.ts +24 -0
- package/script/profile/mod.d.ts.map +1 -0
- package/script/profile/mod.js +33 -0
- package/script/profile/npm.d.ts +51 -0
- package/script/profile/npm.d.ts.map +1 -0
- package/script/profile/npm.js +191 -0
- package/script/profile/resolver.d.ts +60 -0
- package/script/profile/resolver.d.ts.map +1 -0
- package/script/profile/resolver.js +136 -0
- package/script/reporter/mod.js +14 -27
- package/script/validator/attributes.d.ts +43 -0
- package/script/validator/attributes.d.ts.map +1 -0
- package/script/validator/attributes.js +173 -0
- package/script/validator/mod.d.ts +27 -6
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +145 -123
- package/script/validator/normalize.d.ts +21 -0
- package/script/validator/normalize.d.ts.map +1 -0
- package/script/validator/normalize.js +61 -0
- package/script/validator/pattern.d.ts +23 -0
- package/script/validator/pattern.d.ts.map +1 -0
- package/script/validator/pattern.js +47 -0
- package/script/validator/pipeline.d.ts +30 -0
- package/script/validator/pipeline.d.ts.map +1 -0
- package/script/validator/pipeline.js +118 -0
- package/script/validator/traceability.d.ts +48 -0
- package/script/validator/traceability.d.ts.map +1 -0
- package/script/validator/traceability.js +146 -0
- package/script/validator/types.d.ts +48 -0
- package/script/validator/types.d.ts.map +1 -0
- package/script/validator/types.js +144 -0
- package/script/validator/value_types.d.ts +20 -0
- package/script/validator/value_types.d.ts.map +1 -0
- package/script/validator/value_types.js +129 -0
package/esm/parser/markdown.js
CHANGED
|
@@ -2,39 +2,51 @@
|
|
|
2
2
|
* @module parser/markdown
|
|
3
3
|
*
|
|
4
4
|
* CommonMark + MarkSpec extension parser. Walks the mdast AST to detect
|
|
5
|
-
* `- [
|
|
5
|
+
* `- [DISPLAY_ID] Title` entry blocks and extract structured attributes.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { IDENTITY_KEY, shapeFromIdValue } from "../model/mod.js";
|
|
8
|
+
import { collateAttributes, parseAttributes, splitBodyAndAttributes, } from "./attributes.js";
|
|
8
9
|
import { processor } from "./remark.js";
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Reference entry display ID pattern: letters, digits, hyphens.
|
|
11
|
+
* Slug pattern for referenced-entry display IDs.
|
|
12
|
+
*
|
|
13
|
+
* Pandoc/BibTeX cite-key convention, restricted to a portable character set
|
|
14
|
+
* (`.`, `/`, `_`, `-` accepted inside; must start with a letter and end
|
|
15
|
+
* with an alphanumeric).
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
|
|
18
|
+
/** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
|
|
19
|
+
const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* Find the `Id:` attribute on an entry. Returns undefined when absent. If
|
|
22
|
+
* more than one `Id:` is present, returns the first — the validator flags
|
|
23
|
+
* this as MSL-R003.
|
|
21
24
|
*/
|
|
22
|
-
|
|
25
|
+
function findIdentityAttribute(attributes) {
|
|
26
|
+
for (const attr of attributes) {
|
|
27
|
+
if (attr.key === IDENTITY_KEY)
|
|
28
|
+
return attr;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
23
32
|
/**
|
|
24
33
|
* Parse a Markdown string and return all MarkSpec entries found.
|
|
25
34
|
*
|
|
26
|
-
* Walks the mdast AST to detect `- [DISPLAY_ID] Title` list items
|
|
27
|
-
*
|
|
28
|
-
*
|
|
35
|
+
* Walks the mdast AST to detect `- [DISPLAY_ID] Title` list items with
|
|
36
|
+
* indented body content. Extracts display ID, title, body, and trailing
|
|
37
|
+
* attribute blocks. Entry shape (identified or referenced) is decided by
|
|
38
|
+
* the `Id:` attribute's value format.
|
|
29
39
|
*
|
|
30
40
|
* @param markdown - Markdown source text
|
|
31
41
|
* @param options - Parse options (file path for source locations)
|
|
32
|
-
* @returns
|
|
42
|
+
* @returns Parsed entries and any parse-level diagnostics
|
|
33
43
|
*/
|
|
34
44
|
export function parseMarkdown(markdown, options) {
|
|
35
45
|
const file = options?.file ?? "<unknown>";
|
|
46
|
+
const isReferencesDoc = detectReferencesDocument(file, options?.isReferencesDoc);
|
|
36
47
|
const tree = processor.parse(markdown);
|
|
37
48
|
const entries = [];
|
|
49
|
+
const diagnostics = [];
|
|
38
50
|
// Collect link definition identifiers for shortcut reference exclusion.
|
|
39
51
|
const definitions = new Set(tree.children
|
|
40
52
|
.filter((n) => n.type === "definition")
|
|
@@ -47,18 +59,31 @@ export function parseMarkdown(markdown, options) {
|
|
|
47
59
|
if (list.ordered)
|
|
48
60
|
continue;
|
|
49
61
|
for (const item of list.children) {
|
|
50
|
-
const entry = extractEntry(item, markdown, file, definitions);
|
|
62
|
+
const entry = extractEntry(item, markdown, file, definitions, isReferencesDoc, diagnostics);
|
|
51
63
|
if (entry)
|
|
52
64
|
entries.push(entry);
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
|
-
return entries;
|
|
67
|
+
return { entries, diagnostics };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Detect if a file is a references document.
|
|
71
|
+
* References context enables recognition of reference entries (slugs).
|
|
72
|
+
* @param file - File path
|
|
73
|
+
* @param explicit - Explicit override (undefined = auto-detect)
|
|
74
|
+
*/
|
|
75
|
+
function detectReferencesDocument(file, explicit) {
|
|
76
|
+
if (explicit !== undefined)
|
|
77
|
+
return explicit;
|
|
78
|
+
const basename = file.split("/").pop() ?? "";
|
|
79
|
+
return basename === "references.md" || file.includes("/references/");
|
|
56
80
|
}
|
|
57
81
|
/**
|
|
58
82
|
* Attempt to extract a MarkSpec entry from a list item.
|
|
59
83
|
* Returns undefined if the list item is not an entry block.
|
|
84
|
+
* Diagnostics (e.g., deprecation warnings) are pushed into the accumulator.
|
|
60
85
|
*/
|
|
61
|
-
function extractEntry(item, markdown, file, definitions) {
|
|
86
|
+
function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagnostics) {
|
|
62
87
|
// Task list items (remark-gfm sets checked to true/false) are not entries.
|
|
63
88
|
if (item.checked != null)
|
|
64
89
|
return undefined;
|
|
@@ -111,28 +136,61 @@ function extractEntry(item, markdown, file, definitions) {
|
|
|
111
136
|
}
|
|
112
137
|
if (!displayId)
|
|
113
138
|
return undefined;
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
// If there's only one child (the title paragraph) and no further content,
|
|
120
|
-
// it's not an entry block.
|
|
121
|
-
if (item.children.length < 2)
|
|
122
|
-
return undefined;
|
|
123
|
-
// Extract entry type from typed display IDs
|
|
124
|
-
const typedMatch = TYPED_ID_RE.exec(displayId);
|
|
125
|
-
const entryType = typedMatch
|
|
126
|
-
? typedMatch[1]
|
|
127
|
-
: undefined;
|
|
128
|
-
// Extract body content from remaining children
|
|
139
|
+
// Strip optional leading `@` on referenced-entry display IDs for Pandoc
|
|
140
|
+
// citation compatibility. Canonical slug never contains `@`.
|
|
141
|
+
if (displayId.startsWith("@"))
|
|
142
|
+
displayId = displayId.slice(1);
|
|
143
|
+
// Extract body content and attributes.
|
|
129
144
|
const bodyContent = extractBodyContent(item, markdown);
|
|
130
|
-
// Split body and attributes
|
|
131
145
|
const [body, attrLines] = splitBodyAndAttributes(bodyContent);
|
|
132
146
|
const attributes = parseAttributes(attrLines);
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
// Detect legacy paragraph + trailing-backslash attribute form and warn.
|
|
148
|
+
if (attributes.length > 0 &&
|
|
149
|
+
attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
|
|
150
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
151
|
+
diagnostics.push({
|
|
152
|
+
code: "MSL-DEPRECATED-ATTR-001",
|
|
153
|
+
severity: "warning",
|
|
154
|
+
message: "legacy attribute block (paragraph with trailing `\\`) is deprecated; " +
|
|
155
|
+
"run `markspec format` to convert to the canonical indented code block",
|
|
156
|
+
location: { file, line: entryLine, column: 1 },
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// Discriminate shape by the `Id:` attribute's value format.
|
|
160
|
+
let shape;
|
|
161
|
+
let id;
|
|
162
|
+
const identityAttr = findIdentityAttribute(attributes);
|
|
163
|
+
if (identityAttr) {
|
|
164
|
+
id = identityAttr.value;
|
|
165
|
+
shape = shapeFromIdValue(identityAttr.value);
|
|
166
|
+
if (shape === undefined) {
|
|
167
|
+
// `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
|
|
168
|
+
// identified entry so the validator can surface MSL-R004; missing
|
|
169
|
+
// shape on a parsed entry is not useful downstream.
|
|
170
|
+
shape = "identified";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// No `Id:`. Fall back on display-ID shape + document context to decide
|
|
175
|
+
// whether to admit the entry at all.
|
|
176
|
+
if (isReferencesDoc && SLUG_RE.test(displayId)) {
|
|
177
|
+
shape = "referenced";
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// No identity attribute and no references-doc context — admit as
|
|
181
|
+
// identified so the validator can surface the missing-`Id:` error.
|
|
182
|
+
shape = "identified";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Inferred type from display-ID prefix — left to the profile layer. For
|
|
186
|
+
// now the core records no type; downstream profile-aware code populates
|
|
187
|
+
// this field when a profile is loaded.
|
|
188
|
+
const type = undefined;
|
|
189
|
+
// Body requirement: identified entries require a body; referenced entries
|
|
190
|
+
// may omit it. If there's only one child (the title paragraph), admit
|
|
191
|
+
// only referenced entries.
|
|
192
|
+
if (shape !== "referenced" && item.children.length < 2)
|
|
193
|
+
return undefined;
|
|
136
194
|
// Source location
|
|
137
195
|
const line = item.position?.start.line ?? 1;
|
|
138
196
|
const column = item.position?.start.column ?? 1;
|
|
@@ -140,11 +198,14 @@ function extractEntry(item, markdown, file, definitions) {
|
|
|
140
198
|
displayId,
|
|
141
199
|
title: title ?? "",
|
|
142
200
|
body,
|
|
143
|
-
attributes,
|
|
201
|
+
rawAttributes: attributes,
|
|
202
|
+
typedAttributes: collateAttributes(attributes),
|
|
144
203
|
id,
|
|
145
|
-
|
|
204
|
+
type,
|
|
205
|
+
shape,
|
|
146
206
|
location: { file, line, column },
|
|
147
207
|
source: "markdown",
|
|
208
|
+
properties: { file: { path: file, line, column } },
|
|
148
209
|
};
|
|
149
210
|
}
|
|
150
211
|
/**
|
package/esm/parser/mod.d.ts
CHANGED
|
@@ -9,15 +9,17 @@
|
|
|
9
9
|
* - directives: HTML comment directive extraction
|
|
10
10
|
* - source: doc comment extraction from Rust, Kotlin, C, C++, Java
|
|
11
11
|
*/
|
|
12
|
-
import type { Caption, Entry } from "../model/mod.js";
|
|
12
|
+
import type { Caption, Diagnostic, Document, Entry } from "../model/mod.js";
|
|
13
13
|
import { type DetectCaptionsOptions } from "./captions.js";
|
|
14
14
|
export type { DetectCaptionsOptions } from "./captions.js";
|
|
15
15
|
export { detectDirectives } from "./directives.js";
|
|
16
16
|
export type { DetectDirectivesOptions } from "./directives.js";
|
|
17
|
+
export { extractFrontMatter } from "./frontmatter.js";
|
|
18
|
+
export type { ExtractFrontMatterOptions, FrontMatterResult, } from "./frontmatter.js";
|
|
17
19
|
export { detectInlineRefs } from "./references.js";
|
|
18
20
|
export type { DetectInlineRefsOptions } from "./references.js";
|
|
19
21
|
export { parseSource } from "./source.js";
|
|
20
|
-
export type { ParseSourceOptions } from "./source.js";
|
|
22
|
+
export type { ParseSourceOptions, ParseSourceResult } from "./source.js";
|
|
21
23
|
export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
22
24
|
/** Options for {@linkcode parse}. */
|
|
23
25
|
export interface ParseOptions {
|
|
@@ -32,20 +34,34 @@ export interface ParseOptions {
|
|
|
32
34
|
* @returns Array of parsed entries
|
|
33
35
|
*/
|
|
34
36
|
export declare function parse(markdown: string, options?: ParseOptions): Entry[];
|
|
37
|
+
/** Result of parsing a file (entries + optional document + diagnostics). */
|
|
38
|
+
export interface ParseFileResult {
|
|
39
|
+
/** Parsed entries. */
|
|
40
|
+
readonly entries: Entry[];
|
|
41
|
+
/**
|
|
42
|
+
* Document-level metadata parsed from YAML front matter. `undefined` for
|
|
43
|
+
* source files (Rust/Kotlin/C/...) and for Markdown files without front
|
|
44
|
+
* matter; present otherwise so downstream consumers can resolve
|
|
45
|
+
* `{{document.*}}` inline references.
|
|
46
|
+
*/
|
|
47
|
+
readonly document?: Document;
|
|
48
|
+
/**
|
|
49
|
+
* Parse-level diagnostics (forbidden front-matter keys, malformed YAML).
|
|
50
|
+
* Merged into the compile result's diagnostics.
|
|
51
|
+
*/
|
|
52
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
53
|
+
}
|
|
35
54
|
/**
|
|
36
|
-
* Parse a file and return
|
|
55
|
+
* Parse a file and return entries, annotation links, and (for Markdown
|
|
56
|
+
* files) a Document with front-matter attributes.
|
|
37
57
|
*
|
|
38
58
|
* Source files (`.rs`, `.java`, `.c`, `.cpp`, etc.) are parsed with
|
|
39
|
-
* tree-sitter to extract doc comment entries
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param content - File content
|
|
43
|
-
* @param options - Must include `file` path for extension detection
|
|
44
|
-
* @returns Array of parsed entries
|
|
59
|
+
* tree-sitter to extract doc comment entries; no front matter is
|
|
60
|
+
* recognized on source files.
|
|
45
61
|
*/
|
|
46
62
|
export declare function parseFile(content: string, options: {
|
|
47
63
|
readonly file: string;
|
|
48
|
-
}): Promise<
|
|
64
|
+
}): Promise<ParseFileResult>;
|
|
49
65
|
/**
|
|
50
66
|
* Detect table and figure captions in a Markdown string.
|
|
51
67
|
*
|
package/esm/parser/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAElE,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,EAAE,CAET;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAYD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC,eAAe,CAAC,CAiC1B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,EAAE,CAEX"}
|
package/esm/parser/mod.js
CHANGED
|
@@ -13,8 +13,10 @@ import { extname } from "@std/path";
|
|
|
13
13
|
import { parseMarkdown } from "./markdown.js";
|
|
14
14
|
import { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
15
15
|
import { parseSource } from "./source.js";
|
|
16
|
+
import { extractFrontMatter } from "./frontmatter.js";
|
|
16
17
|
import { detectCaptions as detectCaptionsImpl, } from "./captions.js";
|
|
17
18
|
export { detectDirectives } from "./directives.js";
|
|
19
|
+
export { extractFrontMatter } from "./frontmatter.js";
|
|
18
20
|
export { detectInlineRefs } from "./references.js";
|
|
19
21
|
export { parseSource } from "./source.js";
|
|
20
22
|
export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
@@ -26,26 +28,54 @@ export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
|
26
28
|
* @returns Array of parsed entries
|
|
27
29
|
*/
|
|
28
30
|
export function parse(markdown, options) {
|
|
29
|
-
return parseMarkdown(markdown, options);
|
|
31
|
+
return parseMarkdown(markdown, options).entries;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Detect if a file is a references document.
|
|
35
|
+
* References context enables recognition of reference entries (slugs).
|
|
36
|
+
* @param file - File path
|
|
37
|
+
*/
|
|
38
|
+
function isReferencesDocument(file) {
|
|
39
|
+
const basename = file.split("/").pop() ?? "";
|
|
40
|
+
return basename === "references.md" || file.includes("/references/");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parse a file and return entries, annotation links, and (for Markdown
|
|
44
|
+
* files) a Document with front-matter attributes.
|
|
33
45
|
*
|
|
34
46
|
* Source files (`.rs`, `.java`, `.c`, `.cpp`, etc.) are parsed with
|
|
35
|
-
* tree-sitter to extract doc comment entries
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param content - File content
|
|
39
|
-
* @param options - Must include `file` path for extension detection
|
|
40
|
-
* @returns Array of parsed entries
|
|
47
|
+
* tree-sitter to extract doc comment entries; no front matter is
|
|
48
|
+
* recognized on source files.
|
|
41
49
|
*/
|
|
42
50
|
export async function parseFile(content, options) {
|
|
43
51
|
const ext = extname(options.file);
|
|
44
52
|
if (isSupportedExtension(ext)) {
|
|
45
53
|
const language = await loadGrammar(ext);
|
|
46
|
-
|
|
54
|
+
const result = parseSource(content, {
|
|
55
|
+
file: options.file,
|
|
56
|
+
language,
|
|
57
|
+
});
|
|
58
|
+
return { entries: result.entries, diagnostics: [] };
|
|
47
59
|
}
|
|
48
|
-
|
|
60
|
+
const fm = extractFrontMatter(content, { file: options.file });
|
|
61
|
+
const body = fm.hadFrontMatter ? fm.markdown : content;
|
|
62
|
+
const isReferencesDoc = isReferencesDocument(options.file);
|
|
63
|
+
const { entries, diagnostics: parseDiagnostics } = parseMarkdown(body, {
|
|
64
|
+
file: options.file,
|
|
65
|
+
isReferencesDoc,
|
|
66
|
+
});
|
|
67
|
+
const document = fm.hadFrontMatter
|
|
68
|
+
? {
|
|
69
|
+
file: options.file,
|
|
70
|
+
attributes: fm.attributes,
|
|
71
|
+
properties: {},
|
|
72
|
+
}
|
|
73
|
+
: undefined;
|
|
74
|
+
return {
|
|
75
|
+
entries,
|
|
76
|
+
document,
|
|
77
|
+
diagnostics: [...fm.diagnostics, ...parseDiagnostics],
|
|
78
|
+
};
|
|
49
79
|
}
|
|
50
80
|
/**
|
|
51
81
|
* Detect table and figure captions in a Markdown string.
|
package/esm/parser/source.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module parser/source
|
|
3
3
|
*
|
|
4
|
-
* Source-code doc-comment parser. Extracts MarkSpec
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Source-code doc-comment parser. Extracts MarkSpec entry blocks from doc
|
|
5
|
+
* comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
|
|
6
|
+
* content to the markdown parser for entry extraction.
|
|
7
7
|
*/
|
|
8
8
|
import Parser from "web-tree-sitter";
|
|
9
9
|
import type { Entry } from "../model/mod.js";
|
|
@@ -14,16 +14,20 @@ export interface ParseSourceOptions {
|
|
|
14
14
|
/** Pre-loaded tree-sitter language grammar. */
|
|
15
15
|
readonly language: Parser.Language;
|
|
16
16
|
}
|
|
17
|
+
/** Result of parsing a source file. */
|
|
18
|
+
export interface ParseSourceResult {
|
|
19
|
+
/** Entries found in doc comment blocks. */
|
|
20
|
+
readonly entries: Entry[];
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
|
-
* Parse a source file and return
|
|
23
|
+
* Parse a source file and return entries extracted from doc comments.
|
|
19
24
|
*
|
|
20
25
|
* Uses tree-sitter to parse the source, walks the AST to find doc comment
|
|
21
|
-
* nodes, strips comment prefixes, and delegates to the markdown parser
|
|
22
|
-
*
|
|
26
|
+
* nodes, strips comment prefixes, and delegates to the markdown parser for
|
|
27
|
+
* entry extraction. Doc comments that don't contain entry blocks are ignored.
|
|
23
28
|
*
|
|
24
29
|
* @param content - Source file text
|
|
25
30
|
* @param options - Parse options (language grammar, file path)
|
|
26
|
-
* @returns Array of parsed entries with `source: "doc-comment"`
|
|
27
31
|
*/
|
|
28
|
-
export declare function parseSource(content: string, options: ParseSourceOptions):
|
|
32
|
+
export declare function parseSource(content: string, options: ParseSourceOptions): ParseSourceResult;
|
|
29
33
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CACpC;AAYD
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CACpC;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;CAC3B;AAYD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAsCnB"}
|
package/esm/parser/source.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module parser/source
|
|
3
3
|
*
|
|
4
|
-
* Source-code doc-comment parser. Extracts MarkSpec
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Source-code doc-comment parser. Extracts MarkSpec entry blocks from doc
|
|
5
|
+
* comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
|
|
6
|
+
* content to the markdown parser for entry extraction.
|
|
7
7
|
*/
|
|
8
8
|
import Parser from "web-tree-sitter";
|
|
9
9
|
import { parseMarkdown } from "./markdown.js";
|
|
10
10
|
/**
|
|
11
|
-
* Parse a source file and return
|
|
11
|
+
* Parse a source file and return entries extracted from doc comments.
|
|
12
12
|
*
|
|
13
13
|
* Uses tree-sitter to parse the source, walks the AST to find doc comment
|
|
14
|
-
* nodes, strips comment prefixes, and delegates to the markdown parser
|
|
15
|
-
*
|
|
14
|
+
* nodes, strips comment prefixes, and delegates to the markdown parser for
|
|
15
|
+
* entry extraction. Doc comments that don't contain entry blocks are ignored.
|
|
16
16
|
*
|
|
17
17
|
* @param content - Source file text
|
|
18
18
|
* @param options - Parse options (language grammar, file path)
|
|
19
|
-
* @returns Array of parsed entries with `source: "doc-comment"`
|
|
20
19
|
*/
|
|
21
20
|
export function parseSource(content, options) {
|
|
22
21
|
const file = options.file ?? "<unknown>";
|
|
@@ -28,22 +27,30 @@ export function parseSource(content, options) {
|
|
|
28
27
|
const entries = [];
|
|
29
28
|
for (const block of blocks) {
|
|
30
29
|
const markdown = wrapAsListItem(block.lines);
|
|
31
|
-
const parsed = parseMarkdown(markdown, { file });
|
|
30
|
+
const { entries: parsed } = parseMarkdown(markdown, { file });
|
|
32
31
|
for (const entry of parsed) {
|
|
32
|
+
const location = {
|
|
33
|
+
file,
|
|
34
|
+
line: block.startLine,
|
|
35
|
+
column: block.startColumn,
|
|
36
|
+
};
|
|
33
37
|
entries.push({
|
|
34
38
|
...entry,
|
|
35
39
|
source: "doc-comment",
|
|
36
|
-
location
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
location,
|
|
41
|
+
properties: {
|
|
42
|
+
file: {
|
|
43
|
+
path: file,
|
|
44
|
+
line: block.startLine,
|
|
45
|
+
column: block.startColumn,
|
|
46
|
+
},
|
|
40
47
|
},
|
|
41
48
|
});
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
tree.delete();
|
|
45
52
|
parser.delete();
|
|
46
|
-
return entries;
|
|
53
|
+
return { entries };
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* Recursively walk the tree-sitter AST and collect doc comment blocks.
|
|
@@ -95,7 +102,7 @@ function walkForDocComments(node, blocks) {
|
|
|
95
102
|
});
|
|
96
103
|
continue;
|
|
97
104
|
}
|
|
98
|
-
// Non-comment node — flush pending line comments, then recurse
|
|
105
|
+
// Non-comment node — flush pending line comments, then recurse.
|
|
99
106
|
flushLineBlock();
|
|
100
107
|
if (child.childCount > 0) {
|
|
101
108
|
walkForDocComments(child, blocks);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/cache
|
|
3
|
+
*
|
|
4
|
+
* XDG-compliant cache directory resolution for profile storage.
|
|
5
|
+
* Profiles fetched from git or npm are cached globally so they can
|
|
6
|
+
* be shared across projects.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Environment variables consulted for cache directory resolution.
|
|
10
|
+
* Injectable for testing — production code passes `Deno.env.toObject()`.
|
|
11
|
+
*/
|
|
12
|
+
export interface CacheEnv {
|
|
13
|
+
readonly XDG_CACHE_HOME?: string;
|
|
14
|
+
readonly HOME?: string;
|
|
15
|
+
readonly LOCALAPPDATA?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the global markspec cache directory (XDG-compliant).
|
|
19
|
+
*
|
|
20
|
+
* - `$XDG_CACHE_HOME/markspec` if set (any platform)
|
|
21
|
+
* - macOS: `~/Library/Caches/markspec`
|
|
22
|
+
* - Windows: `%LOCALAPPDATA%/markspec/cache`
|
|
23
|
+
* - Linux/other: `~/.cache/markspec`
|
|
24
|
+
*
|
|
25
|
+
* @param env - Environment variables (injectable for tests)
|
|
26
|
+
* @param platform - OS platform string (injectable for tests; defaults to `Deno.build.os`)
|
|
27
|
+
*/
|
|
28
|
+
export declare function cacheDir(env?: CacheEnv, platform?: string): string;
|
|
29
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/profile/cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,GAAG,CAAC,EAAE,QAAQ,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAsBR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/cache
|
|
3
|
+
*
|
|
4
|
+
* XDG-compliant cache directory resolution for profile storage.
|
|
5
|
+
* Profiles fetched from git or npm are cached globally so they can
|
|
6
|
+
* be shared across projects.
|
|
7
|
+
*/
|
|
8
|
+
import { join } from "@std/path";
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the global markspec cache directory (XDG-compliant).
|
|
11
|
+
*
|
|
12
|
+
* - `$XDG_CACHE_HOME/markspec` if set (any platform)
|
|
13
|
+
* - macOS: `~/Library/Caches/markspec`
|
|
14
|
+
* - Windows: `%LOCALAPPDATA%/markspec/cache`
|
|
15
|
+
* - Linux/other: `~/.cache/markspec`
|
|
16
|
+
*
|
|
17
|
+
* @param env - Environment variables (injectable for tests)
|
|
18
|
+
* @param platform - OS platform string (injectable for tests; defaults to `Deno.build.os`)
|
|
19
|
+
*/
|
|
20
|
+
export function cacheDir(env, platform) {
|
|
21
|
+
const e = env ?? envFromDeno();
|
|
22
|
+
const os = platform ?? Deno.build.os;
|
|
23
|
+
if (e.XDG_CACHE_HOME) {
|
|
24
|
+
return join(e.XDG_CACHE_HOME, "markspec");
|
|
25
|
+
}
|
|
26
|
+
if (os === "darwin") {
|
|
27
|
+
const home = e.HOME ?? "/tmp";
|
|
28
|
+
return join(home, "Library", "Caches", "markspec");
|
|
29
|
+
}
|
|
30
|
+
if (os === "windows") {
|
|
31
|
+
const localAppData = e.LOCALAPPDATA ??
|
|
32
|
+
join(e.HOME ?? "C:\\Users\\default", "AppData", "Local");
|
|
33
|
+
return join(localAppData, "markspec", "cache");
|
|
34
|
+
}
|
|
35
|
+
// Linux and others — XDG default
|
|
36
|
+
const home = e.HOME ?? "/tmp";
|
|
37
|
+
return join(home, ".cache", "markspec");
|
|
38
|
+
}
|
|
39
|
+
function envFromDeno() {
|
|
40
|
+
return {
|
|
41
|
+
XDG_CACHE_HOME: Deno.env.get("XDG_CACHE_HOME"),
|
|
42
|
+
HOME: Deno.env.get("HOME"),
|
|
43
|
+
LOCALAPPDATA: Deno.env.get("LOCALAPPDATA"),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/chain
|
|
3
|
+
*
|
|
4
|
+
* Profile chain loader. Walks the `extends:` pointer from a leaf specifier
|
|
5
|
+
* up to the root, producing a multi-tier {@linkcode ProfileChain} ordered
|
|
6
|
+
* root → leaf.
|
|
7
|
+
*
|
|
8
|
+
* Supports both local and git specifiers, with cycle + depth detection. Git
|
|
9
|
+
* specifiers route through {@linkcode resolveGitSpecifier} (per-project
|
|
10
|
+
* shallow+sparse clone cache); local specifiers route through
|
|
11
|
+
* {@linkcode resolveLocalSpecifier}. The chain's {@linkcode EffectiveProfile}
|
|
12
|
+
* is produced by {@linkcode mergeChain}.
|
|
13
|
+
*/
|
|
14
|
+
import type { ReadFile } from "../config/mod.js";
|
|
15
|
+
import type { Diagnostic, ProfileChain, ProfileSpecifier } from "../model/mod.js";
|
|
16
|
+
import type { AppendFile, RunGit } from "./git-cache.js";
|
|
17
|
+
/** Result of loading a profile chain. */
|
|
18
|
+
export interface LoadChainResult {
|
|
19
|
+
readonly chain: ProfileChain | null;
|
|
20
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
21
|
+
}
|
|
22
|
+
/** Options accepted by {@linkcode loadChain}. */
|
|
23
|
+
export interface LoadChainOptions {
|
|
24
|
+
readonly runGit?: RunGit;
|
|
25
|
+
readonly appendFile?: AppendFile;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load a profile chain from a specifier, walking the `extends:` pointer up
|
|
29
|
+
* to the root. The returned chain's tiers are ordered root → leaf, so
|
|
30
|
+
* `tiers[0]` is the ultimate ancestor and `tiers[last]` is the leaf
|
|
31
|
+
* specified by the caller.
|
|
32
|
+
*
|
|
33
|
+
* @param specifier - The leaf specifier (from `.markspec.yaml`)
|
|
34
|
+
* @param contextDir - Directory the specifier was declared in (for local
|
|
35
|
+
* path resolution)
|
|
36
|
+
* @param projectRoot - Absolute path of the project root (used to locate
|
|
37
|
+
* the `.markspec/cache/` directory for git specifiers)
|
|
38
|
+
* @param readFile - File reader abstraction
|
|
39
|
+
* @param opts - Injectable runners for git-cache operations (optional)
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadChain(specifier: ProfileSpecifier, contextDir: string, projectRoot: string, readFile: ReadFile, opts?: LoadChainOptions): Promise<LoadChainResult>;
|
|
42
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/profile/chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EAGV,YAAY,EACZ,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAYzD,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,eAAe,CAAC,CA+G1B"}
|