Skip to content

Commit

Permalink
Fixed annoying title bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 26, 2012
1 parent 34f9120 commit 81d0ca4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dox.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports.parseComment = function(str, options) {
, description = {};

// parse comment body
description.full = str.split('\n@')[0].replace(/^([\w ]+):$/gm, '## $1');
description.full = str.split('\n@')[0].replace(/^([A-Z][\w ]+):$/gm, '## $1');
description.summary = description.full.split('\n\n')[0];
description.body = description.full.split('\n\n').slice(1).join('\n\n');
comment.description = description;
Expand Down
10 changes: 10 additions & 0 deletions test/dox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ module.exports = {
});
},

'test .parseComments() titles': function(done){
fixture('titles.js', function(err, str){
var comments = dox.parseComments(str);
comments[0].description.body.should.include('<h2>Some examples</h2>');
comments[0].description.body.should.not.include('<h2>for example</h2>');
comments[0].description.body.should.include('<p>Some longer thing<br />for example:</p>');
done();
});
},

'test .parseCodeContext() function statement': function(){
var ctx = dox.parseCodeContext('function foo(){\n\n}');
ctx.type.should.equal('function');
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/titles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

/**
* Description.
*
* Some examples:
*
* foo
*
* Some longer thing
* for example:
*
* bar
*
*/

0 comments on commit 81d0ca4

Please sign in to comment.