comment-parser 1.3.0 → 1.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/CHANGELOG.md +7 -1
- package/browser/index.js +2 -5
- package/es6/index.d.ts +14 -14
- package/es6/parser/block-parser.d.ts +3 -3
- package/es6/parser/index.d.ts +3 -3
- package/es6/parser/index.js +0 -3
- package/es6/parser/source-parser.d.ts +2 -2
- package/es6/parser/spec-parser.d.ts +3 -3
- package/es6/parser/tokenizers/description.d.ts +4 -4
- package/es6/parser/tokenizers/index.d.ts +2 -2
- package/es6/parser/tokenizers/name.d.ts +1 -1
- package/es6/parser/tokenizers/tag.d.ts +2 -2
- package/es6/parser/tokenizers/tag.js +1 -1
- package/es6/parser/tokenizers/type.d.ts +3 -3
- package/es6/primitives.js +1 -1
- package/es6/stringifier/index.d.ts +2 -2
- package/es6/stringifier/inspect.d.ts +1 -1
- package/es6/transforms/align.d.ts +2 -2
- package/es6/transforms/crlf.d.ts +2 -2
- package/es6/transforms/indent.d.ts +1 -1
- package/es6/transforms/index.d.ts +2 -2
- package/es6/util.d.ts +1 -1
- package/jest.config.cjs +3 -1
- package/lib/index.cjs +39 -33
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +14 -14
- package/lib/parser/block-parser.d.ts +3 -3
- package/lib/parser/index.cjs +16 -20
- package/lib/parser/index.cjs.map +1 -1
- package/lib/parser/index.d.ts +3 -3
- package/lib/parser/source-parser.cjs +8 -8
- package/lib/parser/source-parser.cjs.map +1 -1
- package/lib/parser/source-parser.d.ts +2 -2
- package/lib/parser/spec-parser.cjs +2 -2
- package/lib/parser/spec-parser.cjs.map +1 -1
- package/lib/parser/spec-parser.d.ts +3 -3
- package/lib/parser/tokenizers/description.cjs +4 -4
- package/lib/parser/tokenizers/description.cjs.map +1 -1
- package/lib/parser/tokenizers/description.d.ts +4 -4
- package/lib/parser/tokenizers/index.d.ts +2 -2
- package/lib/parser/tokenizers/name.cjs +4 -4
- package/lib/parser/tokenizers/name.cjs.map +1 -1
- package/lib/parser/tokenizers/name.d.ts +1 -1
- package/lib/parser/tokenizers/tag.cjs +1 -1
- package/lib/parser/tokenizers/tag.cjs.map +1 -1
- package/lib/parser/tokenizers/tag.d.ts +2 -2
- package/lib/parser/tokenizers/type.cjs +2 -2
- package/lib/parser/tokenizers/type.cjs.map +1 -1
- package/lib/parser/tokenizers/type.d.ts +3 -3
- package/lib/stringifier/index.d.ts +2 -2
- package/lib/stringifier/inspect.cjs +2 -2
- package/lib/stringifier/inspect.cjs.map +1 -1
- package/lib/stringifier/inspect.d.ts +1 -1
- package/lib/transforms/align.cjs +5 -5
- package/lib/transforms/align.cjs.map +1 -1
- package/lib/transforms/align.d.ts +2 -2
- package/lib/transforms/crlf.cjs +2 -2
- package/lib/transforms/crlf.cjs.map +1 -1
- package/lib/transforms/crlf.d.ts +2 -2
- package/lib/transforms/indent.cjs +2 -2
- package/lib/transforms/indent.cjs.map +1 -1
- package/lib/transforms/indent.d.ts +1 -1
- package/lib/transforms/index.d.ts +2 -2
- package/lib/util.d.ts +1 -1
- package/package.json +4 -6
- package/src/index.ts +13 -13
- package/src/parser/block-parser.ts +1 -1
- package/src/parser/index.ts +10 -14
- package/src/parser/source-parser.ts +2 -2
- package/src/parser/spec-parser.ts +3 -3
- package/src/parser/tokenizers/description.ts +2 -2
- package/src/parser/tokenizers/index.ts +1 -1
- package/src/parser/tokenizers/name.ts +3 -3
- package/src/parser/tokenizers/tag.ts +3 -3
- package/src/parser/tokenizers/type.ts +3 -3
- package/src/stringifier/index.ts +1 -1
- package/src/stringifier/inspect.ts +2 -2
- package/src/transforms/align.ts +3 -3
- package/src/transforms/crlf.ts +3 -3
- package/src/transforms/indent.ts +3 -3
- package/src/transforms/index.ts +1 -1
- package/src/util.ts +1 -1
- package/tests/e2e/parse.spec.js +0 -9
- package/tests/unit/block-parser.spec.ts +3 -3
- package/tests/unit/inspect.spec.ts +3 -3
- package/tests/unit/parser.spec.ts +107 -7
- package/tests/unit/source-parser.spec.ts +3 -3
- package/tests/unit/spacer-description-joiner.spec.ts +3 -3
- package/tests/unit/spec-description-tokenizer.spec.ts +2 -2
- package/tests/unit/spec-name-tokenizer.spec.ts +2 -2
- package/tests/unit/spec-parser.spec.ts +7 -7
- package/tests/unit/spec-tag-tokenizer.spec.ts +2 -2
- package/tests/unit/spec-type-tokenizer.spec.ts +2 -2
- package/tests/unit/stringifier.spec.ts +1 -1
- package/tests/unit/transforms-align.spec.ts +3 -3
- package/tests/unit/transforms-crlf.spec.ts +3 -3
- package/tests/unit/transforms-indent.spec.ts +3 -3
- package/tests/unit/transforms.spec.ts +3 -3
- package/tests/unit/util-rewire.spec.ts +1 -1
- package/tests/unit/util.spec.ts +11 -1
- package/tsconfig.json +1 -2
- package/tsconfig.node.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# v1.4.0
|
|
2
|
+
- ESM compatibility improvements; fixes #159, #161
|
|
3
|
+
|
|
4
|
+
# v1.3.1
|
|
5
|
+
- allow for valid empty jsdoc; fixes #128
|
|
6
|
+
|
|
1
7
|
# v1.3.0
|
|
2
8
|
- add support for custom block markers
|
|
3
9
|
|
|
@@ -120,7 +126,7 @@
|
|
|
120
126
|
|
|
121
127
|
# v0.3.1
|
|
122
128
|
- use `readable-stream` fro Node 0.8 comatibility
|
|
123
|
-
- allow to pass optional parameters to `parse.file(path [,opts], done)`
|
|
129
|
+
- allow to pass optional parameters to `parse.file(path [,opts], done)`
|
|
124
130
|
- allow `parse.stream` to work with Buffers in addition to strings
|
|
125
131
|
|
|
126
132
|
# v0.3.0
|
package/browser/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var CommentParser = (function (exports) {
|
|
|
8
8
|
Markers["nostart"] = "/***";
|
|
9
9
|
Markers["delim"] = "*";
|
|
10
10
|
Markers["end"] = "*/";
|
|
11
|
-
})(exports.Markers || (exports.Markers = {}));
|
|
11
|
+
})(exports.Markers = exports.Markers || (exports.Markers = {}));
|
|
12
12
|
|
|
13
13
|
function isSpace(source) {
|
|
14
14
|
return /^\s+$/.test(source);
|
|
@@ -149,7 +149,7 @@ var CommentParser = (function (exports) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
|
-
* Splits the `@prefix` from remaining `Spec.lines[].token.
|
|
152
|
+
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
|
|
153
153
|
* and populates `spec.tag`
|
|
154
154
|
*/
|
|
155
155
|
function tagTokenizer() {
|
|
@@ -388,15 +388,12 @@ var CommentParser = (function (exports) {
|
|
|
388
388
|
const parseBlock = getParser$3({ fence });
|
|
389
389
|
const parseSpec = getParser$1({ tokenizers });
|
|
390
390
|
const joinDescription = getJoiner(spacing);
|
|
391
|
-
const notEmpty = (line) => line.tokens.description.trim() != '';
|
|
392
391
|
return function (source) {
|
|
393
392
|
const blocks = [];
|
|
394
393
|
for (const line of splitLines(source)) {
|
|
395
394
|
const lines = parseSource(line);
|
|
396
395
|
if (lines === null)
|
|
397
396
|
continue;
|
|
398
|
-
if (lines.find(notEmpty) === undefined)
|
|
399
|
-
continue;
|
|
400
397
|
const sections = parseBlock(lines);
|
|
401
398
|
const specs = sections.slice(1).map(parseSpec);
|
|
402
399
|
blocks.push({
|
package/es6/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Options as ParserOptions } from './parser/index';
|
|
2
|
-
import descriptionTokenizer from './parser/tokenizers/description';
|
|
3
|
-
import nameTokenizer from './parser/tokenizers/name';
|
|
4
|
-
import tagTokenizer from './parser/tokenizers/tag';
|
|
5
|
-
import typeTokenizer from './parser/tokenizers/type';
|
|
6
|
-
import alignTransform from './transforms/align';
|
|
7
|
-
import indentTransform from './transforms/indent';
|
|
8
|
-
import crlfTransform from './transforms/crlf';
|
|
9
|
-
import { flow as flowTransform } from './transforms/index';
|
|
10
|
-
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
|
|
11
|
-
export * from './primitives';
|
|
12
|
-
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives").Block[];
|
|
13
|
-
export declare const stringify: import("./stringifier/index").Stringifier;
|
|
14
|
-
export { default as inspect } from './stringifier/inspect';
|
|
1
|
+
import { Options as ParserOptions } from './parser/index.js';
|
|
2
|
+
import descriptionTokenizer from './parser/tokenizers/description.js';
|
|
3
|
+
import nameTokenizer from './parser/tokenizers/name.js';
|
|
4
|
+
import tagTokenizer from './parser/tokenizers/tag.js';
|
|
5
|
+
import typeTokenizer from './parser/tokenizers/type.js';
|
|
6
|
+
import alignTransform from './transforms/align.js';
|
|
7
|
+
import indentTransform from './transforms/indent.js';
|
|
8
|
+
import crlfTransform from './transforms/crlf.js';
|
|
9
|
+
import { flow as flowTransform } from './transforms/index.js';
|
|
10
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util.js';
|
|
11
|
+
export * from './primitives.js';
|
|
12
|
+
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives.js").Block[];
|
|
13
|
+
export declare const stringify: import("./stringifier/index.js").Stringifier;
|
|
14
|
+
export { default as inspect } from './stringifier/inspect.js';
|
|
15
15
|
export declare const transforms: {
|
|
16
16
|
flow: typeof flowTransform;
|
|
17
17
|
align: typeof alignTransform;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Line } from '../primitives';
|
|
1
|
+
import { Line } from '../primitives.js';
|
|
2
2
|
/**
|
|
3
3
|
* Groups source lines in sections representing tags.
|
|
4
4
|
* First section is a block description if present. Last section captures lines starting with
|
|
5
5
|
* the last tag to the end of the block, including dangling closing marker.
|
|
6
6
|
* @param {Line[]} block souce lines making a single comment block
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Parser = (block: Line[]) => Line[][];
|
|
9
9
|
/**
|
|
10
10
|
* Predicate telling if string contains opening/closing escaping sequence
|
|
11
11
|
* @param {string} source raw source line
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type Fencer = (source: string) => boolean;
|
|
14
14
|
/**
|
|
15
15
|
* `Parser` configuration options
|
|
16
16
|
*/
|
package/es6/parser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Block, BlockMarkers } from '../primitives';
|
|
2
|
-
import { Tokenizer } from './tokenizers/index';
|
|
1
|
+
import { Block, BlockMarkers } from '../primitives.js';
|
|
2
|
+
import { Tokenizer } from './tokenizers/index.js';
|
|
3
3
|
export interface Options {
|
|
4
4
|
startLine: number;
|
|
5
5
|
fence: string;
|
|
@@ -7,5 +7,5 @@ export interface Options {
|
|
|
7
7
|
markers: BlockMarkers;
|
|
8
8
|
tokenizers: Tokenizer[];
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type Parser = (source: string) => Block[];
|
|
11
11
|
export default function getParser({ startLine, fence, spacing, markers, tokenizers, }?: Partial<Options>): Parser;
|
package/es6/parser/index.js
CHANGED
|
@@ -19,15 +19,12 @@ export default function getParser({ startLine = 0, fence = '```', spacing = 'com
|
|
|
19
19
|
const parseBlock = blockParser({ fence });
|
|
20
20
|
const parseSpec = specParser({ tokenizers });
|
|
21
21
|
const joinDescription = getDescriptionJoiner(spacing);
|
|
22
|
-
const notEmpty = (line) => line.tokens.description.trim() != '';
|
|
23
22
|
return function (source) {
|
|
24
23
|
const blocks = [];
|
|
25
24
|
for (const line of splitLines(source)) {
|
|
26
25
|
const lines = parseSource(line);
|
|
27
26
|
if (lines === null)
|
|
28
27
|
continue;
|
|
29
|
-
if (lines.find(notEmpty) === undefined)
|
|
30
|
-
continue;
|
|
31
28
|
const sections = parseBlock(lines);
|
|
32
29
|
const specs = sections.slice(1).map(parseSpec);
|
|
33
30
|
blocks.push({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Line, BlockMarkers } from '../primitives';
|
|
1
|
+
import { Line, BlockMarkers } from '../primitives.js';
|
|
2
2
|
export interface Options {
|
|
3
3
|
startLine: number;
|
|
4
4
|
markers: BlockMarkers;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export type Parser = (source: string) => Line[] | null;
|
|
7
7
|
export default function getParser({ startLine, markers, }?: Partial<Options>): Parser;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Line, Spec } from '../primitives';
|
|
2
|
-
import { Tokenizer } from './tokenizers/index';
|
|
3
|
-
export
|
|
1
|
+
import { Line, Spec } from '../primitives.js';
|
|
2
|
+
import { Tokenizer } from './tokenizers/index.js';
|
|
3
|
+
export type Parser = (source: Line[]) => Spec;
|
|
4
4
|
export interface Options {
|
|
5
5
|
tokenizers: Tokenizer[];
|
|
6
6
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Line, BlockMarkers, Markers } from '../../primitives';
|
|
2
|
-
import { Tokenizer } from './index';
|
|
1
|
+
import { Line, BlockMarkers, Markers } from '../../primitives.js';
|
|
2
|
+
import { Tokenizer } from './index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Walks over provided lines joining description token into a single string.
|
|
5
5
|
* */
|
|
6
|
-
export
|
|
6
|
+
export type Joiner = (lines: Line[], markers?: BlockMarkers) => string;
|
|
7
7
|
/**
|
|
8
8
|
* Shortcut for standard Joiners
|
|
9
9
|
* compact - strip surrounding whitespace and concat lines using a single string
|
|
10
10
|
* preserve - preserves original whitespace and line breaks as is
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type Spacing = 'compact' | 'preserve' | Joiner;
|
|
13
13
|
/**
|
|
14
14
|
* Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`
|
|
15
15
|
* following given spacing srtategy
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Spec } from '../../primitives';
|
|
1
|
+
import { Spec } from '../../primitives.js';
|
|
2
2
|
/**
|
|
3
3
|
* Splits `spect.lines[].token.description` into other tokens,
|
|
4
4
|
* and populates the spec.{tag, name, type, description}. Invoked in a chaing
|
|
5
5
|
* with other tokens, operations listed above can be moved to separate tokenizers
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Tokenizer = (spec: Spec) => Spec;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tokenizer } from './index';
|
|
1
|
+
import { Tokenizer } from './index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Splits the `@prefix` from remaining `Spec.lines[].token.
|
|
3
|
+
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
|
|
4
4
|
* and populates `spec.tag`
|
|
5
5
|
*/
|
|
6
6
|
export default function tagTokenizer(): Tokenizer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Splits the `@prefix` from remaining `Spec.lines[].token.
|
|
2
|
+
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
|
|
3
3
|
* and populates `spec.tag`
|
|
4
4
|
*/
|
|
5
5
|
export default function tagTokenizer() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tokenizer } from './index';
|
|
1
|
+
import { Tokenizer } from './index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Joiner is a function taking collected type token string parts,
|
|
4
4
|
* and joining them together. In most of the cases this will be
|
|
@@ -10,13 +10,13 @@ import { Tokenizer } from './index';
|
|
|
10
10
|
* )}
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type Joiner = (parts: string[]) => string;
|
|
14
14
|
/**
|
|
15
15
|
* Shortcut for standard Joiners
|
|
16
16
|
* compact - trim surrounding space, replace line breaks with a single space
|
|
17
17
|
* preserve - concat as is
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type Spacing = 'compact' | 'preserve' | Joiner;
|
|
20
20
|
/**
|
|
21
21
|
* Sets splits remaining `Spec.lines[].tokes.description` into `type` and `description`
|
|
22
22
|
* tokens and populates Spec.type`
|
package/es6/primitives.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Block } from '../primitives';
|
|
2
|
-
export
|
|
1
|
+
import { Block } from '../primitives.js';
|
|
2
|
+
export type Stringifier = (block: Block) => string;
|
|
3
3
|
export default function getStringifier(): Stringifier;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Block } from '../primitives';
|
|
1
|
+
import { Block } from '../primitives.js';
|
|
2
2
|
export default function inspect({ source }: Block): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Transform } from './index';
|
|
2
|
-
import { Markers } from '../primitives';
|
|
1
|
+
import { Transform } from './index.js';
|
|
2
|
+
import { Markers } from '../primitives.js';
|
|
3
3
|
export default function align(markers?: typeof Markers): Transform;
|
package/es6/transforms/crlf.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Transform } from './index';
|
|
2
|
-
export
|
|
1
|
+
import { Transform } from './index.js';
|
|
2
|
+
export type Ending = 'LF' | 'CRLF';
|
|
3
3
|
export default function crlf(ending: Ending): Transform;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Transform } from './index';
|
|
1
|
+
import { Transform } from './index.js';
|
|
2
2
|
export default function indent(pos: number): Transform;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Block } from '../primitives';
|
|
2
|
-
export
|
|
1
|
+
import { Block } from '../primitives.js';
|
|
2
|
+
export type Transform = (Block: Block) => Block;
|
|
3
3
|
export declare function flow(...transforms: Transform[]): Transform;
|
package/es6/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block, Tokens, Spec } from './primitives';
|
|
1
|
+
import { Block, Tokens, Spec } from './primitives.js';
|
|
2
2
|
export declare function isSpace(source: string): boolean;
|
|
3
3
|
export declare function hasCR(source: string): boolean;
|
|
4
4
|
export declare function splitCR(source: string): [string, string];
|
package/jest.config.cjs
CHANGED
|
@@ -94,7 +94,9 @@ module.exports = {
|
|
|
94
94
|
// ],
|
|
95
95
|
|
|
96
96
|
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
97
|
-
|
|
97
|
+
moduleNameMapper: {
|
|
98
|
+
[/(.+)\.js$/.source]: ['$1.js', '$1.ts']
|
|
99
|
+
},
|
|
98
100
|
|
|
99
101
|
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
100
102
|
// modulePathIgnorePatterns: [],
|
package/lib/index.cjs
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return m[k];
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
11
17
|
} : function (o, m, k, k2) {
|
|
12
18
|
if (k2 === undefined) k2 = k;
|
|
13
19
|
o[k2] = m[k];
|
|
@@ -22,61 +28,61 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
22
28
|
});
|
|
23
29
|
exports.util = exports.tokenizers = exports.transforms = exports.inspect = exports.stringify = exports.parse = void 0;
|
|
24
30
|
|
|
25
|
-
const
|
|
31
|
+
const index_js_1 = require("./parser/index.cjs");
|
|
26
32
|
|
|
27
|
-
const
|
|
33
|
+
const description_js_1 = require("./parser/tokenizers/description.cjs");
|
|
28
34
|
|
|
29
|
-
const
|
|
35
|
+
const name_js_1 = require("./parser/tokenizers/name.cjs");
|
|
30
36
|
|
|
31
|
-
const
|
|
37
|
+
const tag_js_1 = require("./parser/tokenizers/tag.cjs");
|
|
32
38
|
|
|
33
|
-
const
|
|
39
|
+
const type_js_1 = require("./parser/tokenizers/type.cjs");
|
|
34
40
|
|
|
35
|
-
const
|
|
41
|
+
const index_js_2 = require("./stringifier/index.cjs");
|
|
36
42
|
|
|
37
|
-
const
|
|
43
|
+
const align_js_1 = require("./transforms/align.cjs");
|
|
38
44
|
|
|
39
|
-
const
|
|
45
|
+
const indent_js_1 = require("./transforms/indent.cjs");
|
|
40
46
|
|
|
41
|
-
const
|
|
47
|
+
const crlf_js_1 = require("./transforms/crlf.cjs");
|
|
42
48
|
|
|
43
|
-
const
|
|
49
|
+
const index_js_3 = require("./transforms/index.cjs");
|
|
44
50
|
|
|
45
|
-
const
|
|
51
|
+
const util_js_1 = require("./util.cjs");
|
|
46
52
|
|
|
47
53
|
__exportStar(require("./primitives.cjs"), exports);
|
|
48
54
|
|
|
49
55
|
function parse(source, options = {}) {
|
|
50
|
-
return
|
|
56
|
+
return (0, index_js_1.default)(options)(source);
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
exports.parse = parse;
|
|
54
|
-
exports.stringify =
|
|
60
|
+
exports.stringify = (0, index_js_2.default)();
|
|
55
61
|
|
|
56
|
-
var
|
|
62
|
+
var inspect_js_1 = require("./stringifier/inspect.cjs");
|
|
57
63
|
|
|
58
64
|
Object.defineProperty(exports, "inspect", {
|
|
59
65
|
enumerable: true,
|
|
60
66
|
get: function () {
|
|
61
|
-
return
|
|
67
|
+
return inspect_js_1.default;
|
|
62
68
|
}
|
|
63
69
|
});
|
|
64
70
|
exports.transforms = {
|
|
65
|
-
flow:
|
|
66
|
-
align:
|
|
67
|
-
indent:
|
|
68
|
-
crlf:
|
|
71
|
+
flow: index_js_3.flow,
|
|
72
|
+
align: align_js_1.default,
|
|
73
|
+
indent: indent_js_1.default,
|
|
74
|
+
crlf: crlf_js_1.default
|
|
69
75
|
};
|
|
70
76
|
exports.tokenizers = {
|
|
71
|
-
tag:
|
|
72
|
-
type:
|
|
73
|
-
name:
|
|
74
|
-
description:
|
|
77
|
+
tag: tag_js_1.default,
|
|
78
|
+
type: type_js_1.default,
|
|
79
|
+
name: name_js_1.default,
|
|
80
|
+
description: description_js_1.default
|
|
75
81
|
};
|
|
76
82
|
exports.util = {
|
|
77
|
-
rewireSpecs:
|
|
78
|
-
rewireSource:
|
|
79
|
-
seedBlock:
|
|
80
|
-
seedTokens:
|
|
83
|
+
rewireSpecs: util_js_1.rewireSpecs,
|
|
84
|
+
rewireSource: util_js_1.rewireSource,
|
|
85
|
+
seedBlock: util_js_1.seedBlock,
|
|
86
|
+
seedTokens: util_js_1.seedTokens
|
|
81
87
|
};
|
|
82
88
|
//# 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","
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":["__createBinding","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__exportStar","exports","p","prototype","hasOwnProperty","call","value","util","tokenizers","transforms","inspect","stringify","parse","index_js_1","require","description_js_1","name_js_1","tag_js_1","type_js_1","index_js_2","align_js_1","indent_js_1","crlf_js_1","index_js_3","util_js_1","source","options","default","inspect_js_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;AACtB,MAAIG,IAAI,GAAGP,MAAM,CAACQ,wBAAP,CAAgCL,CAAhC,EAAmCC,CAAnC,CAAX;;AACA,MAAI,CAACG,IAAD,KAAU,SAASA,IAAT,GAAgB,CAACJ,CAAC,CAACM,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AAA,IAAI,EAAEhB,SAAS,CAACS,OAFC;AAGjBQ,EAAAA,IAAI,EAAEnB,SAAS,CAACW,OAHC;AAIjBS,EAAAA,WAAW,EAAErB,gBAAgB,CAACY;AAJb,CAArB;AAMA1B,OAAO,CAACM,IAAR,GAAe;AAAE8B,EAAAA,WAAW,EAAEb,SAAS,CAACa,WAAzB;AAAsCC,EAAAA,YAAY,EAAEd,SAAS,CAACc,YAA9D;AAA4EC,EAAAA,SAAS,EAAEf,SAAS,CAACe,SAAjG;AAA4GC,EAAAA,UAAU,EAAEhB,SAAS,CAACgB;AAAlI,CAAf","sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\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_js_1 = require(\"./parser/index.js\");\nconst description_js_1 = require(\"./parser/tokenizers/description.js\");\nconst name_js_1 = require(\"./parser/tokenizers/name.js\");\nconst tag_js_1 = require(\"./parser/tokenizers/tag.js\");\nconst type_js_1 = require(\"./parser/tokenizers/type.js\");\nconst index_js_2 = require(\"./stringifier/index.js\");\nconst align_js_1 = require(\"./transforms/align.js\");\nconst indent_js_1 = require(\"./transforms/indent.js\");\nconst crlf_js_1 = require(\"./transforms/crlf.js\");\nconst index_js_3 = require(\"./transforms/index.js\");\nconst util_js_1 = require(\"./util.js\");\n__exportStar(require(\"./primitives.js\"), exports);\nfunction parse(source, options = {}) {\n return (0, index_js_1.default)(options)(source);\n}\nexports.parse = parse;\nexports.stringify = (0, index_js_2.default)();\nvar inspect_js_1 = require(\"./stringifier/inspect.js\");\nObject.defineProperty(exports, \"inspect\", { enumerable: true, get: function () { return inspect_js_1.default; } });\nexports.transforms = {\n flow: index_js_3.flow,\n align: align_js_1.default,\n indent: indent_js_1.default,\n crlf: crlf_js_1.default,\n};\nexports.tokenizers = {\n tag: tag_js_1.default,\n type: type_js_1.default,\n name: name_js_1.default,\n description: description_js_1.default,\n};\nexports.util = { rewireSpecs: util_js_1.rewireSpecs, rewireSource: util_js_1.rewireSource, seedBlock: util_js_1.seedBlock, seedTokens: util_js_1.seedTokens };\n"],"file":"index.cjs"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Options as ParserOptions } from './parser/index';
|
|
2
|
-
import descriptionTokenizer from './parser/tokenizers/description';
|
|
3
|
-
import nameTokenizer from './parser/tokenizers/name';
|
|
4
|
-
import tagTokenizer from './parser/tokenizers/tag';
|
|
5
|
-
import typeTokenizer from './parser/tokenizers/type';
|
|
6
|
-
import alignTransform from './transforms/align';
|
|
7
|
-
import indentTransform from './transforms/indent';
|
|
8
|
-
import crlfTransform from './transforms/crlf';
|
|
9
|
-
import { flow as flowTransform } from './transforms/index';
|
|
10
|
-
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
|
|
11
|
-
export * from './primitives';
|
|
12
|
-
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives").Block[];
|
|
13
|
-
export declare const stringify: import("./stringifier/index").Stringifier;
|
|
14
|
-
export { default as inspect } from './stringifier/inspect';
|
|
1
|
+
import { Options as ParserOptions } from './parser/index.js';
|
|
2
|
+
import descriptionTokenizer from './parser/tokenizers/description.js';
|
|
3
|
+
import nameTokenizer from './parser/tokenizers/name.js';
|
|
4
|
+
import tagTokenizer from './parser/tokenizers/tag.js';
|
|
5
|
+
import typeTokenizer from './parser/tokenizers/type.js';
|
|
6
|
+
import alignTransform from './transforms/align.js';
|
|
7
|
+
import indentTransform from './transforms/indent.js';
|
|
8
|
+
import crlfTransform from './transforms/crlf.js';
|
|
9
|
+
import { flow as flowTransform } from './transforms/index.js';
|
|
10
|
+
import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util.js';
|
|
11
|
+
export * from './primitives.js';
|
|
12
|
+
export declare function parse(source: string, options?: Partial<ParserOptions>): import("./primitives.js").Block[];
|
|
13
|
+
export declare const stringify: import("./stringifier/index.js").Stringifier;
|
|
14
|
+
export { default as inspect } from './stringifier/inspect.js';
|
|
15
15
|
export declare const transforms: {
|
|
16
16
|
flow: typeof flowTransform;
|
|
17
17
|
align: typeof alignTransform;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Line } from '../primitives';
|
|
1
|
+
import { Line } from '../primitives.js';
|
|
2
2
|
/**
|
|
3
3
|
* Groups source lines in sections representing tags.
|
|
4
4
|
* First section is a block description if present. Last section captures lines starting with
|
|
5
5
|
* the last tag to the end of the block, including dangling closing marker.
|
|
6
6
|
* @param {Line[]} block souce lines making a single comment block
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Parser = (block: Line[]) => Line[][];
|
|
9
9
|
/**
|
|
10
10
|
* Predicate telling if string contains opening/closing escaping sequence
|
|
11
11
|
* @param {string} source raw source line
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type Fencer = (source: string) => boolean;
|
|
14
14
|
/**
|
|
15
15
|
* `Parser` configuration options
|
|
16
16
|
*/
|
package/lib/parser/index.cjs
CHANGED
|
@@ -4,53 +4,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const primitives_js_1 = require("../primitives.cjs");
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const util_js_1 = require("../util.cjs");
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const block_parser_js_1 = require("./block-parser.cjs");
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const source_parser_js_1 = require("./source-parser.cjs");
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const spec_parser_js_1 = require("./spec-parser.cjs");
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const tag_js_1 = require("./tokenizers/tag.cjs");
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const type_js_1 = require("./tokenizers/type.cjs");
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const name_js_1 = require("./tokenizers/name.cjs");
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const description_js_1 = require("./tokenizers/description.cjs");
|
|
24
24
|
|
|
25
25
|
function getParser({
|
|
26
26
|
startLine = 0,
|
|
27
27
|
fence = '```',
|
|
28
28
|
spacing = 'compact',
|
|
29
|
-
markers =
|
|
30
|
-
tokenizers = [
|
|
29
|
+
markers = primitives_js_1.Markers,
|
|
30
|
+
tokenizers = [(0, tag_js_1.default)(), (0, type_js_1.default)(spacing), (0, name_js_1.default)(), (0, description_js_1.default)(spacing)]
|
|
31
31
|
} = {}) {
|
|
32
32
|
if (startLine < 0 || startLine % 1 > 0) throw new Error('Invalid startLine');
|
|
33
|
-
const parseSource =
|
|
33
|
+
const parseSource = (0, source_parser_js_1.default)({
|
|
34
34
|
startLine,
|
|
35
35
|
markers
|
|
36
36
|
});
|
|
37
|
-
const parseBlock =
|
|
37
|
+
const parseBlock = (0, block_parser_js_1.default)({
|
|
38
38
|
fence
|
|
39
39
|
});
|
|
40
|
-
const parseSpec =
|
|
40
|
+
const parseSpec = (0, spec_parser_js_1.default)({
|
|
41
41
|
tokenizers
|
|
42
42
|
});
|
|
43
|
-
const joinDescription =
|
|
44
|
-
|
|
45
|
-
const notEmpty = line => line.tokens.description.trim() != '';
|
|
46
|
-
|
|
43
|
+
const joinDescription = (0, description_js_1.getJoiner)(spacing);
|
|
47
44
|
return function (source) {
|
|
48
45
|
const blocks = [];
|
|
49
46
|
|
|
50
|
-
for (const line of
|
|
47
|
+
for (const line of (0, util_js_1.splitLines)(source)) {
|
|
51
48
|
const lines = parseSource(line);
|
|
52
49
|
if (lines === null) continue;
|
|
53
|
-
if (lines.find(notEmpty) === undefined) continue;
|
|
54
50
|
const sections = parseBlock(lines);
|
|
55
51
|
const specs = sections.slice(1).map(parseSpec);
|
|
56
52
|
blocks.push({
|
package/lib/parser/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":["Object","defineProperty","exports","value","
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":["Object","defineProperty","exports","value","primitives_js_1","require","util_js_1","block_parser_js_1","source_parser_js_1","spec_parser_js_1","tag_js_1","type_js_1","name_js_1","description_js_1","getParser","startLine","fence","spacing","markers","Markers","tokenizers","default","Error","parseSource","parseBlock","parseSpec","joinDescription","getJoiner","source","blocks","line","splitLines","lines","sections","specs","slice","map","push","description","tags","problems","reduce","acc","spec","concat"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;;AACA,MAAMC,eAAe,GAAGC,OAAH,qBAArB;;AACA,MAAMC,SAAS,GAAGD,OAAH,eAAf;;AACA,MAAME,iBAAiB,GAAGF,OAAH,sBAAvB;;AACA,MAAMG,kBAAkB,GAAGH,OAAH,uBAAxB;;AACA,MAAMI,gBAAgB,GAAGJ,OAAH,qBAAtB;;AACA,MAAMK,QAAQ,GAAGL,OAAH,wBAAd;;AACA,MAAMM,SAAS,GAAGN,OAAH,yBAAf;;AACA,MAAMO,SAAS,GAAGP,OAAH,yBAAf;;AACA,MAAMQ,gBAAgB,GAAGR,OAAH,gCAAtB;;AACA,SAASS,SAAT,CAAmB;AAAEC,EAAAA,SAAS,GAAG,CAAd;AAAiBC,EAAAA,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AAT,CAAe,CAAf,EAAkBC,GAAlB,CAAsBX,SAAtB,CAAd;AACAI,MAAAA,MAAM,CAACQ,IAAP,CAAY;AACRC,QAAAA,WAAW,EAAEZ,eAAe,CAACO,QAAQ,CAAC,CAAD,CAAT,EAAcf,OAAd,CADpB;AAERqB,QAAAA,IAAI,EAAEL,KAFE;AAGRN,QAAAA,MAAM,EAAEI,KAHA;AAIRQ,QAAAA,QAAQ,EAAEN,KAAK,CAACO,MAAN,CAAa,CAACC,GAAD,EAAMC,IAAN,KAAeD,GAAG,CAACE,MAAJ,CAAWD,IAAI,CAACH,QAAhB,CAA5B,EAAuD,EAAvD;AAJF,OAAZ;AAMH;;AACD,WAAOX,MAAP;AACH,GAhBD;AAiBH;;AACD3B,OAAO,CAACmB,OAAR,GAAkBP,SAAlB","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst primitives_js_1 = require(\"../primitives.js\");\nconst util_js_1 = require(\"../util.js\");\nconst block_parser_js_1 = require(\"./block-parser.js\");\nconst source_parser_js_1 = require(\"./source-parser.js\");\nconst spec_parser_js_1 = require(\"./spec-parser.js\");\nconst tag_js_1 = require(\"./tokenizers/tag.js\");\nconst type_js_1 = require(\"./tokenizers/type.js\");\nconst name_js_1 = require(\"./tokenizers/name.js\");\nconst description_js_1 = require(\"./tokenizers/description.js\");\nfunction getParser({ startLine = 0, fence = '```', spacing = 'compact', markers = primitives_js_1.Markers, tokenizers = [\n (0, tag_js_1.default)(),\n (0, type_js_1.default)(spacing),\n (0, name_js_1.default)(),\n (0, description_js_1.default)(spacing),\n], } = {}) {\n if (startLine < 0 || startLine % 1 > 0)\n throw new Error('Invalid startLine');\n const parseSource = (0, source_parser_js_1.default)({ startLine, markers });\n const parseBlock = (0, block_parser_js_1.default)({ fence });\n const parseSpec = (0, spec_parser_js_1.default)({ tokenizers });\n const joinDescription = (0, description_js_1.getJoiner)(spacing);\n return function (source) {\n const blocks = [];\n for (const line of (0, util_js_1.splitLines)(source)) {\n const lines = parseSource(line);\n if (lines === null)\n continue;\n const sections = parseBlock(lines);\n const specs = sections.slice(1).map(parseSpec);\n blocks.push({\n description: joinDescription(sections[0], markers),\n tags: specs,\n source: lines,\n problems: specs.reduce((acc, spec) => acc.concat(spec.problems), []),\n });\n }\n return blocks;\n };\n}\nexports.default = getParser;\n"],"file":"index.cjs"}
|