Skip to content
This repository
Browse code

Fixed annoying title bug

  • Loading branch information...
commit 81d0ca418549e47a94d17f05f90cd063086c4ae0 1 parent 34f9120
TJ Holowaychuk authored April 25, 2012
2  lib/dox.js
@@ -101,7 +101,7 @@ exports.parseComment = function(str, options) {
101 101
     , description = {};
102 102
 
103 103
   // parse comment body
104  
-  description.full = str.split('\n@')[0].replace(/^([\w ]+):$/gm, '## $1');
  104
+  description.full = str.split('\n@')[0].replace(/^([A-Z][\w ]+):$/gm, '## $1');
105 105
   description.summary = description.full.split('\n\n')[0];
106 106
   description.body = description.full.split('\n\n').slice(1).join('\n\n');
107 107
   comment.description = description;
10  test/dox.test.js
@@ -147,6 +147,16 @@ module.exports = {
147 147
     });
148 148
   },
149 149
 
  150
+  'test .parseComments() titles': function(done){
  151
+    fixture('titles.js', function(err, str){
  152
+      var comments = dox.parseComments(str);
  153
+      comments[0].description.body.should.include('<h2>Some examples</h2>');
  154
+      comments[0].description.body.should.not.include('<h2>for example</h2>');
  155
+      comments[0].description.body.should.include('<p>Some longer thing<br />for example:</p>');
  156
+      done();
  157
+    });
  158
+  },
  159
+
150 160
   'test .parseCodeContext() function statement': function(){
151 161
     var ctx = dox.parseCodeContext('function foo(){\n\n}');
152 162
     ctx.type.should.equal('function');
14  test/fixtures/titles.js
... ...
@@ -0,0 +1,14 @@
  1
+
  2
+/**
  3
+ * Description.
  4
+ * 
  5
+ * Some examples:
  6
+ * 
  7
+ *  foo
  8
+ * 
  9
+ * Some longer thing
  10
+ * for example:
  11
+ * 
  12
+ *  bar
  13
+ * 
  14
+ */

0 notes on commit 81d0ca4

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