init
This commit is contained in:
		
							
								
								
									
										57
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/DocNodeTransforms.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/DocNodeTransforms.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.DocNodeTransforms = void 0;
 | 
			
		||||
var TrimSpacesTransform_1 = require("./TrimSpacesTransform");
 | 
			
		||||
/**
 | 
			
		||||
 * Helper functions that transform DocNode trees.
 | 
			
		||||
 */
 | 
			
		||||
var DocNodeTransforms = /** @class */ (function () {
 | 
			
		||||
    function DocNodeTransforms() {
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * trimSpacesInParagraphNodes() collapses extra spacing characters from plain text nodes.
 | 
			
		||||
     *
 | 
			
		||||
     * @remarks
 | 
			
		||||
     * This is useful when emitting HTML, where any number of spaces are equivalent
 | 
			
		||||
     * to a single space.  It's also useful when emitting Markdown, where spaces
 | 
			
		||||
     * can be misinterpreted as an indented code block.
 | 
			
		||||
     *
 | 
			
		||||
     * For example, we might transform this:
 | 
			
		||||
     *
 | 
			
		||||
     * ```
 | 
			
		||||
     * nodes: [
 | 
			
		||||
     *   { kind: PlainText, text: "   Here   are some   " },
 | 
			
		||||
     *   { kind: SoftBreak }
 | 
			
		||||
     *   { kind: PlainText, text: "   words" },
 | 
			
		||||
     *   { kind: SoftBreak }
 | 
			
		||||
     *   { kind: InlineTag, text: "{\@inheritDoc}" },
 | 
			
		||||
     *   { kind: PlainText, text: "to process." },
 | 
			
		||||
     *   { kind: PlainText, text: "  " },
 | 
			
		||||
     *   { kind: PlainText, text: "  " }
 | 
			
		||||
     * ]
 | 
			
		||||
     * ```
 | 
			
		||||
     *
 | 
			
		||||
     * ...to this:
 | 
			
		||||
     *
 | 
			
		||||
     * ```
 | 
			
		||||
     * nodes: [
 | 
			
		||||
     *   { kind: PlainText, text: "Here are some " },
 | 
			
		||||
     *   { kind: PlainText, text: "words " },
 | 
			
		||||
     *   { kind: InlineTag, text: "{\@inheritDoc}" },
 | 
			
		||||
     *   { kind: PlainText, text: "to process." }
 | 
			
		||||
     * ]
 | 
			
		||||
     * ```
 | 
			
		||||
     *
 | 
			
		||||
     * Note that in this example, `"words "` is not merged with the preceding node because
 | 
			
		||||
     * its DocPlainText.excerpt cannot span multiple lines.
 | 
			
		||||
     *
 | 
			
		||||
     * @param docParagraph - a DocParagraph containing nodes to be transformed
 | 
			
		||||
     * @returns The transformed child nodes.
 | 
			
		||||
     */
 | 
			
		||||
    DocNodeTransforms.trimSpacesInParagraph = function (docParagraph) {
 | 
			
		||||
        return TrimSpacesTransform_1.TrimSpacesTransform.transform(docParagraph);
 | 
			
		||||
    };
 | 
			
		||||
    return DocNodeTransforms;
 | 
			
		||||
}());
 | 
			
		||||
exports.DocNodeTransforms = DocNodeTransforms;
 | 
			
		||||
//# sourceMappingURL=DocNodeTransforms.js.map
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/DocNodeTransforms.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/DocNodeTransforms.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
{"version":3,"file":"DocNodeTransforms.js","sourceRoot":"","sources":["../../src/transforms/DocNodeTransforms.ts"],"names":[],"mappings":";;;AAAA,6DAA4D;AAG5D;;GAEG;AACH;IAAA;IA4CA,CAAC;IA3CC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACW,uCAAqB,GAAnC,UAAoC,YAA0B;QAC5D,OAAO,yCAAmB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IACH,wBAAC;AAAD,CAAC,AA5CD,IA4CC;AA5CY,8CAAiB","sourcesContent":["import { TrimSpacesTransform } from './TrimSpacesTransform';\r\nimport { DocParagraph } from '../nodes';\r\n\r\n/**\r\n * Helper functions that transform DocNode trees.\r\n */\r\nexport class DocNodeTransforms {\r\n  /**\r\n   * trimSpacesInParagraphNodes() collapses extra spacing characters from plain text nodes.\r\n   *\r\n   * @remarks\r\n   * This is useful when emitting HTML, where any number of spaces are equivalent\r\n   * to a single space.  It's also useful when emitting Markdown, where spaces\r\n   * can be misinterpreted as an indented code block.\r\n   *\r\n   * For example, we might transform this:\r\n   *\r\n   * ```\r\n   * nodes: [\r\n   *   { kind: PlainText, text: \"   Here   are some   \" },\r\n   *   { kind: SoftBreak }\r\n   *   { kind: PlainText, text: \"   words\" },\r\n   *   { kind: SoftBreak }\r\n   *   { kind: InlineTag, text: \"{\\@inheritDoc}\" },\r\n   *   { kind: PlainText, text: \"to process.\" },\r\n   *   { kind: PlainText, text: \"  \" },\r\n   *   { kind: PlainText, text: \"  \" }\r\n   * ]\r\n   * ```\r\n   *\r\n   * ...to this:\r\n   *\r\n   * ```\r\n   * nodes: [\r\n   *   { kind: PlainText, text: \"Here are some \" },\r\n   *   { kind: PlainText, text: \"words \" },\r\n   *   { kind: InlineTag, text: \"{\\@inheritDoc}\" },\r\n   *   { kind: PlainText, text: \"to process.\" }\r\n   * ]\r\n   * ```\r\n   *\r\n   * Note that in this example, `\"words \"` is not merged with the preceding node because\r\n   * its DocPlainText.excerpt cannot span multiple lines.\r\n   *\r\n   * @param docParagraph - a DocParagraph containing nodes to be transformed\r\n   * @returns The transformed child nodes.\r\n   */\r\n  public static trimSpacesInParagraph(docParagraph: DocParagraph): DocParagraph {\r\n    return TrimSpacesTransform.transform(docParagraph);\r\n  }\r\n}\r\n"]}
 | 
			
		||||
							
								
								
									
										90
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/TrimSpacesTransform.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/TrimSpacesTransform.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.TrimSpacesTransform = void 0;
 | 
			
		||||
var nodes_1 = require("../nodes");
 | 
			
		||||
/**
 | 
			
		||||
 * Implementation of DocNodeTransforms.trimSpacesInParagraphNodes()
 | 
			
		||||
 */
 | 
			
		||||
var TrimSpacesTransform = /** @class */ (function () {
 | 
			
		||||
    function TrimSpacesTransform() {
 | 
			
		||||
    }
 | 
			
		||||
    TrimSpacesTransform.transform = function (docParagraph) {
 | 
			
		||||
        var transformedNodes = [];
 | 
			
		||||
        // Whether the next nonempty node to be added needs a space before it
 | 
			
		||||
        var pendingSpace = false;
 | 
			
		||||
        // The DocPlainText node that we're currently accumulating
 | 
			
		||||
        var accumulatedTextChunks = [];
 | 
			
		||||
        var accumulatedNodes = [];
 | 
			
		||||
        // We always trim leading whitespace for a paragraph.  This flag gets set to true
 | 
			
		||||
        // as soon as nonempty content is encountered.
 | 
			
		||||
        var finishedSkippingLeadingSpaces = false;
 | 
			
		||||
        for (var _i = 0, _a = docParagraph.nodes; _i < _a.length; _i++) {
 | 
			
		||||
            var node = _a[_i];
 | 
			
		||||
            switch (node.kind) {
 | 
			
		||||
                case nodes_1.DocNodeKind.PlainText:
 | 
			
		||||
                    var docPlainText = node;
 | 
			
		||||
                    var text = docPlainText.text;
 | 
			
		||||
                    var startedWithSpace = /^\s/.test(text);
 | 
			
		||||
                    var endedWithSpace = /\s$/.test(text);
 | 
			
		||||
                    var collapsedText = text.replace(/\s+/g, ' ').trim();
 | 
			
		||||
                    if (startedWithSpace && finishedSkippingLeadingSpaces) {
 | 
			
		||||
                        pendingSpace = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (collapsedText.length > 0) {
 | 
			
		||||
                        if (pendingSpace) {
 | 
			
		||||
                            accumulatedTextChunks.push(' ');
 | 
			
		||||
                            pendingSpace = false;
 | 
			
		||||
                        }
 | 
			
		||||
                        accumulatedTextChunks.push(collapsedText);
 | 
			
		||||
                        accumulatedNodes.push(node);
 | 
			
		||||
                        finishedSkippingLeadingSpaces = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (endedWithSpace && finishedSkippingLeadingSpaces) {
 | 
			
		||||
                        pendingSpace = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case nodes_1.DocNodeKind.SoftBreak:
 | 
			
		||||
                    if (finishedSkippingLeadingSpaces) {
 | 
			
		||||
                        pendingSpace = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    accumulatedNodes.push(node);
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    if (pendingSpace) {
 | 
			
		||||
                        accumulatedTextChunks.push(' ');
 | 
			
		||||
                        pendingSpace = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    // Push the accumulated text
 | 
			
		||||
                    if (accumulatedTextChunks.length > 0) {
 | 
			
		||||
                        // TODO: We should probably track the accumulatedNodes somehow, e.g. so we can map them back to the
 | 
			
		||||
                        // original excerpts.  But we need a developer scenario before we can design this API.
 | 
			
		||||
                        transformedNodes.push(new nodes_1.DocPlainText({
 | 
			
		||||
                            configuration: docParagraph.configuration,
 | 
			
		||||
                            text: accumulatedTextChunks.join('')
 | 
			
		||||
                        }));
 | 
			
		||||
                        accumulatedTextChunks.length = 0;
 | 
			
		||||
                        accumulatedNodes.length = 0;
 | 
			
		||||
                    }
 | 
			
		||||
                    transformedNodes.push(node);
 | 
			
		||||
                    finishedSkippingLeadingSpaces = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // Push the accumulated text
 | 
			
		||||
        if (accumulatedTextChunks.length > 0) {
 | 
			
		||||
            transformedNodes.push(new nodes_1.DocPlainText({
 | 
			
		||||
                configuration: docParagraph.configuration,
 | 
			
		||||
                text: accumulatedTextChunks.join('')
 | 
			
		||||
            }));
 | 
			
		||||
            accumulatedTextChunks.length = 0;
 | 
			
		||||
            accumulatedNodes.length = 0;
 | 
			
		||||
        }
 | 
			
		||||
        var transformedParagraph = new nodes_1.DocParagraph({
 | 
			
		||||
            configuration: docParagraph.configuration
 | 
			
		||||
        });
 | 
			
		||||
        transformedParagraph.appendNodes(transformedNodes);
 | 
			
		||||
        return transformedParagraph;
 | 
			
		||||
    };
 | 
			
		||||
    return TrimSpacesTransform;
 | 
			
		||||
}());
 | 
			
		||||
exports.TrimSpacesTransform = TrimSpacesTransform;
 | 
			
		||||
//# sourceMappingURL=TrimSpacesTransform.js.map
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/TrimSpacesTransform.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@microsoft/tsdoc/lib-commonjs/transforms/TrimSpacesTransform.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user