From abfa24578ce25806eeceb455659c37d7749d2ee8 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Wed, 2 Jul 2014 20:11:39 -0700 Subject: [PATCH] don't log an error when a comment only contains whitespace (#698) --- lib/jsdoc/doclet.js | 2 +- test/fixtures/emptycomments.js | 27 +++++++++++++++++++++++ test/specs/documentation/emptycomments.js | 15 +++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/emptycomments.js create mode 100644 test/specs/documentation/emptycomments.js diff --git a/lib/jsdoc/doclet.js b/lib/jsdoc/doclet.js index deb2d2e2..5fe0e435 100644 --- a/lib/jsdoc/doclet.js +++ b/lib/jsdoc/doclet.js @@ -130,7 +130,7 @@ function toTags(docletSrc) { } function fixDescription(docletSrc) { - if (!/^\s*@/.test(docletSrc)) { + if (!/^\s*@/.test(docletSrc) && docletSrc.replace(/\s/g, '').length) { docletSrc = '@description ' + docletSrc; } return docletSrc; diff --git a/test/fixtures/emptycomments.js b/test/fixtures/emptycomments.js new file mode 100644 index 00000000..6ddd67ee --- /dev/null +++ b/test/fixtures/emptycomments.js @@ -0,0 +1,27 @@ +/** */ +function first() {} + +/** */ +function second() {} + +// the next comment must contain a single hard tab (\t) character +/** */ +function third() {} + +// the next comment must contain at least two hard tab (\t) characters +/** */ +function fourth() {} + +// the next comment must contain one newline (\n) character +/** + */ +function fifth() {} + +// the next comment must contain multiple newline (\n) characters +/** + * + * + * + * + */ +function sixth() {} diff --git a/test/specs/documentation/emptycomments.js b/test/specs/documentation/emptycomments.js new file mode 100644 index 00000000..6747f1ad --- /dev/null +++ b/test/specs/documentation/emptycomments.js @@ -0,0 +1,15 @@ +/*global describe, expect, it, jasmine, spyOn */ +'use strict'; + +var logger = require('jsdoc/util/logger'); + +describe('empty JSDoc comments', function() { + it('should not report an error when a JSDoc comment contains only whitespace', function() { + var doclets; + + spyOn(logger, 'error'); + doclets = jasmine.getDocSetFromFile('test/fixtures/emptycomments.js'); + + expect(logger.error).not.toHaveBeenCalled(); + }); +});