@conformetry/languages 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/CHANGELOG.md +18 -0
- package/README.md +157 -137
- package/dist/src/index.d.ts +42 -1
- package/dist/src/index.js +312 -195
- package/package.json +3 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ declare interface CompareChildrenArguments {
|
|
|
51
51
|
|
|
52
52
|
/** The outcome of walking one level of two trees. */
|
|
53
53
|
declare interface CompareChildrenResult {
|
|
54
|
+
/** What each placeholder value stood for — see `DocumentValidationResult`. */
|
|
55
|
+
readonly captures?: Readonly<Record<string, string>>;
|
|
54
56
|
readonly differences: MarkdownComparisonError[];
|
|
55
57
|
/** Template nodes the level weighed the instance against. */
|
|
56
58
|
readonly totalWeight: number;
|
|
@@ -206,6 +208,8 @@ export declare class FilesService {
|
|
|
206
208
|
|
|
207
209
|
/** What structurally comparing two JSON values produced. */
|
|
208
210
|
export declare interface JsonComparison {
|
|
211
|
+
/** What each placeholder value stood for — see `DocumentValidationResult`. */
|
|
212
|
+
readonly captures?: Readonly<Record<string, string>>;
|
|
209
213
|
readonly differences: ConformetryDifference[];
|
|
210
214
|
/** Template nodes the walk weighed the instance against. */
|
|
211
215
|
readonly totalWeight: number;
|
|
@@ -239,7 +243,12 @@ export declare class JsonComparisonService {
|
|
|
239
243
|
constructor(scoringService: ScoringService);
|
|
240
244
|
/** Builds one structural error at a JSON path. */
|
|
241
245
|
private buildError;
|
|
242
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Captures what a template string's placeholder values stand for in an
|
|
248
|
+
* instance value, or `undefined` when the two do not match as a pattern.
|
|
249
|
+
*/
|
|
250
|
+
private captureString;
|
|
251
|
+
/** Merges sibling comparisons into one, keeping the first captures. */
|
|
243
252
|
private combine;
|
|
244
253
|
/** Matches one required array entry against the instance array. */
|
|
245
254
|
private compareArrayItem;
|
|
@@ -518,6 +527,18 @@ export declare class MarkdownNodesService {
|
|
|
518
527
|
private readColumnCount;
|
|
519
528
|
/** Compares two optional string fields, treating absent as empty. */
|
|
520
529
|
private sameField;
|
|
530
|
+
/**
|
|
531
|
+
* Matches an instance node against a template node, returning what any
|
|
532
|
+
* placeholder value in the template node's text captured, or `undefined`
|
|
533
|
+
* when the instance node does not satisfy it.
|
|
534
|
+
*
|
|
535
|
+
* A node failing its ordinary rule is tried once more with its plain text
|
|
536
|
+
* as a pattern, provided the type and heading depth agree.
|
|
537
|
+
*/
|
|
538
|
+
capture(args: {
|
|
539
|
+
instanceNode: MarkdownNode;
|
|
540
|
+
templateNode: MarkdownNode;
|
|
541
|
+
}): Record<string, string> | undefined;
|
|
521
542
|
/**
|
|
522
543
|
* Counts a node and every countable node beneath it.
|
|
523
544
|
*
|
|
@@ -579,6 +600,8 @@ export declare class MarkdownTreeService {
|
|
|
579
600
|
constructor(markdownNodesService: MarkdownNodesService, scoringService: ScoringService);
|
|
580
601
|
/** Describes a template node the instance does not contain. */
|
|
581
602
|
private buildError;
|
|
603
|
+
/** What the first matching candidate captured for the template node. */
|
|
604
|
+
private captureFirst;
|
|
582
605
|
/**
|
|
583
606
|
* Matches a container node, then descends into it.
|
|
584
607
|
*
|
|
@@ -760,6 +783,11 @@ export declare class TextModule {
|
|
|
760
783
|
export declare class TextService implements ConformetryLanguageValidator {
|
|
761
784
|
constructor();
|
|
762
785
|
readonly descriptor: LanguageValidatorDescriptor;
|
|
786
|
+
/**
|
|
787
|
+
* Captures what a template line's placeholder values stand for, taking the
|
|
788
|
+
* first unclaimed instance line that fits it as a pattern and claiming it.
|
|
789
|
+
*/
|
|
790
|
+
private captureLine;
|
|
763
791
|
/** Counts how many times each line occurs, for duplicate-aware matching. */
|
|
764
792
|
private countLines;
|
|
765
793
|
/** Finds template lines the instance does not supply often enough. */
|
|
@@ -776,6 +804,8 @@ export declare class TextService implements ConformetryLanguageValidator {
|
|
|
776
804
|
|
|
777
805
|
/** What comparing two syntax trees produced. */
|
|
778
806
|
declare interface TreeComparison {
|
|
807
|
+
/** What each placeholder value stood for — see `DocumentValidationResult`. */
|
|
808
|
+
readonly captures?: Readonly<Record<string, string>>;
|
|
779
809
|
readonly differences: TypescriptComparisonError[];
|
|
780
810
|
/** Number of template nodes the walk weighed the instance against. */
|
|
781
811
|
readonly totalWeight: number;
|
|
@@ -958,6 +988,17 @@ export declare class TypescriptTreeService {
|
|
|
958
988
|
private compareBestCandidate;
|
|
959
989
|
/** Matches one template child against the instance's children. */
|
|
960
990
|
private compareChild;
|
|
991
|
+
/**
|
|
992
|
+
* Matches a template node on its key, returning what any placeholder value
|
|
993
|
+
* in the key captured, or `undefined` when the instance node does not match.
|
|
994
|
+
*
|
|
995
|
+
* A key holding a placeholder value is a pattern, and is only tried against
|
|
996
|
+
* nodes of the same syntax kind: a bare value would otherwise match any key
|
|
997
|
+
* at all, the callee's own name included.
|
|
998
|
+
*/
|
|
999
|
+
private matchKey;
|
|
1000
|
+
/** Matches a keyless template node on syntax kind alone. */
|
|
1001
|
+
private matchKind;
|
|
961
1002
|
/** Compares one level of two trees, descending into every match. */
|
|
962
1003
|
compareTree(args: CompareTreeArguments): TreeComparison;
|
|
963
1004
|
}
|