|
90 | 90 | title === 'public' || title === 'private' || title === 'protected';
|
91 | 91 | }
|
92 | 92 |
|
93 |
| - function trim(str) { |
94 |
| - return str.replace(/^\s+/, '').replace(/\s+$/, ''); |
95 |
| - } |
96 |
| - |
97 | 93 | function unwrapComment(doc) {
|
98 | 94 | // JSDoc comment is following form
|
99 | 95 | // /**
|
|
544 | 540 | };
|
545 | 541 |
|
546 | 542 | TagParser.prototype.parseDescription = function parseDescription() {
|
547 |
| - var description = trim(sliceSource(source, index, this._last)); |
| 543 | + var description = sliceSource(source, index, this._last).trim(); |
548 | 544 | if (description) {
|
549 | 545 | if ((/^-\s+/).test(description)) {
|
550 | 546 | description = description.substring(2);
|
|
555 | 551 | };
|
556 | 552 |
|
557 | 553 | TagParser.prototype.parseCaption = function parseDescription() {
|
558 |
| - var description = trim(sliceSource(source, index, this._last)); |
| 554 | + var description = sliceSource(source, index, this._last).trim(); |
559 | 555 | var captionStartTag = '<caption>';
|
560 | 556 | var captionEndTag = '</caption>';
|
561 | 557 | var captionStart = description.indexOf(captionStartTag);
|
562 | 558 | var captionEnd = description.indexOf(captionEndTag);
|
563 | 559 | if (captionStart >= 0 && captionEnd >= 0) {
|
564 |
| - this._tag.caption = trim(description.substring( |
565 |
| - captionStart + captionStartTag.length, captionEnd)); |
566 |
| - this._tag.description = trim(description.substring(captionEnd + captionEndTag.length)); |
| 560 | + this._tag.caption = description.substring( |
| 561 | + captionStart + captionStartTag.length, captionEnd).trim(); |
| 562 | + this._tag.description = description.substring(captionEnd + captionEndTag.length).trim(); |
567 | 563 | } else {
|
568 | 564 | this._tag.description = description;
|
569 | 565 | }
|
|
585 | 581 | 'namespace': true,
|
586 | 582 | 'typedef': true
|
587 | 583 | };
|
588 |
| - kind = trim(sliceSource(source, index, this._last)); |
| 584 | + kind = sliceSource(source, index, this._last).trim(); |
589 | 585 | this._tag.kind = kind;
|
590 | 586 | if (!hasOwnProperty(kinds, kind)) {
|
591 | 587 | if (!this.addError('Invalid kind name \'%0\'', kind)) {
|
|
597 | 593 |
|
598 | 594 | TagParser.prototype.parseAccess = function parseAccess() {
|
599 | 595 | var access;
|
600 |
| - access = trim(sliceSource(source, index, this._last)); |
| 596 | + access = sliceSource(source, index, this._last).trim(); |
601 | 597 | this._tag.access = access;
|
602 | 598 | if (access !== 'private' && access !== 'protected' && access !== 'public') {
|
603 | 599 | if (!this.addError('Invalid access name \'%0\'', access)) {
|
|
610 | 606 | TagParser.prototype.parseThis = function parseThis() {
|
611 | 607 | // this name may be a name expression (e.g. {foo.bar}),
|
612 | 608 | // an union (e.g. {foo.bar|foo.baz}) or a name path (e.g. foo.bar)
|
613 |
| - var value = trim(sliceSource(source, index, this._last)); |
| 609 | + var value = sliceSource(source, index, this._last).trim(); |
614 | 610 | if (value && value.charAt(0) === '{') {
|
615 | 611 | var gotType = this.parseType();
|
616 | 612 | if (gotType && this._tag.type.type === 'NameExpression' || this._tag.type.type === 'UnionType') {
|
|
626 | 622 |
|
627 | 623 | TagParser.prototype.parseVariation = function parseVariation() {
|
628 | 624 | var variation, text;
|
629 |
| - text = trim(sliceSource(source, index, this._last)); |
| 625 | + text = sliceSource(source, index, this._last).trim(); |
630 | 626 | variation = parseFloat(text, 10);
|
631 | 627 | this._tag.variation = variation;
|
632 | 628 | if (isNaN(variation)) {
|
|
638 | 634 | };
|
639 | 635 |
|
640 | 636 | TagParser.prototype.ensureEnd = function () {
|
641 |
| - var shouldBeEmpty = trim(sliceSource(source, index, this._last)); |
| 637 | + var shouldBeEmpty = sliceSource(source, index, this._last).trim(); |
642 | 638 | if (shouldBeEmpty) {
|
643 | 639 | if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
|
644 | 640 | return false;
|
|
819 | 815 | description += advance();
|
820 | 816 | }
|
821 | 817 |
|
822 |
| - return preserveWhitespace ? description : trim(description); |
| 818 | + return preserveWhitespace ? description : description.trim(); |
823 | 819 | }
|
824 | 820 |
|
825 | 821 | function parse(comment, options) {
|
|
0 commit comments