Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comment-parser

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comment-parser - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v0.2.2
- `feature` allow spaces in default values `@my-tag {my.type} [name=John Doe]`
# v0.2.1

@@ -2,0 +6,0 @@

@@ -63,3 +63,3 @@

}
if (curlies) {
if (curlies !== 0) {
// throw new Error('Unpaired curly in type doc');

@@ -75,3 +75,22 @@ error = 'Unpaired curly in type doc';

_skipws();
return _tag();
var ch;
var res = '';
var brackets = 0;
var re = /\s/;
while (pos < l) {
ch = str[pos];
brackets += ch === '[' ? 1 : ch === ']' ? -1 : 0;
res += ch;
pos ++;
if (brackets === 0 && re.test(str[pos])) {
break;
}
}
if (brackets) {
// throw new Error('Unpaired curly in type doc');
error = 'Unpaired brackets in type doc';
pos -= res.length;
return '';
}
return res;
}

@@ -113,5 +132,5 @@ function _rest() { // (?:\s+([^$]+))?

// probably if should be hidden with option or moved out to some jsdoc standard
if (tag_node.name.match(/^\[(\S+)\]$/)) {
if (tag_node.name[0] === '[' && tag_node.name[tag_node.name.length - 1] === ']') {
tag_node.optional = true;
tag_node.name = RegExp.$1;
tag_node.name = tag_node.name.substr(1, tag_node.name.length - 2);

@@ -122,3 +141,3 @@ // default value here

tag_node.name = parts[0];
tag_node.default = parts[1];
tag_node.default = parts[1].replace(/^(["'])(.+)(\1)$/, '$2');
}

@@ -125,0 +144,0 @@ }

2

package.json
{
"name": "comment-parser",
"version": "0.2.1",
"version": "0.2.2",
"description": "Generic JSDoc-like comment parser. ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -187,6 +187,7 @@ var fs = require('fs');

it('should parse `@tag {my.type} [name=value]`', function() {
// http://usejsdoc.org/tags-param.html
it('should parse `@tag {my.type} [name=John Doe]`', function() {
expect(parsed(function(){
/**
* @my-tag {my.type} [name=value]
* @my-tag {my.type} [name=John Doe]
*/

@@ -204,3 +205,3 @@ })[0])

optional : true,
default : 'value'
default : 'John Doe'
}]

@@ -210,2 +211,65 @@ });

// https://github.com/senchalabs/jsduck/wiki/@param
it('should parse quoted optionals like `@tag [name="yay"] desc`', function() {
expect(parsed(function(){
/**
* @tag {t} [name="yay!"] desc
*/
})[0])
.to.eql({
line: 0,
description: '',
tags: [{
tag : 'tag',
line : 1,
type : 't',
name : 'name',
default : 'yay!',
optional : true,
description : 'desc'
}]
});
});
it('shouldn\'t strip different quotes in `@tag [name="yay\'] desc`', function() {
expect(parsed(function(){
/**
* @tag {t} [name="yay!'] desc
*/
})[0])
.to.eql({
line: 0,
description: '',
tags: [{
tag : 'tag',
line : 1,
type : 't',
name : 'name',
default : '"yay!\'',
optional : true,
description : 'desc'
}]
});
});
it('should parse optional names like `@tag [...name] desc`', function() {
expect(parsed(function(){
/**
* @tag {t} [...name] desc
*/
})[0])
.to.eql({
line: 0,
description: '',
tags: [{
tag : 'tag',
line : 1,
type : 't',
name : '...name',
optional : true,
description : 'desc'
}]
});
});
it('should parse multiple tags', function() {

@@ -212,0 +276,0 @@ expect(parsed(function(){

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc