Skip to content
Browse files

Prevent error when using --api & comments have no example code.

  • Loading branch information...
1 parent 1752888 commit c9c8087958c56cda342c5bd79aba06a50808e323 @timoxley committed
Showing with 10 additions and 2 deletions.
  1. +1 −1 lib/api.js
  2. +9 −1 test/dox.test.js
View
2 lib/api.js
@@ -20,7 +20,7 @@ module.exports = function(comments){
.join('\n')
.replace(/^ *#/gm, '')
- var code = buf.match(/^( {4}[^\n]+\n*)+/gm);
+ var code = buf.match(/^( {4}[^\n]+\n*)+/gm) || [];
code.forEach(function(block){
var code = block.replace(/^ {4}/gm, '');
View
10 test/dox.test.js
@@ -311,4 +311,12 @@ module.exports = {
done();
});
},
-};
+ 'test .api() without inline code in comments': function(done) {
+ fixture('a.js', function(err, str){
+ var comments = dox.parseComments(str);
+ var apiDocs = dox.api(comments);
+ apiDocs.should.equal(" - [exports.version](#exportsversion)\n\n## exports.version\n\n <p>Library version.</p>\n");
+ done();
+ });
+ }
+};

0 comments on commit c9c8087

Please sign in to comment.
Something went wrong with that request. Please try again.