Permalink
Browse files

Support uncommented files

  • Loading branch information...
1 parent 5a031ec commit 431344f3a4cf3342b52d20c8a8bfc689d76f67c4 @ForbesLindesay ForbesLindesay committed Jun 30, 2012
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
@@ -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
@@ -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();
+ });
+ },
};
@@ -0,0 +1,3 @@
+function foo() {
+ doSomething();
+}

0 comments on commit 431344f

Please sign in to comment.