@microsoft/api-documenter 7.28.9 → 7.29.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 (209) hide show
  1. package/CHANGELOG.json +29 -0
  2. package/CHANGELOG.md +8 -1
  3. package/bin/api-documenter +1 -1
  4. package/dist/tsdoc-metadata.json +1 -1
  5. package/lib-esm/cli/ApiDocumenterCommandLine.js +22 -0
  6. package/lib-esm/cli/ApiDocumenterCommandLine.js.map +1 -0
  7. package/lib-esm/cli/BaseAction.js +93 -0
  8. package/lib-esm/cli/BaseAction.js.map +1 -0
  9. package/lib-esm/cli/GenerateAction.js +45 -0
  10. package/lib-esm/cli/GenerateAction.js.map +1 -0
  11. package/lib-esm/cli/MarkdownAction.js +24 -0
  12. package/lib-esm/cli/MarkdownAction.js.map +1 -0
  13. package/lib-esm/cli/YamlAction.js +43 -0
  14. package/lib-esm/cli/YamlAction.js.map +1 -0
  15. package/lib-esm/documenters/DocumenterConfig.js +43 -0
  16. package/lib-esm/documenters/DocumenterConfig.js.map +1 -0
  17. package/lib-esm/documenters/ExperimentalYamlDocumenter.js +136 -0
  18. package/lib-esm/documenters/ExperimentalYamlDocumenter.js.map +1 -0
  19. package/lib-esm/documenters/IConfigFile.js +4 -0
  20. package/lib-esm/documenters/IConfigFile.js.map +1 -0
  21. package/lib-esm/documenters/MarkdownDocumenter.js +987 -0
  22. package/lib-esm/documenters/MarkdownDocumenter.js.map +1 -0
  23. package/lib-esm/documenters/OfficeYamlDocumenter.js +101 -0
  24. package/lib-esm/documenters/OfficeYamlDocumenter.js.map +1 -0
  25. package/lib-esm/documenters/YamlDocumenter.js +804 -0
  26. package/lib-esm/documenters/YamlDocumenter.js.map +1 -0
  27. package/lib-esm/index.js +6 -0
  28. package/lib-esm/index.js.map +1 -0
  29. package/lib-esm/markdown/CustomMarkdownEmitter.js +146 -0
  30. package/lib-esm/markdown/CustomMarkdownEmitter.js.map +1 -0
  31. package/lib-esm/markdown/MarkdownEmitter.js +190 -0
  32. package/lib-esm/markdown/MarkdownEmitter.js.map +1 -0
  33. package/lib-esm/nodes/CustomDocNodeKind.js +51 -0
  34. package/lib-esm/nodes/CustomDocNodeKind.js.map +1 -0
  35. package/lib-esm/nodes/DocEmphasisSpan.js +20 -0
  36. package/lib-esm/nodes/DocEmphasisSpan.js.map +1 -0
  37. package/lib-esm/nodes/DocHeading.js +26 -0
  38. package/lib-esm/nodes/DocHeading.js.map +1 -0
  39. package/lib-esm/nodes/DocNoteBox.js +22 -0
  40. package/lib-esm/nodes/DocNoteBox.js.map +1 -0
  41. package/lib-esm/nodes/DocTable.js +56 -0
  42. package/lib-esm/nodes/DocTable.js.map +1 -0
  43. package/lib-esm/nodes/DocTableCell.js +18 -0
  44. package/lib-esm/nodes/DocTableCell.js.map +1 -0
  45. package/lib-esm/nodes/DocTableRow.js +47 -0
  46. package/lib-esm/nodes/DocTableRow.js.map +1 -0
  47. package/lib-esm/plugin/IApiDocumenterPluginManifest.js +4 -0
  48. package/lib-esm/plugin/IApiDocumenterPluginManifest.js.map +1 -0
  49. package/lib-esm/plugin/MarkdownDocumenterAccessor.js +26 -0
  50. package/lib-esm/plugin/MarkdownDocumenterAccessor.js.map +1 -0
  51. package/lib-esm/plugin/MarkdownDocumenterFeature.js +47 -0
  52. package/lib-esm/plugin/MarkdownDocumenterFeature.js.map +1 -0
  53. package/lib-esm/plugin/PluginFeature.js +54 -0
  54. package/lib-esm/plugin/PluginFeature.js.map +1 -0
  55. package/lib-esm/plugin/PluginLoader.js +78 -0
  56. package/lib-esm/plugin/PluginLoader.js.map +1 -0
  57. package/lib-esm/schemas/api-documenter-template.json +99 -0
  58. package/lib-esm/schemas/api-documenter.schema.json +47 -0
  59. package/lib-esm/start.js +12 -0
  60. package/lib-esm/start.js.map +1 -0
  61. package/lib-esm/utils/IndentedWriter.js +235 -0
  62. package/lib-esm/utils/IndentedWriter.js.map +1 -0
  63. package/lib-esm/utils/ToSdpConvertHelper.js +338 -0
  64. package/lib-esm/utils/ToSdpConvertHelper.js.map +1 -0
  65. package/lib-esm/utils/Utilities.js +24 -0
  66. package/lib-esm/utils/Utilities.js.map +1 -0
  67. package/lib-esm/yaml/ISDPYamlFile.js +4 -0
  68. package/lib-esm/yaml/ISDPYamlFile.js.map +1 -0
  69. package/lib-esm/yaml/IYamlApiFile.js +4 -0
  70. package/lib-esm/yaml/IYamlApiFile.js.map +1 -0
  71. package/lib-esm/yaml/IYamlTocFile.js +4 -0
  72. package/lib-esm/yaml/IYamlTocFile.js.map +1 -0
  73. package/lib-esm/yaml/typescript.schema.json +643 -0
  74. package/package.json +35 -9
  75. /package/{lib → lib-commonjs}/cli/ApiDocumenterCommandLine.js +0 -0
  76. /package/{lib → lib-commonjs}/cli/ApiDocumenterCommandLine.js.map +0 -0
  77. /package/{lib → lib-commonjs}/cli/BaseAction.js +0 -0
  78. /package/{lib → lib-commonjs}/cli/BaseAction.js.map +0 -0
  79. /package/{lib → lib-commonjs}/cli/GenerateAction.js +0 -0
  80. /package/{lib → lib-commonjs}/cli/GenerateAction.js.map +0 -0
  81. /package/{lib → lib-commonjs}/cli/MarkdownAction.js +0 -0
  82. /package/{lib → lib-commonjs}/cli/MarkdownAction.js.map +0 -0
  83. /package/{lib → lib-commonjs}/cli/YamlAction.js +0 -0
  84. /package/{lib → lib-commonjs}/cli/YamlAction.js.map +0 -0
  85. /package/{lib → lib-commonjs}/documenters/DocumenterConfig.js +0 -0
  86. /package/{lib → lib-commonjs}/documenters/DocumenterConfig.js.map +0 -0
  87. /package/{lib → lib-commonjs}/documenters/ExperimentalYamlDocumenter.js +0 -0
  88. /package/{lib → lib-commonjs}/documenters/ExperimentalYamlDocumenter.js.map +0 -0
  89. /package/{lib → lib-commonjs}/documenters/IConfigFile.js +0 -0
  90. /package/{lib → lib-commonjs}/documenters/IConfigFile.js.map +0 -0
  91. /package/{lib → lib-commonjs}/documenters/MarkdownDocumenter.js +0 -0
  92. /package/{lib → lib-commonjs}/documenters/MarkdownDocumenter.js.map +0 -0
  93. /package/{lib → lib-commonjs}/documenters/OfficeYamlDocumenter.js +0 -0
  94. /package/{lib → lib-commonjs}/documenters/OfficeYamlDocumenter.js.map +0 -0
  95. /package/{lib → lib-commonjs}/documenters/YamlDocumenter.js +0 -0
  96. /package/{lib → lib-commonjs}/documenters/YamlDocumenter.js.map +0 -0
  97. /package/{lib → lib-commonjs}/index.js +0 -0
  98. /package/{lib → lib-commonjs}/index.js.map +0 -0
  99. /package/{lib → lib-commonjs}/markdown/CustomMarkdownEmitter.js +0 -0
  100. /package/{lib → lib-commonjs}/markdown/CustomMarkdownEmitter.js.map +0 -0
  101. /package/{lib → lib-commonjs}/markdown/MarkdownEmitter.js +0 -0
  102. /package/{lib → lib-commonjs}/markdown/MarkdownEmitter.js.map +0 -0
  103. /package/{lib → lib-commonjs}/nodes/CustomDocNodeKind.js +0 -0
  104. /package/{lib → lib-commonjs}/nodes/CustomDocNodeKind.js.map +0 -0
  105. /package/{lib → lib-commonjs}/nodes/DocEmphasisSpan.js +0 -0
  106. /package/{lib → lib-commonjs}/nodes/DocEmphasisSpan.js.map +0 -0
  107. /package/{lib → lib-commonjs}/nodes/DocHeading.js +0 -0
  108. /package/{lib → lib-commonjs}/nodes/DocHeading.js.map +0 -0
  109. /package/{lib → lib-commonjs}/nodes/DocNoteBox.js +0 -0
  110. /package/{lib → lib-commonjs}/nodes/DocNoteBox.js.map +0 -0
  111. /package/{lib → lib-commonjs}/nodes/DocTable.js +0 -0
  112. /package/{lib → lib-commonjs}/nodes/DocTable.js.map +0 -0
  113. /package/{lib → lib-commonjs}/nodes/DocTableCell.js +0 -0
  114. /package/{lib → lib-commonjs}/nodes/DocTableCell.js.map +0 -0
  115. /package/{lib → lib-commonjs}/nodes/DocTableRow.js +0 -0
  116. /package/{lib → lib-commonjs}/nodes/DocTableRow.js.map +0 -0
  117. /package/{lib → lib-commonjs}/plugin/IApiDocumenterPluginManifest.js +0 -0
  118. /package/{lib → lib-commonjs}/plugin/IApiDocumenterPluginManifest.js.map +0 -0
  119. /package/{lib → lib-commonjs}/plugin/MarkdownDocumenterAccessor.js +0 -0
  120. /package/{lib → lib-commonjs}/plugin/MarkdownDocumenterAccessor.js.map +0 -0
  121. /package/{lib → lib-commonjs}/plugin/MarkdownDocumenterFeature.js +0 -0
  122. /package/{lib → lib-commonjs}/plugin/MarkdownDocumenterFeature.js.map +0 -0
  123. /package/{lib → lib-commonjs}/plugin/PluginFeature.js +0 -0
  124. /package/{lib → lib-commonjs}/plugin/PluginFeature.js.map +0 -0
  125. /package/{lib → lib-commonjs}/plugin/PluginLoader.js +0 -0
  126. /package/{lib → lib-commonjs}/plugin/PluginLoader.js.map +0 -0
  127. /package/{lib → lib-commonjs}/schemas/api-documenter-template.json +0 -0
  128. /package/{lib → lib-commonjs}/schemas/api-documenter.schema.json +0 -0
  129. /package/{lib → lib-commonjs}/start.js +0 -0
  130. /package/{lib → lib-commonjs}/start.js.map +0 -0
  131. /package/{lib → lib-commonjs}/utils/IndentedWriter.js +0 -0
  132. /package/{lib → lib-commonjs}/utils/IndentedWriter.js.map +0 -0
  133. /package/{lib → lib-commonjs}/utils/ToSdpConvertHelper.js +0 -0
  134. /package/{lib → lib-commonjs}/utils/ToSdpConvertHelper.js.map +0 -0
  135. /package/{lib → lib-commonjs}/utils/Utilities.js +0 -0
  136. /package/{lib → lib-commonjs}/utils/Utilities.js.map +0 -0
  137. /package/{lib → lib-commonjs}/yaml/ISDPYamlFile.js +0 -0
  138. /package/{lib → lib-commonjs}/yaml/ISDPYamlFile.js.map +0 -0
  139. /package/{lib → lib-commonjs}/yaml/IYamlApiFile.js +0 -0
  140. /package/{lib → lib-commonjs}/yaml/IYamlApiFile.js.map +0 -0
  141. /package/{lib → lib-commonjs}/yaml/IYamlTocFile.js +0 -0
  142. /package/{lib → lib-commonjs}/yaml/IYamlTocFile.js.map +0 -0
  143. /package/{lib → lib-commonjs}/yaml/typescript.schema.json +0 -0
  144. /package/{lib → lib-dts}/cli/ApiDocumenterCommandLine.d.ts +0 -0
  145. /package/{lib → lib-dts}/cli/ApiDocumenterCommandLine.d.ts.map +0 -0
  146. /package/{lib → lib-dts}/cli/BaseAction.d.ts +0 -0
  147. /package/{lib → lib-dts}/cli/BaseAction.d.ts.map +0 -0
  148. /package/{lib → lib-dts}/cli/GenerateAction.d.ts +0 -0
  149. /package/{lib → lib-dts}/cli/GenerateAction.d.ts.map +0 -0
  150. /package/{lib → lib-dts}/cli/MarkdownAction.d.ts +0 -0
  151. /package/{lib → lib-dts}/cli/MarkdownAction.d.ts.map +0 -0
  152. /package/{lib → lib-dts}/cli/YamlAction.d.ts +0 -0
  153. /package/{lib → lib-dts}/cli/YamlAction.d.ts.map +0 -0
  154. /package/{lib → lib-dts}/documenters/DocumenterConfig.d.ts +0 -0
  155. /package/{lib → lib-dts}/documenters/DocumenterConfig.d.ts.map +0 -0
  156. /package/{lib → lib-dts}/documenters/ExperimentalYamlDocumenter.d.ts +0 -0
  157. /package/{lib → lib-dts}/documenters/ExperimentalYamlDocumenter.d.ts.map +0 -0
  158. /package/{lib → lib-dts}/documenters/IConfigFile.d.ts +0 -0
  159. /package/{lib → lib-dts}/documenters/IConfigFile.d.ts.map +0 -0
  160. /package/{lib → lib-dts}/documenters/MarkdownDocumenter.d.ts +0 -0
  161. /package/{lib → lib-dts}/documenters/MarkdownDocumenter.d.ts.map +0 -0
  162. /package/{lib → lib-dts}/documenters/OfficeYamlDocumenter.d.ts +0 -0
  163. /package/{lib → lib-dts}/documenters/OfficeYamlDocumenter.d.ts.map +0 -0
  164. /package/{lib → lib-dts}/documenters/YamlDocumenter.d.ts +0 -0
  165. /package/{lib → lib-dts}/documenters/YamlDocumenter.d.ts.map +0 -0
  166. /package/{lib → lib-dts}/index.d.ts +0 -0
  167. /package/{lib → lib-dts}/index.d.ts.map +0 -0
  168. /package/{lib → lib-dts}/markdown/CustomMarkdownEmitter.d.ts +0 -0
  169. /package/{lib → lib-dts}/markdown/CustomMarkdownEmitter.d.ts.map +0 -0
  170. /package/{lib → lib-dts}/markdown/MarkdownEmitter.d.ts +0 -0
  171. /package/{lib → lib-dts}/markdown/MarkdownEmitter.d.ts.map +0 -0
  172. /package/{lib → lib-dts}/nodes/CustomDocNodeKind.d.ts +0 -0
  173. /package/{lib → lib-dts}/nodes/CustomDocNodeKind.d.ts.map +0 -0
  174. /package/{lib → lib-dts}/nodes/DocEmphasisSpan.d.ts +0 -0
  175. /package/{lib → lib-dts}/nodes/DocEmphasisSpan.d.ts.map +0 -0
  176. /package/{lib → lib-dts}/nodes/DocHeading.d.ts +0 -0
  177. /package/{lib → lib-dts}/nodes/DocHeading.d.ts.map +0 -0
  178. /package/{lib → lib-dts}/nodes/DocNoteBox.d.ts +0 -0
  179. /package/{lib → lib-dts}/nodes/DocNoteBox.d.ts.map +0 -0
  180. /package/{lib → lib-dts}/nodes/DocTable.d.ts +0 -0
  181. /package/{lib → lib-dts}/nodes/DocTable.d.ts.map +0 -0
  182. /package/{lib → lib-dts}/nodes/DocTableCell.d.ts +0 -0
  183. /package/{lib → lib-dts}/nodes/DocTableCell.d.ts.map +0 -0
  184. /package/{lib → lib-dts}/nodes/DocTableRow.d.ts +0 -0
  185. /package/{lib → lib-dts}/nodes/DocTableRow.d.ts.map +0 -0
  186. /package/{lib → lib-dts}/plugin/IApiDocumenterPluginManifest.d.ts +0 -0
  187. /package/{lib → lib-dts}/plugin/IApiDocumenterPluginManifest.d.ts.map +0 -0
  188. /package/{lib → lib-dts}/plugin/MarkdownDocumenterAccessor.d.ts +0 -0
  189. /package/{lib → lib-dts}/plugin/MarkdownDocumenterAccessor.d.ts.map +0 -0
  190. /package/{lib → lib-dts}/plugin/MarkdownDocumenterFeature.d.ts +0 -0
  191. /package/{lib → lib-dts}/plugin/MarkdownDocumenterFeature.d.ts.map +0 -0
  192. /package/{lib → lib-dts}/plugin/PluginFeature.d.ts +0 -0
  193. /package/{lib → lib-dts}/plugin/PluginFeature.d.ts.map +0 -0
  194. /package/{lib → lib-dts}/plugin/PluginLoader.d.ts +0 -0
  195. /package/{lib → lib-dts}/plugin/PluginLoader.d.ts.map +0 -0
  196. /package/{lib → lib-dts}/start.d.ts +0 -0
  197. /package/{lib → lib-dts}/start.d.ts.map +0 -0
  198. /package/{lib → lib-dts}/utils/IndentedWriter.d.ts +0 -0
  199. /package/{lib → lib-dts}/utils/IndentedWriter.d.ts.map +0 -0
  200. /package/{lib → lib-dts}/utils/ToSdpConvertHelper.d.ts +0 -0
  201. /package/{lib → lib-dts}/utils/ToSdpConvertHelper.d.ts.map +0 -0
  202. /package/{lib → lib-dts}/utils/Utilities.d.ts +0 -0
  203. /package/{lib → lib-dts}/utils/Utilities.d.ts.map +0 -0
  204. /package/{lib → lib-dts}/yaml/ISDPYamlFile.d.ts +0 -0
  205. /package/{lib → lib-dts}/yaml/ISDPYamlFile.d.ts.map +0 -0
  206. /package/{lib → lib-dts}/yaml/IYamlApiFile.d.ts +0 -0
  207. /package/{lib → lib-dts}/yaml/IYamlApiFile.d.ts.map +0 -0
  208. /package/{lib → lib-dts}/yaml/IYamlTocFile.d.ts +0 -0
  209. /package/{lib → lib-dts}/yaml/IYamlTocFile.d.ts.map +0 -0
