Permalink
Browse files

Merge pull request #90 from stephenmathieson/tab-indented-comments

support tab-indented comments
  • Loading branch information...
2 parents 06b1fd7 + 670604e commit 4240030ba353cadae55be9a7b18a4c30ae74494b @tj committed Mar 16, 2013
Showing with 33 additions and 1 deletion.
  1. +1 −1 lib/dox.js
  2. +17 −0 test/dox.test.js
  3. +15 −0 test/fixtures/d-tabs.js
View
@@ -58,7 +58,7 @@ exports.parseComments = function(js, options){
// end comment
} else if (withinMultiline && !withinSingle && '*' == js[i] && '/' == js[i+1]) {
i += 2;
- buf = buf.replace(/^ *\* ?/gm, '');
+ buf = buf.replace(/^[ \t]*\* ?/gm, '');
var comment = exports.parseComment(buf, options);
comment.ignore = ignore;
comments.push(comment);
View
@@ -128,6 +128,23 @@ module.exports = {
});
},
+ 'test .parseComments() tags with tabs': function (done) {
+ fixture('d-tabs.js', function (err, str) {
+ var comments = dox.parseComments(str)
+ , first = comments.shift();
+
+ first.tags.should.have.length(4);
+ first.description.full.should.equal('<p>Parse tag type string "{Array|Object}" etc.</p>');
+ first.description.summary.should.equal('<p>Parse tag type string "{Array|Object}" etc.</p>');
+ first.description.body.should.equal('');
+ first.ctx.type.should.equal('method');
+ first.ctx.receiver.should.equal('exports');
+ first.ctx.name.should.equal('parseTagTypes');
+ first.code.should.equal('exports.parseTagTypes = function(str) {\n\t\treturn str\n\t\t\t.replace(/[{}]/g, \'\')\n\t\t\t.split(/ *[|,\\/] */);\n\t};');
+ done();
+ });
+ },
+
'test .parseComments() prototypes': function (done){
fixture('prototypes.js', function(err, str){
var comments = dox.parseComments(str)
View
@@ -0,0 +1,15 @@
+
+ /**
+ * Parse tag type string "{Array|Object}" etc.
+ *
+ * @name is arbitrary
+ * @param {String} str
+ * @return {Array}
+ * @api public
+ */
+
+ exports.parseTagTypes = function(str) {
+ return str
+ .replace(/[{}]/g, '')
+ .split(/ *[|,\/] */);
+ };

0 comments on commit 4240030

Please sign in to comment.