comment-parser 0.2.3 → 0.3.2

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.
@@ -1,154 +0,0 @@
1
- var fs = require('fs');
2
- var expect = require('chai').expect;
3
- var parse = require('../index');
4
-
5
- describe('Single comment string parsing', function() {
6
-
7
- function parsed(func, opts) {
8
- opts = opts || {};
9
- opts.raw_value = true;
10
- var str = func.toString();
11
- return parse(str.slice(
12
- str.indexOf('{') + 1,
13
- str.lastIndexOf('}')
14
- ).trim(), opts);
15
- }
16
-
17
- it('should return `@tag`', function() {
18
- expect(parsed(function(){
19
- /**
20
- * @my-tag
21
- */
22
- var a;
23
- })[0].tags[0].value)
24
- .to.eq('@my-tag');
25
- });
26
-
27
- it('should return `@tag {my.type}`', function() {
28
- expect(parsed(function(){
29
- /**
30
- * @my-tag {my.type}
31
- */
32
- var a;
33
- })[0].tags[0].value)
34
- .to.eq('@my-tag {my.type}');
35
- });
36
-
37
- it('should return `@tag {my.type} name`', function() {
38
- expect(parsed(function(){
39
- /**
40
- * @my-tag {my.type} name
41
- */
42
- var a;
43
- })[0].tags[0].value)
44
- .to.eq('@my-tag {my.type} name');
45
- });
46
-
47
- it('should return `@tag name`', function() {
48
- expect(parsed(function(){
49
- /**
50
- * @my-tag name
51
- */
52
- })[0].tags[0].value)
53
- .to.eq('@my-tag name');
54
- });
55
-
56
- it('should return `@tag {my.type} [name]`', function() {
57
- expect(parsed(function(){
58
- /**
59
- * @my-tag {my.type} [name]
60
- */
61
- })[0].tags[0].value)
62
- .to.eq('@my-tag {my.type} [name]');
63
- });
64
-
65
- it('should parse `@tag {my.type} [name=value]` and return value', function() {
66
- expect(parsed(function(){
67
- /**
68
- * @my-tag {my.type} [name=value]
69
- */
70
- })[0])
71
- .to.eql({
72
- description: '',
73
- line: 0,
74
- tags: [{
75
- tag : 'my-tag',
76
- type : 'my.type',
77
- name : 'name',
78
- description : '',
79
- optional : true,
80
- default : 'value',
81
- line : 1,
82
- value : '@my-tag {my.type} [name=value]'
83
- }]
84
- });
85
- });
86
-
87
- it('should parse multiple tags and set raw value for them', function() {
88
- expect(parsed(function(){
89
- /**
90
- * Description
91
- * @my-tag1
92
- * @my-tag2
93
- */
94
- })[0])
95
- .to.eql({
96
- description : 'Description',
97
- line : 1,
98
- tags : [{
99
- tag : 'my-tag1',
100
- type : '',
101
- name : '',
102
- description : '',
103
- line : 2,
104
- value : '@my-tag1'
105
- }, {
106
- tag : 'my-tag2',
107
- type : '',
108
- name : '',
109
- description : '',
110
- line : 3,
111
- value : '@my-tag2'
112
- }]
113
- });
114
- });
115
-
116
- it('should parse nested tags and return raw values', function() {
117
- expect(parsed(function(){
118
- /**
119
- * Description
120
- * @my-tag name
121
- * @my-tag name.sub-name
122
- * @my-tag name.sub-name.sub-sub-name
123
- */
124
- }, {dotted_names: true})[0])
125
- .to.eql({
126
- description : 'Description',
127
- line : 1,
128
- tags : [{
129
- tag : 'my-tag',
130
- type : '',
131
- name : 'name',
132
- description : '',
133
- line : 2,
134
- value : '@my-tag name',
135
- tags : [{
136
- tag : 'my-tag',
137
- type : '',
138
- name : 'sub-name',
139
- description : '',
140
- line : 3,
141
- value : '@my-tag name.sub-name',
142
- tags : [{
143
- tag : 'my-tag',
144
- type : '',
145
- name : 'sub-sub-name',
146
- description : '',
147
- line : 4,
148
- value : '@my-tag name.sub-name.sub-sub-name'
149
- }]
150
- }]
151
- }]
152
- });
153
- });
154
- });
@@ -1,169 +0,0 @@
1
- var fs = require('fs');
2
- var expect = require('chai').expect;
3
- var parse = require('../index');
4
-
5
- describe('Single comment string parsing', function() {
6
-
7
- function parsed(func, opts) {
8
- opts = opts || {};
9
- opts.line_numbers = true;
10
- var str = func.toString();
11
- return parse(str.slice(
12
- str.indexOf('{') + 1,
13
- str.lastIndexOf('}')
14
- ).trim(), opts);
15
- }
16
-
17
- it('should locate description', function() {
18
- expect(parsed(function(){
19
- /**
20
- * Description first line
21
- *
22
- * Description second line
23
- */
24
- var a;
25
- })[0].line)
26
- .to.eq(1);
27
- });
28
-
29
- it('should locate omitted description as 1', function() {
30
- expect(parsed(function(){
31
- /**
32
- *
33
- */
34
- var a;
35
- })[0].line)
36
- .to.eq(1);
37
- });
38
-
39
- it('should locate multiple comments separately', function() {
40
- var p = parsed(function(){
41
- /**
42
- * Description first line
43
- */
44
- var a;
45
-
46
- /**
47
- * Description second line
48
- */
49
- var b;
50
- });
51
-
52
- expect(p.length)
53
- .to.eq(2);
54
-
55
- expect(p[0].line)
56
- .to.eq(1);
57
-
58
- expect(p[1].line)
59
- .to.eq(1);
60
- });
61
-
62
- it('should locate parsed `@tag {my.type} [name=value]`', function() {
63
- expect(parsed(function(){
64
- /**
65
- * @my-tag {my.type} [name=value]
66
- */
67
- })[0].tags[0].line)
68
- .to.eq(1);
69
- });
70
-
71
- it('should locate parsed multiple tags', function() {
72
- expect(parsed(function(){
73
- /**
74
- * Description
75
- * @my-tag1
76
- * @my-tag2
77
- */
78
- })[0])
79
- .to.eql({
80
- description : 'Description',
81
- line : 1,
82
- tags : [{
83
- tag : 'my-tag1',
84
- type : '',
85
- name : '',
86
- description : '',
87
- line : 2
88
- }, {
89
- tag : 'my-tag2',
90
- type : '',
91
- name : '',
92
- description : '',
93
- line : 3
94
- }]
95
- });
96
- });
97
-
98
- it('should locate parsed nested tags', function() {
99
- expect(parsed(function(){
100
- /**
101
- * Description
102
- * @my-tag name
103
- * @my-tag name.sub-name
104
- * @my-tag name.sub-name.sub-sub-name
105
- */
106
- })[0])
107
- .to.eql({
108
- description : 'Description',
109
- line : 1,
110
- tags : [{
111
- tag : 'my-tag',
112
- type : '',
113
- name : 'name',
114
- description : '',
115
- line : 2
116
- }, {
117
- tag : 'my-tag',
118
- type : '',
119
- name : 'name.sub-name',
120
- description : '',
121
- line : 3,
122
- }, {
123
- tag : 'my-tag',
124
- type : '',
125
- name : 'name.sub-name.sub-sub-name',
126
- description : '',
127
- line : 4
128
- }]
129
- });
130
- });
131
-
132
-
133
- it('should locate nested tags', function() {
134
- expect(parsed(function(){
135
- /**
136
- * Description
137
- * @my-tag name
138
- * @my-tag name.sub-name
139
- * @my-tag name.sub-name.sub-sub-name
140
- */
141
- }, {dotted_names: true})[0])
142
- .to.eql({
143
- description : 'Description',
144
- line : 1,
145
- tags : [{
146
- tag : 'my-tag',
147
- type : '',
148
- name : 'name',
149
- description : '',
150
- line : 2,
151
- tags : [{
152
- tag : 'my-tag',
153
- type : '',
154
- name : 'sub-name',
155
- description : '',
156
- line : 3,
157
- tags : [{
158
- tag : 'my-tag',
159
- type : '',
160
- name : 'sub-sub-name',
161
- description : '',
162
- line : 4
163
- }]
164
- }]
165
- }]
166
- });
167
- });
168
-
169
- });