typedoc 0.25.13 → 0.26.0-beta.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 (207) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.js +3 -2
  3. package/dist/lib/application.d.ts +15 -3
  4. package/dist/lib/application.js +65 -23
  5. package/dist/lib/cli.js +1 -1
  6. package/dist/lib/converter/comments/blockLexer.d.ts +1 -1
  7. package/dist/lib/converter/comments/blockLexer.js +1 -2
  8. package/dist/lib/converter/comments/declarationReference.js +8 -8
  9. package/dist/lib/converter/comments/declarationReferenceResolver.d.ts +1 -1
  10. package/dist/lib/converter/comments/declarationReferenceResolver.js +15 -14
  11. package/dist/lib/converter/comments/discovery.d.ts +3 -3
  12. package/dist/lib/converter/comments/discovery.js +21 -19
  13. package/dist/lib/converter/comments/index.d.ts +1 -1
  14. package/dist/lib/converter/comments/index.js +35 -16
  15. package/dist/lib/converter/comments/lineLexer.d.ts +1 -1
  16. package/dist/lib/converter/comments/lineLexer.js +1 -2
  17. package/dist/lib/converter/comments/linkResolver.d.ts +2 -2
  18. package/dist/lib/converter/comments/linkResolver.js +5 -3
  19. package/dist/lib/converter/comments/parser.d.ts +14 -3
  20. package/dist/lib/converter/comments/parser.js +144 -39
  21. package/dist/lib/converter/comments/rawLexer.d.ts +7 -1
  22. package/dist/lib/converter/comments/rawLexer.js +21 -70
  23. package/dist/lib/converter/comments/tagName.js +1 -2
  24. package/dist/lib/converter/context.d.ts +7 -2
  25. package/dist/lib/converter/context.js +7 -2
  26. package/dist/lib/converter/convert-expression.js +2 -3
  27. package/dist/lib/converter/converter.d.ts +8 -3
  28. package/dist/lib/converter/converter.js +16 -13
  29. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  30. package/dist/lib/converter/factories/index-signature.js +9 -12
  31. package/dist/lib/converter/factories/signature.d.ts +1 -1
  32. package/dist/lib/converter/factories/signature.js +11 -12
  33. package/dist/lib/converter/jsdoc.js +2 -3
  34. package/dist/lib/converter/plugins/CategoryPlugin.d.ts +3 -3
  35. package/dist/lib/converter/plugins/CategoryPlugin.js +22 -15
  36. package/dist/lib/converter/plugins/CommentPlugin.d.ts +1 -1
  37. package/dist/lib/converter/plugins/CommentPlugin.js +58 -67
  38. package/dist/lib/converter/plugins/GroupPlugin.d.ts +4 -4
  39. package/dist/lib/converter/plugins/GroupPlugin.js +52 -18
  40. package/dist/lib/converter/plugins/ImplementsPlugin.js +4 -3
  41. package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +1 -1
  42. package/dist/lib/converter/plugins/InheritDocPlugin.js +5 -6
  43. package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +2 -2
  44. package/dist/lib/converter/plugins/PackagePlugin.d.ts +0 -2
  45. package/dist/lib/converter/plugins/PackagePlugin.js +8 -30
  46. package/dist/lib/converter/plugins/SourcePlugin.js +2 -2
  47. package/dist/lib/converter/symbols.js +31 -11
  48. package/dist/lib/converter/types.d.ts +1 -1
  49. package/dist/lib/converter/types.js +4 -5
  50. package/dist/lib/converter/utils/nodes.js +3 -4
  51. package/dist/lib/converter/utils/reflections.d.ts +1 -1
  52. package/dist/lib/converter/utils/reflections.js +1 -2
  53. package/dist/lib/converter/utils/repository.js +4 -4
  54. package/dist/lib/converter/utils/symbols.js +1 -2
  55. package/dist/lib/internationalization/index.d.ts +7 -0
  56. package/dist/lib/internationalization/index.js +11 -0
  57. package/dist/lib/internationalization/internationalization.d.ts +92 -0
  58. package/dist/lib/internationalization/internationalization.js +194 -0
  59. package/dist/lib/internationalization/locales/en.cjs +3 -0
  60. package/dist/lib/internationalization/locales/en.d.cts +2 -0
  61. package/dist/lib/internationalization/locales/test.cjs +8 -0
  62. package/dist/lib/internationalization/locales/test.d.cts +5 -0
  63. package/dist/lib/internationalization/translatable.d.ts +297 -0
  64. package/dist/lib/internationalization/translatable.js +322 -0
  65. package/dist/lib/models/ReflectionCategory.d.ts +2 -2
  66. package/dist/lib/models/ReflectionGroup.d.ts +2 -2
  67. package/dist/lib/models/comments/comment.d.ts +17 -3
  68. package/dist/lib/models/comments/comment.js +377 -298
  69. package/dist/lib/models/reflections/ReflectionSymbolId.js +2 -2
  70. package/dist/lib/models/reflections/abstract.d.ts +11 -8
  71. package/dist/lib/models/reflections/abstract.js +17 -11
  72. package/dist/lib/models/reflections/container.d.ts +25 -3
  73. package/dist/lib/models/reflections/container.js +64 -0
  74. package/dist/lib/models/reflections/declaration.d.ts +3 -15
  75. package/dist/lib/models/reflections/declaration.js +16 -21
  76. package/dist/lib/models/reflections/document.d.ts +27 -0
  77. package/dist/lib/models/reflections/document.js +43 -0
  78. package/dist/lib/models/reflections/index.d.ts +4 -3
  79. package/dist/lib/models/reflections/index.js +5 -4
  80. package/dist/lib/models/reflections/kind.d.ts +13 -1
  81. package/dist/lib/models/reflections/kind.js +12 -0
  82. package/dist/lib/models/reflections/parameter.d.ts +1 -1
  83. package/dist/lib/models/reflections/project.d.ts +2 -2
  84. package/dist/lib/models/reflections/project.js +8 -7
  85. package/dist/lib/models/reflections/signature.d.ts +2 -2
  86. package/dist/lib/models/reflections/type-parameter.d.ts +1 -1
  87. package/dist/lib/models/reflections/utils.js +1 -2
  88. package/dist/lib/models/reflections/variant.d.ts +2 -0
  89. package/dist/lib/models/types.d.ts +4 -4
  90. package/dist/lib/models/types.js +3 -3
  91. package/dist/lib/output/events.d.ts +5 -5
  92. package/dist/lib/output/events.js +2 -1
  93. package/dist/lib/output/index.d.ts +1 -1
  94. package/dist/lib/output/index.js +2 -1
  95. package/dist/lib/output/plugins/AssetsPlugin.js +1 -1
  96. package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +3 -1
  97. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +28 -8
  98. package/dist/lib/output/plugins/SitemapPlugin.d.ts +1 -1
  99. package/dist/lib/output/plugins/SitemapPlugin.js +24 -13
  100. package/dist/lib/output/renderer.d.ts +1 -1
  101. package/dist/lib/output/renderer.js +5 -7
  102. package/dist/lib/output/themes/MarkedPlugin.d.ts +13 -24
  103. package/dist/lib/output/themes/MarkedPlugin.js +75 -160
  104. package/dist/lib/output/themes/default/DefaultTheme.d.ts +16 -4
  105. package/dist/lib/output/themes/default/DefaultTheme.js +62 -16
  106. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +44 -44
  107. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +10 -10
  108. package/dist/lib/output/themes/default/layouts/default.js +1 -1
  109. package/dist/lib/output/themes/default/partials/analytics.js +1 -2
  110. package/dist/lib/output/themes/default/partials/anchor-icon.js +2 -3
  111. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  112. package/dist/lib/output/themes/default/partials/comment.js +3 -4
  113. package/dist/lib/output/themes/default/partials/footer.d.ts +1 -1
  114. package/dist/lib/output/themes/default/partials/footer.js +19 -5
  115. package/dist/lib/output/themes/default/partials/header.d.ts +1 -1
  116. package/dist/lib/output/themes/default/partials/header.js +4 -3
  117. package/dist/lib/output/themes/default/partials/hierarchy.js +3 -4
  118. package/dist/lib/output/themes/default/partials/icon.js +7 -2
  119. package/dist/lib/output/themes/default/partials/index.js +4 -4
  120. package/dist/lib/output/themes/default/partials/member.d.ts +2 -2
  121. package/dist/lib/output/themes/default/partials/member.declaration.js +2 -3
  122. package/dist/lib/output/themes/default/partials/member.js +13 -2
  123. package/dist/lib/output/themes/default/partials/member.reference.d.ts +1 -1
  124. package/dist/lib/output/themes/default/partials/member.reference.js +9 -6
  125. package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +1 -1
  126. package/dist/lib/output/themes/default/partials/member.signature.body.js +4 -4
  127. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +1 -1
  128. package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -2
  129. package/dist/lib/output/themes/default/partials/member.sources.js +12 -6
  130. package/dist/lib/output/themes/default/partials/members.d.ts +1 -1
  131. package/dist/lib/output/themes/default/partials/members.group.js +1 -2
  132. package/dist/lib/output/themes/default/partials/members.js +1 -2
  133. package/dist/lib/output/themes/default/partials/navigation.d.ts +1 -1
  134. package/dist/lib/output/themes/default/partials/navigation.js +18 -15
  135. package/dist/lib/output/themes/default/partials/parameter.d.ts +1 -1
  136. package/dist/lib/output/themes/default/partials/parameter.js +15 -15
  137. package/dist/lib/output/themes/default/partials/reflectionPreview.js +1 -2
  138. package/dist/lib/output/themes/default/partials/toolbar.js +4 -4
  139. package/dist/lib/output/themes/default/partials/type.d.ts +1 -1
  140. package/dist/lib/output/themes/default/partials/type.js +14 -14
  141. package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +1 -1
  142. package/dist/lib/output/themes/default/partials/typeParameters.js +2 -3
  143. package/dist/lib/output/themes/default/templates/document.d.ts +5 -0
  144. package/dist/lib/output/themes/default/templates/document.js +7 -0
  145. package/dist/lib/output/themes/default/templates/hierarchy.js +1 -2
  146. package/dist/lib/output/themes/default/templates/reflection.d.ts +1 -1
  147. package/dist/lib/output/themes/default/templates/reflection.js +21 -19
  148. package/dist/lib/output/themes/lib.d.ts +1 -1
  149. package/dist/lib/output/themes/lib.js +12 -16
  150. package/dist/lib/serialization/deserializer.d.ts +3 -3
  151. package/dist/lib/serialization/deserializer.js +7 -5
  152. package/dist/lib/serialization/schema.d.ts +10 -3
  153. package/dist/lib/utils/array.js +9 -10
  154. package/dist/lib/utils/component.d.ts +1 -1
  155. package/dist/lib/utils/component.js +2 -2
  156. package/dist/lib/utils/entry-point.d.ts +11 -0
  157. package/dist/lib/utils/entry-point.js +51 -24
  158. package/dist/lib/utils/enum.js +6 -7
  159. package/dist/lib/utils/fs.js +15 -16
  160. package/dist/lib/utils/general.d.ts +4 -3
  161. package/dist/lib/utils/general.js +4 -5
  162. package/dist/lib/utils/highlighter.d.ts +4 -2
  163. package/dist/lib/utils/highlighter.js +41 -40
  164. package/dist/lib/utils/html.js +2 -3
  165. package/dist/lib/utils/index.d.ts +1 -1
  166. package/dist/lib/utils/index.js +1 -2
  167. package/dist/lib/utils/jsx.elements.d.ts +12 -0
  168. package/dist/lib/utils/jsx.js +4 -4
  169. package/dist/lib/utils/loggers.d.ts +13 -7
  170. package/dist/lib/utils/loggers.js +13 -10
  171. package/dist/lib/utils/map.d.ts +1 -1
  172. package/dist/lib/utils/map.js +1 -1
  173. package/dist/lib/utils/options/declaration.d.ts +40 -21
  174. package/dist/lib/utils/options/declaration.js +36 -36
  175. package/dist/lib/utils/options/help.d.ts +2 -1
  176. package/dist/lib/utils/options/help.js +10 -10
  177. package/dist/lib/utils/options/index.d.ts +1 -1
  178. package/dist/lib/utils/options/index.js +1 -2
  179. package/dist/lib/utils/options/options.d.ts +5 -34
  180. package/dist/lib/utils/options/options.js +10 -23
  181. package/dist/lib/utils/options/readers/arguments.js +3 -5
  182. package/dist/lib/utils/options/readers/package-json.js +2 -2
  183. package/dist/lib/utils/options/readers/tsconfig.js +8 -12
  184. package/dist/lib/utils/options/readers/typedoc.js +7 -6
  185. package/dist/lib/utils/options/sources/typedoc.js +187 -178
  186. package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
  187. package/dist/lib/utils/options/tsdoc-defaults.js +2 -0
  188. package/dist/lib/utils/package-manifest.d.ts +1 -1
  189. package/dist/lib/utils/package-manifest.js +9 -11
  190. package/dist/lib/utils/paths.js +4 -5
  191. package/dist/lib/utils/perf.js +3 -4
  192. package/dist/lib/utils/plugins.js +4 -5
  193. package/dist/lib/utils/reflections.d.ts +1 -1
  194. package/dist/lib/utils/reflections.js +2 -3
  195. package/dist/lib/utils/sort.d.ts +3 -2
  196. package/dist/lib/utils/sort.js +37 -6
  197. package/dist/lib/utils/tsconfig.js +3 -4
  198. package/dist/lib/utils/tsutils.js +2 -3
  199. package/dist/lib/utils/validation.js +4 -4
  200. package/dist/lib/validation/documentation.d.ts +1 -1
  201. package/dist/lib/validation/documentation.js +9 -4
  202. package/dist/lib/validation/exports.js +3 -5
  203. package/dist/lib/validation/links.js +2 -3
  204. package/package.json +12 -11
  205. package/static/main.js +4 -4
  206. package/static/style.css +18 -10
  207. package/tsdoc.json +9 -0
@@ -1,9 +1,44 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.Comment = exports.CommentTag = void 0;
4
38
  const utils_1 = require("../../utils");
5
39
  const kind_1 = require("../reflections/kind");
6
40
  const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
41
+ const general_1 = require("../../utils/general");
7
42
  /**
8
43
  * A model that represents a single TypeDoc comment tag.
9
44
  *
@@ -46,321 +81,365 @@ exports.CommentTag = CommentTag;
46
81
  * through the {@link DeclarationReflection.comment} property.
47
82
  * @category Comments
48
83
  */
49
- class Comment {
50
- /**
51
- * Debugging utility for combining parts into a simple string. Not suitable for
52
- * rendering, but can be useful in tests.
53
- */
54
- static combineDisplayParts(parts) {
55
- let result = "";
56
- for (const item of parts || []) {
57
- switch (item.kind) {
58
- case "text":
59
- case "code":
60
- result += item.text;
61
- break;
62
- case "inline-tag":
63
- result += `{${item.tag} ${item.text}}`;
64
- break;
65
- default:
66
- (0, utils_1.assertNever)(item);
84
+ let Comment = (() => {
85
+ var _a;
86
+ let _sourcePath_decorators;
87
+ let _sourcePath_initializers = [];
88
+ let _sourcePath_extraInitializers = [];
89
+ let _discoveryId_decorators;
90
+ let _discoveryId_initializers = [];
91
+ let _discoveryId_extraInitializers = [];
92
+ return _a = class Comment {
93
+ /**
94
+ * Debugging utility for combining parts into a simple string. Not suitable for
95
+ * rendering, but can be useful in tests.
96
+ */
97
+ static combineDisplayParts(parts) {
98
+ let result = "";
99
+ for (const item of parts || []) {
100
+ switch (item.kind) {
101
+ case "text":
102
+ case "code":
103
+ result += item.text;
104
+ break;
105
+ case "inline-tag":
106
+ result += `{${item.tag} ${item.text}}`;
107
+ break;
108
+ default:
109
+ (0, utils_1.assertNever)(item);
110
+ }
111
+ }
112
+ return result;
67
113
  }
68
- }
69
- return result;
70
- }
71
- /**
72
- * Helper function to convert an array of comment display parts into markdown suitable for
73
- * passing into Marked. `urlTo` will be used to resolve urls to any reflections linked to with
74
- * `@link` tags.
75
- */
76
- static displayPartsToMarkdown(parts, urlTo) {
77
- const result = [];
78
- for (const part of parts) {
79
- switch (part.kind) {
80
- case "text":
81
- case "code":
82
- result.push(part.text);
83
- break;
84
- case "inline-tag":
85
- switch (part.tag) {
86
- case "@label":
87
- case "@inheritdoc": // Shouldn't happen
88
- break; // Not rendered.
89
- case "@link":
90
- case "@linkcode":
91
- case "@linkplain": {
92
- if (part.target) {
93
- let url;
94
- let kindClass;
95
- if (typeof part.target === "string") {
96
- url = part.target;
97
- }
98
- else if (part.target && "id" in part.target) {
99
- // No point in trying to resolve a ReflectionSymbolId at this point, we've already
100
- // tried and failed during the resolution step.
101
- url = urlTo(part.target);
102
- kindClass = kind_1.ReflectionKind.classString(part.target.kind);
114
+ /**
115
+ * Helper function to convert an array of comment display parts into markdown suitable for
116
+ * passing into markdown-it.
117
+ * @param urlTo - Used to resolve urls to any reflections linked to with `@link` tags..
118
+ * @param useHtml - If set, will produce `<a>` links which can be colored according to the reflection type they are pointed at.
119
+ */
120
+ static displayPartsToMarkdown(parts, urlTo, useHtml) {
121
+ const result = [];
122
+ for (const part of parts) {
123
+ switch (part.kind) {
124
+ case "text":
125
+ case "code":
126
+ result.push(part.text);
127
+ break;
128
+ case "inline-tag":
129
+ switch (part.tag) {
130
+ case "@label":
131
+ case "@inheritdoc": // Shouldn't happen
132
+ break; // Not rendered.
133
+ case "@link":
134
+ case "@linkcode":
135
+ case "@linkplain": {
136
+ if (part.target) {
137
+ let url;
138
+ let kindClass;
139
+ if (typeof part.target === "string") {
140
+ url = part.target;
141
+ }
142
+ else if (part.target && "id" in part.target) {
143
+ // No point in trying to resolve a ReflectionSymbolId at this point, we've already
144
+ // tried and failed during the resolution step.
145
+ url = urlTo(part.target);
146
+ kindClass = kind_1.ReflectionKind.classString(part.target.kind);
147
+ }
148
+ if (useHtml) {
149
+ const text = part.tag === "@linkcode"
150
+ ? `<code>${part.text}</code>`
151
+ : part.text;
152
+ result.push(url
153
+ ? `<a href="${url}"${kindClass
154
+ ? ` class="${kindClass}"`
155
+ : ""}>${text}</a>`
156
+ : part.text);
157
+ }
158
+ else {
159
+ const text = part.tag === "@linkcode"
160
+ ? "`" + part.text + "`"
161
+ : part.text;
162
+ result.push(url ? `[${text}](${url})` : text);
163
+ }
164
+ }
165
+ else {
166
+ result.push(part.text);
167
+ }
168
+ break;
103
169
  }
104
- const text = part.tag === "@linkcode"
105
- ? `<code>${part.text}</code>`
106
- : part.text;
107
- result.push(url
108
- ? `<a href="${url}"${kindClass
109
- ? ` class="${kindClass}"`
110
- : ""}>${text}</a>`
111
- : part.text);
112
- }
113
- else {
114
- result.push(part.text);
170
+ default:
171
+ // Hmm... probably want to be able to render these somehow, so custom inline tags can be given
172
+ // special rendering rules. Future capability. For now, just render their text.
173
+ result.push(`{${part.tag} ${part.text}}`);
174
+ break;
115
175
  }
116
176
  break;
117
- }
118
177
  default:
119
- // Hmm... probably want to be able to render these somehow, so custom inline tags can be given
120
- // special rendering rules. Future capability. For now, just render their text.
121
- result.push(`{${part.tag} ${part.text}}`);
122
- break;
178
+ (0, utils_1.assertNever)(part);
123
179
  }
124
- break;
125
- default:
126
- (0, utils_1.assertNever)(part);
180
+ }
181
+ return result.join("");
127
182
  }
128
- }
129
- return result.join("");
130
- }
131
- /**
132
- * Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
133
- */
134
- static cloneDisplayParts(parts) {
135
- return parts.map((p) => ({ ...p }));
136
- }
137
- static serializeDisplayParts(serializer, parts) {
138
- return parts?.map((part) => {
139
- switch (part.kind) {
140
- case "text":
141
- case "code":
142
- return { ...part };
143
- case "inline-tag": {
144
- let target;
145
- if (typeof part.target === "string") {
146
- target = part.target;
183
+ /**
184
+ * Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
185
+ */
186
+ static cloneDisplayParts(parts) {
187
+ return parts.map((p) => ({ ...p }));
188
+ }
189
+ static serializeDisplayParts(serializer, parts) {
190
+ return parts?.map((part) => {
191
+ switch (part.kind) {
192
+ case "text":
193
+ case "code":
194
+ return { ...part };
195
+ case "inline-tag": {
196
+ let target;
197
+ if (typeof part.target === "string") {
198
+ target = part.target;
199
+ }
200
+ else if (part.target) {
201
+ if ("id" in part.target) {
202
+ target = part.target.id;
203
+ }
204
+ else {
205
+ target = part.target.toObject(serializer);
206
+ }
207
+ }
208
+ return {
209
+ ...part,
210
+ target,
211
+ };
212
+ }
147
213
  }
148
- else if (part.target) {
149
- if ("id" in part.target) {
150
- target = part.target.id;
214
+ });
215
+ }
216
+ //Since display parts are plain objects, this lives here
217
+ static deserializeDisplayParts(de, parts) {
218
+ const links = [];
219
+ const result = parts.map((part) => {
220
+ switch (part.kind) {
221
+ case "text":
222
+ case "code":
223
+ return { ...part };
224
+ case "inline-tag": {
225
+ if (typeof part.target === "number") {
226
+ const part2 = {
227
+ kind: part.kind,
228
+ tag: part.tag,
229
+ text: part.text,
230
+ target: undefined,
231
+ tsLinkText: part.tsLinkText,
232
+ };
233
+ links.push([part.target, part2]);
234
+ return part2;
235
+ }
236
+ else if (typeof part.target === "string" ||
237
+ part.target === undefined) {
238
+ return {
239
+ kind: "inline-tag",
240
+ tag: part.tag,
241
+ text: part.text,
242
+ target: part.target,
243
+ tsLinkText: part.tsLinkText,
244
+ };
245
+ }
246
+ else if (typeof part.target === "object") {
247
+ return {
248
+ kind: "inline-tag",
249
+ tag: part.tag,
250
+ text: part.text,
251
+ target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target),
252
+ tsLinkText: part.tsLinkText,
253
+ };
254
+ }
255
+ else {
256
+ (0, utils_1.assertNever)(part.target);
257
+ }
151
258
  }
152
- else {
153
- target = part.target.toObject(serializer);
259
+ }
260
+ });
261
+ if (links.length) {
262
+ de.defer((project) => {
263
+ for (const [oldId, part] of links) {
264
+ part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1);
265
+ if (!part.target) {
266
+ de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(oldId.toString()));
267
+ }
154
268
  }
269
+ });
270
+ }
271
+ return result;
272
+ }
273
+ /**
274
+ * Splits the provided parts into a header (first line, as a string)
275
+ * and body (remaining lines). If the header line contains inline tags
276
+ * they will be serialized to a string.
277
+ */
278
+ static splitPartsToHeaderAndBody(parts) {
279
+ let index = parts.findIndex((part) => {
280
+ switch (part.kind) {
281
+ case "text":
282
+ case "code":
283
+ return part.text.includes("\n");
284
+ case "inline-tag":
285
+ return false;
155
286
  }
287
+ });
288
+ if (index === -1) {
156
289
  return {
157
- ...part,
158
- target,
290
+ header: _a.combineDisplayParts(parts),
291
+ body: [],
159
292
  };
160
293
  }
161
- }
162
- });
163
- }
164
- //Since display parts are plain objects, this lives here
165
- static deserializeDisplayParts(de, parts) {
166
- const links = [];
167
- const result = parts.map((part) => {
168
- switch (part.kind) {
169
- case "text":
170
- case "code":
171
- return { ...part };
172
- case "inline-tag": {
173
- if (typeof part.target === "number") {
174
- const part2 = {
175
- kind: part.kind,
176
- tag: part.tag,
177
- text: part.text,
178
- target: undefined,
179
- tsLinkText: part.tsLinkText,
180
- };
181
- links.push([part.target, part2]);
182
- return part2;
183
- }
184
- else if (typeof part.target === "string" ||
185
- part.target === undefined) {
186
- return {
187
- kind: "inline-tag",
188
- tag: part.tag,
189
- text: part.text,
190
- target: part.target,
191
- tsLinkText: part.tsLinkText,
192
- };
193
- }
194
- else if (typeof part.target === "object") {
195
- return {
196
- kind: "inline-tag",
197
- tag: part.tag,
198
- text: part.text,
199
- target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target),
200
- tsLinkText: part.tsLinkText,
201
- };
202
- }
203
- else {
204
- (0, utils_1.assertNever)(part.target);
205
- }
294
+ // Do not split a code block, stop the header at the end of the previous block
295
+ if (parts[index].kind === "code") {
296
+ --index;
206
297
  }
207
- }
208
- });
209
- if (links.length) {
210
- de.defer((project) => {
211
- for (const [oldId, part] of links) {
212
- part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1);
213
- if (!part.target) {
214
- de.logger.warn(`Serialized project contained a link to ${oldId} (${part.text}), which was not a part of the project.`);
215
- }
298
+ if (index === -1) {
299
+ return { header: "", body: _a.cloneDisplayParts(parts) };
216
300
  }
217
- });
218
- }
219
- return result;
220
- }
221
- /**
222
- * Splits the provided parts into a header (first line, as a string)
223
- * and body (remaining lines). If the header line contains inline tags
224
- * they will be serialized to a string.
225
- */
226
- static splitPartsToHeaderAndBody(parts) {
227
- let index = parts.findIndex((part) => {
228
- switch (part.kind) {
229
- case "text":
230
- case "code":
231
- return part.text.includes("\n");
232
- case "inline-tag":
233
- return false;
301
+ let header = _a.combineDisplayParts(parts.slice(0, index));
302
+ const split = parts[index].text.indexOf("\n");
303
+ let body;
304
+ if (split === -1) {
305
+ header += parts[index].text;
306
+ body = _a.cloneDisplayParts(parts.slice(index + 1));
307
+ }
308
+ else {
309
+ header += parts[index].text.substring(0, split);
310
+ body = _a.cloneDisplayParts(parts.slice(index));
311
+ body[0].text = body[0].text.substring(split + 1);
312
+ }
313
+ if (!body[0].text) {
314
+ body.shift();
315
+ }
316
+ return { header: header.trim(), body };
234
317
  }
235
- });
236
- if (index === -1) {
237
- return {
238
- header: Comment.combineDisplayParts(parts),
239
- body: [],
240
- };
241
- }
242
- // Do not split a code block, stop the header at the end of the previous block
243
- if (parts[index].kind === "code") {
244
- --index;
245
- }
246
- if (index === -1) {
247
- return { header: "", body: Comment.cloneDisplayParts(parts) };
248
- }
249
- let header = Comment.combineDisplayParts(parts.slice(0, index));
250
- const split = parts[index].text.indexOf("\n");
251
- let body;
252
- if (split === -1) {
253
- header += parts[index].text;
254
- body = Comment.cloneDisplayParts(parts.slice(index + 1));
255
- }
256
- else {
257
- header += parts[index].text.substring(0, split);
258
- body = Comment.cloneDisplayParts(parts.slice(index));
259
- body[0].text = body[0].text.substring(split + 1);
260
- }
261
- if (!body[0].text) {
262
- body.shift();
263
- }
264
- return { header: header.trim(), body };
265
- }
266
- /**
267
- * Creates a new Comment instance.
268
- */
269
- constructor(summary = [], blockTags = [], modifierTags = new Set()) {
270
- /**
271
- * All associated block level tags.
272
- */
273
- this.blockTags = [];
274
- /**
275
- * All modifier tags present on the comment, e.g. `@alpha`, `@beta`.
276
- */
277
- this.modifierTags = new Set();
278
- this.summary = summary;
279
- this.blockTags = blockTags;
280
- this.modifierTags = modifierTags;
281
- extractLabelTag(this);
282
- }
283
- /**
284
- * Create a deep clone of this comment.
285
- */
286
- clone() {
287
- return new Comment(Comment.cloneDisplayParts(this.summary), this.blockTags.map((tag) => tag.clone()), new Set(this.modifierTags));
288
- }
289
- /**
290
- * Returns true if this comment is completely empty.
291
- * @internal
292
- */
293
- isEmpty() {
294
- return !this.hasVisibleComponent() && this.modifierTags.size === 0;
295
- }
296
- /**
297
- * Has this comment a visible component?
298
- *
299
- * @returns TRUE when this comment has a visible component.
300
- */
301
- hasVisibleComponent() {
302
- return (this.summary.some((x) => x.kind !== "text" || x.text !== "") ||
303
- this.blockTags.length > 0);
304
- }
305
- /**
306
- * Test whether this comment contains a tag with the given name.
307
- *
308
- * @param tagName The name of the tag to look for.
309
- * @returns TRUE when this comment contains a tag with the given name, otherwise FALSE.
310
- */
311
- hasModifier(tagName) {
312
- return this.modifierTags.has(tagName);
313
- }
314
- removeModifier(tagName) {
315
- this.modifierTags.delete(tagName);
316
- }
317
- /**
318
- * Return the first tag with the given name.
319
- *
320
- * @param tagName The name of the tag to look for.
321
- * @returns The found tag or undefined.
322
- */
323
- getTag(tagName) {
324
- return this.blockTags.find((tag) => tag.tag === tagName);
325
- }
326
- /**
327
- * Get all tags with the given tag name.
328
- */
329
- getTags(tagName) {
330
- return this.blockTags.filter((tag) => tag.tag === tagName);
331
- }
332
- getIdentifiedTag(identifier, tagName) {
333
- return this.blockTags.find((tag) => tag.tag === tagName && tag.name === identifier);
334
- }
335
- /**
336
- * Removes all block tags with the given tag name from the comment.
337
- * @param tagName
338
- */
339
- removeTags(tagName) {
340
- (0, utils_1.removeIf)(this.blockTags, (tag) => tag.tag === tagName);
341
- }
342
- toObject(serializer) {
343
- return {
344
- summary: Comment.serializeDisplayParts(serializer, this.summary),
345
- blockTags: serializer.toObjectsOptional(this.blockTags),
346
- modifierTags: this.modifierTags.size > 0
347
- ? Array.from(this.modifierTags)
348
- : undefined,
349
- label: this.label,
350
- };
351
- }
352
- fromObject(de, obj) {
353
- this.summary = Comment.deserializeDisplayParts(de, obj.summary);
354
- this.blockTags =
355
- obj.blockTags?.map((tagObj) => {
356
- const tag = new CommentTag(tagObj.tag, []);
357
- de.fromObject(tag, tagObj);
358
- return tag;
359
- }) || [];
360
- this.modifierTags = new Set(obj.modifierTags);
361
- this.label = obj.label;
362
- }
363
- }
318
+ /**
319
+ * Creates a new Comment instance.
320
+ */
321
+ constructor(summary = [], blockTags = [], modifierTags = new Set()) {
322
+ /**
323
+ * All associated block level tags.
324
+ */
325
+ this.blockTags = [];
326
+ /**
327
+ * All modifier tags present on the comment, e.g. `@alpha`, `@beta`.
328
+ */
329
+ this.modifierTags = new Set();
330
+ /**
331
+ * Full path to the file where this comment originated from, if any.
332
+ * This field will not be serialized, so will not be present when handling JSON-revived reflections.
333
+ *
334
+ * Note: This field is non-enumerable to make testing comment contents with `deepEqual` easier.
335
+ */
336
+ this.sourcePath = __runInitializers(this, _sourcePath_initializers, void 0);
337
+ /**
338
+ * Internal discovery ID used to prevent symbol comments from
339
+ * being duplicated on signatures. Only set when the comment was created
340
+ * @internal
341
+ */
342
+ this.discoveryId = (__runInitializers(this, _sourcePath_extraInitializers), __runInitializers(this, _discoveryId_initializers, void 0));
343
+ __runInitializers(this, _discoveryId_extraInitializers);
344
+ this.summary = summary;
345
+ this.blockTags = blockTags;
346
+ this.modifierTags = modifierTags;
347
+ extractLabelTag(this);
348
+ }
349
+ /**
350
+ * Create a deep clone of this comment.
351
+ */
352
+ clone() {
353
+ const comment = new _a(_a.cloneDisplayParts(this.summary), this.blockTags.map((tag) => tag.clone()), new Set(this.modifierTags));
354
+ comment.discoveryId = this.discoveryId;
355
+ comment.sourcePath = this.sourcePath;
356
+ return comment;
357
+ }
358
+ /**
359
+ * Returns true if this comment is completely empty.
360
+ * @internal
361
+ */
362
+ isEmpty() {
363
+ return !this.hasVisibleComponent() && this.modifierTags.size === 0;
364
+ }
365
+ /**
366
+ * Has this comment a visible component?
367
+ *
368
+ * @returns TRUE when this comment has a visible component.
369
+ */
370
+ hasVisibleComponent() {
371
+ return (this.summary.some((x) => x.kind !== "text" || x.text !== "") ||
372
+ this.blockTags.length > 0);
373
+ }
374
+ /**
375
+ * Test whether this comment contains a tag with the given name.
376
+ *
377
+ * @param tagName The name of the tag to look for.
378
+ * @returns TRUE when this comment contains a tag with the given name, otherwise FALSE.
379
+ */
380
+ hasModifier(tagName) {
381
+ return this.modifierTags.has(tagName);
382
+ }
383
+ removeModifier(tagName) {
384
+ this.modifierTags.delete(tagName);
385
+ }
386
+ /**
387
+ * Return the first tag with the given name.
388
+ *
389
+ * @param tagName The name of the tag to look for.
390
+ * @returns The found tag or undefined.
391
+ */
392
+ getTag(tagName) {
393
+ return this.blockTags.find((tag) => tag.tag === tagName);
394
+ }
395
+ /**
396
+ * Get all tags with the given tag name.
397
+ */
398
+ getTags(tagName) {
399
+ return this.blockTags.filter((tag) => tag.tag === tagName);
400
+ }
401
+ getIdentifiedTag(identifier, tagName) {
402
+ return this.blockTags.find((tag) => tag.tag === tagName && tag.name === identifier);
403
+ }
404
+ /**
405
+ * Removes all block tags with the given tag name from the comment.
406
+ * @param tagName
407
+ */
408
+ removeTags(tagName) {
409
+ (0, utils_1.removeIf)(this.blockTags, (tag) => tag.tag === tagName);
410
+ }
411
+ toObject(serializer) {
412
+ return {
413
+ summary: _a.serializeDisplayParts(serializer, this.summary),
414
+ blockTags: serializer.toObjectsOptional(this.blockTags),
415
+ modifierTags: this.modifierTags.size > 0
416
+ ? Array.from(this.modifierTags)
417
+ : undefined,
418
+ label: this.label,
419
+ };
420
+ }
421
+ fromObject(de, obj) {
422
+ this.summary = _a.deserializeDisplayParts(de, obj.summary);
423
+ this.blockTags =
424
+ obj.blockTags?.map((tagObj) => {
425
+ const tag = new CommentTag(tagObj.tag, []);
426
+ de.fromObject(tag, tagObj);
427
+ return tag;
428
+ }) || [];
429
+ this.modifierTags = new Set(obj.modifierTags);
430
+ this.label = obj.label;
431
+ }
432
+ },
433
+ (() => {
434
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
435
+ _sourcePath_decorators = [general_1.NonEnumerable];
436
+ _discoveryId_decorators = [general_1.NonEnumerable];
437
+ __esDecorate(null, null, _sourcePath_decorators, { kind: "field", name: "sourcePath", static: false, private: false, access: { has: obj => "sourcePath" in obj, get: obj => obj.sourcePath, set: (obj, value) => { obj.sourcePath = value; } }, metadata: _metadata }, _sourcePath_initializers, _sourcePath_extraInitializers);
438
+ __esDecorate(null, null, _discoveryId_decorators, { kind: "field", name: "discoveryId", static: false, private: false, access: { has: obj => "discoveryId" in obj, get: obj => obj.discoveryId, set: (obj, value) => { obj.discoveryId = value; } }, metadata: _metadata }, _discoveryId_initializers, _discoveryId_extraInitializers);
439
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
440
+ })(),
441
+ _a;
442
+ })();
364
443
  exports.Comment = Comment;
365
444
  function extractLabelTag(comment) {
366
445
  const index = comment.summary.findIndex((part) => part.kind === "inline-tag" && part.tag === "@label");