@microsoft/api-extractor 7.55.2 → 7.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +54 -0
- package/CHANGELOG.md +25 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/generators/ApiModelGenerator.d.ts +1 -1
- package/lib/generators/ApiModelGenerator.d.ts.map +1 -1
- package/lib/generators/ApiModelGenerator.js +101 -71
- package/lib/generators/ApiModelGenerator.js.map +1 -1
- package/lib/generators/ApiReportGenerator.d.ts.map +1 -1
- package/lib/generators/ApiReportGenerator.js +29 -4
- package/lib/generators/ApiReportGenerator.js.map +1 -1
- package/lib/generators/DtsEmitHelpers.d.ts +13 -0
- package/lib/generators/DtsEmitHelpers.d.ts.map +1 -1
- package/lib/generators/DtsEmitHelpers.js +99 -0
- package/lib/generators/DtsEmitHelpers.js.map +1 -1
- package/lib/generators/DtsRollupGenerator.d.ts.map +1 -1
- package/lib/generators/DtsRollupGenerator.js +7 -0
- package/lib/generators/DtsRollupGenerator.js.map +1 -1
- package/lib/generators/ExcerptBuilder.d.ts +13 -8
- package/lib/generators/ExcerptBuilder.d.ts.map +1 -1
- package/lib/generators/ExcerptBuilder.js +32 -13
- package/lib/generators/ExcerptBuilder.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DtsRollupGenerator.js","sourceRoot":"","sources":["../../src/generators/DtsRollupGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wEAA4D;AAC5D,oEAA2F;AAG3F,qEAAkE;AAClE,2CAAsF;AACtF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aA2BX;AA3BD,W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AQ,OAAO,EAAE,CAAC;YAChB,KAAK,aAAa,CAAC,eAAe;gBAChC,OAAO,IAAI,CAAC;YACd,KAAK,aAAa,CAAC,YAAY;gBAC7B,OAAO,CACL,UAAU,KAAK,gCAAU,CAAC,KAAK;oBAC/B,UAAU,KAAK,gCAAU,CAAC,IAAI;oBAC9B,UAAU,KAAK,gCAAU,CAAC,MAAM;oBAChC,uFAAuF;oBACvF,UAAU,KAAK,gCAAU,CAAC,IAAI,CAC/B,CAAC;YACJ,KAAK,aAAa,CAAC,WAAW;gBAC5B,OAAO,CACL,UAAU,KAAK,gCAAU,CAAC,IAAI;oBAC9B,UAAU,KAAK,gCAAU,CAAC,MAAM;oBAChC,uFAAuF;oBACvF,UAAU,KAAK,gCAAU,CAAC,IAAI,CAC/B,CAAC;YACJ,KAAK,aAAa,CAAC,aAAa;gBAC9B,OAAO,UAAU,KAAK,gCAAU,CAAC,MAAM,IAAI,UAAU,KAAK,gCAAU,CAAC,IAAI,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF;AAtaD,gDAsaC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\nimport { FileSystem, type NewlineKind, InternalError } from '@rushstack/node-core-library';\n\nimport type { Collector } from '../collector/Collector';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { IndentDocCommentScope, Span, type SpanModification } from '../analyzer/Span';\nimport { AstImport } from '../analyzer/AstImport';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { SymbolMetadata } from '../collector/SymbolMetadata';\nimport { IndentedWriter } from './IndentedWriter';\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport type { IAstModuleExportInfo } from '../analyzer/AstModule';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport type { AstEntity } from '../analyzer/AstEntity';\n\n/**\n * Used with DtsRollupGenerator.writeTypingsFile()\n */\nexport enum DtsRollupKind {\n /**\n * Generate a *.d.ts file for an internal release, or for the trimming=false mode.\n * This output file will contain all definitions that are reachable from the entry point.\n */\n InternalRelease,\n\n /**\n * Generate a *.d.ts file for a preview release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@internal.\n */\n AlphaRelease,\n\n /**\n * Generate a *.d.ts file for a preview release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@alpha or \\@internal.\n */\n BetaRelease,\n\n /**\n * Generate a *.d.ts file for a public release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@beta, \\@alpha, or \\@internal.\n */\n PublicRelease\n}\n\nexport class DtsRollupGenerator {\n /**\n * Generates the typings file and writes it to disk.\n *\n * @param dtsFilename - The *.d.ts output filename\n */\n public static writeTypingsFile(\n collector: Collector,\n dtsFilename: string,\n dtsKind: DtsRollupKind,\n newlineKind: NewlineKind\n ): void {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n DtsRollupGenerator._generateTypingsFileContent(collector, writer, dtsKind);\n\n FileSystem.writeFile(dtsFilename, writer.toString(), {\n convertLineEndings: newlineKind,\n ensureFolderExists: true\n });\n }\n\n private static _generateTypingsFileContent(\n collector: Collector,\n writer: IndentedWriter,\n dtsKind: DtsRollupKind\n ): void {\n // Emit the @packageDocumentation comment at the top of the file\n if (collector.workingPackage.tsdocParserContext) {\n writer.trimLeadingSpaces = false;\n writer.writeLine(collector.workingPackage.tsdocParserContext.sourceRange.toString());\n writer.trimLeadingSpaces = true;\n writer.ensureSkippedLine();\n }\n\n // Emit the triple slash directives\n for (const typeDirectiveReference of collector.dtsTypeReferenceDirectives) {\n // https://github.com/microsoft/TypeScript/blob/611ebc7aadd7a44a4c0447698bfda9222a78cb66/src/compiler/declarationEmitter.ts#L162\n writer.writeLine(`/// <reference types=\"${typeDirectiveReference}\" />`);\n }\n for (const libDirectiveReference of collector.dtsLibReferenceDirectives) {\n writer.writeLine(`/// <reference lib=\"${libDirectiveReference}\" />`);\n }\n writer.ensureSkippedLine();\n\n // Emit the imports\n for (const entity of collector.entities) {\n if (entity.astEntity instanceof AstImport) {\n // Note: it isn't valid to trim imports based on their release tags.\n // E.g. class Foo (`@public`) extends interface Bar (`@beta`) from some external library.\n // API-Extractor cannot trim `import { Bar } from \"external-library\"` when generating its public rollup,\n // or the export of `Foo` would include a broken reference to `Bar`.\n const astImport: AstImport = entity.astEntity;\n DtsEmitHelpers.emitImport(writer, entity, astImport);\n }\n }\n writer.ensureSkippedLine();\n\n // Emit the regular declarations\n for (const entity of collector.entities) {\n const astEntity: AstEntity = entity.astEntity;\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astEntity);\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\n ? symbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n\n if (!this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n }\n\n if (astEntity instanceof AstSymbol) {\n // Emit all the declarations for this entry\n for (const astDeclaration of astEntity.astDeclarations || []) {\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\n\n if (!this._shouldIncludeReleaseTag(apiItemMetadata.effectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded declaration from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n } else {\n const span: Span = new Span(astDeclaration.declaration);\n DtsRollupGenerator._modifySpan(collector, span, entity, astDeclaration, dtsKind);\n writer.ensureSkippedLine();\n span.writeModifiedText(writer);\n writer.ensureNewLine();\n }\n }\n }\n\n if (astEntity instanceof AstNamespaceImport) {\n const astModuleExportInfo: IAstModuleExportInfo = astEntity.fetchAstModuleExportInfo(collector);\n\n if (entity.nameForEmit === undefined) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n if (astModuleExportInfo.starExportedExternalModules.size > 0) {\n // We could support this, but we would need to find a way to safely represent it.\n throw new Error(\n `The ${entity.nameForEmit} namespace import includes a start export, which is not supported:\\n` +\n SourceFileLocationFormatter.formatDeclaration(astEntity.declaration)\n );\n }\n\n // Emit a synthetic declaration for the namespace. It will look like this:\n //\n // declare namespace example {\n // export {\n // f1,\n // f2\n // }\n // }\n //\n // Note that we do not try to relocate f1()/f2() to be inside the namespace because other type\n // signatures may reference them directly (without using the namespace qualifier).\n\n writer.ensureSkippedLine();\n if (entity.shouldInlineExport) {\n writer.write('export ');\n }\n writer.writeLine(`declare namespace ${entity.nameForEmit} {`);\n\n // all local exports of local imported module are just references to top-level declarations\n writer.increaseIndent();\n writer.writeLine('export {');\n writer.increaseIndent();\n\n const exportClauses: string[] = [];\n for (const [exportedName, exportedEntity] of astModuleExportInfo.exportedLocalEntities) {\n const collectorEntity: CollectorEntity | undefined =\n collector.tryGetCollectorEntity(exportedEntity);\n if (collectorEntity === undefined) {\n // This should never happen\n // top-level exports of local imported module should be added as collector entities before\n throw new InternalError(\n `Cannot find collector entity for ${entity.nameForEmit}.${exportedEntity.localName}`\n );\n }\n\n // If the entity's declaration won't be included, then neither should the namespace export it\n // This fixes the issue encountered here: https://github.com/microsoft/rushstack/issues/2791\n const exportedSymbolMetadata: SymbolMetadata | undefined =\n collector.tryFetchMetadataForAstEntity(exportedEntity);\n const exportedMaxEffectiveReleaseTag: ReleaseTag = exportedSymbolMetadata\n ? exportedSymbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n if (!this._shouldIncludeReleaseTag(exportedMaxEffectiveReleaseTag, dtsKind)) {\n continue;\n }\n\n if (collectorEntity.nameForEmit === exportedName) {\n exportClauses.push(collectorEntity.nameForEmit);\n } else {\n exportClauses.push(`${collectorEntity.nameForEmit} as ${exportedName}`);\n }\n }\n writer.writeLine(exportClauses.join(',\\n'));\n\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"export { ... }\"\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"declare namespace { ... }\"\n }\n\n if (!entity.shouldInlineExport) {\n for (const exportName of entity.exportNames) {\n DtsEmitHelpers.emitNamedExport(writer, exportName, entity);\n }\n }\n\n writer.ensureSkippedLine();\n }\n\n DtsEmitHelpers.emitStarExports(writer, collector);\n\n // Emit \"export { }\" which is a special directive that prevents consumers from importing declarations\n // that don't have an explicit \"export\" modifier.\n writer.ensureSkippedLine();\n writer.writeLine('export { }');\n }\n\n /**\n * Before writing out a declaration, _modifySpan() applies various fixups to make it nice.\n */\n private static _modifySpan(\n collector: Collector,\n span: Span,\n entity: CollectorEntity,\n astDeclaration: AstDeclaration,\n dtsKind: DtsRollupKind\n ): void {\n const previousSpan: Span | undefined = span.previousSibling;\n\n let recurseChildren: boolean = true;\n switch (span.kind) {\n case ts.SyntaxKind.JSDocComment:\n // If the @packageDocumentation comment seems to be attached to one of the regular API items,\n // omit it. It gets explictly emitted at the top of the file.\n if (span.node.getText().match(/(?:\\s|\\*)@packageDocumentation(?:\\s|\\*)/gi)) {\n span.modification.skipAll();\n }\n\n // For now, we don't transform JSDoc comment nodes at all\n recurseChildren = false;\n break;\n\n case ts.SyntaxKind.ExportKeyword:\n case ts.SyntaxKind.DefaultKeyword:\n case ts.SyntaxKind.DeclareKeyword:\n // Delete any explicit \"export\" or \"declare\" keywords -- we will re-add them below\n span.modification.skipAll();\n break;\n\n case ts.SyntaxKind.InterfaceKeyword:\n case ts.SyntaxKind.ClassKeyword:\n case ts.SyntaxKind.EnumKeyword:\n case ts.SyntaxKind.NamespaceKeyword:\n case ts.SyntaxKind.ModuleKeyword:\n case ts.SyntaxKind.TypeKeyword:\n case ts.SyntaxKind.FunctionKeyword:\n // Replace the stuff we possibly deleted above\n let replacedModifiers: string = '';\n\n // Add a declare statement for root declarations (but not for nested declarations)\n if (!astDeclaration.parent) {\n replacedModifiers += 'declare ';\n }\n\n if (entity.shouldInlineExport) {\n replacedModifiers = 'export ' + replacedModifiers;\n }\n\n if (previousSpan && previousSpan.kind === ts.SyntaxKind.SyntaxList) {\n // If there is a previous span of type SyntaxList, then apply it before any other modifiers\n // (e.g. \"abstract\") that appear there.\n previousSpan.modification.prefix = replacedModifiers + previousSpan.modification.prefix;\n } else {\n // Otherwise just stick it in front of this span\n span.modification.prefix = replacedModifiers + span.modification.prefix;\n }\n break;\n\n case ts.SyntaxKind.VariableDeclaration:\n // Is this a top-level variable declaration?\n // (The logic below does not apply to variable declarations that are part of an explicit \"namespace\" block,\n // since the compiler prefers not to emit \"declare\" or \"export\" keywords for those declarations.)\n if (!span.parent) {\n // The VariableDeclaration node is part of a VariableDeclarationList, however\n // the Entry.followedSymbol points to the VariableDeclaration part because\n // multiple definitions might share the same VariableDeclarationList.\n //\n // Since we are emitting a separate declaration for each one, we need to look upwards\n // in the ts.Node tree and write a copy of the enclosing VariableDeclarationList\n // content (e.g. \"var\" from \"var x=1, y=2\").\n const list: ts.VariableDeclarationList | undefined = TypeScriptHelpers.matchAncestor(span.node, [\n ts.SyntaxKind.VariableDeclarationList,\n ts.SyntaxKind.VariableDeclaration\n ]);\n if (!list) {\n // This should not happen unless the compiler API changes somehow\n throw new InternalError('Unsupported variable declaration');\n }\n const listPrefix: string = list\n .getSourceFile()\n .text.substring(list.getStart(), list.declarations[0].getStart());\n span.modification.prefix = 'declare ' + listPrefix + span.modification.prefix;\n span.modification.suffix = ';';\n\n if (entity.shouldInlineExport) {\n span.modification.prefix = 'export ' + span.modification.prefix;\n }\n\n const declarationMetadata: DeclarationMetadata = collector.fetchDeclarationMetadata(astDeclaration);\n if (declarationMetadata.tsdocParserContext) {\n // Typically the comment for a variable declaration is attached to the outer variable statement\n // (which may possibly contain multiple variable declarations), so it's not part of the Span.\n // Instead we need to manually inject it.\n let originalComment: string = declarationMetadata.tsdocParserContext.sourceRange.toString();\n if (!/\\r?\\n\\s*$/.test(originalComment)) {\n originalComment += '\\n';\n }\n span.modification.indentDocComment = IndentDocCommentScope.PrefixOnly;\n span.modification.prefix = originalComment + span.modification.prefix;\n }\n }\n break;\n\n case ts.SyntaxKind.Identifier:\n {\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(\n span.node as ts.Identifier\n );\n\n if (referencedEntity) {\n if (!referencedEntity.nameForEmit) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n span.modification.prefix = referencedEntity.nameForEmit;\n // For debugging:\n // span.modification.prefix += '/*R=FIX*/';\n } else {\n // For debugging:\n // span.modification.prefix += '/*R=KEEP*/';\n }\n }\n break;\n\n case ts.SyntaxKind.ImportType:\n DtsEmitHelpers.modifyImportTypeSpan(\n collector,\n span,\n astDeclaration,\n (childSpan, childAstDeclaration) => {\n DtsRollupGenerator._modifySpan(collector, childSpan, entity, childAstDeclaration, dtsKind);\n }\n );\n break;\n }\n\n if (recurseChildren) {\n for (const child of span.children) {\n let childAstDeclaration: AstDeclaration = astDeclaration;\n\n // Should we trim this node?\n let trimmed: boolean = false;\n if (AstDeclaration.isSupportedSyntaxKind(child.kind)) {\n childAstDeclaration = collector.astSymbolTable.getChildAstDeclarationByNode(\n child.node,\n astDeclaration\n );\n const releaseTag: ReleaseTag =\n collector.fetchApiItemMetadata(childAstDeclaration).effectiveReleaseTag;\n\n if (!this._shouldIncludeReleaseTag(releaseTag, dtsKind)) {\n let nodeToTrim: Span = child;\n\n // If we are trimming a variable statement, then we need to trim the outer VariableDeclarationList\n // as well.\n if (child.kind === ts.SyntaxKind.VariableDeclaration) {\n const variableStatement: Span | undefined = child.findFirstParent(\n ts.SyntaxKind.VariableStatement\n );\n if (variableStatement !== undefined) {\n nodeToTrim = variableStatement;\n }\n }\n\n const modification: SpanModification = nodeToTrim.modification;\n\n // Yes, trim it and stop here\n const name: string = childAstDeclaration.astSymbol.localName;\n modification.omitChildren = true;\n\n if (!collector.extractorConfig.omitTrimmingComments) {\n modification.prefix = `/* Excluded from this release type: ${name} */`;\n } else {\n modification.prefix = '';\n }\n modification.suffix = '';\n\n if (nodeToTrim.children.length > 0) {\n // If there are grandchildren, then keep the last grandchild's separator,\n // since it often has useful whitespace\n modification.suffix = nodeToTrim.children[nodeToTrim.children.length - 1].separator;\n }\n\n if (nodeToTrim.nextSibling) {\n // If the thing we are trimming is followed by a comma, then trim the comma also.\n // An example would be an enum member.\n if (nodeToTrim.nextSibling.kind === ts.SyntaxKind.CommaToken) {\n // Keep its separator since it often has useful whitespace\n modification.suffix += nodeToTrim.nextSibling.separator;\n nodeToTrim.nextSibling.modification.skipAll();\n }\n }\n\n trimmed = true;\n }\n }\n\n if (!trimmed) {\n DtsRollupGenerator._modifySpan(collector, child, entity, childAstDeclaration, dtsKind);\n }\n }\n }\n }\n\n private static _shouldIncludeReleaseTag(releaseTag: ReleaseTag, dtsKind: DtsRollupKind): boolean {\n switch (dtsKind) {\n case DtsRollupKind.InternalRelease:\n return true;\n case DtsRollupKind.AlphaRelease:\n return (\n releaseTag === ReleaseTag.Alpha ||\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.BetaRelease:\n return (\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.PublicRelease:\n return releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None;\n default:\n throw new Error(`${DtsRollupKind[dtsKind]} is not implemented`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DtsRollupGenerator.js","sourceRoot":"","sources":["../../src/generators/DtsRollupGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wEAA4D;AAC5D,oEAA2F;AAG3F,qEAAkE;AAClE,2CAAsF;AACtF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aA2BX;AA3BD,WAAY,aAAa;IACvB;;;OAGG;IACH,uEAAe,CAAA;IAEf;;;;OAIG;IACH,iEAAY,CAAA;IAEZ;;;;OAIG;IACH,+DAAW,CAAA;IAEX;;;;OAIG;IACH,mEAAa,CAAA;AACf,CAAC,EA3BW,aAAa,6BAAb,aAAa,QA2BxB;AAED,MAAa,kBAAkB;IAC7B;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAC5B,SAAoB,EACpB,WAAmB,EACnB,OAAsB,EACtB,WAAwB;QAExB,MAAM,MAAM,GAAmB,IAAI,+BAAc,EAAE,CAAC;QACpD,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAEhC,kBAAkB,CAAC,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,8BAAU,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE;YACnD,kBAAkB,EAAE,WAAW;YAC/B,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,2BAA2B,CACxC,SAAoB,EACpB,MAAsB,EACtB,OAAsB;QAEtB,gEAAgE;QAChE,IAA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AU,KAAK,gCAAU,CAAC,MAAM,IAAI,UAAU,KAAK,gCAAU,CAAC,IAAI,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF;AA9aD,gDA8aC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\nimport { FileSystem, type NewlineKind, InternalError } from '@rushstack/node-core-library';\n\nimport type { Collector } from '../collector/Collector';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { IndentDocCommentScope, Span, type SpanModification } from '../analyzer/Span';\nimport { AstImport } from '../analyzer/AstImport';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { SymbolMetadata } from '../collector/SymbolMetadata';\nimport { IndentedWriter } from './IndentedWriter';\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport type { IAstModuleExportInfo } from '../analyzer/AstModule';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport type { AstEntity } from '../analyzer/AstEntity';\n\n/**\n * Used with DtsRollupGenerator.writeTypingsFile()\n */\nexport enum DtsRollupKind {\n /**\n * Generate a *.d.ts file for an internal release, or for the trimming=false mode.\n * This output file will contain all definitions that are reachable from the entry point.\n */\n InternalRelease,\n\n /**\n * Generate a *.d.ts file for a preview release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@internal.\n */\n AlphaRelease,\n\n /**\n * Generate a *.d.ts file for a preview release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@alpha or \\@internal.\n */\n BetaRelease,\n\n /**\n * Generate a *.d.ts file for a public release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@beta, \\@alpha, or \\@internal.\n */\n PublicRelease\n}\n\nexport class DtsRollupGenerator {\n /**\n * Generates the typings file and writes it to disk.\n *\n * @param dtsFilename - The *.d.ts output filename\n */\n public static writeTypingsFile(\n collector: Collector,\n dtsFilename: string,\n dtsKind: DtsRollupKind,\n newlineKind: NewlineKind\n ): void {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n DtsRollupGenerator._generateTypingsFileContent(collector, writer, dtsKind);\n\n FileSystem.writeFile(dtsFilename, writer.toString(), {\n convertLineEndings: newlineKind,\n ensureFolderExists: true\n });\n }\n\n private static _generateTypingsFileContent(\n collector: Collector,\n writer: IndentedWriter,\n dtsKind: DtsRollupKind\n ): void {\n // Emit the @packageDocumentation comment at the top of the file\n if (collector.workingPackage.tsdocParserContext) {\n writer.trimLeadingSpaces = false;\n writer.writeLine(collector.workingPackage.tsdocParserContext.sourceRange.toString());\n writer.trimLeadingSpaces = true;\n writer.ensureSkippedLine();\n }\n\n // Emit the triple slash directives\n for (const typeDirectiveReference of collector.dtsTypeReferenceDirectives) {\n // https://github.com/microsoft/TypeScript/blob/611ebc7aadd7a44a4c0447698bfda9222a78cb66/src/compiler/declarationEmitter.ts#L162\n writer.writeLine(`/// <reference types=\"${typeDirectiveReference}\" />`);\n }\n for (const libDirectiveReference of collector.dtsLibReferenceDirectives) {\n writer.writeLine(`/// <reference lib=\"${libDirectiveReference}\" />`);\n }\n writer.ensureSkippedLine();\n\n // Emit the imports\n for (const entity of collector.entities) {\n if (entity.astEntity instanceof AstImport) {\n // Note: it isn't valid to trim imports based on their release tags.\n // E.g. class Foo (`@public`) extends interface Bar (`@beta`) from some external library.\n // API-Extractor cannot trim `import { Bar } from \"external-library\"` when generating its public rollup,\n // or the export of `Foo` would include a broken reference to `Bar`.\n const astImport: AstImport = entity.astEntity;\n DtsEmitHelpers.emitImport(writer, entity, astImport);\n }\n }\n writer.ensureSkippedLine();\n\n // Emit the regular declarations\n for (const entity of collector.entities) {\n const astEntity: AstEntity = entity.astEntity;\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astEntity);\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\n ? symbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n\n if (!this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n }\n\n if (astEntity instanceof AstSymbol) {\n // Emit all the declarations for this entry\n for (const astDeclaration of astEntity.astDeclarations || []) {\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\n\n if (!this._shouldIncludeReleaseTag(apiItemMetadata.effectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded declaration from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n } else {\n const span: Span = new Span(astDeclaration.declaration);\n DtsRollupGenerator._modifySpan(collector, span, entity, astDeclaration, dtsKind);\n writer.ensureSkippedLine();\n span.writeModifiedText(writer);\n writer.ensureNewLine();\n }\n }\n }\n\n if (astEntity instanceof AstNamespaceImport) {\n const astModuleExportInfo: IAstModuleExportInfo = astEntity.fetchAstModuleExportInfo(collector);\n\n if (entity.nameForEmit === undefined) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n if (astModuleExportInfo.starExportedExternalModules.size > 0) {\n // We could support this, but we would need to find a way to safely represent it.\n throw new Error(\n `The ${entity.nameForEmit} namespace import includes a start export, which is not supported:\\n` +\n SourceFileLocationFormatter.formatDeclaration(astEntity.declaration)\n );\n }\n\n // Emit a synthetic declaration for the namespace. It will look like this:\n //\n // declare namespace example {\n // export {\n // f1,\n // f2\n // }\n // }\n //\n // Note that we do not try to relocate f1()/f2() to be inside the namespace because other type\n // signatures may reference them directly (without using the namespace qualifier).\n\n writer.ensureSkippedLine();\n if (entity.shouldInlineExport) {\n writer.write('export ');\n }\n writer.writeLine(`declare namespace ${entity.nameForEmit} {`);\n\n // all local exports of local imported module are just references to top-level declarations\n writer.increaseIndent();\n writer.writeLine('export {');\n writer.increaseIndent();\n\n const exportClauses: string[] = [];\n for (const [exportedName, exportedEntity] of astModuleExportInfo.exportedLocalEntities) {\n const collectorEntity: CollectorEntity | undefined =\n collector.tryGetCollectorEntity(exportedEntity);\n if (collectorEntity === undefined) {\n // This should never happen\n // top-level exports of local imported module should be added as collector entities before\n throw new InternalError(\n `Cannot find collector entity for ${entity.nameForEmit}.${exportedEntity.localName}`\n );\n }\n\n // If the entity's declaration won't be included, then neither should the namespace export it\n // This fixes the issue encountered here: https://github.com/microsoft/rushstack/issues/2791\n const exportedSymbolMetadata: SymbolMetadata | undefined =\n collector.tryFetchMetadataForAstEntity(exportedEntity);\n const exportedMaxEffectiveReleaseTag: ReleaseTag = exportedSymbolMetadata\n ? exportedSymbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n if (!this._shouldIncludeReleaseTag(exportedMaxEffectiveReleaseTag, dtsKind)) {\n continue;\n }\n\n if (collectorEntity.nameForEmit === exportedName) {\n exportClauses.push(collectorEntity.nameForEmit);\n } else {\n exportClauses.push(`${collectorEntity.nameForEmit} as ${exportedName}`);\n }\n }\n writer.writeLine(exportClauses.join(',\\n'));\n\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"export { ... }\"\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"declare namespace { ... }\"\n }\n\n if (!entity.shouldInlineExport) {\n for (const exportName of entity.exportNames) {\n DtsEmitHelpers.emitNamedExport(writer, exportName, entity);\n }\n }\n\n writer.ensureSkippedLine();\n }\n\n DtsEmitHelpers.emitStarExports(writer, collector);\n\n // Emit \"export { }\" which is a special directive that prevents consumers from importing declarations\n // that don't have an explicit \"export\" modifier.\n writer.ensureSkippedLine();\n writer.writeLine('export { }');\n }\n\n /**\n * Before writing out a declaration, _modifySpan() applies various fixups to make it nice.\n */\n private static _modifySpan(\n collector: Collector,\n span: Span,\n entity: CollectorEntity,\n astDeclaration: AstDeclaration,\n dtsKind: DtsRollupKind\n ): void {\n const previousSpan: Span | undefined = span.previousSibling;\n\n let recurseChildren: boolean = true;\n switch (span.kind) {\n case ts.SyntaxKind.JSDocComment:\n // If the @packageDocumentation comment seems to be attached to one of the regular API items,\n // omit it. It gets explictly emitted at the top of the file.\n if (span.node.getText().match(/(?:\\s|\\*)@packageDocumentation(?:\\s|\\*)/gi)) {\n span.modification.skipAll();\n }\n\n // For now, we don't transform JSDoc comment nodes at all\n recurseChildren = false;\n break;\n\n case ts.SyntaxKind.ExportKeyword:\n if (DtsEmitHelpers.isExportKeywordInNamespaceExportDeclaration(span.node)) {\n // This is an export declaration inside a namespace - preserve the export keyword\n break;\n }\n // Otherwise, delete the export keyword -- we will re-add it below\n span.modification.skipAll();\n break;\n\n case ts.SyntaxKind.DefaultKeyword:\n case ts.SyntaxKind.DeclareKeyword:\n // Delete any explicit \"export\" or \"declare\" keywords -- we will re-add them below\n span.modification.skipAll();\n break;\n\n case ts.SyntaxKind.InterfaceKeyword:\n case ts.SyntaxKind.ClassKeyword:\n case ts.SyntaxKind.EnumKeyword:\n case ts.SyntaxKind.NamespaceKeyword:\n case ts.SyntaxKind.ModuleKeyword:\n case ts.SyntaxKind.TypeKeyword:\n case ts.SyntaxKind.FunctionKeyword:\n // Replace the stuff we possibly deleted above\n let replacedModifiers: string = '';\n\n // Add a declare statement for root declarations (but not for nested declarations)\n if (!astDeclaration.parent) {\n replacedModifiers += 'declare ';\n }\n\n if (entity.shouldInlineExport) {\n replacedModifiers = 'export ' + replacedModifiers;\n }\n\n if (previousSpan && previousSpan.kind === ts.SyntaxKind.SyntaxList) {\n // If there is a previous span of type SyntaxList, then apply it before any other modifiers\n // (e.g. \"abstract\") that appear there.\n previousSpan.modification.prefix = replacedModifiers + previousSpan.modification.prefix;\n } else {\n // Otherwise just stick it in front of this span\n span.modification.prefix = replacedModifiers + span.modification.prefix;\n }\n break;\n\n case ts.SyntaxKind.VariableDeclaration:\n // Is this a top-level variable declaration?\n // (The logic below does not apply to variable declarations that are part of an explicit \"namespace\" block,\n // since the compiler prefers not to emit \"declare\" or \"export\" keywords for those declarations.)\n if (!span.parent) {\n // The VariableDeclaration node is part of a VariableDeclarationList, however\n // the Entry.followedSymbol points to the VariableDeclaration part because\n // multiple definitions might share the same VariableDeclarationList.\n //\n // Since we are emitting a separate declaration for each one, we need to look upwards\n // in the ts.Node tree and write a copy of the enclosing VariableDeclarationList\n // content (e.g. \"var\" from \"var x=1, y=2\").\n const list: ts.VariableDeclarationList | undefined = TypeScriptHelpers.matchAncestor(span.node, [\n ts.SyntaxKind.VariableDeclarationList,\n ts.SyntaxKind.VariableDeclaration\n ]);\n if (!list) {\n // This should not happen unless the compiler API changes somehow\n throw new InternalError('Unsupported variable declaration');\n }\n const listPrefix: string = list\n .getSourceFile()\n .text.substring(list.getStart(), list.declarations[0].getStart());\n span.modification.prefix = 'declare ' + listPrefix + span.modification.prefix;\n span.modification.suffix = ';';\n\n if (entity.shouldInlineExport) {\n span.modification.prefix = 'export ' + span.modification.prefix;\n }\n\n const declarationMetadata: DeclarationMetadata = collector.fetchDeclarationMetadata(astDeclaration);\n if (declarationMetadata.tsdocParserContext) {\n // Typically the comment for a variable declaration is attached to the outer variable statement\n // (which may possibly contain multiple variable declarations), so it's not part of the Span.\n // Instead we need to manually inject it.\n let originalComment: string = declarationMetadata.tsdocParserContext.sourceRange.toString();\n if (!/\\r?\\n\\s*$/.test(originalComment)) {\n originalComment += '\\n';\n }\n span.modification.indentDocComment = IndentDocCommentScope.PrefixOnly;\n span.modification.prefix = originalComment + span.modification.prefix;\n }\n }\n break;\n\n case ts.SyntaxKind.Identifier:\n {\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(\n span.node as ts.Identifier\n );\n\n if (referencedEntity) {\n if (!referencedEntity.nameForEmit) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n span.modification.prefix = referencedEntity.nameForEmit;\n // For debugging:\n // span.modification.prefix += '/*R=FIX*/';\n } else {\n // For debugging:\n // span.modification.prefix += '/*R=KEEP*/';\n }\n }\n break;\n\n case ts.SyntaxKind.ImportType:\n DtsEmitHelpers.modifyImportTypeSpan(\n collector,\n span,\n astDeclaration,\n (childSpan, childAstDeclaration) => {\n DtsRollupGenerator._modifySpan(collector, childSpan, entity, childAstDeclaration, dtsKind);\n }\n );\n break;\n }\n\n if (recurseChildren) {\n for (const child of span.children) {\n let childAstDeclaration: AstDeclaration = astDeclaration;\n\n // Should we trim this node?\n let trimmed: boolean = false;\n if (AstDeclaration.isSupportedSyntaxKind(child.kind)) {\n childAstDeclaration = collector.astSymbolTable.getChildAstDeclarationByNode(\n child.node,\n astDeclaration\n );\n const releaseTag: ReleaseTag =\n collector.fetchApiItemMetadata(childAstDeclaration).effectiveReleaseTag;\n\n if (!this._shouldIncludeReleaseTag(releaseTag, dtsKind)) {\n let nodeToTrim: Span = child;\n\n // If we are trimming a variable statement, then we need to trim the outer VariableDeclarationList\n // as well.\n if (child.kind === ts.SyntaxKind.VariableDeclaration) {\n const variableStatement: Span | undefined = child.findFirstParent(\n ts.SyntaxKind.VariableStatement\n );\n if (variableStatement !== undefined) {\n nodeToTrim = variableStatement;\n }\n }\n\n const modification: SpanModification = nodeToTrim.modification;\n\n // Yes, trim it and stop here\n const name: string = childAstDeclaration.astSymbol.localName;\n modification.omitChildren = true;\n\n if (!collector.extractorConfig.omitTrimmingComments) {\n modification.prefix = `/* Excluded from this release type: ${name} */`;\n } else {\n modification.prefix = '';\n }\n modification.suffix = '';\n\n if (nodeToTrim.children.length > 0) {\n // If there are grandchildren, then keep the last grandchild's separator,\n // since it often has useful whitespace\n modification.suffix = nodeToTrim.children[nodeToTrim.children.length - 1].separator;\n }\n\n if (nodeToTrim.nextSibling) {\n // If the thing we are trimming is followed by a comma, then trim the comma also.\n // An example would be an enum member.\n if (nodeToTrim.nextSibling.kind === ts.SyntaxKind.CommaToken) {\n // Keep its separator since it often has useful whitespace\n modification.suffix += nodeToTrim.nextSibling.separator;\n nodeToTrim.nextSibling.modification.skipAll();\n }\n }\n\n trimmed = true;\n }\n }\n\n if (!trimmed) {\n DtsRollupGenerator._modifySpan(collector, child, entity, childAstDeclaration, dtsKind);\n }\n }\n }\n }\n\n private static _shouldIncludeReleaseTag(releaseTag: ReleaseTag, dtsKind: DtsRollupKind): boolean {\n switch (dtsKind) {\n case DtsRollupKind.InternalRelease:\n return true;\n case DtsRollupKind.AlphaRelease:\n return (\n releaseTag === ReleaseTag.Alpha ||\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.BetaRelease:\n return (\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.PublicRelease:\n return releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None;\n default:\n throw new Error(`${DtsRollupKind[dtsKind]} is not implemented`);\n }\n }\n}\n"]}
|
|
@@ -5,16 +5,20 @@ import type { AstDeclaration } from '../analyzer/AstDeclaration';
|
|
|
5
5
|
/**
|
|
6
6
|
* Used to provide ExcerptBuilder with a list of nodes whose token range we want to capture.
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface IExcerptBuilderNodeTransform {
|
|
9
9
|
/**
|
|
10
|
-
* The node to
|
|
10
|
+
* The node to process
|
|
11
11
|
*/
|
|
12
|
-
node: ts.Node
|
|
12
|
+
node: ts.Node;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* tokens corresponding to
|
|
14
|
+
* A token range whose startIndex/endIndex will be overwritten with the indexes for the
|
|
15
|
+
* tokens corresponding to IExcerptBuilderNodeTransform.node
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
captureTokenRange?: IExcerptTokenRange;
|
|
18
|
+
/**
|
|
19
|
+
* Text that will replace the text of the given node during emit.
|
|
20
|
+
*/
|
|
21
|
+
replacementText?: string;
|
|
18
22
|
}
|
|
19
23
|
export declare class ExcerptBuilder {
|
|
20
24
|
/**
|
|
@@ -25,10 +29,11 @@ export declare class ExcerptBuilder {
|
|
|
25
29
|
/**
|
|
26
30
|
* Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.
|
|
27
31
|
* @param excerptTokens - The target token list to append to
|
|
28
|
-
* @param
|
|
32
|
+
* @param nodeTransforms - A list of child nodes whose token ranges we want to capture
|
|
29
33
|
*/
|
|
30
|
-
static addDeclaration(excerptTokens: IExcerptToken[], astDeclaration: AstDeclaration,
|
|
34
|
+
static addDeclaration(excerptTokens: IExcerptToken[], astDeclaration: AstDeclaration, nodeTransforms: IExcerptBuilderNodeTransform[], referenceGenerator: DeclarationReferenceGenerator): void;
|
|
31
35
|
static createEmptyTokenRange(): IExcerptTokenRange;
|
|
36
|
+
/** @returns false if we encountered a token that causes iteration to stop. */
|
|
32
37
|
private static _buildSpan;
|
|
33
38
|
private static _appendToken;
|
|
34
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExcerptBuilder.d.ts","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC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erptBuilder {
|
|
|
58
58
|
/**
|
|
59
59
|
* Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.
|
|
60
60
|
* @param excerptTokens - The target token list to append to
|
|
61
|
-
* @param
|
|
61
|
+
* @param nodeTransforms - A list of child nodes whose token ranges we want to capture
|
|
62
62
|
*/
|
|
63
|
-
static addDeclaration(excerptTokens, astDeclaration,
|
|
63
|
+
static addDeclaration(excerptTokens, astDeclaration, nodeTransforms, referenceGenerator) {
|
|
64
64
|
let stopBeforeChildKind = undefined;
|
|
65
65
|
switch (astDeclaration.declaration.kind) {
|
|
66
66
|
case ts.SyntaxKind.ClassDeclaration:
|
|
@@ -75,33 +75,52 @@ class ExcerptBuilder {
|
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
77
|
const span = new Span_1.Span(astDeclaration.declaration);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const transformsByNode = new Map();
|
|
79
|
+
const captureTokenRanges = [];
|
|
80
|
+
for (const nodeTransform of nodeTransforms || []) {
|
|
81
|
+
transformsByNode.set(nodeTransform.node, nodeTransform);
|
|
82
|
+
if (nodeTransform.captureTokenRange) {
|
|
83
|
+
captureTokenRanges.push(nodeTransform.captureTokenRange);
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
ExcerptBuilder._buildSpan(excerptTokens, span, {
|
|
85
87
|
referenceGenerator: referenceGenerator,
|
|
86
88
|
startingNode: span.node,
|
|
87
89
|
stopBeforeChildKind,
|
|
88
|
-
|
|
90
|
+
transformsByNode: transformsByNode,
|
|
89
91
|
lastAppendedTokenIsSeparator: false
|
|
90
92
|
});
|
|
91
|
-
ExcerptBuilder._condenseTokens(excerptTokens,
|
|
93
|
+
ExcerptBuilder._condenseTokens(excerptTokens, captureTokenRanges);
|
|
92
94
|
}
|
|
93
95
|
static createEmptyTokenRange() {
|
|
94
96
|
return { startIndex: 0, endIndex: 0 };
|
|
95
97
|
}
|
|
98
|
+
/** @returns false if we encountered a token that causes iteration to stop. */
|
|
96
99
|
static _buildSpan(excerptTokens, span, state) {
|
|
97
100
|
if (span.kind === ts.SyntaxKind.JSDocComment) {
|
|
98
101
|
// Discard any comments
|
|
99
102
|
return true;
|
|
100
103
|
}
|
|
101
104
|
// Can this node start a excerpt?
|
|
102
|
-
const
|
|
105
|
+
const transform = state.transformsByNode.get(span.node);
|
|
106
|
+
let captureTokenRange = undefined;
|
|
107
|
+
if (transform) {
|
|
108
|
+
captureTokenRange = transform.captureTokenRange;
|
|
109
|
+
if (transform.replacementText !== undefined) {
|
|
110
|
+
excerptTokens.push({
|
|
111
|
+
kind: api_extractor_model_1.ExcerptTokenKind.Content,
|
|
112
|
+
text: transform.replacementText
|
|
113
|
+
});
|
|
114
|
+
state.lastAppendedTokenIsSeparator = false;
|
|
115
|
+
if (captureTokenRange) {
|
|
116
|
+
captureTokenRange.startIndex = excerptTokens.length;
|
|
117
|
+
captureTokenRange.endIndex = captureTokenRange.startIndex + 1;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
103
122
|
let excerptStartIndex = 0;
|
|
104
|
-
if (
|
|
123
|
+
if (captureTokenRange) {
|
|
105
124
|
// We will assign capturedTokenRange.startIndex to be the index of the next token to be appended
|
|
106
125
|
excerptStartIndex = excerptTokens.length;
|
|
107
126
|
}
|
|
@@ -141,8 +160,8 @@ class ExcerptBuilder {
|
|
|
141
160
|
state.lastAppendedTokenIsSeparator = true;
|
|
142
161
|
}
|
|
143
162
|
// Are we building a excerpt? If so, set its range
|
|
144
|
-
if (
|
|
145
|
-
|
|
163
|
+
if (captureTokenRange) {
|
|
164
|
+
captureTokenRange.startIndex = excerptStartIndex;
|
|
146
165
|
// We will assign capturedTokenRange.startIndex to be the index after the last token
|
|
147
166
|
// that was appended so far. However, if the last appended token was a separator, omit
|
|
148
167
|
// it from the range.
|
|
@@ -150,7 +169,7 @@ class ExcerptBuilder {
|
|
|
150
169
|
if (state.lastAppendedTokenIsSeparator) {
|
|
151
170
|
excerptEndIndex--;
|
|
152
171
|
}
|
|
153
|
-
|
|
172
|
+
captureTokenRange.endIndex = excerptEndIndex;
|
|
154
173
|
}
|
|
155
174
|
return true;
|
|
156
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAGjC,wEAIwC;AAExC,2CAAwC;AAkDxC,MAAa,cAAc;IACzB;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,aAA8B;QACvD,IAAI,QAAQ,GAAW,MAAM,CAAC;QAC9B,kFAAkF;QAClF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1E,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC7B,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sCAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAC1B,aAA8B,EAC9B,cAA8B,EAC9B,cAA8C,EAC9C,kBAAiD;QAEjD,IAAI,mBAAmB,GAA8B,SAAS,CAAC;QAE/D,QAAQ,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACpC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAo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AAE,CAAC,UAAU,CAAC,cAAc;gBAC/B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;CACF;AAvRD,wCAuRC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport {\n ExcerptTokenKind,\n type IExcerptToken,\n type IExcerptTokenRange\n} from '@microsoft/api-extractor-model';\n\nimport { Span } from '../analyzer/Span';\nimport type { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\nimport type { AstDeclaration } from '../analyzer/AstDeclaration';\n\n/**\n * Used to provide ExcerptBuilder with a list of nodes whose token range we want to capture.\n */\nexport interface IExcerptBuilderNodeToCapture {\n /**\n * The node to capture\n */\n node: ts.Node | undefined;\n /**\n * The token range whose startIndex/endIndex will be overwritten with the indexes for the\n * tokens corresponding to IExcerptBuilderNodeToCapture.node\n */\n tokenRange: IExcerptTokenRange;\n}\n\n/**\n * Internal state for ExcerptBuilder\n */\ninterface IBuildSpanState {\n referenceGenerator: DeclarationReferenceGenerator;\n\n /**\n * The AST node that we will traverse to extract tokens\n */\n startingNode: ts.Node;\n\n /**\n * Normally, the excerpt will include all child nodes for `startingNode`; whereas if `childKindToStopBefore`\n * is specified, then the node traversal will stop before (i.e. excluding) the first immediate child\n * of `startingNode` with the specified syntax kind.\n *\n * @remarks\n * For example, suppose the signature is `interface X: Y { z: string }`. The token `{` has syntax kind\n * `ts.SyntaxKind.FirstPunctuation`, so we can specify that to truncate the excerpt to `interface X: Y`.\n */\n stopBeforeChildKind: ts.SyntaxKind | undefined;\n\n tokenRangesByNode: Map<ts.Node, IExcerptTokenRange>;\n\n /**\n * Tracks whether the last appended token was a separator. If so, and we're in the middle of\n * capturing a token range, then omit the separator from the range.\n */\n lastAppendedTokenIsSeparator: boolean;\n}\n\nexport class ExcerptBuilder {\n /**\n * Appends a blank line to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n */\n public static addBlankLine(excerptTokens: IExcerptToken[]): void {\n let newlines: string = '\\n\\n';\n // If the existing text already ended with a newline, then only append one newline\n if (excerptTokens.length > 0) {\n const previousText: string = excerptTokens[excerptTokens.length - 1].text;\n if (/\\n$/.test(previousText)) {\n newlines = '\\n';\n }\n }\n excerptTokens.push({ kind: ExcerptTokenKind.Content, text: newlines });\n }\n\n /**\n * Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n * @param nodesToCapture - A list of child nodes whose token ranges we want to capture\n */\n public static addDeclaration(\n excerptTokens: IExcerptToken[],\n astDeclaration: AstDeclaration,\n nodesToCapture: IExcerptBuilderNodeToCapture[],\n referenceGenerator: DeclarationReferenceGenerator\n ): void {\n let stopBeforeChildKind: ts.SyntaxKind | undefined = undefined;\n\n switch (astDeclaration.declaration.kind) {\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.InterfaceDeclaration:\n // FirstPunctuation = \"{\"\n stopBeforeChildKind = ts.SyntaxKind.FirstPunctuation;\n break;\n case ts.SyntaxKind.ModuleDeclaration:\n // ModuleBlock = the \"{ ... }\" block\n stopBeforeChildKind = ts.SyntaxKind.ModuleBlock;\n break;\n }\n\n const span: Span = new Span(astDeclaration.declaration);\n\n const tokenRangesByNode: Map<ts.Node, IExcerptTokenRange> = new Map<ts.Node, IExcerptTokenRange>();\n for (const excerpt of nodesToCapture || []) {\n if (excerpt.node) {\n tokenRangesByNode.set(excerpt.node, excerpt.tokenRange);\n }\n }\n\n ExcerptBuilder._buildSpan(excerptTokens, span, {\n referenceGenerator: referenceGenerator,\n startingNode: span.node,\n stopBeforeChildKind,\n tokenRangesByNode,\n lastAppendedTokenIsSeparator: false\n });\n ExcerptBuilder._condenseTokens(excerptTokens, [...tokenRangesByNode.values()]);\n }\n\n public static createEmptyTokenRange(): IExcerptTokenRange {\n return { startIndex: 0, endIndex: 0 };\n }\n\n private static _buildSpan(excerptTokens: IExcerptToken[], span: Span, state: IBuildSpanState): boolean {\n if (span.kind === ts.SyntaxKind.JSDocComment) {\n // Discard any comments\n return true;\n }\n\n // Can this node start a excerpt?\n const capturedTokenRange: IExcerptTokenRange | undefined = state.tokenRangesByNode.get(span.node);\n let excerptStartIndex: number = 0;\n\n if (capturedTokenRange) {\n // We will assign capturedTokenRange.startIndex to be the index of the next token to be appended\n excerptStartIndex = excerptTokens.length;\n }\n\n if (span.prefix) {\n let canonicalReference: DeclarationReference | undefined = undefined;\n\n if (span.kind === ts.SyntaxKind.Identifier) {\n const name: ts.Identifier = span.node as ts.Identifier;\n if (!ExcerptBuilder._isDeclarationName(name)) {\n canonicalReference = state.referenceGenerator.getDeclarationReferenceForIdentifier(name);\n }\n }\n\n if (canonicalReference) {\n ExcerptBuilder._appendToken(\n excerptTokens,\n ExcerptTokenKind.Reference,\n span.prefix,\n canonicalReference\n );\n } else {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix);\n }\n state.lastAppendedTokenIsSeparator = false;\n }\n\n for (const child of span.children) {\n if (span.node === state.startingNode) {\n if (state.stopBeforeChildKind && child.kind === state.stopBeforeChildKind) {\n // We reached a child whose kind is stopBeforeChildKind, so stop traversing\n return false;\n }\n }\n\n if (!this._buildSpan(excerptTokens, child, state)) {\n return false;\n }\n }\n\n if (span.suffix) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.suffix);\n state.lastAppendedTokenIsSeparator = false;\n }\n if (span.separator) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator);\n state.lastAppendedTokenIsSeparator = true;\n }\n\n // Are we building a excerpt? If so, set its range\n if (capturedTokenRange) {\n capturedTokenRange.startIndex = excerptStartIndex;\n\n // We will assign capturedTokenRange.startIndex to be the index after the last token\n // that was appended so far. However, if the last appended token was a separator, omit\n // it from the range.\n let excerptEndIndex: number = excerptTokens.length;\n if (state.lastAppendedTokenIsSeparator) {\n excerptEndIndex--;\n }\n\n capturedTokenRange.endIndex = excerptEndIndex;\n }\n\n return true;\n }\n\n private static _appendToken(\n excerptTokens: IExcerptToken[],\n excerptTokenKind: ExcerptTokenKind,\n text: string,\n canonicalReference?: DeclarationReference\n ): void {\n if (text.length === 0) {\n return;\n }\n\n const excerptToken: IExcerptToken = { kind: excerptTokenKind, text: text };\n if (canonicalReference !== undefined) {\n excerptToken.canonicalReference = canonicalReference.toString();\n }\n excerptTokens.push(excerptToken);\n }\n\n /**\n * Condenses the provided excerpt tokens by merging tokens where possible. Updates the provided token ranges to\n * remain accurate after token merging.\n *\n * @remarks\n * For example, suppose we have excerpt tokens [\"A\", \"B\", \"C\"] and a token range [0, 2]. If the excerpt tokens\n * are condensed to [\"AB\", \"C\"], then the token range would be updated to [0, 1]. Note that merges are only\n * performed if they are compatible with the provided token ranges. In the example above, if our token range was\n * originally [0, 1], we would not be able to merge tokens \"A\" and \"B\".\n */\n private static _condenseTokens(excerptTokens: IExcerptToken[], tokenRanges: IExcerptTokenRange[]): void {\n // This set is used to quickly lookup a start or end index.\n const startOrEndIndices: Set<number> = new Set();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n\n for (let currentIndex: number = 1; currentIndex < excerptTokens.length; ++currentIndex) {\n while (currentIndex < excerptTokens.length) {\n const prevPrevToken: IExcerptToken = excerptTokens[currentIndex - 2]; // May be undefined\n const prevToken: IExcerptToken = excerptTokens[currentIndex - 1];\n const currentToken: IExcerptToken = excerptTokens[currentIndex];\n\n // The number of excerpt tokens that are merged in this iteration. We need this to determine\n // how to update the start and end indices of our token ranges.\n let mergeCount: number;\n\n // There are two types of merges that can occur. We only perform these merges if they are\n // compatible with all of our token ranges.\n if (\n prevPrevToken &&\n prevPrevToken.kind === ExcerptTokenKind.Reference &&\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.text.trim() === '.' &&\n currentToken.kind === ExcerptTokenKind.Reference &&\n !startOrEndIndices.has(currentIndex) &&\n !startOrEndIndices.has(currentIndex - 1)\n ) {\n // If the current token is a reference token, the previous token is a \".\", and the previous-\n // previous token is a reference token, then merge all three tokens into a reference token.\n //\n // For example: Given [\"MyNamespace\" (R), \".\", \"MyClass\" (R)], tokens \".\" and \"MyClass\" might\n // be merged into \"MyNamespace\". The condensed token would be [\"MyNamespace.MyClass\" (R)].\n prevPrevToken.text += prevToken.text + currentToken.text;\n prevPrevToken.canonicalReference = currentToken.canonicalReference;\n mergeCount = 2;\n currentIndex--;\n } else if (\n // If the current and previous tokens are both content tokens, then merge the tokens into a\n // single content token. For example: Given [\"export \", \"declare class\"], these tokens\n // might be merged into \"export declare class\".\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.kind === currentToken.kind &&\n !startOrEndIndices.has(currentIndex)\n ) {\n prevToken.text += currentToken.text;\n mergeCount = 1;\n } else {\n // Otherwise, no merging can occur here. Continue to the next index.\n break;\n }\n\n // Remove the now redundant excerpt token(s), as they were merged into a previous token.\n excerptTokens.splice(currentIndex, mergeCount);\n\n // Update the start and end indices for all token ranges based upon how many excerpt\n // tokens were merged and in what positions.\n for (const tokenRange of tokenRanges) {\n if (tokenRange.startIndex > currentIndex) {\n tokenRange.startIndex -= mergeCount;\n }\n\n if (tokenRange.endIndex > currentIndex) {\n tokenRange.endIndex -= mergeCount;\n }\n }\n\n // Clear and repopulate our set with the updated indices.\n startOrEndIndices.clear();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n }\n }\n }\n\n private static _isDeclarationName(name: ts.Identifier): boolean {\n return ExcerptBuilder._isDeclaration(name.parent) && name.parent.name === name;\n }\n\n private static _isDeclaration(node: ts.Node): node is ts.NamedDeclaration {\n switch (node.kind) {\n case ts.SyntaxKind.FunctionDeclaration:\n case ts.SyntaxKind.FunctionExpression:\n case ts.SyntaxKind.VariableDeclaration:\n case ts.SyntaxKind.Parameter:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ClassExpression:\n case ts.SyntaxKind.ModuleDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.TypeAliasDeclaration:\n case ts.SyntaxKind.TypeParameter:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.BindingElement:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAGjC,wEAIwC;AAExC,2CAAwC;AAwDxC,MAAa,cAAc;IACzB;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,aAA8B;QACvD,IAAI,QAAQ,GAAW,MAAM,CAAC;QAC9B,kFAAkF;QAClF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1E,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC7B,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sCAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC;IA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AEO,MAAM,CAAC,cAAc,CAAC,IAAa;QACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACtC,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAC7B,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACpC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC/B,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC/B,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;YACjC,KAAK,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAC9B,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc;gBAC/B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;CACF;AA/SD,wCA+SC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport {\n ExcerptTokenKind,\n type IExcerptToken,\n type IExcerptTokenRange\n} from '@microsoft/api-extractor-model';\n\nimport { Span } from '../analyzer/Span';\nimport type { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\nimport type { AstDeclaration } from '../analyzer/AstDeclaration';\n\n/**\n * Used to provide ExcerptBuilder with a list of nodes whose token range we want to capture.\n */\nexport interface IExcerptBuilderNodeTransform {\n /**\n * The node to process\n */\n node: ts.Node;\n\n /**\n * A token range whose startIndex/endIndex will be overwritten with the indexes for the\n * tokens corresponding to IExcerptBuilderNodeTransform.node\n */\n captureTokenRange?: IExcerptTokenRange;\n\n /**\n * Text that will replace the text of the given node during emit.\n */\n replacementText?: string;\n}\n\n/**\n * Internal state for ExcerptBuilder\n */\ninterface IBuildSpanState {\n referenceGenerator: DeclarationReferenceGenerator;\n\n /**\n * The AST node that we will traverse to extract tokens\n */\n startingNode: ts.Node;\n\n /**\n * Normally, the excerpt will include all child nodes for `startingNode`; whereas if `childKindToStopBefore`\n * is specified, then the node traversal will stop before (i.e. excluding) the first immediate child\n * of `startingNode` with the specified syntax kind.\n *\n * @remarks\n * For example, suppose the signature is `interface X: Y { z: string }`. The token `{` has syntax kind\n * `ts.SyntaxKind.FirstPunctuation`, so we can specify that to truncate the excerpt to `interface X: Y`.\n */\n stopBeforeChildKind: ts.SyntaxKind | undefined;\n\n transformsByNode: Map<ts.Node, IExcerptBuilderNodeTransform>;\n\n /**\n * Tracks whether the last appended token was a separator. If so, and we're in the middle of\n * capturing a token range, then omit the separator from the range.\n */\n lastAppendedTokenIsSeparator: boolean;\n}\n\nexport class ExcerptBuilder {\n /**\n * Appends a blank line to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n */\n public static addBlankLine(excerptTokens: IExcerptToken[]): void {\n let newlines: string = '\\n\\n';\n // If the existing text already ended with a newline, then only append one newline\n if (excerptTokens.length > 0) {\n const previousText: string = excerptTokens[excerptTokens.length - 1].text;\n if (/\\n$/.test(previousText)) {\n newlines = '\\n';\n }\n }\n excerptTokens.push({ kind: ExcerptTokenKind.Content, text: newlines });\n }\n\n /**\n * Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n * @param nodeTransforms - A list of child nodes whose token ranges we want to capture\n */\n public static addDeclaration(\n excerptTokens: IExcerptToken[],\n astDeclaration: AstDeclaration,\n nodeTransforms: IExcerptBuilderNodeTransform[],\n referenceGenerator: DeclarationReferenceGenerator\n ): void {\n let stopBeforeChildKind: ts.SyntaxKind | undefined = undefined;\n\n switch (astDeclaration.declaration.kind) {\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.InterfaceDeclaration:\n // FirstPunctuation = \"{\"\n stopBeforeChildKind = ts.SyntaxKind.FirstPunctuation;\n break;\n case ts.SyntaxKind.ModuleDeclaration:\n // ModuleBlock = the \"{ ... }\" block\n stopBeforeChildKind = ts.SyntaxKind.ModuleBlock;\n break;\n }\n\n const span: Span = new Span(astDeclaration.declaration);\n\n const transformsByNode: Map<ts.Node, IExcerptBuilderNodeTransform> = new Map();\n const captureTokenRanges: IExcerptTokenRange[] = [];\n for (const nodeTransform of nodeTransforms || []) {\n transformsByNode.set(nodeTransform.node, nodeTransform);\n if (nodeTransform.captureTokenRange) {\n captureTokenRanges.push(nodeTransform.captureTokenRange);\n }\n }\n\n ExcerptBuilder._buildSpan(excerptTokens, span, {\n referenceGenerator: referenceGenerator,\n startingNode: span.node,\n stopBeforeChildKind,\n transformsByNode: transformsByNode,\n lastAppendedTokenIsSeparator: false\n });\n\n ExcerptBuilder._condenseTokens(excerptTokens, captureTokenRanges);\n }\n\n public static createEmptyTokenRange(): IExcerptTokenRange {\n return { startIndex: 0, endIndex: 0 };\n }\n\n /** @returns false if we encountered a token that causes iteration to stop. */\n private static _buildSpan(excerptTokens: IExcerptToken[], span: Span, state: IBuildSpanState): boolean {\n if (span.kind === ts.SyntaxKind.JSDocComment) {\n // Discard any comments\n return true;\n }\n\n // Can this node start a excerpt?\n const transform: IExcerptBuilderNodeTransform | undefined = state.transformsByNode.get(span.node);\n\n let captureTokenRange: IExcerptTokenRange | undefined = undefined;\n\n if (transform) {\n captureTokenRange = transform.captureTokenRange;\n if (transform.replacementText !== undefined) {\n excerptTokens.push({\n kind: ExcerptTokenKind.Content,\n text: transform.replacementText\n });\n state.lastAppendedTokenIsSeparator = false;\n\n if (captureTokenRange) {\n captureTokenRange.startIndex = excerptTokens.length;\n captureTokenRange.endIndex = captureTokenRange.startIndex + 1;\n }\n return true;\n }\n }\n\n let excerptStartIndex: number = 0;\n\n if (captureTokenRange) {\n // We will assign capturedTokenRange.startIndex to be the index of the next token to be appended\n excerptStartIndex = excerptTokens.length;\n }\n\n if (span.prefix) {\n let canonicalReference: DeclarationReference | undefined = undefined;\n\n if (span.kind === ts.SyntaxKind.Identifier) {\n const name: ts.Identifier = span.node as ts.Identifier;\n if (!ExcerptBuilder._isDeclarationName(name)) {\n canonicalReference = state.referenceGenerator.getDeclarationReferenceForIdentifier(name);\n }\n }\n\n if (canonicalReference) {\n ExcerptBuilder._appendToken(\n excerptTokens,\n ExcerptTokenKind.Reference,\n span.prefix,\n canonicalReference\n );\n } else {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix);\n }\n state.lastAppendedTokenIsSeparator = false;\n }\n\n for (const child of span.children) {\n if (span.node === state.startingNode) {\n if (state.stopBeforeChildKind && child.kind === state.stopBeforeChildKind) {\n // We reached a child whose kind is stopBeforeChildKind, so stop traversing\n return false;\n }\n }\n\n if (!this._buildSpan(excerptTokens, child, state)) {\n return false;\n }\n }\n\n if (span.suffix) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.suffix);\n state.lastAppendedTokenIsSeparator = false;\n }\n if (span.separator) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator);\n state.lastAppendedTokenIsSeparator = true;\n }\n\n // Are we building a excerpt? If so, set its range\n if (captureTokenRange) {\n captureTokenRange.startIndex = excerptStartIndex;\n\n // We will assign capturedTokenRange.startIndex to be the index after the last token\n // that was appended so far. However, if the last appended token was a separator, omit\n // it from the range.\n let excerptEndIndex: number = excerptTokens.length;\n if (state.lastAppendedTokenIsSeparator) {\n excerptEndIndex--;\n }\n\n captureTokenRange.endIndex = excerptEndIndex;\n }\n\n return true;\n }\n\n private static _appendToken(\n excerptTokens: IExcerptToken[],\n excerptTokenKind: ExcerptTokenKind,\n text: string,\n canonicalReference?: DeclarationReference\n ): void {\n if (text.length === 0) {\n return;\n }\n\n const excerptToken: IExcerptToken = { kind: excerptTokenKind, text: text };\n if (canonicalReference !== undefined) {\n excerptToken.canonicalReference = canonicalReference.toString();\n }\n excerptTokens.push(excerptToken);\n }\n\n /**\n * Condenses the provided excerpt tokens by merging tokens where possible. Updates the provided token ranges to\n * remain accurate after token merging.\n *\n * @remarks\n * For example, suppose we have excerpt tokens [\"A\", \"B\", \"C\"] and a token range [0, 2]. If the excerpt tokens\n * are condensed to [\"AB\", \"C\"], then the token range would be updated to [0, 1]. Note that merges are only\n * performed if they are compatible with the provided token ranges. In the example above, if our token range was\n * originally [0, 1], we would not be able to merge tokens \"A\" and \"B\".\n */\n private static _condenseTokens(excerptTokens: IExcerptToken[], tokenRanges: IExcerptTokenRange[]): void {\n // This set is used to quickly lookup a start or end index.\n const startOrEndIndices: Set<number> = new Set();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n\n for (let currentIndex: number = 1; currentIndex < excerptTokens.length; ++currentIndex) {\n while (currentIndex < excerptTokens.length) {\n const prevPrevToken: IExcerptToken = excerptTokens[currentIndex - 2]; // May be undefined\n const prevToken: IExcerptToken = excerptTokens[currentIndex - 1];\n const currentToken: IExcerptToken = excerptTokens[currentIndex];\n\n // The number of excerpt tokens that are merged in this iteration. We need this to determine\n // how to update the start and end indices of our token ranges.\n let mergeCount: number;\n\n // There are two types of merges that can occur. We only perform these merges if they are\n // compatible with all of our token ranges.\n if (\n prevPrevToken &&\n prevPrevToken.kind === ExcerptTokenKind.Reference &&\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.text.trim() === '.' &&\n currentToken.kind === ExcerptTokenKind.Reference &&\n !startOrEndIndices.has(currentIndex) &&\n !startOrEndIndices.has(currentIndex - 1)\n ) {\n // If the current token is a reference token, the previous token is a \".\", and the previous-\n // previous token is a reference token, then merge all three tokens into a reference token.\n //\n // For example: Given [\"MyNamespace\" (R), \".\", \"MyClass\" (R)], tokens \".\" and \"MyClass\" might\n // be merged into \"MyNamespace\". The condensed token would be [\"MyNamespace.MyClass\" (R)].\n prevPrevToken.text += prevToken.text + currentToken.text;\n prevPrevToken.canonicalReference = currentToken.canonicalReference;\n mergeCount = 2;\n currentIndex--;\n } else if (\n // If the current and previous tokens are both content tokens, then merge the tokens into a\n // single content token. For example: Given [\"export \", \"declare class\"], these tokens\n // might be merged into \"export declare class\".\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.kind === currentToken.kind &&\n !startOrEndIndices.has(currentIndex)\n ) {\n prevToken.text += currentToken.text;\n mergeCount = 1;\n } else {\n // Otherwise, no merging can occur here. Continue to the next index.\n break;\n }\n\n // Remove the now redundant excerpt token(s), as they were merged into a previous token.\n excerptTokens.splice(currentIndex, mergeCount);\n\n // Update the start and end indices for all token ranges based upon how many excerpt\n // tokens were merged and in what positions.\n for (const tokenRange of tokenRanges) {\n if (tokenRange.startIndex > currentIndex) {\n tokenRange.startIndex -= mergeCount;\n }\n\n if (tokenRange.endIndex > currentIndex) {\n tokenRange.endIndex -= mergeCount;\n }\n }\n\n // Clear and repopulate our set with the updated indices.\n startOrEndIndices.clear();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n }\n }\n }\n\n private static _isDeclarationName(name: ts.Identifier): boolean {\n return ExcerptBuilder._isDeclaration(name.parent) && name.parent.name === name;\n }\n\n private static _isDeclaration(node: ts.Node): node is ts.NamedDeclaration {\n switch (node.kind) {\n case ts.SyntaxKind.FunctionDeclaration:\n case ts.SyntaxKind.FunctionExpression:\n case ts.SyntaxKind.VariableDeclaration:\n case ts.SyntaxKind.Parameter:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ClassExpression:\n case ts.SyntaxKind.ModuleDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.TypeAliasDeclaration:\n case ts.SyntaxKind.TypeParameter:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.BindingElement:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/api-extractor",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.56.0",
|
|
4
4
|
"description": "Analyze the exported API for a TypeScript library and generate reviews, documentation, and .d.ts rollups",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"semver": "~7.5.4",
|
|
42
42
|
"source-map": "~0.6.1",
|
|
43
43
|
"typescript": "5.8.2",
|
|
44
|
-
"@rushstack/node-core-library": "5.19.1",
|
|
45
|
-
"@rushstack/rig-package": "0.6.0",
|
|
46
44
|
"@microsoft/api-extractor-model": "7.32.2",
|
|
47
|
-
"@rushstack/
|
|
48
|
-
"@rushstack/ts-command-line": "5.1.
|
|
45
|
+
"@rushstack/node-core-library": "5.19.1",
|
|
46
|
+
"@rushstack/ts-command-line": "5.1.7",
|
|
47
|
+
"@rushstack/terminal": "0.21.0",
|
|
48
|
+
"@rushstack/rig-package": "0.6.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@rushstack/heft": "1.1.
|
|
51
|
+
"@rushstack/heft": "1.1.7",
|
|
52
52
|
"@types/lodash": "4.14.116",
|
|
53
53
|
"@types/resolve": "1.20.2",
|
|
54
54
|
"@types/semver": "7.5.0",
|