comment-parser 1.4.2 → 1.4.3
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 +6 -0
- package/browser/index.js +671 -0
- package/lib/index.cjs +68 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/parser/block-parser.cjs +36 -0
- package/lib/parser/block-parser.cjs.map +1 -0
- package/lib/parser/block-parser.d.ts +24 -0
- package/lib/parser/index.cjs +52 -0
- package/lib/parser/index.cjs.map +1 -0
- package/lib/parser/index.d.ts +11 -0
- package/lib/parser/source-parser.cjs +56 -0
- package/lib/parser/source-parser.cjs.map +1 -0
- package/lib/parser/source-parser.d.ts +7 -0
- package/lib/parser/spec-parser.cjs +23 -0
- package/lib/parser/spec-parser.cjs.map +1 -0
- package/lib/parser/spec-parser.d.ts +7 -0
- package/lib/parser/tokenizers/description.cjs +51 -0
- package/lib/parser/tokenizers/description.cjs.map +1 -0
- package/lib/parser/tokenizers/description.d.ts +20 -0
- package/lib/parser/tokenizers/index.cjs +6 -0
- package/lib/parser/tokenizers/index.cjs.map +1 -0
- package/lib/parser/tokenizers/index.d.ts +7 -0
- package/lib/parser/tokenizers/name.cjs +103 -0
- package/lib/parser/tokenizers/name.cjs.map +1 -0
- package/lib/parser/tokenizers/name.d.ts +6 -0
- package/lib/parser/tokenizers/tag.cjs +36 -0
- package/lib/parser/tokenizers/tag.cjs.map +1 -0
- package/lib/parser/tokenizers/tag.d.ts +6 -0
- package/lib/parser/tokenizers/type.cjs +75 -0
- package/lib/parser/tokenizers/type.cjs.map +1 -0
- package/lib/parser/tokenizers/type.d.ts +27 -0
- package/lib/primitives.cjs +15 -0
- package/lib/primitives.cjs.map +1 -0
- package/lib/primitives.d.ts +54 -0
- package/lib/stringifier/index.cjs +15 -0
- package/lib/stringifier/index.cjs.map +1 -0
- package/lib/stringifier/index.d.ts +3 -0
- package/lib/stringifier/inspect.cjs +56 -0
- package/lib/stringifier/inspect.cjs.map +1 -0
- package/lib/stringifier/inspect.d.ts +2 -0
- package/lib/transforms/align.cjs +104 -0
- package/lib/transforms/align.cjs.map +1 -0
- package/lib/transforms/align.d.ts +3 -0
- package/lib/transforms/crlf.cjs +35 -0
- package/lib/transforms/crlf.cjs.map +1 -0
- package/lib/transforms/crlf.d.ts +3 -0
- package/lib/transforms/indent.cjs +45 -0
- package/lib/transforms/indent.cjs.map +1 -0
- package/lib/transforms/indent.d.ts +2 -0
- package/lib/transforms/index.cjs +10 -0
- package/lib/transforms/index.cjs.map +1 -0
- package/lib/transforms/index.d.ts +3 -0
- package/lib/util.cjs +90 -0
- package/lib/util.cjs.map +1 -0
- package/lib/util.d.ts +21 -0
- package/package.json +4 -2
package/lib/util.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isSpace = isSpace;
|
|
7
|
+
exports.hasCR = hasCR;
|
|
8
|
+
exports.splitCR = splitCR;
|
|
9
|
+
exports.splitSpace = splitSpace;
|
|
10
|
+
exports.splitLines = splitLines;
|
|
11
|
+
exports.seedBlock = seedBlock;
|
|
12
|
+
exports.seedSpec = seedSpec;
|
|
13
|
+
exports.seedTokens = seedTokens;
|
|
14
|
+
exports.rewireSource = rewireSource;
|
|
15
|
+
exports.rewireSpecs = rewireSpecs;
|
|
16
|
+
function isSpace(source) {
|
|
17
|
+
return /^\s+$/.test(source);
|
|
18
|
+
}
|
|
19
|
+
function hasCR(source) {
|
|
20
|
+
return /\r$/.test(source);
|
|
21
|
+
}
|
|
22
|
+
function splitCR(source) {
|
|
23
|
+
const matches = source.match(/\r+$/);
|
|
24
|
+
return matches == null ? ['', source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];
|
|
25
|
+
}
|
|
26
|
+
function splitSpace(source) {
|
|
27
|
+
const matches = source.match(/^\s+/);
|
|
28
|
+
return matches == null ? ['', source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)];
|
|
29
|
+
}
|
|
30
|
+
function splitLines(source) {
|
|
31
|
+
return source.split(/\n/);
|
|
32
|
+
}
|
|
33
|
+
function seedBlock(block = {}) {
|
|
34
|
+
return Object.assign({
|
|
35
|
+
description: '',
|
|
36
|
+
tags: [],
|
|
37
|
+
source: [],
|
|
38
|
+
problems: []
|
|
39
|
+
}, block);
|
|
40
|
+
}
|
|
41
|
+
function seedSpec(spec = {}) {
|
|
42
|
+
return Object.assign({
|
|
43
|
+
tag: '',
|
|
44
|
+
name: '',
|
|
45
|
+
type: '',
|
|
46
|
+
optional: false,
|
|
47
|
+
description: '',
|
|
48
|
+
problems: [],
|
|
49
|
+
source: []
|
|
50
|
+
}, spec);
|
|
51
|
+
}
|
|
52
|
+
function seedTokens(tokens = {}) {
|
|
53
|
+
return Object.assign({
|
|
54
|
+
start: '',
|
|
55
|
+
delimiter: '',
|
|
56
|
+
postDelimiter: '',
|
|
57
|
+
tag: '',
|
|
58
|
+
postTag: '',
|
|
59
|
+
name: '',
|
|
60
|
+
postName: '',
|
|
61
|
+
type: '',
|
|
62
|
+
postType: '',
|
|
63
|
+
description: '',
|
|
64
|
+
end: '',
|
|
65
|
+
lineEnd: ''
|
|
66
|
+
}, tokens);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Assures Block.tags[].source contains references to the Block.source items,
|
|
70
|
+
* using Block.source as a source of truth. This is a counterpart of rewireSpecs
|
|
71
|
+
* @param block parsed coments block
|
|
72
|
+
*/
|
|
73
|
+
function rewireSource(block) {
|
|
74
|
+
const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map());
|
|
75
|
+
for (const spec of block.tags) {
|
|
76
|
+
spec.source = spec.source.map(line => source.get(line.number));
|
|
77
|
+
}
|
|
78
|
+
return block;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Assures Block.source contains references to the Block.tags[].source items,
|
|
82
|
+
* using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
|
|
83
|
+
* @param block parsed coments block
|
|
84
|
+
*/
|
|
85
|
+
function rewireSpecs(block) {
|
|
86
|
+
const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());
|
|
87
|
+
block.source = block.source.map(line => source.get(line.number) || line);
|
|
88
|
+
return block;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=util.cjs.map
|
package/lib/util.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.cjs","names":["Object","defineProperty","exports","value","isSpace","hasCR","splitCR","splitSpace","splitLines","seedBlock","seedSpec","seedTokens","rewireSource","rewireSpecs","source","test","matches","match","slice","length","split","block","assign","description","tags","problems","spec","tag","name","type","optional","tokens","start","delimiter","postDelimiter","postTag","postName","postType","end","lineEnd","reduce","acc","line","set","number","Map","map","get"],"sources":["util.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isSpace = isSpace;\nexports.hasCR = hasCR;\nexports.splitCR = splitCR;\nexports.splitSpace = splitSpace;\nexports.splitLines = splitLines;\nexports.seedBlock = seedBlock;\nexports.seedSpec = seedSpec;\nexports.seedTokens = seedTokens;\nexports.rewireSource = rewireSource;\nexports.rewireSpecs = rewireSpecs;\nfunction isSpace(source) {\n return /^\\s+$/.test(source);\n}\nfunction hasCR(source) {\n return /\\r$/.test(source);\n}\nfunction splitCR(source) {\n const matches = source.match(/\\r+$/);\n return matches == null\n ? ['', source]\n : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];\n}\nfunction splitSpace(source) {\n const matches = source.match(/^\\s+/);\n return matches == null\n ? ['', source]\n : [source.slice(0, matches[0].length), source.slice(matches[0].length)];\n}\nfunction splitLines(source) {\n return source.split(/\\n/);\n}\nfunction seedBlock(block = {}) {\n return Object.assign({ description: '', tags: [], source: [], problems: [] }, block);\n}\nfunction seedSpec(spec = {}) {\n return Object.assign({ tag: '', name: '', type: '', optional: false, description: '', problems: [], source: [] }, spec);\n}\nfunction seedTokens(tokens = {}) {\n return Object.assign({ start: '', delimiter: '', postDelimiter: '', tag: '', postTag: '', name: '', postName: '', type: '', postType: '', description: '', end: '', lineEnd: '' }, tokens);\n}\n/**\n * Assures Block.tags[].source contains references to the Block.source items,\n * using Block.source as a source of truth. This is a counterpart of rewireSpecs\n * @param block parsed coments block\n */\nfunction rewireSource(block) {\n const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map());\n for (const spec of block.tags) {\n spec.source = spec.source.map((line) => source.get(line.number));\n }\n return block;\n}\n/**\n * Assures Block.source contains references to the Block.tags[].source items,\n * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource\n * @param block parsed coments block\n */\nfunction rewireSpecs(block) {\n const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());\n block.source = block.source.map((line) => source.get(line.number) || line);\n return block;\n}\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,OAAO,GAAGA,OAAO;AACzBF,OAAO,CAACG,KAAK,GAAGA,KAAK;AACrBH,OAAO,CAACI,OAAO,GAAGA,OAAO;AACzBJ,OAAO,CAACK,UAAU,GAAGA,UAAU;AAC/BL,OAAO,CAACM,UAAU,GAAGA,UAAU;AAC/BN,OAAO,CAACO,SAAS,GAAGA,SAAS;AAC7BP,OAAO,CAACQ,QAAQ,GAAGA,QAAQ;AAC3BR,OAAO,CAACS,UAAU,GAAGA,UAAU;AAC/BT,OAAO,CAACU,YAAY,GAAGA,YAAY;AACnCV,OAAO,CAACW,WAAW,GAAGA,WAAW;AACjC,SAAST,OAAOA,CAACU,MAAM,EAAE;EACrB,OAAO,OAAO,CAACC,IAAI,CAACD,MAAM,CAAC;AAC/B;AACA,SAA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,CAACC,GAAG,EAAEf,IAAI,KAAKA,IAAI,CAACZ,MAAM,CAAC0B,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAKD,GAAG,CAACE,GAAG,CAACD,IAAI,CAACE,MAAM,EAAEF,IAAI,CAAC,EAAED,GAAG,CAAC,EAAE,IAAII,GAAG,CAAC,CAAC,CAAC;EAC9HxB,KAAK,CAACP,MAAM,GAAGO,KAAK,CAACP,MAAM,CAACgC,GAAG,CAAEJ,IAAI,IAAK5B,MAAM,CAACiC,GAAG,CAACL,IAAI,CAACE,MAAM,CAAC,IAAIF,IAAI,CAAC;EAC1E,OAAOrB,KAAK;AAChB","ignoreList":[]}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Block, Tokens, Spec } from './primitives.js';
|
|
2
|
+
export declare function isSpace(source: string): boolean;
|
|
3
|
+
export declare function hasCR(source: string): boolean;
|
|
4
|
+
export declare function splitCR(source: string): [string, string];
|
|
5
|
+
export declare function splitSpace(source: string): [string, string];
|
|
6
|
+
export declare function splitLines(source: string): string[];
|
|
7
|
+
export declare function seedBlock(block?: Partial<Block>): Block;
|
|
8
|
+
export declare function seedSpec(spec?: Partial<Spec>): Spec;
|
|
9
|
+
export declare function seedTokens(tokens?: Partial<Tokens>): Tokens;
|
|
10
|
+
/**
|
|
11
|
+
* Assures Block.tags[].source contains references to the Block.source items,
|
|
12
|
+
* using Block.source as a source of truth. This is a counterpart of rewireSpecs
|
|
13
|
+
* @param block parsed coments block
|
|
14
|
+
*/
|
|
15
|
+
export declare function rewireSource(block: Block): Block;
|
|
16
|
+
/**
|
|
17
|
+
* Assures Block.source contains references to the Block.tags[].source items,
|
|
18
|
+
* using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
|
|
19
|
+
* @param block parsed coments block
|
|
20
|
+
*/
|
|
21
|
+
export declare function rewireSpecs(block: Block): Block;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-parser",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Generic JSDoc-like comment parser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -56,7 +56,9 @@
|
|
|
56
56
|
"format": "prettier --write src tests",
|
|
57
57
|
"pretest": "rimraf coverage; npm run build",
|
|
58
58
|
"test": "prettier --check src tests && jest --verbose",
|
|
59
|
-
"preversion": "npm run build"
|
|
59
|
+
"preversion": "npm run build",
|
|
60
|
+
"prepare": "npm run build",
|
|
61
|
+
"prepublishOnly": "npm run build"
|
|
60
62
|
},
|
|
61
63
|
"repository": {
|
|
62
64
|
"type": "git",
|