Skip to content

Commit f9f47d9

Browse files
committed
test(description-tag): Confirm behavior of description tag with tests
The `@description` tag allows people to specify a description of a node in any place in the JSDoc comment, instead of only at the beginning. Fixes #341
1 parent e4e7866 commit f9f47d9

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

test/fixture/meta.input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
2-
* This function returns the number one.
2+
* This description is ignored because the method has a tagged description.
33
* @returns {number} numberone
4+
* @description This function returns the number one.
45
* @see {@link http://github.com/|github}
56
* @see TestCase
67
* @see [markdown link](http://foo.com/)

test/fixture/meta.output.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -62,40 +62,45 @@
6262
"name": "number"
6363
}
6464
},
65+
{
66+
"title": "description",
67+
"description": "This function returns the number one.",
68+
"lineNumber": 3
69+
},
6570
{
6671
"title": "see",
6772
"description": "{@link http://github.com/|github}",
68-
"lineNumber": 3
73+
"lineNumber": 4
6974
},
7075
{
7176
"title": "see",
7277
"description": "TestCase",
73-
"lineNumber": 4
78+
"lineNumber": 5
7479
},
7580
{
7681
"title": "see",
7782
"description": "[markdown link](http://foo.com/)",
78-
"lineNumber": 5
83+
"lineNumber": 6
7984
},
8085
{
8186
"title": "version",
8287
"description": "1.0.0",
83-
"lineNumber": 6
88+
"lineNumber": 7
8489
},
8590
{
8691
"title": "since",
8792
"description": "2.0.0",
88-
"lineNumber": 7
93+
"lineNumber": 8
8994
},
9095
{
9196
"title": "copyright",
9297
"description": "Tom MacWright",
93-
"lineNumber": 8
98+
"lineNumber": 9
9499
},
95100
{
96101
"title": "license",
97102
"description": "BSD",
98-
"lineNumber": 9
103+
"lineNumber": 10
99104
}
100105
],
101106
"loc": {
@@ -104,18 +109,18 @@
104109
"column": 0
105110
},
106111
"end": {
107-
"line": 11,
112+
"line": 12,
108113
"column": 3
109114
}
110115
},
111116
"context": {
112117
"loc": {
113118
"start": {
114-
"line": 12,
119+
"line": 13,
115120
"column": 0
116121
},
117122
"end": {
118-
"line": 15,
123+
"line": 16,
119124
"column": 2
120125
}
121126
}

test/lib/parse.js

+15
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ test('parse - @augments', function(t) {
107107
t.end();
108108
});
109109

110+
test('parse - @description', function(t) {
111+
t.deepEqual(
112+
evaluate(function() {
113+
/**
114+
* This is a free-form description
115+
* @description This tagged description wins, and [is markdown](http://markdown.com).
116+
*/
117+
})[0].description,
118+
remark().parse('This tagged description wins, and [is markdown](http://markdown.com).'),
119+
'description'
120+
);
121+
122+
t.end();
123+
});
124+
110125
/*
111126
* Dossier-style augments tag
112127
* https://github.com/google/closure-library/issues/746

0 commit comments

Comments
 (0)