mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
remove extra period from end of summary
This commit is contained in:
parent
ca62994d22
commit
cfd9743eaa
@ -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 += '.';
|
||||||
|
|
||||||
|
|||||||
@ -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 = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user