Skip to content
Browse files

Merge pull request #58 from ForbesLindesay/SupportUncommentedFiles

Support uncommented files
  • Loading branch information...
2 parents 5a031ec + 431344f commit 9c81b77f425a81eff37de89952c932c2cacb4afc @tj committed
Showing with 21 additions and 1 deletion.
  1. +8 −0 lib/dox.js
  2. +10 −1 test/dox.test.js
  3. +3 −0 test/fixtures/uncommented.js
View
8 lib/dox.js
@@ -63,6 +63,14 @@ exports.parseComments = function(js, options){
}
}
+ if (comments.length === 0) {
+ comments.push({
+ tags: [],
+ description: {full: '', summary: '', body: ''},
+ isPrivate: false
+ });
+ }
+
// trailing code
if (buf.trim().length) {
comment = comments[comments.length - 1];
View
11 test/dox.test.js
@@ -283,5 +283,14 @@ module.exports = {
var tag = dox.parseTag('@hello universe is better than world');
tag.type.should.equal('hello');
tag.string.should.equal('universe is better than world');
- }
+ },
+
+ 'test .parseComments() code with no comments': function(done){
+ fixture('uncommented.js', function(err, str){
+ var comments = dox.parseComments(str)
+ , all = comments.shift();
+ all.code.should.equal("function foo() {\n doSomething();\n}");
+ done();
+ });
+ },
};
View
3 test/fixtures/uncommented.js
@@ -0,0 +1,3 @@
+function foo() {
+ doSomething();
+}

0 comments on commit 9c81b77

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