@eriknaslund/skiss 0.4.0 → 0.6.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 +9 -4
- package/dist/cli.js +317 -30
- package/dist/index.d.ts +58 -5
- package/dist/index.js +427 -35
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,12 @@ interface FieldNode {
|
|
|
55
55
|
}
|
|
56
56
|
interface ClassNode {
|
|
57
57
|
name: Name;
|
|
58
|
+
/**
|
|
59
|
+
* The class after `<` (SPEC §3.10), set by `parse` whenever one is written.
|
|
60
|
+
* `resolve` clears it on the class whose `<` closes a circle, as it clears
|
|
61
|
+
* `identifier` on a second `*`, so no generator has to know about circles.
|
|
62
|
+
*/
|
|
63
|
+
parent?: Name;
|
|
58
64
|
system?: Name;
|
|
59
65
|
similarTo?: Name;
|
|
60
66
|
description?: string;
|
|
@@ -65,10 +71,11 @@ interface ClassNode {
|
|
|
65
71
|
type Severity = 'error' | 'warning';
|
|
66
72
|
/**
|
|
67
73
|
* Codes from the tables in docs/ARCHITECTURE.md. `parse` adds the `E_` codes,
|
|
68
|
-
* `resolve` the `W_` codes
|
|
74
|
+
* `resolve` the `W_` codes and `E_INHERITANCE_CYCLE`, the one error no single
|
|
75
|
+
* line can see (SPEC §7), and `importLinkML` the one code of its own,
|
|
69
76
|
* `E_NOT_YAML`, for a text no schema can be read out of.
|
|
70
77
|
*/
|
|
71
|
-
type DiagnosticCode = 'E_UNPARSABLE' | 'E_FIELD_WITHOUT_CLASS' | 'E_MISSING_TYPE' | 'E_UNCLOSED_MANY' | 'E_BAD_NAME' | 'W_UNKNOWN_TYPE' | 'W_UNDECLARED_CLASS' | 'W_UNDECLARED_FIELD' | 'W_DUPLICATE_CLASS' | 'W_DUPLICATE_FIELD' | 'W_DUPLICATE_ENUM_VALUE' | 'W_MULTIPLE_IDENTIFIERS' | 'E_NOT_YAML';
|
|
78
|
+
type DiagnosticCode = 'E_UNPARSABLE' | 'E_FIELD_WITHOUT_CLASS' | 'E_MISSING_TYPE' | 'E_UNCLOSED_MANY' | 'E_BAD_NAME' | 'E_INHERITANCE_CYCLE' | 'W_UNKNOWN_TYPE' | 'W_UNDECLARED_CLASS' | 'W_UNDECLARED_FIELD' | 'W_DUPLICATE_CLASS' | 'W_DUPLICATE_FIELD' | 'W_DUPLICATE_ENUM_VALUE' | 'W_MULTIPLE_IDENTIFIERS' | 'W_REDUNDANT_OVERRIDE' | 'E_NOT_YAML';
|
|
72
79
|
interface Diagnostic {
|
|
73
80
|
severity: Severity;
|
|
74
81
|
code: DiagnosticCode;
|
|
@@ -106,9 +113,10 @@ interface LinkMLAttribute {
|
|
|
106
113
|
identifier?: boolean;
|
|
107
114
|
annotations?: LinkMLAnnotations;
|
|
108
115
|
}
|
|
109
|
-
/** One entry under `classes`. Key order is SPEC §5.
|
|
116
|
+
/** One entry under `classes`. Key order is SPEC §5.1, Inheritance. */
|
|
110
117
|
interface LinkMLClass {
|
|
111
118
|
description?: string;
|
|
119
|
+
is_a?: string;
|
|
112
120
|
annotations?: LinkMLAnnotations;
|
|
113
121
|
close_mappings?: string[];
|
|
114
122
|
attributes?: Record<string, LinkMLAttribute>;
|
|
@@ -197,6 +205,51 @@ declare function formatDropped(dropped: Dropped[]): string;
|
|
|
197
205
|
|
|
198
206
|
declare function toSkiss(doc: Document): string;
|
|
199
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Where the words of a Skiss line are, so an editor can colour them.
|
|
210
|
+
*
|
|
211
|
+
* This is not a parser and holds no language logic (AGENTS.md §2): nothing
|
|
212
|
+
* here decides whether a line is valid, what it means or what it compiles to.
|
|
213
|
+
* It reads the shapes of SPEC §3 and §4 far enough to say "this run of
|
|
214
|
+
* characters is a class name, that one is an operator", and says nothing at
|
|
215
|
+
* all about a run it does not recognise, which is what leaves a half-typed
|
|
216
|
+
* line looking calm instead of wrong. Diagnostics stay the compiler's, and
|
|
217
|
+
* reach the editor through the gutter.
|
|
218
|
+
*
|
|
219
|
+
* Every line is read on its own, as the language is (SPEC §4): no state is
|
|
220
|
+
* carried from one line to the next, so an edit is never more than one line
|
|
221
|
+
* of work.
|
|
222
|
+
*
|
|
223
|
+
* The productions come from `parse.ts` — the name shapes, the primitive
|
|
224
|
+
* table, what a word is and where a trailer starts — so that the colours and
|
|
225
|
+
* the compiler can never disagree about them (ADR 0010).
|
|
226
|
+
*/
|
|
227
|
+
/** What a run of characters is, as far as colour is concerned. */
|
|
228
|
+
type TokenKind = 'class' | 'field' | 'system' | 'primitive'
|
|
229
|
+
/** A lowercase word after `:` that is no primitive. The compiler warns; the colour does not. */
|
|
230
|
+
| 'type' | 'enum'
|
|
231
|
+
/** The operators of SPEC §4, `<` included, and the `.` of a `= Class.field` join. */
|
|
232
|
+
| 'operator'
|
|
233
|
+
/** The `*` that marks the identifier. */
|
|
234
|
+
| 'marker'
|
|
235
|
+
/** A `#` trailer, the `#` included. */
|
|
236
|
+
| 'description'
|
|
237
|
+
/** A `?` trailer, the `?` included. */
|
|
238
|
+
| 'doubt'
|
|
239
|
+
/** A whole `#` line at column 0. */
|
|
240
|
+
| 'comment';
|
|
241
|
+
/** A run of one line, from `from` up to but not including `to`. */
|
|
242
|
+
interface Token {
|
|
243
|
+
kind: TokenKind;
|
|
244
|
+
from: number;
|
|
245
|
+
to: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The tokens of one line, in the order they appear, never overlapping. A blank
|
|
249
|
+
* line, and a line of nothing the tokenizer recognises, has none.
|
|
250
|
+
*/
|
|
251
|
+
declare function tokenizeLine(line: string): Token[];
|
|
252
|
+
|
|
200
253
|
interface ImportResult {
|
|
201
254
|
/** The projected sketch as canonical Skiss text, `\n`-terminated. */
|
|
202
255
|
output: string;
|
|
@@ -215,6 +268,6 @@ interface ResolvedDocument extends Document {
|
|
|
215
268
|
}
|
|
216
269
|
declare function resolve(doc: Document): ResolvedDocument;
|
|
217
270
|
|
|
218
|
-
declare const VERSION = "0.
|
|
271
|
+
declare const VERSION = "0.6.0";
|
|
219
272
|
|
|
220
|
-
export { type ClassNode, type CompileOptions, type CompileResult, type Diagnostic, type DiagnosticCode, type Document, type Dropped, type FieldNode, type FromLinkMLResult, type ImportResult, type JoinRef, type LinkMLAnnotations, type LinkMLAttribute, type LinkMLClass, type LinkMLCompileOptions, type LinkMLEnum, type LinkMLOptions, type LinkMLSchema, type MermaidCompileOptions, type MermaidOptions, type Name, type Primitive, type ResolvedDocument, type SerializeFormat, type Severity, type TypeRef, VERSION, compile, formatDiagnostic, formatDropped, fromLinkML, importLinkML, parse, resolve, serialize, toLinkML, toMermaid, toSkiss };
|
|
273
|
+
export { type ClassNode, type CompileOptions, type CompileResult, type Diagnostic, type DiagnosticCode, type Document, type Dropped, type FieldNode, type FromLinkMLResult, type ImportResult, type JoinRef, type LinkMLAnnotations, type LinkMLAttribute, type LinkMLClass, type LinkMLCompileOptions, type LinkMLEnum, type LinkMLOptions, type LinkMLSchema, type MermaidCompileOptions, type MermaidOptions, type Name, type Primitive, type ResolvedDocument, type SerializeFormat, type Severity, type Token, type TokenKind, type TypeRef, VERSION, compile, formatDiagnostic, formatDropped, fromLinkML, importLinkML, parse, resolve, serialize, toLinkML, toMermaid, toSkiss, tokenizeLine };
|