@@ -0,0 +1,987 @@
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 { PackageName, FileSystem, NewlineKind } from '@rushstack/node-core-library';
5
+ import { DocSection, DocPlainText, DocLinkTag, StringBuilder, DocNodeKind, DocParagraph, DocCodeSpan, DocFencedCode, StandardTags } from '@microsoft/tsdoc';
6
+ import { ApiItemKind, ApiReleaseTagMixin, ApiDocumentedItem, ApiClass, ReleaseTag, ApiStaticMixin, ApiPropertyItem, ApiInterface, ApiAbstractMixin, ApiParameterListMixin, ApiReturnTypeMixin, ApiDeclaredItem, ExcerptTokenKind, ApiTypeAlias, ApiOptionalMixin, ApiInitializerMixin, ApiProtectedMixin, ApiReadonlyMixin } from '@microsoft/api-extractor-model';
7
+ import { CustomDocNodes } from '../nodes/CustomDocNodeKind';
8
+ import { DocHeading } from '../nodes/DocHeading';
9
+ import { DocTable } from '../nodes/DocTable';
10
+ import { DocEmphasisSpan } from '../nodes/DocEmphasisSpan';
11
+ import { DocTableRow } from '../nodes/DocTableRow';
12
+ import { DocTableCell } from '../nodes/DocTableCell';
13
+ import { DocNoteBox } from '../nodes/DocNoteBox';
14
+ import { Utilities } from '../utils/Utilities';
15
+ import { CustomMarkdownEmitter } from '../markdown/CustomMarkdownEmitter';
16
+ import { PluginLoader } from '../plugin/PluginLoader';
17
+ import { MarkdownDocumenterFeatureContext } from '../plugin/MarkdownDocumenterFeature';
18
+ import { MarkdownDocumenterAccessor } from '../plugin/MarkdownDocumenterAccessor';
19
+ /**
20
+ * Renders API documentation in the Markdown file format.
21
+ * For more info: https://en.wikipedia.org/wiki/Markdown
22
+ */
23
+ export class MarkdownDocumenter {
24
+ constructor(options) {
25
+ this._apiModel = options.apiModel;
26
+ this._documenterConfig = options.documenterConfig;
27
+ this._outputFolder = options.outputFolder;
28
+ this._tsdocConfiguration = CustomDocNodes.configuration;
29
+ this._markdownEmitter = new CustomMarkdownEmitter(this._apiModel);
30
+ this._pluginLoader = new PluginLoader();
31
+ }
32
+ generateFiles() {
33
+ if (this._documenterConfig) {
34
+ this._pluginLoader.load(this._documenterConfig, () => {
35
+ return new MarkdownDocumenterFeatureContext({
36
+ apiModel: this._apiModel,
37
+ outputFolder: this._outputFolder,
38
+ documenter: new MarkdownDocumenterAccessor({
39
+ getLinkForApiItem: (apiItem) => {
40
+ return this._getLinkFilenameForApiItem(apiItem);
41
+ }
42
+ })
43
+ });
44
+ });
45
+ }
46
+ console.log();
47
+ this._deleteOldOutputFiles();
48
+ this._writeApiItemPage(this._apiModel);
49
+ if (this._pluginLoader.markdownDocumenterFeature) {
50
+ this._pluginLoader.markdownDocumenterFeature.onFinished({});
51
+ }
52
+ }
53
+ _writeApiItemPage(apiItem) {
54
+ const configuration = this._tsdocConfiguration;
55
+ const output = new DocSection({ configuration });
56
+ this._writeBreadcrumb(output, apiItem);
57
+ const scopedName = apiItem.getScopedNameWithinPackage();
58
+ switch (apiItem.kind) {
59
+ case ApiItemKind.Class:
60
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} class` }));
61
+ break;
62
+ case ApiItemKind.Enum:
63
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} enum` }));
64
+ break;
65
+ case ApiItemKind.Interface:
66
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} interface` }));
67
+ break;
68
+ case ApiItemKind.Constructor:
69
+ case ApiItemKind.ConstructSignature:
70
+ output.appendNode(new DocHeading({ configuration, title: scopedName }));
71
+ break;
72
+ case ApiItemKind.Method:
73
+ case ApiItemKind.MethodSignature:
74
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} method` }));
75
+ break;
76
+ case ApiItemKind.Function:
77
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} function` }));
78
+ break;
79
+ case ApiItemKind.Model:
80
+ output.appendNode(new DocHeading({ configuration, title: `API Reference` }));
81
+ break;
82
+ case ApiItemKind.Namespace:
83
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} namespace` }));
84
+ break;
85
+ case ApiItemKind.Package:
86
+ console.log(`Writing ${apiItem.displayName} package`);
87
+ const unscopedPackageName = PackageName.getUnscopedName(apiItem.displayName);
88
+ output.appendNode(new DocHeading({ configuration, title: `${unscopedPackageName} package` }));
89
+ break;
90
+ case ApiItemKind.Property:
91
+ case ApiItemKind.PropertySignature:
92
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} property` }));
93
+ break;
94
+ case ApiItemKind.TypeAlias:
95
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} type` }));
96
+ break;
97
+ case ApiItemKind.Variable:
98
+ output.appendNode(new DocHeading({ configuration, title: `${scopedName} variable` }));
99
+ break;
100
+ default:
101
+ throw new Error('Unsupported API item kind: ' + apiItem.kind);
102
+ }
103
+ if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
104
+ if (apiItem.releaseTag === ReleaseTag.Alpha) {
105
+ this._writeAlphaWarning(output);
106
+ }
107
+ else if (apiItem.releaseTag === ReleaseTag.Beta) {
108
+ this._writeBetaWarning(output);
109
+ }
110
+ }
111
+ const decoratorBlocks = [];
112
+ if (apiItem instanceof ApiDocumentedItem) {
113
+ const tsdocComment = apiItem.tsdocComment;
114
+ if (tsdocComment) {
115
+ decoratorBlocks.push(...tsdocComment.customBlocks.filter((block) => block.blockTag.tagNameWithUpperCase === StandardTags.decorator.tagNameWithUpperCase));
116
+ if (tsdocComment.deprecatedBlock) {
117
+ output.appendNode(new DocNoteBox({ configuration }, [
118
+ new DocParagraph({ configuration }, [
119
+ new DocPlainText({
120
+ configuration,
121
+ text: 'Warning: This API is now obsolete. '
122
+ })
123
+ ]),
124
+ ...tsdocComment.deprecatedBlock.content.nodes
125
+ ]));
126
+ }
127
+ this._appendSection(output, tsdocComment.summarySection);
128
+ }
129
+ }
130
+ if (apiItem instanceof ApiDeclaredItem) {
131
+ if (apiItem.excerpt.text.length > 0) {
132
+ output.appendNode(new DocParagraph({ configuration }, [
133
+ new DocEmphasisSpan({ configuration, bold: true }, [
134
+ new DocPlainText({ configuration, text: 'Signature:' })
135
+ ])
136
+ ]));
137
+ output.appendNode(new DocFencedCode({
138
+ configuration,
139
+ code: apiItem.getExcerptWithModifiers(),
140
+ language: 'typescript'
141
+ }));
142
+ }
143
+ this._writeHeritageTypes(output, apiItem);
144
+ }
145
+ if (decoratorBlocks.length > 0) {
146
+ output.appendNode(new DocParagraph({ configuration }, [
147
+ new DocEmphasisSpan({ configuration, bold: true }, [
148
+ new DocPlainText({ configuration, text: 'Decorators:' })
149
+ ])
150
+ ]));
151
+ for (const decoratorBlock of decoratorBlocks) {
152
+ output.appendNodes(decoratorBlock.content.nodes);
153
+ }
154
+ }
155
+ let appendRemarks = true;
156
+ switch (apiItem.kind) {
157
+ case ApiItemKind.Class:
158
+ case ApiItemKind.Interface:
159
+ case ApiItemKind.Namespace:
160
+ case ApiItemKind.Package:
161
+ this._writeRemarksSection(output, apiItem);
162
+ appendRemarks = false;
163
+ break;
164
+ }
165
+ switch (apiItem.kind) {
166
+ case ApiItemKind.Class:
167
+ this._writeClassTables(output, apiItem);
168
+ break;
169
+ case ApiItemKind.Enum:
170
+ this._writeEnumTables(output, apiItem);
171
+ break;
172
+ case ApiItemKind.Interface:
173
+ this._writeInterfaceTables(output, apiItem);
174
+ break;
175
+ case ApiItemKind.Constructor:
176
+ case ApiItemKind.ConstructSignature:
177
+ case ApiItemKind.Method:
178
+ case ApiItemKind.MethodSignature:
179
+ case ApiItemKind.Function:
180
+ this._writeParameterTables(output, apiItem);
181
+ this._writeThrowsSection(output, apiItem);
182
+ break;
183
+ case ApiItemKind.Namespace:
184
+ this._writePackageOrNamespaceTables(output, apiItem);
185
+ break;
186
+ case ApiItemKind.Model:
187
+ this._writeModelTable(output, apiItem);
188
+ break;
189
+ case ApiItemKind.Package:
190
+ this._writePackageOrNamespaceTables(output, apiItem);
191
+ break;
192
+ case ApiItemKind.Property:
193
+ case ApiItemKind.PropertySignature:
194
+ break;
195
+ case ApiItemKind.TypeAlias:
196
+ break;
197
+ case ApiItemKind.Variable:
198
+ break;
199
+ default:
200
+ throw new Error('Unsupported API item kind: ' + apiItem.kind);
201
+ }
202
+ if (appendRemarks) {
203
+ this._writeRemarksSection(output, apiItem);
204
+ }
205
+ const filename = path.join(this._outputFolder, this._getFilenameForApiItem(apiItem));
206
+ const stringBuilder = new StringBuilder();
207
+ stringBuilder.append('<!-- Do not edit this file. It is automatically generated by API Documenter. -->\n\n');
208
+ this._markdownEmitter.emit(stringBuilder, output, {
209
+ contextApiItem: apiItem,
210
+ onGetFilenameForApiItem: (apiItemForFilename) => {
211
+ return this._getLinkFilenameForApiItem(apiItemForFilename);
212
+ }
213
+ });
214
+ let pageContent = stringBuilder.toString();
215
+ if (this._pluginLoader.markdownDocumenterFeature) {
216
+ // Allow the plugin to customize the pageContent
217
+ const eventArgs = {
218
+ apiItem: apiItem,
219
+ outputFilename: filename,
220
+ pageContent: pageContent
221
+ };
222
+ this._pluginLoader.markdownDocumenterFeature.onBeforeWritePage(eventArgs);
223
+ pageContent = eventArgs.pageContent;
224
+ }
225
+ FileSystem.writeFile(filename, pageContent, {
226
+ convertLineEndings: this._documenterConfig ? this._documenterConfig.newlineKind : NewlineKind.CrLf
227
+ });
228
+ }
229
+ _writeHeritageTypes(output, apiItem) {
230
+ const configuration = this._tsdocConfiguration;
231
+ if (apiItem instanceof ApiClass) {
232
+ if (apiItem.extendsType) {
233
+ const extendsParagraph = new DocParagraph({ configuration }, [
234
+ new DocEmphasisSpan({ configuration, bold: true }, [
235
+ new DocPlainText({ configuration, text: 'Extends: ' })
236
+ ])
237
+ ]);
238
+ this._appendExcerptWithHyperlinks(extendsParagraph, apiItem.extendsType.excerpt);
239
+ output.appendNode(extendsParagraph);
240
+ }
241
+ if (apiItem.implementsTypes.length > 0) {
242
+ const implementsParagraph = new DocParagraph({ configuration }, [
243
+ new DocEmphasisSpan({ configuration, bold: true }, [
244
+ new DocPlainText({ configuration, text: 'Implements: ' })
245
+ ])
246
+ ]);
247
+ let needsComma = false;
248
+ for (const implementsType of apiItem.implementsTypes) {
249
+ if (needsComma) {
250
+ implementsParagraph.appendNode(new DocPlainText({ configuration, text: ', ' }));
251
+ }
252
+ this._appendExcerptWithHyperlinks(implementsParagraph, implementsType.excerpt);
253
+ needsComma = true;
254
+ }
255
+ output.appendNode(implementsParagraph);
256
+ }
257
+ }
258
+ if (apiItem instanceof ApiInterface) {
259
+ if (apiItem.extendsTypes.length > 0) {
260
+ const extendsParagraph = new DocParagraph({ configuration }, [
261
+ new DocEmphasisSpan({ configuration, bold: true }, [
262
+ new DocPlainText({ configuration, text: 'Extends: ' })
263
+ ])
264
+ ]);
265
+ let needsComma = false;
266
+ for (const extendsType of apiItem.extendsTypes) {
267
+ if (needsComma) {
268
+ extendsParagraph.appendNode(new DocPlainText({ configuration, text: ', ' }));
269
+ }
270
+ this._appendExcerptWithHyperlinks(extendsParagraph, extendsType.excerpt);
271
+ needsComma = true;
272
+ }
273
+ output.appendNode(extendsParagraph);
274
+ }
275
+ }
276
+ if (apiItem instanceof ApiTypeAlias) {
277
+ const refs = apiItem.excerptTokens.filter((token) => token.kind === ExcerptTokenKind.Reference &&
278
+ token.canonicalReference &&
279
+ this._apiModel.resolveDeclarationReference(token.canonicalReference, undefined).resolvedApiItem);
280
+ if (refs.length > 0) {
281
+ const referencesParagraph = new DocParagraph({ configuration }, [
282
+ new DocEmphasisSpan({ configuration, bold: true }, [
283
+ new DocPlainText({ configuration, text: 'References: ' })
284
+ ])
285
+ ]);
286
+ let needsComma = false;
287
+ const visited = new Set();
288
+ for (const ref of refs) {
289
+ if (visited.has(ref.text)) {
290
+ continue;
291
+ }
292
+ visited.add(ref.text);
293
+ if (needsComma) {
294
+ referencesParagraph.appendNode(new DocPlainText({ configuration, text: ', ' }));
295
+ }
296
+ this._appendExcerptTokenWithHyperlinks(referencesParagraph, ref);
297
+ needsComma = true;
298
+ }
299
+ output.appendNode(referencesParagraph);
300
+ }
301
+ }
302
+ }
303
+ _writeRemarksSection(output, apiItem) {
304
+ const configuration = this._tsdocConfiguration;
305
+ if (apiItem instanceof ApiDocumentedItem) {
306
+ const tsdocComment = apiItem.tsdocComment;
307
+ if (tsdocComment) {
308
+ // Write the @remarks block
309
+ if (tsdocComment.remarksBlock) {
310
+ output.appendNode(new DocHeading({ configuration, title: 'Remarks' }));
311
+ this._appendSection(output, tsdocComment.remarksBlock.content);
312
+ }
313
+ // Write the @example blocks
314
+ const exampleBlocks = tsdocComment.customBlocks.filter((x) => x.blockTag.tagNameWithUpperCase === StandardTags.example.tagNameWithUpperCase);
315
+ let exampleNumber = 1;
316
+ for (const exampleBlock of exampleBlocks) {
317
+ const heading = exampleBlocks.length > 1 ? `Example ${exampleNumber}` : 'Example';
318
+ output.appendNode(new DocHeading({ configuration, title: heading }));
319
+ this._appendSection(output, exampleBlock.content);
320
+ ++exampleNumber;
321
+ }
322
+ }
323
+ }
324
+ }
325
+ _writeThrowsSection(output, apiItem) {
326
+ const configuration = this._tsdocConfiguration;
327
+ if (apiItem instanceof ApiDocumentedItem) {
328
+ const tsdocComment = apiItem.tsdocComment;
329
+ if (tsdocComment) {
330
+ // Write the @throws blocks
331
+ const throwsBlocks = tsdocComment.customBlocks.filter((x) => x.blockTag.tagNameWithUpperCase === StandardTags.throws.tagNameWithUpperCase);
332
+ if (throwsBlocks.length > 0) {
333
+ const heading = 'Exceptions';
334
+ output.appendNode(new DocHeading({ configuration, title: heading }));
335
+ for (const throwsBlock of throwsBlocks) {
336
+ this._appendSection(output, throwsBlock.content);
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }
342
+ /**
343
+ * GENERATE PAGE: MODEL
344
+ */
345
+ _writeModelTable(output, apiModel) {
346
+ const configuration = this._tsdocConfiguration;
347
+ const packagesTable = new DocTable({
348
+ configuration,
349
+ headerTitles: ['Package', 'Description']
350
+ });
351
+ for (const apiMember of apiModel.members) {
352
+ const row = new DocTableRow({ configuration }, [
353
+ this._createTitleCell(apiMember),
354
+ this._createDescriptionCell(apiMember)
355
+ ]);
356
+ switch (apiMember.kind) {
357
+ case ApiItemKind.Package:
358
+ packagesTable.addRow(row);
359
+ this._writeApiItemPage(apiMember);
360
+ break;
361
+ }
362
+ }
363
+ if (packagesTable.rows.length > 0) {
364
+ output.appendNode(new DocHeading({ configuration, title: 'Packages' }));
365
+ output.appendNode(packagesTable);
366
+ }
367
+ }
368
+ /**
369
+ * GENERATE PAGE: PACKAGE or NAMESPACE
370
+ */
371
+ _writePackageOrNamespaceTables(output, apiContainer) {
372
+ const configuration = this._tsdocConfiguration;
373
+ const abstractClassesTable = new DocTable({
374
+ configuration,
375
+ headerTitles: ['Abstract Class', 'Description']
376
+ });
377
+ const classesTable = new DocTable({
378
+ configuration,
379
+ headerTitles: ['Class', 'Description']
380
+ });
381
+ const enumerationsTable = new DocTable({
382
+ configuration,
383
+ headerTitles: ['Enumeration', 'Description']
384
+ });
385
+ const functionsTable = new DocTable({
386
+ configuration,
387
+ headerTitles: ['Function', 'Description']
388
+ });
389
+ const interfacesTable = new DocTable({
390
+ configuration,
391
+ headerTitles: ['Interface', 'Description']
392
+ });
393
+ const namespacesTable = new DocTable({
394
+ configuration,
395
+ headerTitles: ['Namespace', 'Description']
396
+ });
397
+ const variablesTable = new DocTable({
398
+ configuration,
399
+ headerTitles: ['Variable', 'Description']
400
+ });
401
+ const typeAliasesTable = new DocTable({
402
+ configuration,
403
+ headerTitles: ['Type Alias', 'Description']
404
+ });
405
+ const apiMembers = apiContainer.kind === ApiItemKind.Package
406
+ ? apiContainer.entryPoints[0].members
407
+ : apiContainer.members;
408
+ for (const apiMember of apiMembers) {
409
+ const row = new DocTableRow({ configuration }, [
410
+ this._createTitleCell(apiMember),
411
+ this._createDescriptionCell(apiMember)
412
+ ]);
413
+ switch (apiMember.kind) {
414
+ case ApiItemKind.Class:
415
+ if (ApiAbstractMixin.isBaseClassOf(apiMember) && apiMember.isAbstract) {
416
+ abstractClassesTable.addRow(row);
417
+ }
418
+ else {
419
+ classesTable.addRow(row);
420
+ }
421
+ this._writeApiItemPage(apiMember);
422
+ break;
423
+ case ApiItemKind.Enum:
424
+ enumerationsTable.addRow(row);
425
+ this._writeApiItemPage(apiMember);
426
+ break;
427
+ case ApiItemKind.Interface:
428
+ interfacesTable.addRow(row);
429
+ this._writeApiItemPage(apiMember);
430
+ break;
431
+ case ApiItemKind.Namespace:
432
+ namespacesTable.addRow(row);
433
+ this._writeApiItemPage(apiMember);
434
+ break;
435
+ case ApiItemKind.Function:
436
+ functionsTable.addRow(row);
437
+ this._writeApiItemPage(apiMember);
438
+ break;
439
+ case ApiItemKind.TypeAlias:
440
+ typeAliasesTable.addRow(row);
441
+ this._writeApiItemPage(apiMember);
442
+ break;
443
+ case ApiItemKind.Variable:
444
+ variablesTable.addRow(row);
445
+ this._writeApiItemPage(apiMember);
446
+ break;
447
+ }
448
+ }
449
+ if (classesTable.rows.length > 0) {
450
+ output.appendNode(new DocHeading({ configuration, title: 'Classes' }));
451
+ output.appendNode(classesTable);
452
+ }
453
+ if (abstractClassesTable.rows.length > 0) {
454
+ output.appendNode(new DocHeading({ configuration, title: 'Abstract Classes' }));
455
+ output.appendNode(abstractClassesTable);
456
+ }
457
+ if (enumerationsTable.rows.length > 0) {
458
+ output.appendNode(new DocHeading({ configuration, title: 'Enumerations' }));
459
+ output.appendNode(enumerationsTable);
460
+ }
461
+ if (functionsTable.rows.length > 0) {
462
+ output.appendNode(new DocHeading({ configuration, title: 'Functions' }));
463
+ output.appendNode(functionsTable);
464
+ }
465
+ if (interfacesTable.rows.length > 0) {
466
+ output.appendNode(new DocHeading({ configuration, title: 'Interfaces' }));
467
+ output.appendNode(interfacesTable);
468
+ }
469
+ if (namespacesTable.rows.length > 0) {
470
+ output.appendNode(new DocHeading({ configuration, title: 'Namespaces' }));
471
+ output.appendNode(namespacesTable);
472
+ }
473
+ if (variablesTable.rows.length > 0) {
474
+ output.appendNode(new DocHeading({ configuration, title: 'Variables' }));
475
+ output.appendNode(variablesTable);
476
+ }
477
+ if (typeAliasesTable.rows.length > 0) {
478
+ output.appendNode(new DocHeading({ configuration, title: 'Type Aliases' }));
479
+ output.appendNode(typeAliasesTable);
480
+ }
481
+ }
482
+ /**
483
+ * GENERATE PAGE: CLASS
484
+ */
485
+ _writeClassTables(output, apiClass) {
486
+ const configuration = this._tsdocConfiguration;
487
+ const eventsTable = new DocTable({
488
+ configuration,
489
+ headerTitles: ['Property', 'Modifiers', 'Type', 'Description']
490
+ });
491
+ const constructorsTable = new DocTable({
492
+ configuration,
493
+ headerTitles: ['Constructor', 'Modifiers', 'Description']
494
+ });
495
+ const propertiesTable = new DocTable({
496
+ configuration,
497
+ headerTitles: ['Property', 'Modifiers', 'Type', 'Description']
498
+ });
499
+ const methodsTable = new DocTable({
500
+ configuration,
501
+ headerTitles: ['Method', 'Modifiers', 'Description']
502
+ });
503
+ const apiMembers = this._getMembersAndWriteIncompleteWarning(apiClass, output);
504
+ for (const apiMember of apiMembers) {
505
+ const isInherited = apiMember.parent !== apiClass;
506
+ switch (apiMember.kind) {
507
+ case ApiItemKind.Constructor: {
508
+ constructorsTable.addRow(new DocTableRow({ configuration }, [
509
+ this._createTitleCell(apiMember),
510
+ this._createModifiersCell(apiMember),
511
+ this._createDescriptionCell(apiMember, isInherited)
512
+ ]));
513
+ this._writeApiItemPage(apiMember);
514
+ break;
515
+ }
516
+ case ApiItemKind.Method: {
517
+ methodsTable.addRow(new DocTableRow({ configuration }, [
518
+ this._createTitleCell(apiMember),
519
+ this._createModifiersCell(apiMember),
520
+ this._createDescriptionCell(apiMember, isInherited)
521
+ ]));
522
+ this._writeApiItemPage(apiMember);
523
+ break;
524
+ }
525
+ case ApiItemKind.Property: {
526
+ if (apiMember.isEventProperty) {
527
+ eventsTable.addRow(new DocTableRow({ configuration }, [
528
+ this._createTitleCell(apiMember),
529
+ this._createModifiersCell(apiMember),
530
+ this._createPropertyTypeCell(apiMember),
531
+ this._createDescriptionCell(apiMember, isInherited)
532
+ ]));
533
+ }
534
+ else {
535
+ propertiesTable.addRow(new DocTableRow({ configuration }, [
536
+ this._createTitleCell(apiMember),
537
+ this._createModifiersCell(apiMember),
538
+ this._createPropertyTypeCell(apiMember),
539
+ this._createDescriptionCell(apiMember, isInherited)
540
+ ]));
541
+ }
542
+ this._writeApiItemPage(apiMember);
543
+ break;
544
+ }
545
+ }
546
+ }
547
+ if (eventsTable.rows.length > 0) {
548
+ output.appendNode(new DocHeading({ configuration, title: 'Events' }));
549
+ output.appendNode(eventsTable);
550
+ }
551
+ if (constructorsTable.rows.length > 0) {
552
+ output.appendNode(new DocHeading({ configuration, title: 'Constructors' }));
553
+ output.appendNode(constructorsTable);
554
+ }
555
+ if (propertiesTable.rows.length > 0) {
556
+ output.appendNode(new DocHeading({ configuration, title: 'Properties' }));
557
+ output.appendNode(propertiesTable);
558
+ }
559
+ if (methodsTable.rows.length > 0) {
560
+ output.appendNode(new DocHeading({ configuration, title: 'Methods' }));
561
+ output.appendNode(methodsTable);
562
+ }
563
+ }
564
+ /**
565
+ * GENERATE PAGE: ENUM
566
+ */
567
+ _writeEnumTables(output, apiEnum) {
568
+ const configuration = this._tsdocConfiguration;
569
+ const enumMembersTable = new DocTable({
570
+ configuration,
571
+ headerTitles: ['Member', 'Value', 'Description']
572
+ });
573
+ for (const apiEnumMember of apiEnum.members) {
574
+ enumMembersTable.addRow(new DocTableRow({ configuration }, [
575
+ new DocTableCell({ configuration }, [
576
+ new DocParagraph({ configuration }, [
577
+ new DocPlainText({ configuration, text: Utilities.getConciseSignature(apiEnumMember) })
578
+ ])
579
+ ]),
580
+ this._createInitializerCell(apiEnumMember),
581
+ this._createDescriptionCell(apiEnumMember)
582
+ ]));
583
+ }
584
+ if (enumMembersTable.rows.length > 0) {
585
+ output.appendNode(new DocHeading({ configuration, title: 'Enumeration Members' }));
586
+ output.appendNode(enumMembersTable);
587
+ }
588
+ }
589
+ /**
590
+ * GENERATE PAGE: INTERFACE
591
+ */
592
+ _writeInterfaceTables(output, apiInterface) {
593
+ const configuration = this._tsdocConfiguration;
594
+ const eventsTable = new DocTable({
595
+ configuration,
596
+ headerTitles: ['Property', 'Modifiers', 'Type', 'Description']
597
+ });
598
+ const propertiesTable = new DocTable({
599
+ configuration,
600
+ headerTitles: ['Property', 'Modifiers', 'Type', 'Description']
601
+ });
602
+ const methodsTable = new DocTable({
603
+ configuration,
604
+ headerTitles: ['Method', 'Description']
605
+ });
606
+ const apiMembers = this._getMembersAndWriteIncompleteWarning(apiInterface, output);
607
+ for (const apiMember of apiMembers) {
608
+ const isInherited = apiMember.parent !== apiInterface;
609
+ switch (apiMember.kind) {
610
+ case ApiItemKind.ConstructSignature:
611
+ case ApiItemKind.MethodSignature: {
612
+ methodsTable.addRow(new DocTableRow({ configuration }, [
613
+ this._createTitleCell(apiMember),
614
+ this._createDescriptionCell(apiMember, isInherited)
615
+ ]));
616
+ this._writeApiItemPage(apiMember);
617
+ break;
618
+ }
619
+ case ApiItemKind.PropertySignature: {
620
+ if (apiMember.isEventProperty) {
621
+ eventsTable.addRow(new DocTableRow({ configuration }, [
622
+ this._createTitleCell(apiMember),
623
+ this._createModifiersCell(apiMember),
624
+ this._createPropertyTypeCell(apiMember),
625
+ this._createDescriptionCell(apiMember, isInherited)
626
+ ]));
627
+ }
628
+ else {
629
+ propertiesTable.addRow(new DocTableRow({ configuration }, [
630
+ this._createTitleCell(apiMember),
631
+ this._createModifiersCell(apiMember),
632
+ this._createPropertyTypeCell(apiMember),
633
+ this._createDescriptionCell(apiMember, isInherited)
634
+ ]));
635
+ }
636
+ this._writeApiItemPage(apiMember);
637
+ break;
638
+ }
639
+ }
640
+ }
641
+ if (eventsTable.rows.length > 0) {
642
+ output.appendNode(new DocHeading({ configuration, title: 'Events' }));
643
+ output.appendNode(eventsTable);
644
+ }
645
+ if (propertiesTable.rows.length > 0) {
646
+ output.appendNode(new DocHeading({ configuration, title: 'Properties' }));
647
+ output.appendNode(propertiesTable);
648
+ }
649
+ if (methodsTable.rows.length > 0) {
650
+ output.appendNode(new DocHeading({ configuration, title: 'Methods' }));
651
+ output.appendNode(methodsTable);
652
+ }
653
+ }
654
+ /**
655
+ * GENERATE PAGE: FUNCTION-LIKE
656
+ */
657
+ _writeParameterTables(output, apiParameterListMixin) {
658
+ const configuration = this._tsdocConfiguration;
659
+ const parametersTable = new DocTable({
660
+ configuration,
661
+ headerTitles: ['Parameter', 'Type', 'Description']
662
+ });
663
+ for (const apiParameter of apiParameterListMixin.parameters) {
664
+ const parameterDescription = new DocSection({ configuration });
665
+ if (apiParameter.isOptional) {
666
+ parameterDescription.appendNodesInParagraph([
667
+ new DocEmphasisSpan({ configuration, italic: true }, [
668
+ new DocPlainText({ configuration, text: '(Optional)' })
669
+ ]),
670
+ new DocPlainText({ configuration, text: ' ' })
671
+ ]);
672
+ }
673
+ if (apiParameter.tsdocParamBlock) {
674
+ this._appendAndMergeSection(parameterDescription, apiParameter.tsdocParamBlock.content);
675
+ }
676
+ parametersTable.addRow(new DocTableRow({ configuration }, [
677
+ new DocTableCell({ configuration }, [
678
+ new DocParagraph({ configuration }, [
679
+ new DocPlainText({ configuration, text: apiParameter.name })
680
+ ])
681
+ ]),
682
+ new DocTableCell({ configuration }, [
683
+ this._createParagraphForTypeExcerpt(apiParameter.parameterTypeExcerpt)
684
+ ]),
685
+ new DocTableCell({ configuration }, parameterDescription.nodes)
686
+ ]));
687
+ }
688
+ if (parametersTable.rows.length > 0) {
689
+ output.appendNode(new DocHeading({ configuration, title: 'Parameters' }));
690
+ output.appendNode(parametersTable);
691
+ }
692
+ if (ApiReturnTypeMixin.isBaseClassOf(apiParameterListMixin)) {
693
+ const returnTypeExcerpt = apiParameterListMixin.returnTypeExcerpt;
694
+ output.appendNode(new DocParagraph({ configuration }, [
695
+ new DocEmphasisSpan({ configuration, bold: true }, [
696
+ new DocPlainText({ configuration, text: 'Returns:' })
697
+ ])
698
+ ]));
699
+ output.appendNode(this._createParagraphForTypeExcerpt(returnTypeExcerpt));
700
+ if (apiParameterListMixin instanceof ApiDocumentedItem) {
701
+ if (apiParameterListMixin.tsdocComment && apiParameterListMixin.tsdocComment.returnsBlock) {
702
+ this._appendSection(output, apiParameterListMixin.tsdocComment.returnsBlock.content);
703
+ }
704
+ }
705
+ }
706
+ }
707
+ _createParagraphForTypeExcerpt(excerpt) {
708
+ const configuration = this._tsdocConfiguration;
709
+ const paragraph = new DocParagraph({ configuration });
710
+ if (!excerpt.text.trim()) {
711
+ paragraph.appendNode(new DocPlainText({ configuration, text: '(not declared)' }));
712
+ }
713
+ else {
714
+ this._appendExcerptWithHyperlinks(paragraph, excerpt);
715
+ }
716
+ return paragraph;
717
+ }
718
+ _appendExcerptWithHyperlinks(docNodeContainer, excerpt) {
719
+ for (const token of excerpt.spannedTokens) {
720
+ this._appendExcerptTokenWithHyperlinks(docNodeContainer, token);
721
+ }
722
+ }
723
+ _appendExcerptTokenWithHyperlinks(docNodeContainer, token) {
724
+ const configuration = this._tsdocConfiguration;
725
+ // Markdown doesn't provide a standardized syntax for hyperlinks inside code spans, so we will render
726
+ // the type expression as DocPlainText. Instead of creating multiple DocParagraphs, we can simply
727
+ // discard any newlines and let the renderer do normal word-wrapping.
728
+ const unwrappedTokenText = token.text.replace(/[\r\n]+/g, ' ');
729
+ // If it's hyperlinkable, then append a DocLinkTag
730
+ if (token.kind === ExcerptTokenKind.Reference && token.canonicalReference) {
731
+ const apiItemResult = this._apiModel.resolveDeclarationReference(token.canonicalReference, undefined);
732
+ if (apiItemResult.resolvedApiItem) {
733
+ docNodeContainer.appendNode(new DocLinkTag({
734
+ configuration,
735
+ tagName: '@link',
736
+ linkText: unwrappedTokenText,
737
+ urlDestination: this._getLinkFilenameForApiItem(apiItemResult.resolvedApiItem)
738
+ }));
739
+ return;
740
+ }
741
+ }
742
+ // Otherwise append non-hyperlinked text
743
+ docNodeContainer.appendNode(new DocPlainText({ configuration, text: unwrappedTokenText }));
744
+ }
745
+ _createTitleCell(apiItem) {
746
+ const configuration = this._tsdocConfiguration;
747
+ let linkText = Utilities.getConciseSignature(apiItem);
748
+ if (ApiOptionalMixin.isBaseClassOf(apiItem) && apiItem.isOptional) {
749
+ linkText += '?';
750
+ }
751
+ return new DocTableCell({ configuration }, [
752
+ new DocParagraph({ configuration }, [
753
+ new DocLinkTag({
754
+ configuration,
755
+ tagName: '@link',
756
+ linkText: linkText,
757
+ urlDestination: this._getLinkFilenameForApiItem(apiItem)
758
+ })
759
+ ])
760
+ ]);
761
+ }
762
+ /**
763
+ * This generates a DocTableCell for an ApiItem including the summary section and "(BETA)" annotation.
764
+ *
765
+ * @remarks
766
+ * We mostly assume that the input is an ApiDocumentedItem, but it's easier to perform this as a runtime
767
+ * check than to have each caller perform a type cast.
768
+ */
769
+ _createDescriptionCell(apiItem, isInherited = false) {
770
+ const configuration = this._tsdocConfiguration;
771
+ const section = new DocSection({ configuration });
772
+ if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
773
+ if (apiItem.releaseTag === ReleaseTag.Alpha || apiItem.releaseTag === ReleaseTag.Beta) {
774
+ section.appendNodesInParagraph([
775
+ new DocEmphasisSpan({ configuration, bold: true, italic: true }, [
776
+ new DocPlainText({
777
+ configuration,
778
+ text: `(${apiItem.releaseTag === ReleaseTag.Alpha ? 'ALPHA' : 'BETA'})`
779
+ })
780
+ ]),
781
+ new DocPlainText({ configuration, text: ' ' })
782
+ ]);
783
+ }
784
+ }
785
+ if (ApiOptionalMixin.isBaseClassOf(apiItem) && apiItem.isOptional) {
786
+ section.appendNodesInParagraph([
787
+ new DocEmphasisSpan({ configuration, italic: true }, [
788
+ new DocPlainText({ configuration, text: '(Optional)' })
789
+ ]),
790
+ new DocPlainText({ configuration, text: ' ' })
791
+ ]);
792
+ }
793
+ if (apiItem instanceof ApiDocumentedItem) {
794
+ if (apiItem.tsdocComment !== undefined) {
795
+ this._appendAndMergeSection(section, apiItem.tsdocComment.summarySection);
796
+ }
797
+ }
798
+ if (isInherited && apiItem.parent) {
799
+ section.appendNode(new DocParagraph({ configuration }, [
800
+ new DocPlainText({ configuration, text: '(Inherited from ' }),
801
+ new DocLinkTag({
802
+ configuration,
803
+ tagName: '@link',
804
+ linkText: apiItem.parent.displayName,
805
+ urlDestination: this._getLinkFilenameForApiItem(apiItem.parent)
806
+ }),
807
+ new DocPlainText({ configuration, text: ')' })
808
+ ]));
809
+ }
810
+ return new DocTableCell({ configuration }, section.nodes);
811
+ }
812
+ _createModifiersCell(apiItem) {
813
+ const configuration = this._tsdocConfiguration;
814
+ const section = new DocSection({ configuration });
815
+ // Output modifiers in syntactically correct order: first access modifier (here: `protected`), then
816
+ // `static` or `abstract` (no member can be both, so the order between the two of them does not matter),
817
+ // last `readonly`. If `override` was supported, it would go directly before `readonly`.
818
+ if (ApiProtectedMixin.isBaseClassOf(apiItem)) {
819
+ if (apiItem.isProtected) {
820
+ section.appendNode(new DocParagraph({ configuration }, [new DocCodeSpan({ configuration, code: 'protected' })]));
821
+ }
822
+ }
823
+ if (ApiStaticMixin.isBaseClassOf(apiItem)) {
824
+ if (apiItem.isStatic) {
825
+ section.appendNode(new DocParagraph({ configuration }, [new DocCodeSpan({ configuration, code: 'static' })]));
826
+ }
827
+ }
828
+ if (ApiAbstractMixin.isBaseClassOf(apiItem)) {
829
+ if (apiItem.isAbstract) {
830
+ section.appendNode(new DocParagraph({ configuration }, [new DocCodeSpan({ configuration, code: 'abstract' })]));
831
+ }
832
+ }
833
+ if (ApiReadonlyMixin.isBaseClassOf(apiItem)) {
834
+ if (apiItem.isReadonly) {
835
+ section.appendNode(new DocParagraph({ configuration }, [new DocCodeSpan({ configuration, code: 'readonly' })]));
836
+ }
837
+ }
838
+ return new DocTableCell({ configuration }, section.nodes);
839
+ }
840
+ _createPropertyTypeCell(apiItem) {
841
+ const configuration = this._tsdocConfiguration;
842
+ const section = new DocSection({ configuration });
843
+ if (apiItem instanceof ApiPropertyItem) {
844
+ section.appendNode(this._createParagraphForTypeExcerpt(apiItem.propertyTypeExcerpt));
845
+ }
846
+ return new DocTableCell({ configuration }, section.nodes);
847
+ }
848
+ _createInitializerCell(apiItem) {
849
+ const configuration = this._tsdocConfiguration;
850
+ const section = new DocSection({ configuration });
851
+ if (ApiInitializerMixin.isBaseClassOf(apiItem)) {
852
+ if (apiItem.initializerExcerpt) {
853
+ section.appendNodeInParagraph(new DocCodeSpan({ configuration, code: apiItem.initializerExcerpt.text }));
854
+ }
855
+ }
856
+ return new DocTableCell({ configuration }, section.nodes);
857
+ }
858
+ _writeBreadcrumb(output, apiItem) {
859
+ const configuration = this._tsdocConfiguration;
860
+ output.appendNodeInParagraph(new DocLinkTag({
861
+ configuration,
862
+ tagName: '@link',
863
+ linkText: 'Home',
864
+ urlDestination: this._getLinkFilenameForApiItem(this._apiModel)
865
+ }));
866
+ for (const hierarchyItem of apiItem.getHierarchy()) {
867
+ switch (hierarchyItem.kind) {
868
+ case ApiItemKind.Model:
869
+ case ApiItemKind.EntryPoint:
870
+ // We don't show the model as part of the breadcrumb because it is the root-level container.
871
+ // We don't show the entry point because today API Extractor doesn't support multiple entry points;
872
+ // this may change in the future.
873
+ break;
874
+ default:
875
+ output.appendNodesInParagraph([
876
+ new DocPlainText({
877
+ configuration,
878
+ text: ' > '
879
+ }),
880
+ new DocLinkTag({
881
+ configuration,
882
+ tagName: '@link',
883
+ linkText: hierarchyItem.displayName,
884
+ urlDestination: this._getLinkFilenameForApiItem(hierarchyItem)
885
+ })
886
+ ]);
887
+ }
888
+ }
889
+ }
890
+ _writeAlphaWarning(output) {
891
+ const configuration = this._tsdocConfiguration;
892
+ const betaWarning = 'This API is provided as an alpha preview for developers and may change' +
893
+ ' based on feedback that we receive. Do not use this API in a production environment.';
894
+ output.appendNode(new DocNoteBox({ configuration }, [
895
+ new DocParagraph({ configuration }, [new DocPlainText({ configuration, text: betaWarning })])
896
+ ]));
897
+ }
898
+ _writeBetaWarning(output) {
899
+ const configuration = this._tsdocConfiguration;
900
+ const betaWarning = 'This API is provided as a beta preview for developers and may change' +
901
+ ' based on feedback that we receive. Do not use this API in a production environment.';
902
+ output.appendNode(new DocNoteBox({ configuration }, [
903
+ new DocParagraph({ configuration }, [new DocPlainText({ configuration, text: betaWarning })])
904
+ ]));
905
+ }
906
+ _appendSection(output, docSection) {
907
+ for (const node of docSection.nodes) {
908
+ output.appendNode(node);
909
+ }
910
+ }
911
+ _appendAndMergeSection(output, docSection) {
912
+ let firstNode = true;
913
+ for (const node of docSection.nodes) {
914
+ if (firstNode) {
915
+ if (node.kind === DocNodeKind.Paragraph) {
916
+ output.appendNodesInParagraph(node.getChildNodes());
917
+ firstNode = false;
918
+ continue;
919
+ }
920
+ }
921
+ firstNode = false;
922
+ output.appendNode(node);
923
+ }
924
+ }
925
+ _getMembersAndWriteIncompleteWarning(apiClassOrInterface, output) {
926
+ var _a;
927
+ const configuration = this._tsdocConfiguration;
928
+ const showInheritedMembers = !!((_a = this._documenterConfig) === null || _a === void 0 ? void 0 : _a.configFile.showInheritedMembers);
929
+ if (!showInheritedMembers) {
930
+ return apiClassOrInterface.members;
931
+ }
932
+ const result = apiClassOrInterface.findMembersWithInheritance();
933
+ // If the result is potentially incomplete, write a short warning communicating this.
934
+ if (result.maybeIncompleteResult) {
935
+ output.appendNode(new DocParagraph({ configuration }, [
936
+ new DocEmphasisSpan({ configuration, italic: true }, [
937
+ new DocPlainText({
938
+ configuration,
939
+ text: '(Some inherited members may not be shown because they are not represented in the documentation.)'
940
+ })
941
+ ])
942
+ ]));
943
+ }
944
+ // Log the messages for diagnostic purposes.
945
+ for (const message of result.messages) {
946
+ console.log(`Diagnostic message for findMembersWithInheritance: ${message.text}`);
947
+ }
948
+ return result.items;
949
+ }
950
+ _getFilenameForApiItem(apiItem) {
951
+ if (apiItem.kind === ApiItemKind.Model) {
952
+ return 'index.md';
953
+ }
954
+ let baseName = '';
955
+ for (const hierarchyItem of apiItem.getHierarchy()) {
956
+ // For overloaded methods, add a suffix such as "MyClass.myMethod_2".
957
+ let qualifiedName = Utilities.getSafeFilenameForName(hierarchyItem.displayName);
958
+ if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
959
+ if (hierarchyItem.overloadIndex > 1) {
960
+ // Subtract one for compatibility with earlier releases of API Documenter.
961
+ // (This will get revamped when we fix GitHub issue #1308)
962
+ qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
963
+ }
964
+ }
965
+ switch (hierarchyItem.kind) {
966
+ case ApiItemKind.Model:
967
+ case ApiItemKind.EntryPoint:
968
+ case ApiItemKind.EnumMember:
969
+ break;
970
+ case ApiItemKind.Package:
971
+ baseName = Utilities.getSafeFilenameForName(PackageName.getUnscopedName(hierarchyItem.displayName));
972
+ break;
973
+ default:
974
+ baseName += '.' + qualifiedName;
975
+ }
976
+ }
977
+ return baseName + '.md';
978
+ }
979
+ _getLinkFilenameForApiItem(apiItem) {
980
+ return './' + this._getFilenameForApiItem(apiItem);
981
+ }
982
+ _deleteOldOutputFiles() {
983
+ console.log('Deleting old output from ' + this._outputFolder);
984
+ FileSystem.ensureEmptyFolder(this._outputFolder);
985
+ }
986
+ }
987
+ //# sourceMappingURL=MarkdownDocumenter.js.map