@microsoft/api-extractor 7.56.2 → 7.57.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.
Files changed (298) hide show
  1. package/CHANGELOG.json +41 -0
  2. package/CHANGELOG.md +15 -1
  3. package/bin/api-extractor +1 -1
  4. package/lib-esm/aedoc/PackageDocComment.js +56 -0
  5. package/lib-esm/aedoc/PackageDocComment.js.map +1 -0
  6. package/lib-esm/analyzer/AstDeclaration.js +214 -0
  7. package/lib-esm/analyzer/AstDeclaration.js.map +1 -0
  8. package/lib-esm/analyzer/AstEntity.js +35 -0
  9. package/lib-esm/analyzer/AstEntity.js.map +1 -0
  10. package/lib-esm/analyzer/AstImport.js +76 -0
  11. package/lib-esm/analyzer/AstImport.js.map +1 -0
  12. package/lib-esm/analyzer/AstModule.js +22 -0
  13. package/lib-esm/analyzer/AstModule.js.map +1 -0
  14. package/lib-esm/analyzer/AstNamespaceExport.js +38 -0
  15. package/lib-esm/analyzer/AstNamespaceExport.js.map +1 -0
  16. package/lib-esm/analyzer/AstNamespaceImport.js +57 -0
  17. package/lib-esm/analyzer/AstNamespaceImport.js.map +1 -0
  18. package/lib-esm/analyzer/AstReferenceResolver.js +202 -0
  19. package/lib-esm/analyzer/AstReferenceResolver.js.map +1 -0
  20. package/lib-esm/analyzer/AstSymbol.js +104 -0
  21. package/lib-esm/analyzer/AstSymbol.js.map +1 -0
  22. package/lib-esm/analyzer/AstSymbolTable.js +524 -0
  23. package/lib-esm/analyzer/AstSymbolTable.js.map +1 -0
  24. package/lib-esm/analyzer/ExportAnalyzer.js +725 -0
  25. package/lib-esm/analyzer/ExportAnalyzer.js.map +1 -0
  26. package/lib-esm/analyzer/PackageMetadataManager.js +235 -0
  27. package/lib-esm/analyzer/PackageMetadataManager.js.map +1 -0
  28. package/lib-esm/analyzer/SourceFileLocationFormatter.js +44 -0
  29. package/lib-esm/analyzer/SourceFileLocationFormatter.js.map +1 -0
  30. package/lib-esm/analyzer/Span.js +545 -0
  31. package/lib-esm/analyzer/Span.js.map +1 -0
  32. package/lib-esm/analyzer/SyntaxHelpers.js +72 -0
  33. package/lib-esm/analyzer/SyntaxHelpers.js.map +1 -0
  34. package/lib-esm/analyzer/TypeScriptHelpers.js +242 -0
  35. package/lib-esm/analyzer/TypeScriptHelpers.js.map +1 -0
  36. package/lib-esm/analyzer/TypeScriptInternals.js +114 -0
  37. package/lib-esm/analyzer/TypeScriptInternals.js.map +1 -0
  38. package/lib-esm/api/CompilerState.js +149 -0
  39. package/lib-esm/api/CompilerState.js.map +1 -0
  40. package/lib-esm/api/ConsoleMessageId.js +82 -0
  41. package/lib-esm/api/ConsoleMessageId.js.map +1 -0
  42. package/lib-esm/api/Extractor.js +290 -0
  43. package/lib-esm/api/Extractor.js.map +1 -0
  44. package/lib-esm/api/ExtractorConfig.js +801 -0
  45. package/lib-esm/api/ExtractorConfig.js.map +1 -0
  46. package/lib-esm/api/ExtractorLogLevel.js +46 -0
  47. package/lib-esm/api/ExtractorLogLevel.js.map +1 -0
  48. package/lib-esm/api/ExtractorMessage.js +140 -0
  49. package/lib-esm/api/ExtractorMessage.js.map +1 -0
  50. package/lib-esm/api/ExtractorMessageId.js +128 -0
  51. package/lib-esm/api/ExtractorMessageId.js.map +1 -0
  52. package/lib-esm/api/IConfigFile.js +4 -0
  53. package/lib-esm/api/IConfigFile.js.map +1 -0
  54. package/lib-esm/cli/ApiExtractorCommandLine.js +51 -0
  55. package/lib-esm/cli/ApiExtractorCommandLine.js.map +1 -0
  56. package/lib-esm/cli/InitAction.js +35 -0
  57. package/lib-esm/cli/InitAction.js.map +1 -0
  58. package/lib-esm/cli/RunAction.js +123 -0
  59. package/lib-esm/cli/RunAction.js.map +1 -0
  60. package/lib-esm/collector/ApiItemMetadata.js +55 -0
  61. package/lib-esm/collector/ApiItemMetadata.js.map +1 -0
  62. package/lib-esm/collector/Collector.js +794 -0
  63. package/lib-esm/collector/Collector.js.map +1 -0
  64. package/lib-esm/collector/CollectorEntity.js +219 -0
  65. package/lib-esm/collector/CollectorEntity.js.map +1 -0
  66. package/lib-esm/collector/DeclarationMetadata.js +24 -0
  67. package/lib-esm/collector/DeclarationMetadata.js.map +1 -0
  68. package/lib-esm/collector/MessageRouter.js +476 -0
  69. package/lib-esm/collector/MessageRouter.js.map +1 -0
  70. package/lib-esm/collector/SourceMapper.js +171 -0
  71. package/lib-esm/collector/SourceMapper.js.map +1 -0
  72. package/lib-esm/collector/SymbolMetadata.js +12 -0
  73. package/lib-esm/collector/SymbolMetadata.js.map +1 -0
  74. package/lib-esm/collector/VisitorState.js +23 -0
  75. package/lib-esm/collector/VisitorState.js.map +1 -0
  76. package/lib-esm/collector/WorkingPackage.js +30 -0
  77. package/lib-esm/collector/WorkingPackage.js.map +1 -0
  78. package/lib-esm/enhancers/DocCommentEnhancer.js +213 -0
  79. package/lib-esm/enhancers/DocCommentEnhancer.js.map +1 -0
  80. package/lib-esm/enhancers/ValidationEnhancer.js +217 -0
  81. package/lib-esm/enhancers/ValidationEnhancer.js.map +1 -0
  82. package/lib-esm/generators/ApiModelGenerator.js +852 -0
  83. package/lib-esm/generators/ApiModelGenerator.js.map +1 -0
  84. package/lib-esm/generators/ApiReportGenerator.js +518 -0
  85. package/lib-esm/generators/ApiReportGenerator.js.map +1 -0
  86. package/lib-esm/generators/DeclarationReferenceGenerator.js +292 -0
  87. package/lib-esm/generators/DeclarationReferenceGenerator.js.map +1 -0
  88. package/lib-esm/generators/DtsEmitHelpers.js +227 -0
  89. package/lib-esm/generators/DtsEmitHelpers.js.map +1 -0
  90. package/lib-esm/generators/DtsRollupGenerator.js +391 -0
  91. package/lib-esm/generators/DtsRollupGenerator.js.map +1 -0
  92. package/lib-esm/generators/ExcerptBuilder.js +259 -0
  93. package/lib-esm/generators/ExcerptBuilder.js.map +1 -0
  94. package/lib-esm/generators/IndentedWriter.js +238 -0
  95. package/lib-esm/generators/IndentedWriter.js.map +1 -0
  96. package/lib-esm/index.js +17 -0
  97. package/lib-esm/index.js.map +1 -0
  98. package/lib-esm/schemas/api-extractor-defaults.json +94 -0
  99. package/lib-esm/schemas/api-extractor-template.json +454 -0
  100. package/lib-esm/schemas/api-extractor.schema.json +257 -0
  101. package/lib-esm/start.js +14 -0
  102. package/lib-esm/start.js.map +1 -0
  103. package/package.json +38 -12
  104. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js +0 -0
  105. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js.map +0 -0
  106. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js +0 -0
  107. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js.map +0 -0
  108. /package/{lib → lib-commonjs}/analyzer/AstEntity.js +0 -0
  109. /package/{lib → lib-commonjs}/analyzer/AstEntity.js.map +0 -0
  110. /package/{lib → lib-commonjs}/analyzer/AstImport.js +0 -0
  111. /package/{lib → lib-commonjs}/analyzer/AstImport.js.map +0 -0
  112. /package/{lib → lib-commonjs}/analyzer/AstModule.js +0 -0
  113. /package/{lib → lib-commonjs}/analyzer/AstModule.js.map +0 -0
  114. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js +0 -0
  115. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js.map +0 -0
  116. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js +0 -0
  117. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js.map +0 -0
  118. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js +0 -0
  119. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js.map +0 -0
  120. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js +0 -0
  121. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js.map +0 -0
  122. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js +0 -0
  123. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js.map +0 -0
  124. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js +0 -0
  125. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js.map +0 -0
  126. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js +0 -0
  127. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js.map +0 -0
  128. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js +0 -0
  129. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js.map +0 -0
  130. /package/{lib → lib-commonjs}/analyzer/Span.js +0 -0
  131. /package/{lib → lib-commonjs}/analyzer/Span.js.map +0 -0
  132. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js +0 -0
  133. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js.map +0 -0
  134. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js +0 -0
  135. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js.map +0 -0
  136. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js +0 -0
  137. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js.map +0 -0
  138. /package/{lib → lib-commonjs}/api/CompilerState.js +0 -0
  139. /package/{lib → lib-commonjs}/api/CompilerState.js.map +0 -0
  140. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js +0 -0
  141. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js.map +0 -0
  142. /package/{lib → lib-commonjs}/api/Extractor.js +0 -0
  143. /package/{lib → lib-commonjs}/api/Extractor.js.map +0 -0
  144. /package/{lib → lib-commonjs}/api/ExtractorConfig.js +0 -0
  145. /package/{lib → lib-commonjs}/api/ExtractorConfig.js.map +0 -0
  146. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js +0 -0
  147. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js.map +0 -0
  148. /package/{lib → lib-commonjs}/api/ExtractorMessage.js +0 -0
  149. /package/{lib → lib-commonjs}/api/ExtractorMessage.js.map +0 -0
  150. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js +0 -0
  151. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js.map +0 -0
  152. /package/{lib → lib-commonjs}/api/IConfigFile.js +0 -0
  153. /package/{lib → lib-commonjs}/api/IConfigFile.js.map +0 -0
  154. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js +0 -0
  155. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js.map +0 -0
  156. /package/{lib → lib-commonjs}/cli/InitAction.js +0 -0
  157. /package/{lib → lib-commonjs}/cli/InitAction.js.map +0 -0
  158. /package/{lib → lib-commonjs}/cli/RunAction.js +0 -0
  159. /package/{lib → lib-commonjs}/cli/RunAction.js.map +0 -0
  160. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js +0 -0
  161. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js.map +0 -0
  162. /package/{lib → lib-commonjs}/collector/Collector.js +0 -0
  163. /package/{lib → lib-commonjs}/collector/Collector.js.map +0 -0
  164. /package/{lib → lib-commonjs}/collector/CollectorEntity.js +0 -0
  165. /package/{lib → lib-commonjs}/collector/CollectorEntity.js.map +0 -0
  166. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js +0 -0
  167. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js.map +0 -0
  168. /package/{lib → lib-commonjs}/collector/MessageRouter.js +0 -0
  169. /package/{lib → lib-commonjs}/collector/MessageRouter.js.map +0 -0
  170. /package/{lib → lib-commonjs}/collector/SourceMapper.js +0 -0
  171. /package/{lib → lib-commonjs}/collector/SourceMapper.js.map +0 -0
  172. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js +0 -0
  173. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js.map +0 -0
  174. /package/{lib → lib-commonjs}/collector/VisitorState.js +0 -0
  175. /package/{lib → lib-commonjs}/collector/VisitorState.js.map +0 -0
  176. /package/{lib → lib-commonjs}/collector/WorkingPackage.js +0 -0
  177. /package/{lib → lib-commonjs}/collector/WorkingPackage.js.map +0 -0
  178. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js +0 -0
  179. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js.map +0 -0
  180. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js +0 -0
  181. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js.map +0 -0
  182. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js +0 -0
  183. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js.map +0 -0
  184. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js +0 -0
  185. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js.map +0 -0
  186. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js +0 -0
  187. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js.map +0 -0
  188. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js +0 -0
  189. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js.map +0 -0
  190. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js +0 -0
  191. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js.map +0 -0
  192. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js +0 -0
  193. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js.map +0 -0
  194. /package/{lib → lib-commonjs}/generators/IndentedWriter.js +0 -0
  195. /package/{lib → lib-commonjs}/generators/IndentedWriter.js.map +0 -0
  196. /package/{lib → lib-commonjs}/index.js +0 -0
  197. /package/{lib → lib-commonjs}/index.js.map +0 -0
  198. /package/{lib → lib-commonjs}/schemas/api-extractor-defaults.json +0 -0
  199. /package/{lib → lib-commonjs}/schemas/api-extractor-template.json +0 -0
  200. /package/{lib → lib-commonjs}/schemas/api-extractor.schema.json +0 -0
  201. /package/{lib → lib-commonjs}/start.js +0 -0
  202. /package/{lib → lib-commonjs}/start.js.map +0 -0
  203. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts +0 -0
  204. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts.map +0 -0
  205. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts +0 -0
  206. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts.map +0 -0
  207. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts +0 -0
  208. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts.map +0 -0
  209. /package/{lib → lib-dts}/analyzer/AstImport.d.ts +0 -0
  210. /package/{lib → lib-dts}/analyzer/AstImport.d.ts.map +0 -0
  211. /package/{lib → lib-dts}/analyzer/AstModule.d.ts +0 -0
  212. /package/{lib → lib-dts}/analyzer/AstModule.d.ts.map +0 -0
  213. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts +0 -0
  214. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts.map +0 -0
  215. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts +0 -0
  216. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts.map +0 -0
  217. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts +0 -0
  218. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts.map +0 -0
  219. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts +0 -0
  220. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts.map +0 -0
  221. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts +0 -0
  222. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts.map +0 -0
  223. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts +0 -0
  224. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts.map +0 -0
  225. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts +0 -0
  226. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts.map +0 -0
  227. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts +0 -0
  228. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts.map +0 -0
  229. /package/{lib → lib-dts}/analyzer/Span.d.ts +0 -0
  230. /package/{lib → lib-dts}/analyzer/Span.d.ts.map +0 -0
  231. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts +0 -0
  232. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts.map +0 -0
  233. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts +0 -0
  234. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts.map +0 -0
  235. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts +0 -0
  236. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts.map +0 -0
  237. /package/{lib → lib-dts}/api/CompilerState.d.ts +0 -0
  238. /package/{lib → lib-dts}/api/CompilerState.d.ts.map +0 -0
  239. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts +0 -0
  240. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts.map +0 -0
  241. /package/{lib → lib-dts}/api/Extractor.d.ts +0 -0
  242. /package/{lib → lib-dts}/api/Extractor.d.ts.map +0 -0
  243. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts +0 -0
  244. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts.map +0 -0
  245. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts +0 -0
  246. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts.map +0 -0
  247. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts +0 -0
  248. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts.map +0 -0
  249. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts +0 -0
  250. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts.map +0 -0
  251. /package/{lib → lib-dts}/api/IConfigFile.d.ts +0 -0
  252. /package/{lib → lib-dts}/api/IConfigFile.d.ts.map +0 -0
  253. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts +0 -0
  254. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts.map +0 -0
  255. /package/{lib → lib-dts}/cli/InitAction.d.ts +0 -0
  256. /package/{lib → lib-dts}/cli/InitAction.d.ts.map +0 -0
  257. /package/{lib → lib-dts}/cli/RunAction.d.ts +0 -0
  258. /package/{lib → lib-dts}/cli/RunAction.d.ts.map +0 -0
  259. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts +0 -0
  260. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts.map +0 -0
  261. /package/{lib → lib-dts}/collector/Collector.d.ts +0 -0
  262. /package/{lib → lib-dts}/collector/Collector.d.ts.map +0 -0
  263. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts +0 -0
  264. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts.map +0 -0
  265. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts +0 -0
  266. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts.map +0 -0
  267. /package/{lib → lib-dts}/collector/MessageRouter.d.ts +0 -0
  268. /package/{lib → lib-dts}/collector/MessageRouter.d.ts.map +0 -0
  269. /package/{lib → lib-dts}/collector/SourceMapper.d.ts +0 -0
  270. /package/{lib → lib-dts}/collector/SourceMapper.d.ts.map +0 -0
  271. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts +0 -0
  272. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts.map +0 -0
  273. /package/{lib → lib-dts}/collector/VisitorState.d.ts +0 -0
  274. /package/{lib → lib-dts}/collector/VisitorState.d.ts.map +0 -0
  275. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts +0 -0
  276. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts.map +0 -0
  277. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts +0 -0
  278. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts.map +0 -0
  279. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts +0 -0
  280. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts.map +0 -0
  281. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts +0 -0
  282. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts.map +0 -0
  283. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts +0 -0
  284. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts.map +0 -0
  285. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts +0 -0
  286. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts.map +0 -0
  287. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts +0 -0
  288. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts.map +0 -0
  289. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts +0 -0
  290. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts.map +0 -0
  291. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts +0 -0
  292. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts.map +0 -0
  293. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts +0 -0
  294. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts.map +0 -0
  295. /package/{lib → lib-dts}/index.d.ts +0 -0
  296. /package/{lib → lib-dts}/index.d.ts.map +0 -0
  297. /package/{lib → lib-dts}/start.d.ts +0 -0
  298. /package/{lib → lib-dts}/start.d.ts.map +0 -0
