This commit is contained in:
2024-02-07 01:33:07 -05:00
commit c1af19d441
4088 changed files with 1260170 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import { DocNode } from '../nodes';
/**
* Renders a DocNode tree as plain text, without any rich text formatting or markup.
*/
export declare class PlainTextEmitter {
/**
* Returns true if the specified node contains any text content.
*
* @remarks
* A documentation tool can use this test to report warnings when a developer neglected to write a code comment
* for a declaration.
*
* @param node - this node and all its children will be considered
* @param requiredCharacters - The test returns true if at least this many non-spacing characters are found.
* The default value is 1.
*/
static hasAnyTextContent(node: DocNode, requiredCharacters?: number): boolean;
/**
* Returns true if the specified collection of nodes contains any text content.
*
* @remarks
* A documentation tool can use this test to report warnings when a developer neglected to write a code comment
* for a declaration.
*
* @param nodes - the collection of nodes to be tested
* @param requiredCharacters - The test returns true if at least this many non-spacing characters are found.
* The default value is 1.
*/
static hasAnyTextContent(nodes: ReadonlyArray<DocNode>, requiredCharacters?: number): boolean;
private static _scanTextContent;
private static _countNonSpaceCharacters;
}
//# sourceMappingURL=PlainTextEmitter.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"PlainTextEmitter.d.ts","sourceRoot":"","sources":["../../src/emitters/PlainTextEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAOR,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;;;;OAUG;WACW,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO;IAEpF;;;;;;;;;;OAUG;WACW,iBAAiB,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO;IAqBpG,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkD/B,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAkBxC"}

View File

@ -0,0 +1,78 @@
import { DocNode, DocNodeKind } from '../nodes';
/**
* Renders a DocNode tree as plain text, without any rich text formatting or markup.
*/
var PlainTextEmitter = /** @class */ (function () {
function PlainTextEmitter() {
}
PlainTextEmitter.hasAnyTextContent = function (nodeOrNodes, requiredCharacters) {
if (requiredCharacters === undefined || requiredCharacters < 1) {
requiredCharacters = 1; // default
}
var nodes;
if (nodeOrNodes instanceof DocNode) {
nodes = [nodeOrNodes];
}
else {
nodes = nodeOrNodes;
}
var foundCharacters = PlainTextEmitter._scanTextContent(nodes, requiredCharacters, 0);
return foundCharacters >= requiredCharacters;
};
PlainTextEmitter._scanTextContent = function (nodes, requiredCharacters, foundCharacters) {
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
var node = nodes_1[_i];
switch (node.kind) {
case DocNodeKind.FencedCode:
var docFencedCode = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docFencedCode.code);
break;
case DocNodeKind.CodeSpan:
var docCodeSpan = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docCodeSpan.code);
break;
case DocNodeKind.EscapedText:
var docEscapedText = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docEscapedText.decodedText);
break;
case DocNodeKind.LinkTag:
var docLinkTag = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docLinkTag.linkText || '');
break;
case DocNodeKind.PlainText:
var docPlainText = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docPlainText.text);
break;
}
if (foundCharacters >= requiredCharacters) {
break;
}
foundCharacters += PlainTextEmitter._scanTextContent(node.getChildNodes(), requiredCharacters, foundCharacters);
if (foundCharacters >= requiredCharacters) {
break;
}
}
return foundCharacters;
};
PlainTextEmitter._countNonSpaceCharacters = function (s) {
var count = 0;
var length = s.length;
var i = 0;
while (i < length) {
switch (s.charCodeAt(i)) {
case 32: // space
case 9: // tab
case 13: // CR
case 10: // LF
break;
default:
++count;
}
++i;
}
return count;
};
return PlainTextEmitter;
}());
export { PlainTextEmitter };
//# sourceMappingURL=PlainTextEmitter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
/**
* An interface for a builder object that allows a large text string to be constructed incrementally by appending
* small chunks.
*
* @remarks
*
* {@link StringBuilder} is the default implementation of this contract.
*/
export interface IStringBuilder {
/**
* Append the specified text to the buffer.
*/
append(text: string): void;
/**
* Returns a single string containing all the text that was appended to the buffer so far.
*
* @remarks
*
* This is a potentially expensive operation.
*/
toString(): string;
}
/**
* This class allows a large text string to be constructed incrementally by appending small chunks. The final
* string can be obtained by calling StringBuilder.toString().
*
* @remarks
* A naive approach might use the `+=` operator to append strings: This would have the downside of copying
* the entire string each time a chunk is appended, resulting in `O(n^2)` bytes of memory being allocated
* (and later freed by the garbage collector), and many of the allocations could be very large objects.
* StringBuilder avoids this overhead by accumulating the chunks in an array, and efficiently joining them
* when `getText()` is finally called.
*/
export declare class StringBuilder implements IStringBuilder {
private _chunks;
constructor();
/** {@inheritdoc IStringBuilder.append} */
append(text: string): void;
/** {@inheritdoc IStringBuilder.toString} */
toString(): string;
}
//# sourceMappingURL=StringBuilder.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"StringBuilder.d.ts","sourceRoot":"","sources":["../../src/emitters/StringBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,OAAO,CAAW;;IAM1B,0CAA0C;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIjC,4CAA4C;IACrC,QAAQ,IAAI,MAAM;CAa1B"}

