don't log an error when a comment only contains whitespace (#698)

This commit is contained in:
Jeff Williams 2014-07-02 20:11:39 -07:00
parent 5c59bc1488
commit abfa24578c
3 changed files with 43 additions and 1 deletions

View File

@ -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;

27
test/fixtures/emptycomments.js vendored Normal file
View File

@ -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() {}

View File

@ -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();
});
});