From c1a6ddf4e18922b6c4690182bb84d23d73640247 Mon Sep 17 00:00:00 2001 From: Boris Staal Date: Sat, 18 Feb 2012 05:47:50 +0700 Subject: [PATCH] Comments can contain inline dots so we should be smarter while cutting the summary --- lib/nodes/doc.js | 2 +- spec/templates/classes/class_documentation.coffee | 2 +- spec/templates/classes/class_documentation.json | 4 ++-- src/nodes/doc.coffee | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nodes/doc.js b/lib/nodes/doc.js index 3ab959c..7330df1 100644 --- a/lib/nodes/doc.js +++ b/lib/nodes/doc.js @@ -90,7 +90,7 @@ } } text = comment.join('\n'); - this.summary = _.str.clean(((_ref = /((?:.|\n)*?\.)/.exec(text)) != null ? _ref[1] : void 0) || text); + this.summary = _.str.clean(((_ref = /((?:.|\n)*?\.[\s$])/.exec(text)) != null ? _ref[1] : void 0) || text); this.comment = marked(text); } } catch (error) { diff --git a/spec/templates/classes/class_documentation.coffee b/spec/templates/classes/class_documentation.coffee index 48ddb25..65b6b7e 100644 --- a/spec/templates/classes/class_documentation.coffee +++ b/spec/templates/classes/class_documentation.coffee @@ -1,4 +1,4 @@ -# This is a test class +# This is a test class with `inline.dot`. Beware. # # @note Please use # this carefully diff --git a/spec/templates/classes/class_documentation.json b/spec/templates/classes/class_documentation.json index 498b8ce..3d5a403 100644 --- a/spec/templates/classes/class_documentation.json +++ b/spec/templates/classes/class_documentation.json @@ -29,8 +29,8 @@ "Netzpirat", "Plasticman" ], - "comment": "

This is a test class\n\n\n\n\n\n

\n", - "summary": "This is a test class" + "comment": "

This is a test class with inline.dot. Beware.\n\n\n\n\n\n

\n", + "summary": "This is a test class with `inline.dot`." }, "class": { "className": "TestClassDocumentation", diff --git a/src/nodes/doc.coffee b/src/nodes/doc.coffee index d743331..d8a3bf5 100644 --- a/src/nodes/doc.coffee +++ b/src/nodes/doc.coffee @@ -103,7 +103,7 @@ module.exports = class Doc comment.push line text = comment.join('\n') - @summary = _.str.clean(/((?:.|\n)*?\.)/.exec(text)?[1] || text) + @summary = _.str.clean(/((?:.|\n)*?\.[\s$])/.exec(text)?[1] || text) @comment = marked(text) catch error