View File

@ -0,0 +1,35 @@
/**
* This class allows a large text string to be constructed incrementally by appending small chunks. The final
* string can be obtained by calling StringBuilder.toString().
*
* @remarks
* A naive approach might use the `+=` operator to append strings: This would have the downside of copying
* the entire string each time a chunk is appended, resulting in `O(n^2)` bytes of memory being allocated
* (and later freed by the garbage collector), and many of the allocations could be very large objects.
* StringBuilder avoids this overhead by accumulating the chunks in an array, and efficiently joining them
* when `getText()` is finally called.
*/
var StringBuilder = /** @class */ (function () {
function StringBuilder() {
this._chunks = [];
}
/** {@inheritdoc IStringBuilder.append} */
StringBuilder.prototype.append = function (text) {
this._chunks.push(text);
};
/** {@inheritdoc IStringBuilder.toString} */
StringBuilder.prototype.toString = function () {
if (this._chunks.length === 0) {
return '';
}
if (this._chunks.length > 1) {
var joined = this._chunks.join('');
this._chunks.length = 1;
this._chunks[0] = joined;
}
return this._chunks[0];
};
return StringBuilder;
}());
export { StringBuilder };
//# sourceMappingURL=StringBuilder.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"StringBuilder.js","sourceRoot":"","sources":["../../src/emitters/StringBuilder.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;GAUG;AACH;IAGE;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,0CAA0C;IACnC,8BAAM,GAAb,UAAc,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,4CAA4C;IACrC,gCAAQ,GAAf;QACE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7B,OAAO,EAAE,CAAC;SACX;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC7C,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;SAC1B;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACH,oBAAC;AAAD,CAAC,AA1BD,IA0BC","sourcesContent":["/**\r\n * An interface for a builder object that allows a large text string to be constructed incrementally by appending\r\n * small chunks.\r\n *\r\n * @remarks\r\n *\r\n * {@link StringBuilder} is the default implementation of this contract.\r\n */\r\nexport interface IStringBuilder {\r\n /**\r\n * Append the specified text to the buffer.\r\n */\r\n append(text: string): void;\r\n\r\n /**\r\n * Returns a single string containing all the text that was appended to the buffer so far.\r\n *\r\n * @remarks\r\n *\r\n * This is a potentially expensive operation.\r\n */\r\n toString(): string;\r\n}\r\n\r\n/**\r\n * This class allows a large text string to be constructed incrementally by appending small chunks. The final\r\n * string can be obtained by calling StringBuilder.toString().\r\n *\r\n * @remarks\r\n * A naive approach might use the `+=` operator to append strings: This would have the downside of copying\r\n * the entire string each time a chunk is appended, resulting in `O(n^2)` bytes of memory being allocated\r\n * (and later freed by the garbage collector), and many of the allocations could be very large objects.\r\n * StringBuilder avoids this overhead by accumulating the chunks in an array, and efficiently joining them\r\n * when `getText()` is finally called.\r\n */\r\nexport class StringBuilder implements IStringBuilder {\r\n private _chunks: string[];\r\n\r\n public constructor() {\r\n this._chunks = [];\r\n }\r\n\r\n /** {@inheritdoc IStringBuilder.append} */\r\n public append(text: string): void {\r\n this._chunks.push(text);\r\n }\r\n\r\n /** {@inheritdoc IStringBuilder.toString} */\r\n public toString(): string {\r\n if (this._chunks.length === 0) {\r\n return '';\r\n }\r\n\r\n if (this._chunks.length > 1) {\r\n const joined: string = this._chunks.join('');\r\n this._chunks.length = 1;\r\n this._chunks[0] = joined;\r\n }\r\n\r\n return this._chunks[0];\r\n }\r\n}\r\n"]}

