Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Trim trailing whitespace from tag strings.

Fixes #167
  • Loading branch information...
commit 9e125a88a8f69bbce691b23dcc76f427f04f09d8 1 parent deedbd0
@ChiperSoft ChiperSoft authored
View
2  lib/dox.js
@@ -379,7 +379,7 @@ exports.parseTag = function(str) {
tag.body = tag.full.split('\n\n').slice(1).join('\n\n');
break;
default:
- tag.string = parts.join(' ');
+ tag.string = parts.join(' ').replace(/\s+$/, '');
break;
}
View
33 test/dox.multilinetags.test.js
@@ -13,8 +13,11 @@ function fixture(name, fn) {
module.exports = {
'test .parseComments() multiline tags': function(done){
fixture('multilinetags.js', function(err, str){
- var comments = dox.parseComments(str)
- , only = comments.shift()
+ var comments = dox.parseComments(str);
+
+ comments.length.should.equal(15);
+
+ var only = comments.shift()
, first = comments.shift()
, last = comments.shift()
, mid = comments.shift()
@@ -72,6 +75,7 @@ module.exports = {
lastParam.tags[1].description.should.equal('<p>one<br />two<br />three</p>');
lastParam.tags[1].string.should.equal('{String} foo\none\ntwo\nthree');
midParam.tags.should.with.lengthOf(3);
+ midParam.tags[0].type.should.equal('foo');
midParam.tags[0].string.should.equal('first');
midParam.tags[0].html.should.equal('<p>first</p>');
midParam.tags[1].type.should.equal('param');
@@ -114,6 +118,31 @@ module.exports = {
example.tags.should.with.lengthOf(1);
example.tags[0].string.should.equal(' test(one);\n test(two);');
example.tags[0].html.should.equal('<pre><code>test(one);\ntest(two);\n</code></pre>');
+
+ var i167 = comments.shift();
+ i167.tags.should.with.lengthOf(3);
+ i167.tags[0].type.should.equal('tag-1');
+ i167.tags[0].string.should.equal('foo');
+ i167.tags[0].html.should.equal('<p>foo</p>');
+ i167.tags[1].type.should.equal('tag-2');
+ i167.tags[1].string.should.equal('bar');
+ i167.tags[1].html.should.equal('<p>bar</p>');
+ i167.tags[2].type.should.equal('tag-3');
+ i167.tags[2].string.should.equal('baz');
+ i167.tags[2].html.should.equal('<p>baz</p>');
+
+ var i167 = comments.shift();
+ i167.tags.should.with.lengthOf(3);
+ i167.tags[0].type.should.equal('tag-1');
+ i167.tags[0].string.should.equal('foo');
+ i167.tags[0].html.should.equal('<p>foo</p>');
+ i167.tags[1].type.should.equal('tag-2');
+ i167.tags[1].string.should.equal('bar');
+ i167.tags[1].html.should.equal('<p>bar</p>');
+ i167.tags[2].type.should.equal('tag-3');
+ i167.tags[2].string.should.equal('baz');
+ i167.tags[2].html.should.equal('<p>baz</p>');
+
done();
});
}
View
19 test/fixtures/multilinetags.js
@@ -72,7 +72,7 @@ function firstParam() {
/**
* last
*
- * @foo first
+ * @foo first
* @param {String} foo
* one
* two
@@ -151,3 +151,20 @@ function midReturn() {
*/
function example() {
}
+
+/**
+ * @tag-1 foo
+ * @tag-2 bar
+ *
+ * @tag-3 baz
+ */
+
+ /**
+ * @tag-1
+ * foo
+ * @tag-2
+ * bar
+ *
+ * @tag-3
+ * baz
+ */
Please sign in to comment.
Something went wrong with that request. Please try again.