Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support uncommented files

  • Loading branch information...
commit 431344f3a4cf3342b52d20c8a8bfc689d76f67c4 1 parent 5a031ec
Forbes Lindesay ForbesLindesay authored
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
8 lib/dox.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];
11 test/dox.test.js
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();
+ });
+ },
};
3  test/fixtures/uncommented.js
View
@@ -0,0 +1,3 @@
+function foo() {
+ doSomething();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.