View File

@ -0,0 +1,26 @@
import type { DocComment, DocDeclarationReference, DocHtmlEndTag, DocHtmlStartTag } from '../nodes';
import { IStringBuilder } from './StringBuilder';
/**
* Renders a DocNode tree as a code comment.
*/
export declare class TSDocEmitter {
readonly eol: string;
private _emitCommentFraming;
private _output;
private _lineState;
private _previousLineHadContent;
private _hangingParagraph;
renderComment(output: IStringBuilder, docComment: DocComment): void;
renderHtmlTag(output: IStringBuilder, htmlTag: DocHtmlStartTag | DocHtmlEndTag): void;
renderDeclarationReference(output: IStringBuilder, declarationReference: DocDeclarationReference): void;
private _renderCompleteObject;
private _renderNode;
private _renderInlineTag;
private _renderNodes;
private _ensureAtStartOfLine;
private _ensureLineSkipped;
private _writeContent;
private _writeNewline;
private _writeEnd;
}
//# sourceMappingURL=TSDocEmitter.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocEmitter.d.ts","sourceRoot":"","sources":["../../src/emitters/TSDocEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EAQV,uBAAuB,EAGvB,aAAa,EACb,eAAe,EAWhB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAWjD;;GAEG;AACH,qBAAa,YAAY;IACvB,SAAgB,GAAG,EAAE,MAAM,CAAQ;IAGnC,OAAO,CAAC,mBAAmB,CAAiB;IAE5C,OAAO,CAAC,OAAO,CAA6B;IAG5C,OAAO,CAAC,UAAU,CAA+B;IAGjD,OAAO,CAAC,uBAAuB,CAAkB;IAKjD,OAAO,CAAC,iBAAiB,CAAkB;IAEpC,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAKnE,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG,IAAI;IAKrF,0BAA0B,CAC/B,MAAM,EAAE,cAAc,EACtB,oBAAoB,EAAE,uBAAuB,GAC5C,IAAI;IAKP,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,WAAW;IAoQnB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,SAAS;CAclB"}

View File

