remove extra period from end of summary

This commit is contained in:
Jeff Williams 2014-07-28 18:49:53 -07:00
parent ca62994d22
commit cfd9743eaa
2 changed files with 12 additions and 2 deletions

View File

@ -18,8 +18,8 @@ exports.handlers = {
// If the summary is missing, grab the first sentence from the description // If the summary is missing, grab the first sentence from the description
// and use that. // and use that.
if (e.doclet && !e.doclet.summary && e.doclet.description) { if (e.doclet && !e.doclet.summary && e.doclet.description) {
// The summary may end with `. ` or with `.<` (a period followed by an HTML tag). // The summary may end with `.$`, `. `, or `.<` (a period followed by an HTML tag).
e.doclet.summary = e.doclet.description.split(/\.\s|\.</)[0]; e.doclet.summary = e.doclet.description.split(/\.$|\.\s|\.</)[0];
// Append `.` as it was removed in both cases, or is possibly missing. // Append `.` as it was removed in both cases, or is possibly missing.
e.doclet.summary += '.'; e.doclet.summary += '.';

View File

@ -51,6 +51,16 @@ describe('summarize', function() {
expect(doclet.summary).toBe('This sentence is the summary.'); expect(doclet.summary).toBe('This sentence is the summary.');
}); });
it('should not add an extra period if there is only one sentence in the description',
function() {
var doclet = {
description: 'This description has only one sentence.'
};
handler({ doclet: doclet });
expect(doclet.summary).toBe('This description has only one sentence.');
});
it('should use the entire description, plus a period, as the summary if the description ' + it('should use the entire description, plus a period, as the summary if the description ' +
'does not contain a period', function() { 'does not contain a period', function() {
var doclet = { var doclet = {