comment-parser 1.1.6-beta.3 → 1.2.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 +12 -0
- package/browser/index.js +15 -0
- package/es6/index.d.ts +7 -0
- package/es6/index.js +2 -0
- package/lib/index.cjs +9 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +7 -0
- package/package.json +3 -3
- package/src/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v1.2.3
|
|
2
|
+
- publishing missing fix: point package's main to .cjs file
|
|
3
|
+
# v1.2.2
|
|
4
|
+
- re-export ./util on the top-level for compatibility with older Node
|
|
5
|
+
- point package's main to .cjs file
|
|
6
|
+
|
|
7
|
+
# v1.2.1
|
|
8
|
+
- bump `engines` per `exports` issues in earlier Node versions
|
|
9
|
+
|
|
10
|
+
# v1.2.0
|
|
11
|
+
- keep and handle appropriately CR line endings
|
|
12
|
+
|
|
1
13
|
# v1.1.6-beta.3
|
|
2
14
|
- process CRs as a separate .lineEnd toke
|
|
3
15
|
|
package/browser/index.js
CHANGED
|
@@ -19,6 +19,9 @@ var CommentParser = (function (exports) {
|
|
|
19
19
|
function splitLines(source) {
|
|
20
20
|
return source.split(/\n/);
|
|
21
21
|
}
|
|
22
|
+
function seedBlock(block = {}) {
|
|
23
|
+
return Object.assign({ description: '', tags: [], source: [], problems: [] }, block);
|
|
24
|
+
}
|
|
22
25
|
function seedSpec(spec = {}) {
|
|
23
26
|
return Object.assign({ tag: '', name: '', type: '', optional: false, description: '', problems: [], source: [] }, spec);
|
|
24
27
|
}
|
|
@@ -37,6 +40,16 @@ var CommentParser = (function (exports) {
|
|
|
37
40
|
}
|
|
38
41
|
return block;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Assures Block.source contains references to the Block.tags[].source items,
|
|
45
|
+
* using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
|
|
46
|
+
* @param block parsed coments block
|
|
47
|
+
*/
|
|
48
|
+
function rewireSpecs(block) {
|
|
49
|
+
const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());
|
|
50
|
+
block.source = block.source.map((line) => source.get(line.number) || line);
|
|
51
|
+
return block;
|
|
52
|
+
}
|
|
40
53
|
|
|
41
54
|
const reTag = /^@\S+/;
|
|
42
55
|
/**
|
|
@@ -622,12 +635,14 @@ var CommentParser = (function (exports) {
|
|
|
622
635
|
name: nameTokenizer,
|
|
623
636
|
description: descriptionTokenizer,
|
|
624
637
|
};
|
|
638
|
+
const util = { rewireSpecs, rewireSource, seedBlock, seedTokens };
|
|
625
639
|
|
|
626
640
|
exports.inspect = inspect;
|
|
627
641
|
exports.parse = parse;
|
|
628
642
|
exports.stringify = stringify;
|
|
629
643
|
exports.tokenizers = tokenizers;
|
|
630
644
|
exports.transforms = transforms;
|
|
645
|
+
exports.util = util;
|
|
631
646
|
|
|
632
647
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
633
648
|
|
package/es6/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import alignTransform from './transforms/align';
|
|
|
7
7
|
import indentTransform from './transforms/indent';
|
|
8
8
|
import crlfTransform from './transforms/crlf';
|
|
9
9
|
import { flow as flowTransform } from './transforms/index';
|
|
10
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
|
|
10
11
|
export * from './primitives';
|
|
11
12
|
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives").Block[];
|
|
12
13
|
export declare const stringify: import("./stringifier/index").Stringifier;
|
|
@@ -23,3 +24,9 @@ export declare const tokenizers: {
|
|
|
23
24
|
name: typeof nameTokenizer;
|
|
24
25
|
description: typeof descriptionTokenizer;
|
|
25
26
|
};
|
|
27
|
+
export declare const util: {
|
|
28
|
+
rewireSpecs: typeof rewireSpecs;
|
|
29
|
+
rewireSource: typeof rewireSource;
|
|
30
|
+
seedBlock: typeof seedBlock;
|
|
31
|
+
seedTokens: typeof seedTokens;
|
|
32
|
+
};
|
package/es6/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import alignTransform from './transforms/align.js';
|
|
|
8
8
|
import indentTransform from './transforms/indent.js';
|
|
9
9
|
import crlfTransform from './transforms/crlf.js';
|
|
10
10
|
import { flow as flowTransform } from './transforms/index.js';
|
|
11
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util.js';
|
|
11
12
|
export * from './primitives.js';
|
|
12
13
|
export function parse(source, options = {}) {
|
|
13
14
|
return getParser(options)(source);
|
|
@@ -26,3 +27,4 @@ export const tokenizers = {
|
|
|
26
27
|
name: nameTokenizer,
|
|
27
28
|
description: descriptionTokenizer,
|
|
28
29
|
};
|
|
30
|
+
export const util = { rewireSpecs, rewireSource, seedBlock, seedTokens };
|
package/lib/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", {
|
|
21
21
|
value: true
|
|
22
22
|
});
|
|
23
|
-
exports.tokenizers = exports.transforms = exports.inspect = exports.stringify = exports.parse = void 0;
|
|
23
|
+
exports.util = exports.tokenizers = exports.transforms = exports.inspect = exports.stringify = exports.parse = void 0;
|
|
24
24
|
|
|
25
25
|
const index_1 = require("./parser/index.cjs");
|
|
26
26
|
|
|
@@ -42,6 +42,8 @@ const crlf_1 = require("./transforms/crlf.cjs");
|
|
|
42
42
|
|
|
43
43
|
const index_3 = require("./transforms/index.cjs");
|
|
44
44
|
|
|
45
|
+
const util_1 = require("./util.cjs");
|
|
46
|
+
|
|
45
47
|
__exportStar(require("./primitives.cjs"), exports);
|
|
46
48
|
|
|
47
49
|
function parse(source, options = {}) {
|
|
@@ -71,4 +73,10 @@ exports.tokenizers = {
|
|
|
71
73
|
name: name_1.default,
|
|
72
74
|
description: description_1.default
|
|
73
75
|
};
|
|
76
|
+
exports.util = {
|
|
77
|
+
rewireSpecs: util_1.rewireSpecs,
|
|
78
|
+
rewireSource: util_1.rewireSource,
|
|
79
|
+
seedBlock: util_1.seedBlock,
|
|
80
|
+
seedTokens: util_1.seedTokens
|
|
81
|
+
};
|
|
74
82
|
//# sourceMappingURL=index.cjs.map
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":["__createBinding","Object","create","o","m","k","k2","undefined","defineProperty","enumerable","get","__exportStar","exports","p","prototype","hasOwnProperty","call","value","tokenizers","transforms","inspect","stringify","parse","index_1","require","description_1","name_1","tag_1","type_1","index_2","align_1","indent_1","crlf_1","index_3","source","options","default","inspect_1","flow","align","indent","crlf","tag","type","name","description"],"mappings":"AAAA;;AACA,IAAIA,eAAe,GAAI,QAAQ,KAAKA,eAAd,KAAmCC,MAAM,CAACC,MAAP,GAAiB,UAASC,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,EAAlB,EAAsB;AAC5F,MAAIA,EAAE,KAAKC,SAAX,EAAsBD,EAAE,GAAGD,CAAL;AACtBJ,EAAAA,MAAM,CAACO,cAAP,CAAsBL,CAAtB,EAAyBG,EAAzB,EAA6B;AAAEG,IAAAA,UAAU,EAAE,IAAd;AAAoBC,IAAAA,GAAG,EAAE,YAAW;AAAE,aAAON,CAAC,CAACC,CAAD,CAAR;AAAc;AAApD,GAA7B;AACH,CAHwD,GAGnD,UAASF,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,EAAlB,EAAsB;AACxB,MAAIA,EAAE,KAAKC,SAAX,EAAsBD,EAAE,GAAGD,CAAL;AACtBF,EAAAA,CAAC,CAACG,EAAD,CAAD,GAAQF,CAAC,CAACC,CAAD,CAAT;AACH,CANqB,CAAtB;;AAOA,IAAIM,YAAY,GAAI,QAAQ,KAAKA,YAAd,IAA+B,UAASP,CAAT,EAAYQ,OAAZ,EAAqB;AACnE,OAAK,IAAIC,CAAT,IAAcT,CAAd,EAAiB,IAAIS,CAAC,KAAK,SAAN,IAAmB,CAACZ,MAAM,CAACa,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCJ,OAArC,EAA8CC,CAA9C,CAAxB,EAA0Eb,eAAe,CAACY,OAAD,EAAUR,CAAV,EAAaS,CAAb,CAAf;AAC9F,CAFD;;AAGAZ,MAAM,CAACO,cAAP,CAAsBI,OAAtB,EAA+B,YAA/B,EAA6C;AAAEK,EAAAA,KAAK,EAAE;AAAT,CAA7C;AACAL,OAAO,CAACM,
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":["__createBinding","Object","create","o","m","k","k2","undefined","defineProperty","enumerable","get","__exportStar","exports","p","prototype","hasOwnProperty","call","value","util","tokenizers","transforms","inspect","stringify","parse","index_1","require","description_1","name_1","tag_1","type_1","index_2","align_1","indent_1","crlf_1","index_3","util_1","source","options","default","inspect_1","flow","align","indent","crlf","tag","type","name","description","rewireSpecs","rewireSource","seedBlock","seedTokens"],"mappings":"AAAA;;AACA,IAAIA,eAAe,GAAI,QAAQ,KAAKA,eAAd,KAAmCC,MAAM,CAACC,MAAP,GAAiB,UAASC,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,EAAlB,EAAsB;AAC5F,MAAIA,EAAE,KAAKC,SAAX,EAAsBD,EAAE,GAAGD,CAAL;AACtBJ,EAAAA,MAAM,CAACO,cAAP,CAAsBL,CAAtB,EAAyBG,EAAzB,EAA6B;AAAEG,IAAAA,UAAU,EAAE,IAAd;AAAoBC,IAAAA,GAAG,EAAE,YAAW;AAAE,aAAON,CAAC,CAACC,CAAD,CAAR;AAAc;AAApD,GAA7B;AACH,CAHwD,GAGnD,UAASF,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,EAAlB,EAAsB;AACxB,MAAIA,EAAE,KAAKC,SAAX,EAAsBD,EAAE,GAAGD,CAAL;AACtBF,EAAAA,CAAC,CAACG,EAAD,CAAD,GAAQF,CAAC,CAACC,CAAD,CAAT;AACH,CANqB,CAAtB;;AAOA,I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AP;AACH;;AACDxB,OAAO,CAACW,KAAR,GAAgBA,KAAhB;AACAX,OAAO,CAACU,SAAR,GAAoBQ,OAAO,CAACQ,OAAR,EAApB;;AACA,IAAIC,SAAS,GAAGd,OAAH,6BAAb;;AACAxB,MAAM,CAACO,cAAP,CAAsBI,OAAtB,EAA+B,SAA/B,EAA0C;AAAEH,EAAAA,UAAU,EAAE,IAAd;AAAoBC,EAAAA,GAAG,EAAE,YAAY;AAAE,WAAO6B,SAAS,CAACD,OAAjB;AAA2B;AAAlE,CAA1C;AACA1B,OAAO,CAACQ,UAAR,GAAqB;AACjBoB,EAAAA,IAAI,EAAEN,OAAO,CAACM,IADG;AAEjBC,EAAAA,KAAK,EAAEV,OAAO,CAACO,OAFE;AAGjBI,EAAAA,MAAM,EAAEV,QAAQ,CAACM,OAHA;AAIjBK,EAAAA,IAAI,EAAEV,MAAM,CAACK;AAJI,CAArB;AAMA1B,OAAO,CAACO,UAAR,GAAqB;AACjByB,EAAAA,GAAG,EAAEhB,KAAK,CAACU,OADM;AAEjBO,EAAAA,IAAI,EAAEhB,MAAM,CAACS,OAFI;AAGjBQ,EAAAA,IAAI,EAAEnB,MAAM,CAACW,OAHI;AAIjBS,EAAAA,WAAW,EAAErB,aAAa,CAACY;AAJV,CAArB;AAMA1B,OAAO,CAACM,IAAR,GAAe;AAAE8B,EAAAA,WAAW,EAAEb,MAAM,CAACa,WAAtB;AAAmCC,EAAAA,YAAY,EAAEd,MAAM,CAACc,YAAxD;AAAsEC,EAAAA,SAAS,EAAEf,MAAM,CAACe,SAAxF;AAAmGC,EAAAA,UAAU,EAAEhB,MAAM,CAACgB;AAAtH,CAAf","sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.util = exports.tokenizers = exports.transforms = exports.inspect = exports.stringify = exports.parse = void 0;\nconst index_1 = require(\"./parser/index\");\nconst description_1 = require(\"./parser/tokenizers/description\");\nconst name_1 = require(\"./parser/tokenizers/name\");\nconst tag_1 = require(\"./parser/tokenizers/tag\");\nconst type_1 = require(\"./parser/tokenizers/type\");\nconst index_2 = require(\"./stringifier/index\");\nconst align_1 = require(\"./transforms/align\");\nconst indent_1 = require(\"./transforms/indent\");\nconst crlf_1 = require(\"./transforms/crlf\");\nconst index_3 = require(\"./transforms/index\");\nconst util_1 = require(\"./util\");\n__exportStar(require(\"./primitives\"), exports);\nfunction parse(source, options = {}) {\n return index_1.default(options)(source);\n}\nexports.parse = parse;\nexports.stringify = index_2.default();\nvar inspect_1 = require(\"./stringifier/inspect\");\nObject.defineProperty(exports, \"inspect\", { enumerable: true, get: function () { return inspect_1.default; } });\nexports.transforms = {\n flow: index_3.flow,\n align: align_1.default,\n indent: indent_1.default,\n crlf: crlf_1.default,\n};\nexports.tokenizers = {\n tag: tag_1.default,\n type: type_1.default,\n name: name_1.default,\n description: description_1.default,\n};\nexports.util = { rewireSpecs: util_1.rewireSpecs, rewireSource: util_1.rewireSource, seedBlock: util_1.seedBlock, seedTokens: util_1.seedTokens };\n"],"file":"index.cjs"}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import alignTransform from './transforms/align';
|
|
|
7
7
|
import indentTransform from './transforms/indent';
|
|
8
8
|
import crlfTransform from './transforms/crlf';
|
|
9
9
|
import { flow as flowTransform } from './transforms/index';
|
|
10
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
|
|
10
11
|
export * from './primitives';
|
|
11
12
|
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives").Block[];
|
|
12
13
|
export declare const stringify: import("./stringifier/index").Stringifier;
|
|
@@ -23,3 +24,9 @@ export declare const tokenizers: {
|
|
|
23
24
|
name: typeof nameTokenizer;
|
|
24
25
|
description: typeof descriptionTokenizer;
|
|
25
26
|
};
|
|
27
|
+
export declare const util: {
|
|
28
|
+
rewireSpecs: typeof rewireSpecs;
|
|
29
|
+
rewireSource: typeof rewireSource;
|
|
30
|
+
seedBlock: typeof seedBlock;
|
|
31
|
+
seedTokens: typeof seedTokens;
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Generic JSDoc-like comment parser",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "lib/index.
|
|
6
|
+
"main": "lib/index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./es6/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^4.3.4"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": "
|
|
49
|
+
"node": "^12.20 || ^14.14.0 || ^16"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "rimraf lib es6 browser; tsc -p tsconfig.json && tsc -p tsconfig.node.json && rollup -o browser/index.js -f iife --context window -n CommentParser es6/index.js && convert-extension cjs lib/ && cd es6 && replace \"from '(\\.[^']*)'\" \"from '\\$1.js'\" * -r --include=\"*.js\"",
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import alignTransform from './transforms/align';
|
|
|
8
8
|
import indentTransform from './transforms/indent';
|
|
9
9
|
import crlfTransform from './transforms/crlf';
|
|
10
10
|
import { flow as flowTransform } from './transforms/index';
|
|
11
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
|
|
11
12
|
|
|
12
13
|
export * from './primitives';
|
|
13
14
|
|
|
@@ -31,3 +32,5 @@ export const tokenizers = {
|
|
|
31
32
|
name: nameTokenizer,
|
|
32
33
|
description: descriptionTokenizer,
|
|
33
34
|
};
|
|
35
|
+
|
|
36
|
+
export const util = { rewireSpecs, rewireSource, seedBlock, seedTokens };
|