@ -0,0 +1,376 @@
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import { DocNodeKind } from '../nodes/DocNode';
import { DocNodeTransforms } from '../transforms/DocNodeTransforms';
import { StandardTags } from '../details/StandardTags';
var LineState;
(function (LineState) {
LineState[LineState["Closed"] = 0] = "Closed";
LineState[LineState["StartOfLine"] = 1] = "StartOfLine";
LineState[LineState["MiddleOfLine"] = 2] = "MiddleOfLine";
})(LineState || (LineState = {}));
/**
* Renders a DocNode tree as a code comment.
*/
var TSDocEmitter = /** @class */ (function () {
function TSDocEmitter() {
this.eol = '\n';
// Whether to emit the /** */ framing
this._emitCommentFraming = true;
// This state machine is used by the writer functions to generate the /** */ framing around the emitted lines
this._lineState = LineState.Closed;
// State for _ensureLineSkipped()
this._previousLineHadContent = false;
// Normally a paragraph is precede by a blank line (unless it's the first thing written).
// But sometimes we want the paragraph to be attached to the previous element, e.g. when it's part of
// an "@param" block. Setting _hangingParagraph=true accomplishes that.
this._hangingParagraph = false;
}
TSDocEmitter.prototype.renderComment = function (output, docComment) {
this._emitCommentFraming = true;
this._renderCompleteObject(output, docComment);
};
TSDocEmitter.prototype.renderHtmlTag = function (output, htmlTag) {
this._emitCommentFraming = false;
this._renderCompleteObject(output, htmlTag);
};
TSDocEmitter.prototype.renderDeclarationReference = function (output, declarationReference) {
this._emitCommentFraming = false;
this._renderCompleteObject(output, declarationReference);
};
TSDocEmitter.prototype._renderCompleteObject = function (output, docNode) {
this._output = output;
this._lineState = LineState.Closed;
this._previousLineHadContent = false;
this._hangingParagraph = false;
this._renderNode(docNode);
this._writeEnd();
};
TSDocEmitter.prototype._renderNode = function (docNode) {
var _this = this;
if (docNode === undefined) {
return;
}
switch (docNode.kind) {
case DocNodeKind.Block:
var docBlock = docNode;
this._ensureLineSkipped();
this._renderNode(docBlock.blockTag);
if (docBlock.blockTag.tagNameWithUpperCase === StandardTags.returns.tagNameWithUpperCase) {
this._writeContent(' ');
this._hangingParagraph = true;
}
this._renderNode(docBlock.content);
break;
case DocNodeKind.BlockTag:
var docBlockTag = docNode;
if (this._lineState === LineState.MiddleOfLine) {
this._writeContent(' ');
}
this._writeContent(docBlockTag.tagName);
break;
case DocNodeKind.CodeSpan:
var docCodeSpan = docNode;
this._writeContent('`');
this._writeContent(docCodeSpan.code);
this._writeContent('`');
break;
case DocNodeKind.Comment:
var docComment = docNode;
this._renderNodes(__spreadArrays([
docComment.summarySection,
docComment.remarksBlock,
docComment.privateRemarks,
docComment.deprecatedBlock,
docComment.params,
docComment.typeParams,
docComment.returnsBlock
], docComment.customBlocks, docComment.seeBlocks, [
docComment.inheritDocTag
]));
if (docComment.modifierTagSet.nodes.length > 0) {
this._ensureLineSkipped();
this._renderNodes(docComment.modifierTagSet.nodes);
}
break;
case DocNodeKind.DeclarationReference:
var docDeclarationReference = docNode;
this._writeContent(docDeclarationReference.packageName);
this._writeContent(docDeclarationReference.importPath);
if (docDeclarationReference.packageName !== undefined ||
docDeclarationReference.importPath !== undefined) {
this._writeContent('#');
}
this._renderNodes(docDeclarationReference.memberReferences);
break;
case DocNodeKind.ErrorText:
var docErrorText = docNode;
this._writeContent(docErrorText.text);
break;
case DocNodeKind.EscapedText:
var docEscapedText = docNode;
this._writeContent(docEscapedText.encodedText);
break;
case DocNodeKind.FencedCode:
var docFencedCode = docNode;
this._ensureAtStartOfLine();
this._writeContent('```');
this._writeContent(docFencedCode.language);
this._writeNewline();
this._writeContent(docFencedCode.code);
this._writeContent('```');
this._writeNewline();
this._writeNewline();
break;
case DocNodeKind.HtmlAttribute:
var docHtmlAttribute = docNode;
this._writeContent(docHtmlAttribute.name);
this._writeContent(docHtmlAttribute.spacingAfterName);
this._writeContent('=');
this._writeContent(docHtmlAttribute.spacingAfterEquals);
this._writeContent(docHtmlAttribute.value);
this._writeContent(docHtmlAttribute.spacingAfterValue);
break;
case DocNodeKind.HtmlEndTag:
var docHtmlEndTag = docNode;
this._writeContent('</');
this._writeContent(docHtmlEndTag.name);
this._writeContent('>');
break;
case DocNodeKind.HtmlStartTag:
var docHtmlStartTag = docNode;
this._writeContent('<');
this._writeContent(docHtmlStartTag.name);
this._writeContent(docHtmlStartTag.spacingAfterName);
var needsSpace = docHtmlStartTag.spacingAfterName === undefined || docHtmlStartTag.spacingAfterName.length === 0;
for (var _i = 0, _a = docHtmlStartTag.htmlAttributes; _i < _a.length; _i++) {
var attribute = _a[_i];
if (needsSpace) {
this._writeContent(' ');
}
this._renderNode(attribute);
needsSpace = attribute.spacingAfterValue === undefined || attribute.spacingAfterValue.length === 0;
}
this._writeContent(docHtmlStartTag.selfClosingTag ? '/>' : '>');
break;
case DocNodeKind.InheritDocTag:
var docInheritDocTag_1 = docNode;
this._renderInlineTag(docInheritDocTag_1, function () {
if (docInheritDocTag_1.declarationReference) {
_this._writeContent(' ');
_this._renderNode(docInheritDocTag_1.declarationReference);
}
});
break;
case DocNodeKind.InlineTag:
var docInlineTag_1 = docNode;
this._renderInlineTag(docInlineTag_1, function () {
if (docInlineTag_1.tagContent.length > 0) {
_this._writeContent(' ');
_this._writeContent(docInlineTag_1.tagContent);
}
});
break;
case DocNodeKind.LinkTag:
var docLinkTag_1 = docNode;
this._renderInlineTag(docLinkTag_1, function () {
if (docLinkTag_1.urlDestination !== undefined || docLinkTag_1.codeDestination !== undefined) {
if (docLinkTag_1.urlDestination !== undefined) {
_this._writeContent(' ');
_this._writeContent(docLinkTag_1.urlDestination);
}
else if (docLinkTag_1.codeDestination !== undefined) {
_this._writeContent(' ');
_this._renderNode(docLinkTag_1.codeDestination);
}
}
if (docLinkTag_1.linkText !== undefined) {
_this._writeContent(' ');
_this._writeContent('|');
_this._writeContent(' ');
_this._writeContent(docLinkTag_1.linkText);
}
});
break;
case DocNodeKind.MemberIdentifier:
var docMemberIdentifier = docNode;
if (docMemberIdentifier.hasQuotes) {
this._writeContent('"');
this._writeContent(docMemberIdentifier.identifier); // todo: encoding
this._writeContent('"');
}
else {
this._writeContent(docMemberIdentifier.identifier);
}
break;
case DocNodeKind.MemberReference:
var docMemberReference = docNode;
if (docMemberReference.hasDot) {
this._writeContent('.');
}
if (docMemberReference.selector) {
this._writeContent('(');
}
if (docMemberReference.memberSymbol) {
this._renderNode(docMemberReference.memberSymbol);
}
else {
this._renderNode(docMemberReference.memberIdentifier);
}
if (docMemberReference.selector) {
this._writeContent(':');
this._renderNode(docMemberReference.selector);
this._writeContent(')');
}
break;
case DocNodeKind.MemberSelector:
var docMemberSelector = docNode;
this._writeContent(docMemberSelector.selector);
break;
case DocNodeKind.MemberSymbol:
var docMemberSymbol = docNode;
this._writeContent('[');
this._renderNode(docMemberSymbol.symbolReference);
this._writeContent(']');
break;
case DocNodeKind.Section:
var docSection = docNode;
this._renderNodes(docSection.nodes);
break;
case DocNodeKind.Paragraph:
var trimmedParagraph = DocNodeTransforms.trimSpacesInParagraph(docNode);
if (trimmedParagraph.nodes.length > 0) {
if (this._hangingParagraph) {
// If it's a hanging paragraph, then don't skip a line
this._hangingParagraph = false;
}
else {
this._ensureLineSkipped();
}
this._renderNodes(trimmedParagraph.nodes);
this._writeNewline();
}
break;
case DocNodeKind.ParamBlock:
var docParamBlock = docNode;
this._ensureLineSkipped();
this._renderNode(docParamBlock.blockTag);
this._writeContent(' ');
this._writeContent(docParamBlock.parameterName);
this._writeContent(' - ');
this._hangingParagraph = true;
this._renderNode(docParamBlock.content);
this._hangingParagraph = false;
break;
case DocNodeKind.ParamCollection:
var docParamCollection = docNode;
this._renderNodes(docParamCollection.blocks);
break;
case DocNodeKind.PlainText:
var docPlainText = docNode;
this._writeContent(docPlainText.text);
break;
}
};
TSDocEmitter.prototype._renderInlineTag = function (docInlineTagBase, writeInlineTagContent) {
this._writeContent('{');
this._writeContent(docInlineTagBase.tagName);
writeInlineTagContent();
this._writeContent('}');
};
TSDocEmitter.prototype._renderNodes = function (docNodes) {
for (var _i = 0, docNodes_1 = docNodes; _i < docNodes_1.length; _i++) {
var docNode = docNodes_1[_i];
this._renderNode(docNode);
}
};
// Calls _writeNewline() only if we're not already at the start of a new line
TSDocEmitter.prototype._ensureAtStartOfLine = function () {
if (this._lineState === LineState.MiddleOfLine) {
this._writeNewline();
}
};
// Calls _writeNewline() if needed to ensure that we have skipped at least one line
TSDocEmitter.prototype._ensureLineSkipped = function () {
this._ensureAtStartOfLine();
if (this._previousLineHadContent) {
this._writeNewline();
}
};
// Writes literal text content. If it contains newlines, they will automatically be converted to
// _writeNewline() calls, to ensure that "*" is written at the start of each line.
TSDocEmitter.prototype._writeContent = function (content) {
if (content === undefined || content.length === 0) {
return;
}
var splitLines = content.split(/\r?\n/g);
if (splitLines.length > 1) {
var firstLine = true;
for (var _i = 0, splitLines_1 = splitLines; _i < splitLines_1.length; _i++) {
var line = splitLines_1[_i];
if (firstLine) {
firstLine = false;
}
else {
this._writeNewline();
}
this._writeContent(line);
}
return;
}
if (this._lineState === LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/**' + this.eol + ' *');
}
this._lineState = LineState.StartOfLine;
}
if (this._lineState === LineState.StartOfLine) {
if (this._emitCommentFraming) {
this._output.append(' ');
}
}
this._output.append(content);
this._lineState = LineState.MiddleOfLine;
this._previousLineHadContent = true;
};
// Starts a new line, and inserts "/**" or "*" as appropriate.
TSDocEmitter.prototype._writeNewline = function () {
if (this._lineState === LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/**' + this.eol + ' *');
}
this._lineState = LineState.StartOfLine;
}
this._previousLineHadContent = this._lineState === LineState.MiddleOfLine;
if (this._emitCommentFraming) {
this._output.append(this.eol + ' *');
}
else {
this._output.append(this.eol);
}
this._lineState = LineState.StartOfLine;
this._hangingParagraph = false;
};
// Closes the comment, adding the final "*/" delimiter
TSDocEmitter.prototype._writeEnd = function () {
if (this._lineState === LineState.MiddleOfLine) {
if (this._emitCommentFraming) {
this._writeNewline();
}
}
if (this._lineState !== LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/' + this.eol);
}
this._lineState = LineState.Closed;
}
};
return TSDocEmitter;
}());
export { TSDocEmitter };
//# sourceMappingURL=TSDocEmitter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=TSDocEmitter.test.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocEmitter.test.d.ts","sourceRoot":"","sources":["../../../src/emitters/__tests__/TSDocEmitter.test.ts"],"names":[],"mappings":""}

File diff suppressed because one or more lines are too long