comment-parser 0.5.4 → 0.5.5

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 CHANGED
@@ -1,3 +1,6 @@
1
+ # v0.5.5
2
+ - allow loose tag names, e.g. @.tag, @-tag
3
+
1
4
  # v0.5.4
2
5
  - allow quoted literal names, e.g. `@tag "My Var" description`
3
6
 
package/README.md CHANGED
@@ -9,7 +9,7 @@ Module provides `parse(s:String[, opts:Object]):Object` function which takes `/*
9
9
 
10
10
  It is not trying to detect relations between tags or somehow recognize their meaning. Any tag can be used, as long as it satisfies the format.
11
11
 
12
- ```
12
+ ```javascript
13
13
  /**
14
14
  * Singleline or multiline description text. Line breaks are preserved.
15
15
  *
@@ -24,7 +24,7 @@ It is not trying to detect relations between tags or somehow recognize their mea
24
24
 
25
25
  this would be parsed into following
26
26
 
27
- ```javascript
27
+ ```json
28
28
  [{
29
29
  "tags": [{
30
30
  "tag": "some-tag",
@@ -78,7 +78,7 @@ By default dotted names like `name.subname.subsubname` will be expanded into nes
78
78
 
79
79
  Below are examples of acceptable comment formats
80
80
 
81
- ```
81
+ ```javascript
82
82
  /** online comment */
83
83
 
84
84
  /** first line
@@ -111,7 +111,7 @@ Each parser function takes string left after previous parsers applied and data p
111
111
 
112
112
  Tag node data is build by merging result bits from all parsers. Here is some example that is not doing actual parsing but is demonstrating the flow:
113
113
 
114
- ```
114
+ ```javascript
115
115
  /**
116
116
  * Source to be parsed below
117
117
  * @tag {type} name Description
@@ -140,12 +140,12 @@ parse(source, {parsers: [
140
140
 
141
141
  This would produce following:
142
142
 
143
- ```
143
+ ```json
144
144
  [{
145
145
  "tags": [{
146
146
  "tag": "tag",
147
147
  "errors": [
148
- "check_tag: Unrecognized tag \\"tag\\""
148
+ "check_tag: Unrecognized tag \"tag\""
149
149
  ],
150
150
  "name": "name2",
151
151
  "optional": false,
@@ -168,4 +168,4 @@ This would produce following:
168
168
 
169
169
  ```
170
170
  > npm info --registry https://registry.npmjs.org comment-parser contributors
171
- ```
171
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comment-parser",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Generic JSDoc-like comment parser. ",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "dependencies": {},
11
11
  "devDependencies": {
12
12
  "chai": "^4.2.0",
13
- "eslint": "^4.7.1",
13
+ "eslint": "^5.16.0",
14
14
  "eslint-config-standard": "^10.2.1",
15
15
  "eslint-plugin-import": "^2.7.0",
16
16
  "eslint-plugin-node": "^5.1.1",
@@ -20,8 +20,9 @@
20
20
  "nodemon": "^1.18.9"
21
21
  },
22
22
  "scripts": {
23
- "pretest": "eslint .",
24
- "test": "mocha tests",
23
+ "test:lint": "eslint .",
24
+ "test:unit": "mocha tests",
25
+ "test": "npm run test:lint && npm run test:unit",
25
26
  "watch": "nodemon -q -i node_modules -x npm test"
26
27
  },
27
28
  "repository": {
package/parser.js CHANGED
@@ -101,7 +101,7 @@ function parse_block (source, opts) {
101
101
  .reduce(function (tags, line) {
102
102
  line.source = trim(line.source)
103
103
 
104
- if (line.source.match(/^\s*@(\w+)/)) {
104
+ if (line.source.match(/^\s*@(\S+)/)) {
105
105
  tags.push({source: [line.source], line: line.number})
106
106
  } else {
107
107
  var tag = tags[tags.length - 1]
@@ -459,6 +459,47 @@ describe('Comment string parsing', function () {
459
459
  })
460
460
  })
461
461
 
462
+ it('should tolerate loose tag names', function () {
463
+ expect(parse(function () {
464
+ /**
465
+ Description text
466
+ @.tag0 tagname Tag 0 description
467
+ @-tag1 tagname Tag 1 description
468
+ @+tag2 tagname Tag 2 description
469
+ */
470
+ })[0])
471
+ .eql({
472
+ description: 'Description text',
473
+ source: 'Description text\n@.tag0 tagname Tag 0 description\n@-tag1 tagname Tag 1 description\n@+tag2 tagname Tag 2 description',
474
+ line: 1,
475
+ tags: [{
476
+ tag: '.tag0',
477
+ name: 'tagname',
478
+ optional: false,
479
+ description: 'Tag 0 description',
480
+ type: '',
481
+ line: 3,
482
+ source: '@.tag0 tagname Tag 0 description'
483
+ }, {
484
+ tag: '-tag1',
485
+ name: 'tagname',
486
+ optional: false,
487
+ description: 'Tag 1 description',
488
+ type: '',
489
+ line: 4,
490
+ source: '@-tag1 tagname Tag 1 description'
491
+ }, {
492
+ tag: '+tag2',
493
+ name: 'tagname',
494
+ optional: false,
495
+ description: 'Tag 2 description',
496
+ type: '',
497
+ line: 5,
498
+ source: '@+tag2 tagname Tag 2 description'
499
+ }]
500
+ })
501
+ })
502
+
462
503
  it('should tolerate default value with whitespces `@tag {my.type} [name=John Doe]`', function () {
463
504
  expect(parse(function () {
464
505
  /**