@@ -0,0 +1,171 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as path from 'node:path';
4
+ import { SourceMapConsumer } from 'source-map';
5
+ import { FileSystem, InternalError, JsonFile, NewlineKind } from '@rushstack/node-core-library';
6
+ export class SourceMapper {
7
+ constructor() {
8
+ // Map from .d.ts file path --> ISourceMap if a source map was found, or null if not found
9
+ this._sourceMapByFilePath = new Map();
10
+ // Cache the FileSystem.exists() result for mapped .ts files
11
+ this._originalFileInfoByPath = new Map();
12
+ }
13
+ /**
14
+ * Given a `.d.ts` source file and a specific position within the file, return the corresponding
15
+ * `ISourceLocation`.
16
+ */
17
+ getSourceLocation(options) {
18
+ const lineAndCharacter = options.sourceFile.getLineAndCharacterOfPosition(options.pos);
19
+ const sourceLocation = {
20
+ sourceFilePath: options.sourceFile.fileName,
21
+ sourceFileLine: lineAndCharacter.line + 1,
22
+ sourceFileColumn: lineAndCharacter.character + 1
23
+ };
24
+ if (options.useDtsLocation) {
25
+ return sourceLocation;
26
+ }
27
+ const mappedSourceLocation = this._getMappedSourceLocation(sourceLocation);
28
+ return mappedSourceLocation || sourceLocation;
29
+ }
30
+ _getMappedSourceLocation(sourceLocation) {
31
+ const { sourceFilePath, sourceFileLine, sourceFileColumn } = sourceLocation;
32
+ if (!FileSystem.exists(sourceFilePath)) {
33
+ // Sanity check
34
+ throw new InternalError('The referenced path was not found: ' + sourceFilePath);
35
+ }
36
+ const sourceMap = this._getSourceMap(sourceFilePath);
37
+ if (!sourceMap)
38
+ return;
39
+ const nearestMappingItem = SourceMapper._findNearestMappingItem(sourceMap.mappingItems, {
40
+ line: sourceFileLine,
41
+ column: sourceFileColumn
42
+ });
43
+ if (!nearestMappingItem)
44
+ return;
45
+ const mappedFilePath = path.resolve(path.dirname(sourceFilePath), nearestMappingItem.source);
46
+ // Does the mapped filename exist? Use a cache to remember the answer.
47
+ let originalFileInfo = this._originalFileInfoByPath.get(mappedFilePath);
48
+ if (originalFileInfo === undefined) {
49
+ originalFileInfo = {
50
+ fileExists: FileSystem.exists(mappedFilePath),
51
+ maxColumnForLine: []
52
+ };
53
+ if (originalFileInfo.fileExists) {
54
+ // Read the file and measure the length of each line
55
+ originalFileInfo.maxColumnForLine = FileSystem.readFile(mappedFilePath, {
56
+ convertLineEndings: NewlineKind.Lf
57
+ })
58
+ .split('\n')
59
+ .map((x) => x.length + 1); // +1 since columns are 1-based
60
+ originalFileInfo.maxColumnForLine.unshift(0); // Extra item since lines are 1-based
61
+ }
62
+ this._originalFileInfoByPath.set(mappedFilePath, originalFileInfo);
63
+ }
64
+ // Don't translate coordinates to a file that doesn't exist
65
+ if (!originalFileInfo.fileExists)
66
+ return;
67
+ // The nearestMappingItem anchor may be above/left of the real position, due to gaps in the mapping. Calculate
68
+ // the delta and apply it to the original position.
69
+ const guessedPosition = {
70
+ line: nearestMappingItem.originalLine + sourceFileLine - nearestMappingItem.generatedLine,
71
+ column: nearestMappingItem.originalColumn + sourceFileColumn - nearestMappingItem.generatedColumn
72
+ };
73
+ // Verify that the result is not out of bounds, in cause our heuristic failed
74
+ if (guessedPosition.line >= 1 &&
75
+ guessedPosition.line < originalFileInfo.maxColumnForLine.length &&
76
+ guessedPosition.column >= 1 &&
77
+ guessedPosition.column <= originalFileInfo.maxColumnForLine[guessedPosition.line]) {
78
+ return {
79
+ sourceFilePath: mappedFilePath,
80
+ sourceFileLine: guessedPosition.line,
81
+ sourceFileColumn: guessedPosition.column
82
+ };
83
+ }
84
+ else {
85
+ // The guessed position was out of bounds, so use the nearestMappingItem position instead.
86
+ return {
87
+ sourceFilePath: mappedFilePath,
88
+ sourceFileLine: nearestMappingItem.originalLine,
89
+ sourceFileColumn: nearestMappingItem.originalColumn
90
+ };
91
+ }
92
+ }
93
+ _getSourceMap(sourceFilePath) {
94
+ let sourceMap = this._sourceMapByFilePath.get(sourceFilePath);
95
+ if (sourceMap === undefined) {
96
+ // Normalize the path and redo the lookup
97
+ const normalizedPath = FileSystem.getRealPath(sourceFilePath);
98
+ sourceMap = this._sourceMapByFilePath.get(normalizedPath);
99
+ if (sourceMap !== undefined) {
100
+ // Copy the result from the normalized to the non-normalized key
101
+ this._sourceMapByFilePath.set(sourceFilePath, sourceMap);
102
+ }
103
+ else {
104
+ // Given "folder/file.d.ts", check for a corresponding "folder/file.d.ts.map"
105
+ const sourceMapPath = normalizedPath + '.map';
106
+ if (FileSystem.exists(sourceMapPath)) {
107
+ // Load up the source map
108
+ const rawSourceMap = JsonFile.load(sourceMapPath);
109
+ const sourceMapConsumer = new SourceMapConsumer(rawSourceMap);
110
+ const mappingItems = [];
111
+ // Extract the list of mapping items
112
+ sourceMapConsumer.eachMapping((mappingItem) => {
113
+ mappingItems.push({
114
+ ...mappingItem,
115
+ // The "source-map" package inexplicably uses 1-based line numbers but 0-based column numbers.
116
+ // Fix that up proactively so we don't have to deal with it later.
117
+ generatedColumn: mappingItem.generatedColumn + 1,
118
+ originalColumn: mappingItem.originalColumn + 1
119
+ });
120
+ }, this, SourceMapConsumer.GENERATED_ORDER);
121
+ sourceMap = { sourceMapConsumer, mappingItems };
122
+ }
123
+ else {
124
+ // No source map for this filename
125
+ sourceMap = null;
126
+ }
127
+ this._sourceMapByFilePath.set(normalizedPath, sourceMap);
128
+ if (sourceFilePath !== normalizedPath) {
129
+ // Add both keys to the map
130
+ this._sourceMapByFilePath.set(sourceFilePath, sourceMap);
131
+ }
132
+ }
133
+ }
134
+ return sourceMap;
135
+ }
136
+ // The `mappingItems` array is sorted by generatedLine/generatedColumn (GENERATED_ORDER).
137
+ // The _findNearestMappingItem() lookup is a simple binary search that returns the previous item
138
+ // if there is no exact match.
139
+ static _findNearestMappingItem(mappingItems, position) {
140
+ if (mappingItems.length === 0) {
141
+ return undefined;
142
+ }
143
+ let startIndex = 0;
144
+ let endIndex = mappingItems.length - 1;
145
+ while (startIndex <= endIndex) {
146
+ const middleIndex = startIndex + Math.floor((endIndex - startIndex) / 2);
147
+ const diff = SourceMapper._compareMappingItem(mappingItems[middleIndex], position);
148
+ if (diff < 0) {
149
+ startIndex = middleIndex + 1;
150
+ }
151
+ else if (diff > 0) {
152
+ endIndex = middleIndex - 1;
153
+ }
154
+ else {
155
+ // Exact match
156
+ return mappingItems[middleIndex];
157
+ }
158
+ }
159
+ // If we didn't find an exact match, then endIndex < startIndex.
160
+ // Take endIndex because it's the smaller value.
161
+ return mappingItems[endIndex];
162
+ }
163
+ static _compareMappingItem(mappingItem, position) {
164
+ const diff = mappingItem.generatedLine - position.line;
165
+ if (diff !== 0) {
166
+ return diff;
167
+ }
168
+ return mappingItem.generatedColumn - position.column;
169
+ }
170
+ }
171
+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;IACtB,MAAM,CAAC,uBAAuB,CACpC,YAA2B,EAC3B,QAAkB;QAElB,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,UAAU,GAAW,CAAC,CAAC;QAC3B,IAAI,QAAQ,GAAW,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QAE/C,OAAO,UAAU,IAAI,QAAQ,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAW,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YAEjF,MAAM,IAAI,GAAW,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;YAE3F,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;gBACb,UAAU,GAAG,WAAW,GAAG,CAAC,CAAC;YAC/B,CAAC;iBAAM,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;gBACpB,QAAQ,GAAG,WAAW,GAAG,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,cAAc;gBACd,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAED,gEAAgE;QAChE,gDAAgD;QAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,WAAwB,EAAE,QAAkB;QAC7E,MAAM,IAAI,GAAW,WAAW,CAAC,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC/D,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,WAAW,CAAC,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;IACvD,CAAC;CACF","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 path from 'node:path';\n\nimport { SourceMapConsumer, type RawSourceMap, type MappingItem, type Position } from 'source-map';\nimport type ts from 'typescript';\n\nimport { FileSystem, InternalError, JsonFile, NewlineKind } from '@rushstack/node-core-library';\n\ninterface ISourceMap {\n sourceMapConsumer: SourceMapConsumer;\n\n // SourceMapConsumer.originalPositionFor() is useless because the mapping contains numerous gaps,\n // and the API provides no way to find the nearest match. So instead we extract all the mapping items\n // and search them using SourceMapper._findNearestMappingItem().\n mappingItems: MappingItem[];\n}\n\ninterface IOriginalFileInfo {\n // Whether the .ts file exists\n fileExists: boolean;\n\n // This is used to check whether the guessed position is out of bounds.\n // Since column/line numbers are 1-based, the 0th item in this array is unused.\n maxColumnForLine: number[];\n}\n\nexport interface ISourceLocation {\n /**\n * The absolute path to the source file.\n */\n sourceFilePath: string;\n\n /**\n * The line number in the source file. The first line number is 1.\n */\n sourceFileLine: number;\n\n /**\n * The column number in the source file. The first column number is 1.\n */\n sourceFileColumn: number;\n}\n\nexport interface IGetSourceLocationOptions {\n /**\n * The source file to get the source location from.\n */\n sourceFile: ts.SourceFile;\n\n /**\n * The position within the source file to get the source location from.\n */\n pos: number;\n\n /**\n * If `false` or not provided, then we attempt to follow source maps in order to resolve the\n * location to the original `.ts` file. If resolution isn't possible for some reason, we fall\n * back to the `.d.ts` location.\n *\n * If `true`, then we don't bother following source maps, and the location refers to the `.d.ts`\n * location.\n */\n useDtsLocation?: boolean;\n}\n\nexport class SourceMapper {\n // Map from .d.ts file path --> ISourceMap if a source map was found, or null if not found\n private _sourceMapByFilePath: Map<string, ISourceMap | null> = new Map<string, ISourceMap | null>();\n\n // Cache the FileSystem.exists() result for mapped .ts files\n private _originalFileInfoByPath: Map<string, IOriginalFileInfo> = new Map<string, IOriginalFileInfo>();\n\n /**\n * Given a `.d.ts` source file and a specific position within the file, return the corresponding\n * `ISourceLocation`.\n */\n public getSourceLocation(options: IGetSourceLocationOptions): ISourceLocation {\n const lineAndCharacter: ts.LineAndCharacter = options.sourceFile.getLineAndCharacterOfPosition(\n options.pos\n );\n const sourceLocation: ISourceLocation = {\n sourceFilePath: options.sourceFile.fileName,\n sourceFileLine: lineAndCharacter.line + 1,\n sourceFileColumn: lineAndCharacter.character + 1\n };\n\n if (options.useDtsLocation) {\n return sourceLocation;\n }\n\n const mappedSourceLocation: ISourceLocation | undefined = this._getMappedSourceLocation(sourceLocation);\n return mappedSourceLocation || sourceLocation;\n }\n\n private _getMappedSourceLocation(sourceLocation: ISourceLocation): ISourceLocation | undefined {\n const { sourceFilePath, sourceFileLine, sourceFileColumn } = sourceLocation;\n\n if (!FileSystem.exists(sourceFilePath)) {\n // Sanity check\n throw new InternalError('The referenced path was not found: ' + sourceFilePath);\n }\n\n const sourceMap: ISourceMap | null = this._getSourceMap(sourceFilePath);\n if (!sourceMap) return;\n\n const nearestMappingItem: MappingItem | undefined = SourceMapper._findNearestMappingItem(\n sourceMap.mappingItems,\n {\n line: sourceFileLine,\n column: sourceFileColumn\n }\n );\n\n if (!nearestMappingItem) return;\n\n const mappedFilePath: string = path.resolve(path.dirname(sourceFilePath), nearestMappingItem.source);\n\n // Does the mapped filename exist? Use a cache to remember the answer.\n let originalFileInfo: IOriginalFileInfo | undefined = this._originalFileInfoByPath.get(mappedFilePath);\n if (originalFileInfo === undefined) {\n originalFileInfo = {\n fileExists: FileSystem.exists(mappedFilePath),\n maxColumnForLine: []\n };\n\n if (originalFileInfo.fileExists) {\n // Read the file and measure the length of each line\n originalFileInfo.maxColumnForLine = FileSystem.readFile(mappedFilePath, {\n convertLineEndings: NewlineKind.Lf\n })\n .split('\\n')\n .map((x) => x.length + 1); // +1 since columns are 1-based\n originalFileInfo.maxColumnForLine.unshift(0); // Extra item since lines are 1-based\n }\n\n this._originalFileInfoByPath.set(mappedFilePath, originalFileInfo);\n }\n\n // Don't translate coordinates to a file that doesn't exist\n if (!originalFileInfo.fileExists) return;\n\n // The nearestMappingItem anchor may be above/left of the real position, due to gaps in the mapping. Calculate\n // the delta and apply it to the original position.\n const guessedPosition: Position = {\n line: nearestMappingItem.originalLine + sourceFileLine - nearestMappingItem.generatedLine,\n column: nearestMappingItem.originalColumn + sourceFileColumn - nearestMappingItem.generatedColumn\n };\n\n // Verify that the result is not out of bounds, in cause our heuristic failed\n if (\n guessedPosition.line >= 1 &&\n guessedPosition.line < originalFileInfo.maxColumnForLine.length &&\n guessedPosition.column >= 1 &&\n guessedPosition.column <= originalFileInfo.maxColumnForLine[guessedPosition.line]\n ) {\n return {\n sourceFilePath: mappedFilePath,\n sourceFileLine: guessedPosition.line,\n sourceFileColumn: guessedPosition.column\n };\n } else {\n // The guessed position was out of bounds, so use the nearestMappingItem position instead.\n return {\n sourceFilePath: mappedFilePath,\n sourceFileLine: nearestMappingItem.originalLine,\n sourceFileColumn: nearestMappingItem.originalColumn\n };\n }\n }\n\n private _getSourceMap(sourceFilePath: string): ISourceMap | null {\n let sourceMap: ISourceMap | null | undefined = this._sourceMapByFilePath.get(sourceFilePath);\n\n if (sourceMap === undefined) {\n // Normalize the path and redo the lookup\n const normalizedPath: string = FileSystem.getRealPath(sourceFilePath);\n\n sourceMap = this._sourceMapByFilePath.get(normalizedPath);\n if (sourceMap !== undefined) {\n // Copy the result from the normalized to the non-normalized key\n this._sourceMapByFilePath.set(sourceFilePath, sourceMap);\n } else {\n // Given \"folder/file.d.ts\", check for a corresponding \"folder/file.d.ts.map\"\n const sourceMapPath: string = normalizedPath + '.map';\n if (FileSystem.exists(sourceMapPath)) {\n // Load up the source map\n const rawSourceMap: RawSourceMap = JsonFile.load(sourceMapPath) as RawSourceMap;\n\n const sourceMapConsumer: SourceMapConsumer = new SourceMapConsumer(rawSourceMap);\n const mappingItems: MappingItem[] = [];\n\n // Extract the list of mapping items\n sourceMapConsumer.eachMapping(\n (mappingItem: MappingItem) => {\n mappingItems.push({\n ...mappingItem,\n // The \"source-map\" package inexplicably uses 1-based line numbers but 0-based column numbers.\n // Fix that up proactively so we don't have to deal with it later.\n generatedColumn: mappingItem.generatedColumn + 1,\n originalColumn: mappingItem.originalColumn + 1\n });\n },\n this,\n SourceMapConsumer.GENERATED_ORDER\n );\n\n sourceMap = { sourceMapConsumer, mappingItems };\n } else {\n // No source map for this filename\n sourceMap = null;\n }\n\n this._sourceMapByFilePath.set(normalizedPath, sourceMap);\n if (sourceFilePath !== normalizedPath) {\n // Add both keys to the map\n this._sourceMapByFilePath.set(sourceFilePath, sourceMap);\n }\n }\n }\n\n return sourceMap;\n }\n\n // The `mappingItems` array is sorted by generatedLine/generatedColumn (GENERATED_ORDER).\n // The _findNearestMappingItem() lookup is a simple binary search that returns the previous item\n // if there is no exact match.\n private static _findNearestMappingItem(\n mappingItems: MappingItem[],\n position: Position\n ): MappingItem | undefined {\n if (mappingItems.length === 0) {\n return undefined;\n }\n\n let startIndex: number = 0;\n let endIndex: number = mappingItems.length - 1;\n\n while (startIndex <= endIndex) {\n const middleIndex: number = startIndex + Math.floor((endIndex - startIndex) / 2);\n\n const diff: number = SourceMapper._compareMappingItem(mappingItems[middleIndex], position);\n\n if (diff < 0) {\n startIndex = middleIndex + 1;\n } else if (diff > 0) {\n endIndex = middleIndex - 1;\n } else {\n // Exact match\n return mappingItems[middleIndex];\n }\n }\n\n // If we didn't find an exact match, then endIndex < startIndex.\n // Take endIndex because it's the smaller value.\n return mappingItems[endIndex];\n }\n\n private static _compareMappingItem(mappingItem: MappingItem, position: Position): number {\n const diff: number = mappingItem.generatedLine - position.line;\n if (diff !== 0) {\n return diff;\n }\n return mappingItem.generatedColumn - position.column;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * Stores the Collector's additional analysis for an `AstSymbol`. This object is assigned to `AstSymbol.metadata`
5
+ * but consumers must always obtain it by calling `Collector.fetchSymbolMetadata()`.
6
+ */
7
+ export class SymbolMetadata {
8
+ constructor(options) {
9
+ this.maxEffectiveReleaseTag = options.maxEffectiveReleaseTag;
10
+ }
11
+ }
12
+ //# sourceMappingURL=SymbolMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SymbolMetadata.js","sourceRoot":"","sources":["../../src/collector/SymbolMetadata.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAW3D;;;GAGG;AACH,MAAM,OAAO,cAAc;IAKzB,YAAmB,OAA+B;QAChD,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAC/D,CAAC;CACF","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 type { ReleaseTag } from '@microsoft/api-extractor-model';\n\n/**\n * Constructor parameters for `SymbolMetadata`.\n */\nexport interface ISymbolMetadataOptions {\n maxEffectiveReleaseTag: ReleaseTag;\n}\n\n/**\n * Stores the Collector's additional analysis for an `AstSymbol`. This object is assigned to `AstSymbol.metadata`\n * but consumers must always obtain it by calling `Collector.fetchSymbolMetadata()`.\n */\nexport class SymbolMetadata {\n // For all declarations associated with this symbol, this is the\n // `ApiItemMetadata.effectiveReleaseTag` value that is most public.\n public readonly maxEffectiveReleaseTag: ReleaseTag;\n\n public constructor(options: ISymbolMetadataOptions) {\n this.maxEffectiveReleaseTag = options.maxEffectiveReleaseTag;\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * Keeps track of a directed graph traversal that needs to detect cycles.
5
+ */
6
+ export var VisitorState;
7
+ (function (VisitorState) {
8
+ /**
9
+ * We have not visited the node yet.
10
+ */
11
+ VisitorState[VisitorState["Unvisited"] = 0] = "Unvisited";
12
+ /**
13
+ * We have visited the node, but have not finished traversing its references yet.
14
+ * If we reach a node that is already in the `Visiting` state, this means we have
15
+ * encountered a cyclic reference.
16
+ */
17
+ VisitorState[VisitorState["Visiting"] = 1] = "Visiting";
18
+ /**
19
+ * We are finished vising the node and all its references.
20
+ */
21
+ VisitorState[VisitorState["Visited"] = 2] = "Visited";
22
+ })(VisitorState || (VisitorState = {}));
23
+ //# sourceMappingURL=VisitorState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisitorState.js","sourceRoot":"","sources":["../../src/collector/VisitorState.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;GAEG;AACH,MAAM,CAAN,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACtB;;OAEG;IACH,yDAAa,CAAA;IAEb;;;;OAIG;IACH,uDAAY,CAAA;IAEZ;;OAEG;IACH,qDAAW,CAAA;AACb,CAAC,EAjBW,YAAY,KAAZ,YAAY,QAiBvB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Keeps track of a directed graph traversal that needs to detect cycles.\n */\nexport enum VisitorState {\n /**\n * We have not visited the node yet.\n */\n Unvisited = 0,\n\n /**\n * We have visited the node, but have not finished traversing its references yet.\n * If we reach a node that is already in the `Visiting` state, this means we have\n * encountered a cyclic reference.\n */\n Visiting = 1,\n\n /**\n * We are finished vising the node and all its references.\n */\n Visited = 2\n}\n"]}
@@ -0,0 +1,30 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * Information about the working package for a particular invocation of API Extractor.
5
+ *
6
+ * @remarks
7
+ * API Extractor tries to model the world as a collection of NPM packages, such that each
8
+ * .d.ts file belongs to at most one package. When API Extractor is invoked on a project,
9
+ * we refer to that project as being the "working package". There is exactly one
10
+ * "working package" for the duration of this analysis. Any files that do not belong to
11
+ * the working package are referred to as "external": external declarations belonging to
12
+ * external packages.
13
+ *
14
+ * If API Extractor is invoked on a standalone .d.ts file, the "working package" may not
15
+ * have an actual package.json file on disk, but we still refer to it in concept.
16
+ */
17
+ export class WorkingPackage {
18
+ constructor(options) {
19
+ this.packageFolder = options.packageFolder;
20
+ this.packageJson = options.packageJson;
21
+ this.entryPointSourceFile = options.entryPointSourceFile;
22
+ }
23
+ /**
24
+ * Returns the full name of the working package.
25
+ */
26
+ get name() {
27
+ return this.packageJson.name;
28
+ }
29
+ }
30
+ //# sourceMappingURL=WorkingPackage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkingPackage.js","sourceRoot":"","sources":["../../src/collector/WorkingPackage.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAgB3D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAc;IAmCzB,YAAmB,OAA+B;QAChD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF","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 type * as ts from 'typescript';\n\nimport type * as tsdoc from '@microsoft/tsdoc';\nimport type { INodePackageJson } from '@rushstack/node-core-library';\n\n/**\n * Constructor options for WorkingPackage\n */\nexport interface IWorkingPackageOptions {\n packageFolder: string;\n packageJson: INodePackageJson;\n entryPointSourceFile: ts.SourceFile;\n}\n\n/**\n * Information about the working package for a particular invocation of API Extractor.\n *\n * @remarks\n * API Extractor tries to model the world as a collection of NPM packages, such that each\n * .d.ts file belongs to at most one package. When API Extractor is invoked on a project,\n * we refer to that project as being the \"working package\". There is exactly one\n * \"working package\" for the duration of this analysis. Any files that do not belong to\n * the working package are referred to as \"external\": external declarations belonging to\n * external packages.\n *\n * If API Extractor is invoked on a standalone .d.ts file, the \"working package\" may not\n * have an actual package.json file on disk, but we still refer to it in concept.\n */\nexport class WorkingPackage {\n /**\n * Returns the folder for the package.json file of the working package.\n *\n * @remarks\n * If the entry point is `C:\\Folder\\project\\src\\index.ts` and the nearest package.json\n * is `C:\\Folder\\project\\package.json`, then the packageFolder is `C:\\Folder\\project`\n */\n public readonly packageFolder: string;\n\n /**\n * The parsed package.json file for the working package.\n */\n public readonly packageJson: INodePackageJson;\n\n /**\n * The entry point being processed during this invocation of API Extractor.\n *\n * @remarks\n * The working package may have multiple entry points; however, today API Extractor\n * only processes a single entry point during an invocation. This will be improved\n * in the future.\n */\n public readonly entryPointSourceFile: ts.SourceFile;\n\n /**\n * The `@packageDocumentation` comment, if any, for the working package.\n */\n public tsdocComment: tsdoc.DocComment | undefined;\n\n /**\n * Additional parser information for `WorkingPackage.tsdocComment`.\n */\n public tsdocParserContext: tsdoc.ParserContext | undefined;\n\n public constructor(options: IWorkingPackageOptions) {\n this.packageFolder = options.packageFolder;\n this.packageJson = options.packageJson;\n this.entryPointSourceFile = options.entryPointSourceFile;\n }\n\n /**\n * Returns the full name of the working package.\n */\n public get name(): string {\n return this.packageJson.name;\n }\n}\n"]}
@@ -0,0 +1,213 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as ts from 'typescript';
4
+ import * as tsdoc from '@microsoft/tsdoc';
5
+ import { ReleaseTag } from '@microsoft/api-extractor-model';
6
+ import { AstSymbol } from '../analyzer/AstSymbol';
7
+ import { ExtractorMessageId } from '../api/ExtractorMessageId';
8
+ import { VisitorState } from '../collector/VisitorState';
9
+ import { ResolverFailure } from '../analyzer/AstReferenceResolver';
10
+ export class DocCommentEnhancer {
11
+ constructor(collector) {
12
+ this._collector = collector;
13
+ }
14
+ static analyze(collector) {
15
+ const docCommentEnhancer = new DocCommentEnhancer(collector);
16
+ docCommentEnhancer.analyze();
17
+ }
18
+ analyze() {
19
+ for (const entity of this._collector.entities) {
20
+ if (entity.astEntity instanceof AstSymbol) {
21
+ if (entity.consumable ||
22
+ this._collector.extractorConfig.apiReportIncludeForgottenExports ||
23
+ this._collector.extractorConfig.docModelIncludeForgottenExports) {
24
+ entity.astEntity.forEachDeclarationRecursive((astDeclaration) => {
25
+ this._analyzeApiItem(astDeclaration);
26
+ });
27
+ }
28
+ }
29
+ }
30
+ }
31
+ _analyzeApiItem(astDeclaration) {
32
+ const metadata = this._collector.fetchApiItemMetadata(astDeclaration);
33
+ if (metadata.docCommentEnhancerVisitorState === VisitorState.Visited) {
34
+ return;
35
+ }
36
+ if (metadata.docCommentEnhancerVisitorState === VisitorState.Visiting) {
37
+ this._collector.messageRouter.addAnalyzerIssue(ExtractorMessageId.CyclicInheritDoc, `The @inheritDoc tag for "${astDeclaration.astSymbol.localName}" refers to its own declaration`, astDeclaration);
38
+ return;
39
+ }
40
+ metadata.docCommentEnhancerVisitorState = VisitorState.Visiting;
41
+ if (metadata.tsdocComment && metadata.tsdocComment.inheritDocTag) {
42
+ this._applyInheritDoc(astDeclaration, metadata.tsdocComment, metadata.tsdocComment.inheritDocTag);
43
+ }
44
+ this._analyzeNeedsDocumentation(astDeclaration, metadata);
45
+ this._checkForBrokenLinks(astDeclaration, metadata);
46
+ metadata.docCommentEnhancerVisitorState = VisitorState.Visited;
47
+ }
48
+ _analyzeNeedsDocumentation(astDeclaration, metadata) {
49
+ if (astDeclaration.declaration.kind === ts.SyntaxKind.Constructor) {
50
+ // Constructors always do pretty much the same thing, so it's annoying to require people to write
51
+ // descriptions for them. Instead, if the constructor lacks a TSDoc summary, then API Extractor
52
+ // will auto-generate one.
53
+ metadata.undocumented = false;
54
+ // The class that contains this constructor
55
+ const classDeclaration = astDeclaration.parent;
56
+ const configuration = this._collector.extractorConfig.tsdocConfiguration;
57
+ if (!metadata.tsdocComment) {
58
+ metadata.tsdocComment = new tsdoc.DocComment({ configuration });
59
+ }
60
+ if (!tsdoc.PlainTextEmitter.hasAnyTextContent(metadata.tsdocComment.summarySection)) {
61
+ metadata.tsdocComment.summarySection.appendNodesInParagraph([
62
+ new tsdoc.DocPlainText({ configuration, text: 'Constructs a new instance of the ' }),
63
+ new tsdoc.DocCodeSpan({
64
+ configuration,
65
+ code: classDeclaration.astSymbol.localName
66
+ }),
67
+ new tsdoc.DocPlainText({ configuration, text: ' class' })
68
+ ]);
69
+ }
70
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
71
+ if (apiItemMetadata.effectiveReleaseTag === ReleaseTag.Internal) {
72
+ // If the constructor is marked as internal, then add a boilerplate notice for the containing class
73
+ const classMetadata = this._collector.fetchApiItemMetadata(classDeclaration);
74
+ if (!classMetadata.tsdocComment) {
75
+ classMetadata.tsdocComment = new tsdoc.DocComment({ configuration });
76
+ }
77
+ if (classMetadata.tsdocComment.remarksBlock === undefined) {
78
+ classMetadata.tsdocComment.remarksBlock = new tsdoc.DocBlock({
79
+ configuration,
80
+ blockTag: new tsdoc.DocBlockTag({
81
+ configuration,
82
+ tagName: tsdoc.StandardTags.remarks.tagName
83
+ })
84
+ });
85
+ }
86
+ classMetadata.tsdocComment.remarksBlock.content.appendNode(new tsdoc.DocParagraph({ configuration }, [
87
+ new tsdoc.DocPlainText({
88
+ configuration,
89
+ text: `The constructor for this class is marked as internal. Third-party code should not` +
90
+ ` call the constructor directly or create subclasses that extend the `
91
+ }),
92
+ new tsdoc.DocCodeSpan({
93
+ configuration,
94
+ code: classDeclaration.astSymbol.localName
95
+ }),
96
+ new tsdoc.DocPlainText({ configuration, text: ' class.' })
97
+ ]));
98
+ }
99
+ return;
100
+ }
101
+ else {
102
+ // For non-constructor items, we will determine whether or not the item is documented as follows:
103
+ // 1. If it contains a summary section with at least 10 characters, then it is considered "documented".
104
+ // 2. If it contains an @inheritDoc tag, then it *may* be considered "documented", depending on whether or not
105
+ // the tag resolves to a "documented" API member.
106
+ // - Note: for external members, we cannot currently determine this, so we will consider the "documented"
107
+ // status to be unknown.
108
+ if (metadata.tsdocComment) {
109
+ if (tsdoc.PlainTextEmitter.hasAnyTextContent(metadata.tsdocComment.summarySection, 10)) {
110
+ // If the API item has a summary comment block (with at least 10 characters), mark it as "documented".
111
+ metadata.undocumented = false;
112
+ }
113
+ else if (metadata.tsdocComment.inheritDocTag) {
114
+ if (this._refersToDeclarationInWorkingPackage(metadata.tsdocComment.inheritDocTag.declarationReference)) {
115
+ // If the API item has an `@inheritDoc` comment that points to an API item in the working package,
116
+ // then the documentation contents should have already been copied from the target via `_applyInheritDoc`.
117
+ // The continued existence of the tag indicates that the declaration reference was invalid, and not
118
+ // documentation contents could be copied.
119
+ // An analyzer issue will have already been logged for this.
120
+ // We will treat such an API as "undocumented".
121
+ metadata.undocumented = true;
122
+ }
123
+ else {
124
+ // If the API item has an `@inheritDoc` comment that points to an external API item, we cannot currently
125
+ // determine whether or not the target is "documented", so we cannot say definitively that this is "undocumented".
126
+ metadata.undocumented = false;
127
+ }
128
+ }
129
+ else {
130
+ // If the API item has neither a summary comment block, nor an `@inheritDoc` comment, mark it as "undocumented".
131
+ metadata.undocumented = true;
132
+ }
133
+ }
134
+ else {
135
+ // If there is no tsdoc comment at all, mark "undocumented".
136
+ metadata.undocumented = true;
137
+ }
138
+ }
139
+ }
140
+ _checkForBrokenLinks(astDeclaration, metadata) {
141
+ if (!metadata.tsdocComment) {
142
+ return;
143
+ }
144
+ this._checkForBrokenLinksRecursive(astDeclaration, metadata.tsdocComment);
145
+ }
146
+ _checkForBrokenLinksRecursive(astDeclaration, node) {
147
+ if (node instanceof tsdoc.DocLinkTag) {
148
+ if (node.codeDestination) {
149
+ // Is it referring to the working package? If not, we don't do any link validation, because
150
+ // AstReferenceResolver doesn't support it yet (but ModelReferenceResolver does of course).
151
+ // Tracked by: https://github.com/microsoft/rushstack/issues/1195
152
+ if (this._refersToDeclarationInWorkingPackage(node.codeDestination)) {
153
+ const referencedAstDeclaration = this._collector.astReferenceResolver.resolve(node.codeDestination);
154
+ if (referencedAstDeclaration instanceof ResolverFailure) {
155
+ this._collector.messageRouter.addAnalyzerIssue(ExtractorMessageId.UnresolvedLink, 'The @link reference could not be resolved: ' + referencedAstDeclaration.reason, astDeclaration);
156
+ }
157
+ }
158
+ }
159
+ }
160
+ for (const childNode of node.getChildNodes()) {
161
+ this._checkForBrokenLinksRecursive(astDeclaration, childNode);
162
+ }
163
+ }
164
+ /**
165
+ * Follow an `{@inheritDoc ___}` reference and copy the content that we find in the referenced comment.
166
+ */
167
+ _applyInheritDoc(astDeclaration, docComment, inheritDocTag) {
168
+ if (!inheritDocTag.declarationReference) {
169
+ this._collector.messageRouter.addAnalyzerIssue(ExtractorMessageId.UnresolvedInheritDocBase, 'The @inheritDoc tag needs a TSDoc declaration reference; signature matching is not supported yet', astDeclaration);
170
+ return;
171
+ }
172
+ if (!this._refersToDeclarationInWorkingPackage(inheritDocTag.declarationReference)) {
173
+ // The `@inheritDoc` tag is referencing an external package. Skip it, since AstReferenceResolver doesn't
174
+ // support it yet. As a workaround, this tag will get handled later by api-documenter.
175
+ // Tracked by: https://github.com/microsoft/rushstack/issues/1195
176
+ return;
177
+ }
178
+ const referencedAstDeclaration = this._collector.astReferenceResolver.resolve(inheritDocTag.declarationReference);
179
+ if (referencedAstDeclaration instanceof ResolverFailure) {
180
+ this._collector.messageRouter.addAnalyzerIssue(ExtractorMessageId.UnresolvedInheritDocReference, 'The @inheritDoc reference could not be resolved: ' + referencedAstDeclaration.reason, astDeclaration);
181
+ return;
182
+ }
183
+ this._analyzeApiItem(referencedAstDeclaration);
184
+ const referencedMetadata = this._collector.fetchApiItemMetadata(referencedAstDeclaration);
185
+ if (referencedMetadata.tsdocComment) {
186
+ this._copyInheritedDocs(docComment, referencedMetadata.tsdocComment);
187
+ }
188
+ }
189
+ /**
190
+ * Copy the content from `sourceDocComment` to `targetDocComment`.
191
+ */
192
+ _copyInheritedDocs(targetDocComment, sourceDocComment) {
193
+ targetDocComment.summarySection = sourceDocComment.summarySection;
194
+ targetDocComment.remarksBlock = sourceDocComment.remarksBlock;
195
+ targetDocComment.params.clear();
196
+ for (const param of sourceDocComment.params) {
197
+ targetDocComment.params.add(param);
198
+ }
199
+ for (const typeParam of sourceDocComment.typeParams) {
200
+ targetDocComment.typeParams.add(typeParam);
201
+ }
202
+ targetDocComment.returnsBlock = sourceDocComment.returnsBlock;
203
+ targetDocComment.inheritDocTag = undefined;
204
+ }
205
+ /**
206
+ * Determines whether or not the provided declaration reference points to an item in the working package.
207
+ */
208
+ _refersToDeclarationInWorkingPackage(declarationReference) {
209
+ return ((declarationReference === null || declarationReference === void 0 ? void 0 : declarationReference.packageName) === undefined ||
210
+ declarationReference.packageName === this._collector.workingPackage.name);
211
+ }
212
+ }
213
+ //# sourceMappingURL=DocCommentEnhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocCommentEnhancer.js","sourceRoot":"","sources":["../../src/enhancers/DocCommentEnhancer.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,OAAO,kBAAkB;IAG7B,YAAmB,SAAoB;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,SAAoB;QACxC,MAAM,kBAAkB,GAAuB,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACjF,kBAAkB,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAEM,OAAO;QACZ,KAAK,MAAM,M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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 * as tsdoc from '@microsoft/tsdoc';\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\n\nimport type { Collector } from '../collector/Collector';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\nimport { VisitorState } from '../collector/VisitorState';\nimport { ResolverFailure } from '../analyzer/AstReferenceResolver';\n\nexport class DocCommentEnhancer {\n private readonly _collector: Collector;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n }\n\n public static analyze(collector: Collector): void {\n const docCommentEnhancer: DocCommentEnhancer = new DocCommentEnhancer(collector);\n docCommentEnhancer.analyze();\n }\n\n public analyze(): void {\n for (const entity of this._collector.entities) {\n if (entity.astEntity instanceof AstSymbol) {\n if (\n entity.consumable ||\n this._collector.extractorConfig.apiReportIncludeForgottenExports ||\n this._collector.extractorConfig.docModelIncludeForgottenExports\n ) {\n entity.astEntity.forEachDeclarationRecursive((astDeclaration: AstDeclaration) => {\n this._analyzeApiItem(astDeclaration);\n });\n }\n }\n }\n }\n\n private _analyzeApiItem(astDeclaration: AstDeclaration): void {\n const metadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);\n if (metadata.docCommentEnhancerVisitorState === VisitorState.Visited) {\n return;\n }\n\n if (metadata.docCommentEnhancerVisitorState === VisitorState.Visiting) {\n this._collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.CyclicInheritDoc,\n `The @inheritDoc tag for \"${astDeclaration.astSymbol.localName}\" refers to its own declaration`,\n astDeclaration\n );\n return;\n }\n metadata.docCommentEnhancerVisitorState = VisitorState.Visiting;\n\n if (metadata.tsdocComment && metadata.tsdocComment.inheritDocTag) {\n this._applyInheritDoc(astDeclaration, metadata.tsdocComment, metadata.tsdocComment.inheritDocTag);\n }\n\n this._analyzeNeedsDocumentation(astDeclaration, metadata);\n\n this._checkForBrokenLinks(astDeclaration, metadata);\n\n metadata.docCommentEnhancerVisitorState = VisitorState.Visited;\n }\n\n private _analyzeNeedsDocumentation(astDeclaration: AstDeclaration, metadata: ApiItemMetadata): void {\n if (astDeclaration.declaration.kind === ts.SyntaxKind.Constructor) {\n // Constructors always do pretty much the same thing, so it's annoying to require people to write\n // descriptions for them. Instead, if the constructor lacks a TSDoc summary, then API Extractor\n // will auto-generate one.\n metadata.undocumented = false;\n\n // The class that contains this constructor\n const classDeclaration: AstDeclaration = astDeclaration.parent!;\n\n const configuration: tsdoc.TSDocConfiguration = this._collector.extractorConfig.tsdocConfiguration;\n\n if (!metadata.tsdocComment) {\n metadata.tsdocComment = new tsdoc.DocComment({ configuration });\n }\n\n if (!tsdoc.PlainTextEmitter.hasAnyTextContent(metadata.tsdocComment.summarySection)) {\n metadata.tsdocComment.summarySection.appendNodesInParagraph([\n new tsdoc.DocPlainText({ configuration, text: 'Constructs a new instance of the ' }),\n new tsdoc.DocCodeSpan({\n configuration,\n code: classDeclaration.astSymbol.localName\n }),\n new tsdoc.DocPlainText({ configuration, text: ' class' })\n ]);\n }\n\n const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);\n if (apiItemMetadata.effectiveReleaseTag === ReleaseTag.Internal) {\n // If the constructor is marked as internal, then add a boilerplate notice for the containing class\n const classMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(classDeclaration);\n\n if (!classMetadata.tsdocComment) {\n classMetadata.tsdocComment = new tsdoc.DocComment({ configuration });\n }\n\n if (classMetadata.tsdocComment.remarksBlock === undefined) {\n classMetadata.tsdocComment.remarksBlock = new tsdoc.DocBlock({\n configuration,\n blockTag: new tsdoc.DocBlockTag({\n configuration,\n tagName: tsdoc.StandardTags.remarks.tagName\n })\n });\n }\n\n classMetadata.tsdocComment.remarksBlock.content.appendNode(\n new tsdoc.DocParagraph({ configuration }, [\n new tsdoc.DocPlainText({\n configuration,\n text:\n `The constructor for this class is marked as internal. Third-party code should not` +\n ` call the constructor directly or create subclasses that extend the `\n }),\n new tsdoc.DocCodeSpan({\n configuration,\n code: classDeclaration.astSymbol.localName\n }),\n new tsdoc.DocPlainText({ configuration, text: ' class.' })\n ])\n );\n }\n return;\n } else {\n // For non-constructor items, we will determine whether or not the item is documented as follows:\n // 1. If it contains a summary section with at least 10 characters, then it is considered \"documented\".\n // 2. If it contains an @inheritDoc tag, then it *may* be considered \"documented\", depending on whether or not\n // the tag resolves to a \"documented\" API member.\n // - Note: for external members, we cannot currently determine this, so we will consider the \"documented\"\n // status to be unknown.\n if (metadata.tsdocComment) {\n if (tsdoc.PlainTextEmitter.hasAnyTextContent(metadata.tsdocComment.summarySection, 10)) {\n // If the API item has a summary comment block (with at least 10 characters), mark it as \"documented\".\n metadata.undocumented = false;\n } else if (metadata.tsdocComment.inheritDocTag) {\n if (\n this._refersToDeclarationInWorkingPackage(\n metadata.tsdocComment.inheritDocTag.declarationReference\n )\n ) {\n // If the API item has an `@inheritDoc` comment that points to an API item in the working package,\n // then the documentation contents should have already been copied from the target via `_applyInheritDoc`.\n // The continued existence of the tag indicates that the declaration reference was invalid, and not\n // documentation contents could be copied.\n // An analyzer issue will have already been logged for this.\n // We will treat such an API as \"undocumented\".\n metadata.undocumented = true;\n } else {\n // If the API item has an `@inheritDoc` comment that points to an external API item, we cannot currently\n // determine whether or not the target is \"documented\", so we cannot say definitively that this is \"undocumented\".\n metadata.undocumented = false;\n }\n } else {\n // If the API item has neither a summary comment block, nor an `@inheritDoc` comment, mark it as \"undocumented\".\n metadata.undocumented = true;\n }\n } else {\n // If there is no tsdoc comment at all, mark \"undocumented\".\n metadata.undocumented = true;\n }\n }\n }\n\n private _checkForBrokenLinks(astDeclaration: AstDeclaration, metadata: ApiItemMetadata): void {\n if (!metadata.tsdocComment) {\n return;\n }\n this._checkForBrokenLinksRecursive(astDeclaration, metadata.tsdocComment);\n }\n\n private _checkForBrokenLinksRecursive(astDeclaration: AstDeclaration, node: tsdoc.DocNode): void {\n if (node instanceof tsdoc.DocLinkTag) {\n if (node.codeDestination) {\n // Is it referring to the working package? If not, we don't do any link validation, because\n // AstReferenceResolver doesn't support it yet (but ModelReferenceResolver does of course).\n // Tracked by: https://github.com/microsoft/rushstack/issues/1195\n if (this._refersToDeclarationInWorkingPackage(node.codeDestination)) {\n const referencedAstDeclaration: AstDeclaration | ResolverFailure =\n this._collector.astReferenceResolver.resolve(node.codeDestination);\n\n if (referencedAstDeclaration instanceof ResolverFailure) {\n this._collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.UnresolvedLink,\n 'The @link reference could not be resolved: ' + referencedAstDeclaration.reason,\n astDeclaration\n );\n }\n }\n }\n }\n for (const childNode of node.getChildNodes()) {\n this._checkForBrokenLinksRecursive(astDeclaration, childNode);\n }\n }\n\n /**\n * Follow an `{@inheritDoc ___}` reference and copy the content that we find in the referenced comment.\n */\n private _applyInheritDoc(\n astDeclaration: AstDeclaration,\n docComment: tsdoc.DocComment,\n inheritDocTag: tsdoc.DocInheritDocTag\n ): void {\n if (!inheritDocTag.declarationReference) {\n this._collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.UnresolvedInheritDocBase,\n 'The @inheritDoc tag needs a TSDoc declaration reference; signature matching is not supported yet',\n astDeclaration\n );\n return;\n }\n\n if (!this._refersToDeclarationInWorkingPackage(inheritDocTag.declarationReference)) {\n // The `@inheritDoc` tag is referencing an external package. Skip it, since AstReferenceResolver doesn't\n // support it yet. As a workaround, this tag will get handled later by api-documenter.\n // Tracked by: https://github.com/microsoft/rushstack/issues/1195\n return;\n }\n\n const referencedAstDeclaration: AstDeclaration | ResolverFailure =\n this._collector.astReferenceResolver.resolve(inheritDocTag.declarationReference);\n\n if (referencedAstDeclaration instanceof ResolverFailure) {\n this._collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.UnresolvedInheritDocReference,\n 'The @inheritDoc reference could not be resolved: ' + referencedAstDeclaration.reason,\n astDeclaration\n );\n return;\n }\n\n this._analyzeApiItem(referencedAstDeclaration);\n\n const referencedMetadata: ApiItemMetadata =\n this._collector.fetchApiItemMetadata(referencedAstDeclaration);\n\n if (referencedMetadata.tsdocComment) {\n this._copyInheritedDocs(docComment, referencedMetadata.tsdocComment);\n }\n }\n\n /**\n * Copy the content from `sourceDocComment` to `targetDocComment`.\n */\n private _copyInheritedDocs(targetDocComment: tsdoc.DocComment, sourceDocComment: tsdoc.DocComment): void {\n targetDocComment.summarySection = sourceDocComment.summarySection;\n targetDocComment.remarksBlock = sourceDocComment.remarksBlock;\n\n targetDocComment.params.clear();\n for (const param of sourceDocComment.params) {\n targetDocComment.params.add(param);\n }\n for (const typeParam of sourceDocComment.typeParams) {\n targetDocComment.typeParams.add(typeParam);\n }\n targetDocComment.returnsBlock = sourceDocComment.returnsBlock;\n\n targetDocComment.inheritDocTag = undefined;\n }\n\n /**\n * Determines whether or not the provided declaration reference points to an item in the working package.\n */\n private _refersToDeclarationInWorkingPackage(\n declarationReference: tsdoc.DocDeclarationReference | undefined\n ): boolean {\n return (\n declarationReference?.packageName === undefined ||\n declarationReference.packageName === this._collector.workingPackage.name\n );\n }\n}\n"]}