visionmedia/dox — pull request #61 by cbou (2012-07-04 22:27:17+00:00)
Title: Single line comment make trouble.

If there is such a comment in a file `// asfasdfasdf /** /////` it causes some trouble in the output.

For example try to parse this part of `c.js`

``` javascript

/**
* Parse tag string "@param {Array} name description" etc.
*
* @param {String}
* @return {Object}
* @api public
*/

exports.parseTag = function(str) {
var tag = {}
, parts = str.split(/ +/)
, type = tag.type = parts.shift().replace('@', '');

/* shouldn't fail */
switch (type) { // asfasdfasdf /** /////
case 'param':
tag.types = exports.parseTagTypes(parts.shift());
tag.name = parts.shift() || '';
tag.description = parts.join(' ');
break;
case 'return':
tag.types = exports.parseTagTypes(parts.shift());
tag.description = parts.join(' ');
break;
case 'see':
if (~str.indexOf('http')) {
tag.title = parts.length > 1
? parts.shift()
: '';
tag.url = parts.join(' ');
} else {
tag.local = parts.join(' ');
}
case 'api':
tag.visibility = parts.shift();
break;
case 'type':
tag.types = exports.parseTagTypes(parts.shift());
break;
}

return tag;
}

/**
* Parse tag type string "{Array|Object}" etc.
*
* @param {String} str
* @return {Array}
* @api public
*/

exports.parseTagTypes = function(str) {
return str
.replace(/[{}]/g, '')
.split(/ *[|,\/] */);
};
```

You will get something like that:

```json
"description": {
"full": "

/////
case 'param':
tag.types = exports.parseTagTypes(parts.shift());
tag.name = parts.shift() || '';
tag.description = parts.join(' ');
break;
case 'return':
tag.types = exports.parseTagTypes(parts.shift());
tag.description = parts.join(' ');
break;
case 'see':
if (~str.indexOf('http')) {
tag.title = parts.length > 1
? parts.shift()
: '';
tag.url = parts.join(' ');
} else {
tag.local = parts.join(' ');
}
case 'api':
tag.visibility = parts.shift();
break;
case 'type':
tag.types = exports.parseTagTypes(parts.shift());
break;
}

\n\n

return tag;
}

\n\n

/**
Parse tag type string \"{Array|Object}\" etc.

",
"summary": "

/////
case 'param':
tag.types = exports.parseTagTypes(parts.shift());
tag.name = parts.shift() || '';
tag.description = parts.join(' ');
break;
case 'return':
tag.types = exports.parseTagTypes(parts.shift());
tag.description = parts.join(' ');
break;
case 'see':
if (~str.indexOf('http')) {
tag.title = parts.length > 1
? parts.shift()
: '';
tag.url = parts.join(' ');
} else {
tag.local = parts.join(' ');
}
case 'api':
tag.visibility = parts.shift();
break;
case 'type':
tag.types = exports.parseTagTypes(parts.shift());
break;
}

",
"body": "

return tag;
}

\n\n

/**
Parse tag type string \"{Array|Object}\" etc.

"
},
```

So I create this pull request to care about single line comment too.

I write a new test, and all current tests are green.

I hope it will help.