comment-parser
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -152,3 +152,3 @@ var CommentParser = (function (exports) { | ||
/** | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.descrioption` into the `tag` token, | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, | ||
* and populates `spec.tag` | ||
@@ -392,3 +392,2 @@ */ | ||
const joinDescription = getJoiner(spacing); | ||
const notEmpty = (line) => line.tokens.description.trim() != ''; | ||
return function (source) { | ||
@@ -400,4 +399,2 @@ const blocks = []; | ||
continue; | ||
if (lines.find(notEmpty) === undefined) | ||
continue; | ||
const sections = parseBlock(lines); | ||
@@ -404,0 +401,0 @@ const specs = sections.slice(1).map(parseSpec); |
@@ -0,1 +1,4 @@ | ||
# v1.3.1 | ||
- allow for valid empty jsdoc; fixes #128 | ||
# v1.3.0 | ||
@@ -2,0 +5,0 @@ - add support for custom block markers |
@@ -22,3 +22,2 @@ import { Markers } from '../primitives.js'; | ||
const joinDescription = getDescriptionJoiner(spacing); | ||
const notEmpty = (line) => line.tokens.description.trim() != ''; | ||
return function (source) { | ||
@@ -30,4 +29,2 @@ const blocks = []; | ||
continue; | ||
if (lines.find(notEmpty) === undefined) | ||
continue; | ||
const sections = parseBlock(lines); | ||
@@ -34,0 +31,0 @@ const specs = sections.slice(1).map(parseSpec); |
import { Tokenizer } from './index'; | ||
/** | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.descrioption` into the `tag` token, | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, | ||
* and populates `spec.tag` | ||
*/ | ||
export default function tagTokenizer(): Tokenizer; |
/** | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.descrioption` into the `tag` token, | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, | ||
* and populates `spec.tag` | ||
@@ -4,0 +4,0 @@ */ |
import { Tokenizer } from './index'; | ||
/** | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.descrioption` into the `tag` token, | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, | ||
* and populates `spec.tag` | ||
*/ | ||
export default function tagTokenizer(): Tokenizer; |
{ | ||
"name": "comment-parser", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Generic JSDoc-like comment parser", | ||
@@ -84,4 +84,3 @@ "type": "module", | ||
}, | ||
"homepage": "https://github.com/syavorsky/comment-parser", | ||
"dependencies": {} | ||
"homepage": "https://github.com/syavorsky/comment-parser" | ||
} |
@@ -48,5 +48,2 @@ import { Block, Line, Problem, BlockMarkers, Markers } from '../primitives'; | ||
const notEmpty = (line: Line): boolean => | ||
line.tokens.description.trim() != ''; | ||
return function (source: string): Block[] { | ||
@@ -58,3 +55,2 @@ const blocks: Block[] = []; | ||
if (lines === null) continue; | ||
if (lines.find(notEmpty) === undefined) continue; | ||
@@ -61,0 +57,0 @@ const sections = parseBlock(lines); |
@@ -5,3 +5,3 @@ import { Spec } from '../../primitives'; | ||
/** | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.descrioption` into the `tag` token, | ||
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, | ||
* and populates `spec.tag` | ||
@@ -8,0 +8,0 @@ */ |
@@ -483,11 +483,2 @@ const { parse } = require('../../lib/index.cjs'); | ||
test('skip empty blocks', () => { | ||
const parsed = parse(` | ||
/** | ||
* | ||
*/ | ||
var a`); | ||
expect(parsed).toHaveLength(0); | ||
}); | ||
test('multiple blocks', () => { | ||
@@ -494,0 +485,0 @@ const parsed = parse(` |
@@ -7,3 +7,3 @@ import getParser from '../../src/parser'; | ||
/** | ||
* Description may go | ||
* Description may go\x20 | ||
* over few lines followed by @tags | ||
@@ -171,6 +171,6 @@ * @param {string} name name parameter | ||
test('no source clonning', () => { | ||
test('no source cloning', () => { | ||
const parsed = getParser()(` | ||
/** | ||
* Description may go | ||
* Description may go\x20 | ||
* over few lines followed by @tags | ||
@@ -184,7 +184,107 @@ * @param {string} name name parameter | ||
test('empty multi-line block', () => { | ||
const parsed = getParser()(` | ||
/** | ||
* | ||
*/`); | ||
expect(parsed).toEqual([ | ||
{ | ||
description: '', | ||
tags: [], | ||
source: [ | ||
{ | ||
number: 1, | ||
source: ' /**', | ||
tokens: { | ||
delimiter: '/**', | ||
description: '', | ||
end: '', | ||
lineEnd: '', | ||
name: '', | ||
postDelimiter: '', | ||
postName: '', | ||
postTag: '', | ||
postType: '', | ||
start: ' ', | ||
tag: '', | ||
type: '', | ||
}, | ||
}, | ||
{ | ||
number: 2, | ||
source: ' *', | ||
tokens: { | ||
delimiter: '*', | ||
description: '', | ||
end: '', | ||
lineEnd: '', | ||
name: '', | ||
postDelimiter: '', | ||
postName: '', | ||
postTag: '', | ||
postType: '', | ||
start: ' ', | ||
tag: '', | ||
type: '', | ||
}, | ||
}, | ||
{ | ||
number: 3, | ||
source: ' */', | ||
tokens: { | ||
delimiter: '', | ||
description: '', | ||
end: '*/', | ||
lineEnd: '', | ||
name: '', | ||
postDelimiter: '', | ||
postName: '', | ||
postTag: '', | ||
postType: '', | ||
start: ' ', | ||
tag: '', | ||
type: '', | ||
}, | ||
}, | ||
], | ||
problems: [], | ||
}, | ||
]); | ||
}); | ||
test('empty one-line block', () => { | ||
const parsed = getParser()(` | ||
/** */`); | ||
expect(parsed).toEqual([ | ||
{ | ||
description: '', | ||
tags: [], | ||
source: [ | ||
{ | ||
number: 1, | ||
source: ' /** */', | ||
tokens: { | ||
delimiter: '/**', | ||
description: '', | ||
end: '*/', | ||
lineEnd: '', | ||
name: '', | ||
postDelimiter: ' ', | ||
postName: '', | ||
postTag: '', | ||
postType: '', | ||
start: ' ', | ||
tag: '', | ||
type: '', | ||
}, | ||
}, | ||
], | ||
problems: [], | ||
}, | ||
]); | ||
}); | ||
test.each([ | ||
['empty', '/**\n*\n*/'], | ||
['one-star', '/*\n*\n*/'], | ||
['three-star', '/***\n*\n*/'], | ||
['empty one-liner', '/** */'], | ||
['one-star oneliner', '/* */'], | ||
@@ -191,0 +291,0 @@ ['three-star oneliner', '/*** */'], |
import { | ||
hasCR, | ||
isSpace, | ||
@@ -11,2 +12,11 @@ seedTokens, | ||
test.each([ | ||
['beginning', '\r to end', false], | ||
['middle', 'has \r in middle', false], | ||
['ending', 'only at end \r', true], | ||
['none', 'no carriage returns', false], | ||
])('carriage returns - %s', (name, source, boolResult) => { | ||
expect(hasCR(source)).toEqual(boolResult); | ||
}); | ||
test.each([ | ||
['win', 'a\r\nb\r\nc', ['a\r', 'b\r', 'c']], | ||
@@ -13,0 +23,0 @@ ['unix', 'a\nb\nc', ['a', 'b', 'c']], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
362504
10138