@cparra/apexdocs 2.25.0-alpha.0 → 2.25.0-alpha.2

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 (215) hide show
  1. package/__mocks__/chalk.js +12 -0
  2. package/__mocks__/log-update.js +6 -0
  3. package/eslint.config.mjs +10 -0
  4. package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +16 -0
  5. package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +73 -0
  6. package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +15 -0
  7. package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +8 -0
  8. package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +7 -0
  9. package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +115 -0
  10. package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +36 -0
  11. package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +173 -0
  12. package/examples/plain-markdown/docs/index.md +33 -0
  13. package/examples/plain-markdown/force-app/classes/MultiInheritanceClass.cls +1 -0
  14. package/examples/plain-markdown/force-app/classes/SampleClass.cls +37 -0
  15. package/examples/plain-markdown/package.json +2 -6
  16. package/jest.config.js +4 -0
  17. package/jest.d.ts +7 -0
  18. package/lib/__spec__/core/expect-extensions.d.ts +3 -0
  19. package/lib/__spec__/core/expect-extensions.js +54 -0
  20. package/lib/__spec__/core/expect-extensions.js.map +1 -0
  21. package/lib/__spec__/core/generating-class-docs.spec.d.ts +1 -0
  22. package/lib/__spec__/core/generating-class-docs.spec.js +427 -0
  23. package/lib/__spec__/core/generating-class-docs.spec.js.map +1 -0
  24. package/lib/__spec__/core/generating-enum-docs.spec.d.ts +1 -0
  25. package/lib/__spec__/core/generating-enum-docs.spec.js +303 -0
  26. package/lib/__spec__/core/generating-enum-docs.spec.js.map +1 -0
  27. package/lib/__spec__/core/generating-interface-docs.spec.d.ts +1 -0
  28. package/lib/__spec__/core/generating-interface-docs.spec.js +361 -0
  29. package/lib/__spec__/core/generating-interface-docs.spec.js.map +1 -0
  30. package/lib/__spec__/core/generating-reference-guide.spec.d.ts +1 -0
  31. package/lib/__spec__/core/generating-reference-guide.spec.js +161 -0
  32. package/lib/__spec__/core/generating-reference-guide.spec.js.map +1 -0
  33. package/lib/adapters/apex-types.d.ts +5 -5
  34. package/lib/adapters/apex-types.js +97 -22
  35. package/lib/adapters/apex-types.js.map +1 -1
  36. package/lib/adapters/documentables.d.ts +4 -3
  37. package/lib/adapters/documentables.js +23 -8
  38. package/lib/adapters/documentables.js.map +1 -1
  39. package/lib/adapters/fields-and-properties.d.ts +4 -3
  40. package/lib/adapters/fields-and-properties.js +26 -5
  41. package/lib/adapters/fields-and-properties.js.map +1 -1
  42. package/lib/adapters/methods-and-constructors.d.ts +4 -3
  43. package/lib/adapters/methods-and-constructors.js +54 -12
  44. package/lib/adapters/methods-and-constructors.js.map +1 -1
  45. package/lib/adapters/references.d.ts +1 -1
  46. package/lib/adapters/references.js +3 -3
  47. package/lib/adapters/references.js.map +1 -1
  48. package/lib/adapters/type-utils.d.ts +1 -1
  49. package/lib/adapters/type-utils.js +1 -2
  50. package/lib/adapters/type-utils.js.map +1 -1
  51. package/lib/application/Apexdocs.js +21 -15
  52. package/lib/application/Apexdocs.js.map +1 -1
  53. package/lib/application/flows/generate-markdown-files.d.ts +3 -0
  54. package/lib/application/flows/generate-markdown-files.js +57 -0
  55. package/lib/application/flows/generate-markdown-files.js.map +1 -0
  56. package/lib/cli/generate.js +7 -7
  57. package/lib/cli/generate.js.map +1 -1
  58. package/lib/core/__test__/inheritance-chain.test.d.ts +1 -0
  59. package/lib/core/__test__/inheritance-chain.test.js +42 -0
  60. package/lib/core/__test__/inheritance-chain.test.js.map +1 -0
  61. package/lib/core/generate-docs.d.ts +24 -0
  62. package/lib/core/generate-docs.js +267 -0
  63. package/lib/core/generate-docs.js.map +1 -0
  64. package/lib/core/inheritance-chain.d.ts +2 -0
  65. package/lib/core/inheritance-chain.js +35 -0
  66. package/lib/core/inheritance-chain.js.map +1 -0
  67. package/lib/core/template.d.ts +10 -0
  68. package/lib/core/template.js +92 -0
  69. package/lib/core/template.js.map +1 -0
  70. package/lib/core/templates/reference-guide.d.ts +1 -0
  71. package/lib/core/templates/reference-guide.js +18 -0
  72. package/lib/core/templates/reference-guide.js.map +1 -0
  73. package/lib/index.d.ts +2 -1
  74. package/lib/index.js +14 -3
  75. package/lib/index.js.map +1 -1
  76. package/lib/model/inheritance.d.ts +4 -1
  77. package/lib/model/manifest.js +8 -2
  78. package/lib/model/manifest.js.map +1 -1
  79. package/lib/model/markdown-file.d.ts +2 -2
  80. package/lib/model/markdown-file.js +5 -4
  81. package/lib/model/markdown-file.js.map +1 -1
  82. package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +3 -4
  83. package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
  84. package/lib/model/markdown-generation-util/field-declaration-util.js +1 -2
  85. package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
  86. package/lib/model/markdown-generation-util/method-declaration-util.js +2 -3
  87. package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
  88. package/lib/model/markdown-generation-util/type-declaration-util.js +1 -2
  89. package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
  90. package/lib/model/markdown-home-file.js.map +1 -1
  91. package/lib/model/markdown-type-file.js.map +1 -1
  92. package/lib/model/openapi/open-api.js.map +1 -1
  93. package/lib/model/outputFile.d.ts +1 -1
  94. package/lib/model/outputFile.js +2 -9
  95. package/lib/model/outputFile.js.map +1 -1
  96. package/lib/model/types-repository.js.map +1 -1
  97. package/lib/service/apex-file-reader.js.map +1 -1
  98. package/lib/service/file-writer.js.map +1 -1
  99. package/lib/service/manifest-factory.js +1 -2
  100. package/lib/service/manifest-factory.js.map +1 -1
  101. package/lib/service/metadata-processor.js.map +1 -1
  102. package/lib/service/parser.js +1 -1
  103. package/lib/service/parser.js.map +1 -1
  104. package/lib/service/state.js.map +1 -1
  105. package/lib/service/walkers/class-walker.js.map +1 -1
  106. package/lib/service/walkers/interface-walker.js.map +1 -1
  107. package/lib/service/walkers/walker-factory.js.map +1 -1
  108. package/lib/service/walkers/walker.js.map +1 -1
  109. package/lib/settings.d.ts +0 -6
  110. package/lib/settings.js +0 -11
  111. package/lib/settings.js.map +1 -1
  112. package/lib/test-helpers/ClassMirrorBuilder.d.ts +4 -0
  113. package/lib/test-helpers/ClassMirrorBuilder.js +11 -1
  114. package/lib/test-helpers/ClassMirrorBuilder.js.map +1 -1
  115. package/lib/transpiler/factory.js.map +1 -1
  116. package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +1 -1
  117. package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
  118. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
  119. package/lib/transpiler/markdown/plain-markdown/class-template.js +53 -12
  120. package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -1
  121. package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +13 -16
  122. package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -1
  123. package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +11 -8
  124. package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -1
  125. package/lib/transpiler/markdown/plain-markdown/enum-template.js +7 -6
  126. package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -1
  127. package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +9 -6
  128. package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -1
  129. package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.d.ts +1 -0
  130. package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js +10 -0
  131. package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js.map +1 -0
  132. package/lib/transpiler/markdown/plain-markdown/interface-template.js +4 -4
  133. package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +18 -20
  134. package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -1
  135. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +0 -4
  136. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +6 -86
  137. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
  138. package/lib/transpiler/markdown/plain-markdown/type-doc-partial.d.ts +1 -0
  139. package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js +31 -0
  140. package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js.map +1 -0
  141. package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
  142. package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
  143. package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
  144. package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +3 -2
  145. package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
  146. package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -1
  147. package/lib/transpiler/transpiler.js.map +1 -1
  148. package/lib/util/error-logger.js.map +1 -1
  149. package/lib/util/logger.js +1 -1
  150. package/lib/util/logger.js.map +1 -1
  151. package/lib/util/string-utils.js +2 -2
  152. package/lib/util/string-utils.js.map +1 -1
  153. package/package.json +17 -17
  154. package/src/__spec__/core/expect-extensions.ts +32 -0
  155. package/src/__spec__/core/generating-class-docs.spec.ts +511 -0
  156. package/src/__spec__/core/generating-enum-docs.spec.ts +355 -0
  157. package/src/__spec__/core/generating-interface-docs.spec.ts +431 -0
  158. package/src/__spec__/core/generating-reference-guide.spec.ts +163 -0
  159. package/src/adapters/__tests__/interface-adapter.spec.ts +15 -11
  160. package/src/adapters/__tests__/references.spec.ts +1 -1
  161. package/src/adapters/apex-types.ts +205 -41
  162. package/src/adapters/documentables.ts +44 -9
  163. package/src/adapters/fields-and-properties.ts +31 -7
  164. package/src/adapters/methods-and-constructors.ts +65 -22
  165. package/src/adapters/references.ts +1 -1
  166. package/src/adapters/type-utils.ts +1 -1
  167. package/src/application/Apexdocs.ts +21 -15
  168. package/src/application/flows/generate-markdown-files.ts +47 -0
  169. package/src/cli/generate.ts +96 -96
  170. package/src/core/__test__/inheritance-chain.test.ts +54 -0
  171. package/src/core/generate-docs.ts +396 -0
  172. package/src/core/inheritance-chain.ts +23 -0
  173. package/src/core/renderable/types.d.ts +131 -0
  174. package/src/core/template.ts +108 -0
  175. package/src/core/templates/reference-guide.ts +14 -0
  176. package/src/index.ts +3 -1
  177. package/src/model/inheritance.ts +2 -1
  178. package/src/model/manifest.ts +12 -2
  179. package/src/model/markdown-file.ts +5 -4
  180. package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +1 -1
  181. package/src/model/markdown-generation-util/method-declaration-util.ts +1 -1
  182. package/src/model/outputFile.ts +2 -11
  183. package/src/service/parser.ts +1 -1
  184. package/src/settings.ts +0 -15
  185. package/src/test-helpers/ClassMirrorBuilder.ts +14 -1
  186. package/src/transpiler/markdown/class-file-generatorHelper.ts +1 -1
  187. package/src/transpiler/markdown/plain-markdown/class-template.ts +53 -12
  188. package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +13 -16
  189. package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +11 -8
  190. package/src/transpiler/markdown/plain-markdown/enum-template.ts +7 -6
  191. package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +9 -6
  192. package/src/transpiler/markdown/plain-markdown/grouped-members-partial-template.ts +6 -0
  193. package/src/transpiler/markdown/plain-markdown/interface-template.ts +4 -4
  194. package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +18 -20
  195. package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +8 -100
  196. package/src/transpiler/markdown/plain-markdown/type-doc-partial.ts +27 -0
  197. package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +3 -2
  198. package/src/util/logger.ts +1 -1
  199. package/tsconfig.json +1 -1
  200. package/.eslintrc.js +0 -12
  201. package/examples/plain-markdown/README.md +0 -301
  202. package/lib/templating/compile.d.ts +0 -7
  203. package/lib/templating/compile.js +0 -98
  204. package/lib/templating/compile.js.map +0 -1
  205. package/lib/templating/helpers.d.ts +0 -2
  206. package/lib/templating/helpers.js +0 -18
  207. package/lib/templating/helpers.js.map +0 -1
  208. package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.d.ts +0 -1
  209. package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js +0 -31
  210. package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js.map +0 -1
  211. package/src/templating/__tests__/compile.spec.ts +0 -741
  212. package/src/templating/compile.ts +0 -187
  213. package/src/templating/helpers.ts +0 -14
  214. package/src/templating/types.d.ts +0 -104
  215. package/src/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.ts +0 -27
@@ -0,0 +1,431 @@
1
+ import { assertEither, extendExpect } from './expect-extensions';
2
+ import { generateDocs } from '../../core/generate-docs';
3
+
4
+ describe('Generates interface documentation', () => {
5
+ beforeAll(() => {
6
+ extendExpect();
7
+ });
8
+
9
+ describe('documentation output', () => {
10
+ it('always returns markdown as the format', () => {
11
+ const input = `
12
+ public interface MyInterface {
13
+ }
14
+ `;
15
+
16
+ const result = generateDocs([input]);
17
+ assertEither(result, (data) => expect(data.format).toBe('markdown'));
18
+ });
19
+
20
+ it('returns the name of the interface', () => {
21
+ const input = `
22
+ public interface MyInterface {
23
+ }
24
+ `;
25
+
26
+ const result = generateDocs([input]);
27
+ expect(result).documentationBundleHasLength(1);
28
+ assertEither(result, (data) => expect(data.docs[0].typeName).toBe('MyInterface'));
29
+ });
30
+
31
+ it('returns the type as interface', () => {
32
+ const input = `
33
+ public interface MyInterface {
34
+ }
35
+ `;
36
+
37
+ const result = generateDocs([input]);
38
+ expect(result).documentationBundleHasLength(1);
39
+ assertEither(result, (data) => expect(data.docs[0].type).toBe('interface'));
40
+ });
41
+
42
+ it('does not return interfaces out of scope', () => {
43
+ const input1 = `
44
+ global interface MyInterface {}
45
+ `;
46
+
47
+ const input2 = `
48
+ public interface AnotherInterface {}
49
+ `;
50
+
51
+ const result = generateDocs([input1, input2], { scope: ['global'] });
52
+ expect(result).documentationBundleHasLength(1);
53
+ });
54
+
55
+ it('does not return interfaces that have an @ignore in the docs', () => {
56
+ const input = `
57
+ /**
58
+ * @ignore
59
+ */
60
+ public interface MyInterface {}`;
61
+
62
+ const result = generateDocs([input]);
63
+ expect(result).documentationBundleHasLength(0);
64
+ });
65
+
66
+ it('does not return interface methods that have @ignore in the docs', () => {
67
+ const input = `
68
+ public interface MyInterface {
69
+ /**
70
+ * @ignore
71
+ */
72
+ void myMethod();
73
+ }`;
74
+
75
+ const result = generateDocs([input]);
76
+ expect(result).documentationBundleHasLength(1);
77
+ assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('myMethod'));
78
+ });
79
+ });
80
+
81
+ describe('documentation content', () => {
82
+ describe('type level information', () => {
83
+ it('generates a heading with the interface name', () => {
84
+ const input = `
85
+ public interface MyInterface {}
86
+ `;
87
+
88
+ const output = `# MyInterface Interface`;
89
+ const result = generateDocs([input]);
90
+ expect(result).documentationBundleHasLength(1);
91
+ assertEither(result, (data) => expect(data).firstDocContains(output));
92
+ });
93
+
94
+ it('displays type level annotations', () => {
95
+ const input = `
96
+ @NamespaceAccessible
97
+ public interface MyInterface {
98
+ @Deprecated
99
+ void myMethod();
100
+ }
101
+ `;
102
+
103
+ const result = generateDocs([input]);
104
+ expect(result).documentationBundleHasLength(1);
105
+ assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
106
+ assertEither(result, (data) => expect(data).firstDocContains('DEPRECATED'));
107
+ });
108
+
109
+ it('displays the description', () => {
110
+ const input = `
111
+ /**
112
+ * This is a description
113
+ */
114
+ public interface MyInterface {}
115
+ `;
116
+
117
+ const result = generateDocs([input]);
118
+ expect(result).documentationBundleHasLength(1);
119
+ assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
120
+ });
121
+
122
+ it('display custom documentation tags', () => {
123
+ const input = `
124
+ /**
125
+ * @custom-tag My Value
126
+ */
127
+ public interface MyInterface {}
128
+ `;
129
+
130
+ const result = generateDocs([input]);
131
+ expect(result).documentationBundleHasLength(1);
132
+ assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
133
+ assertEither(result, (data) => expect(data).firstDocContains('My Value'));
134
+ });
135
+
136
+ it('displays the group', () => {
137
+ const input = `
138
+ /**
139
+ * @group MyGroup
140
+ */
141
+ public interface MyInterface {}`;
142
+
143
+ const result = generateDocs([input]);
144
+ expect(result).documentationBundleHasLength(1);
145
+ assertEither(result, (data) => expect(data).firstDocContains('Group'));
146
+ assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
147
+ });
148
+
149
+ it('displays the author', () => {
150
+ const input = `
151
+ /**
152
+ * @author John Doe
153
+ */
154
+ public interface MyInterface {}`;
155
+
156
+ const result = generateDocs([input]);
157
+ expect(result).documentationBundleHasLength(1);
158
+ assertEither(result, (data) => expect(data).firstDocContains('Author'));
159
+ assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
160
+ });
161
+
162
+ it('displays the date', () => {
163
+ const input = `
164
+ /**
165
+ * @date 2021-01-01
166
+ */
167
+ public interface MyInterface {}`;
168
+
169
+ const result = generateDocs([input]);
170
+ expect(result).documentationBundleHasLength(1);
171
+ assertEither(result, (data) => expect(data).firstDocContains('Date'));
172
+ assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
173
+ });
174
+
175
+ it('displays descriptions', () => {
176
+ const input = `
177
+ /**
178
+ * @description This is a description
179
+ */
180
+ public interface MyInterface {}`;
181
+
182
+ const result = generateDocs([input]);
183
+ expect(result).documentationBundleHasLength(1);
184
+ assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
185
+ });
186
+
187
+ it('displays descriptions with links', () => {
188
+ const input1 = `
189
+ /**
190
+ * @description This is a description with a {@link InterfaceRef} reference
191
+ */
192
+ public enum MyInterface {}
193
+ `;
194
+
195
+ const input2 = 'public interface InterfaceRef {}';
196
+
197
+ const result = generateDocs([input1, input2]);
198
+ expect(result).documentationBundleHasLength(2);
199
+ assertEither(result, (data) =>
200
+ expect(data).firstDocContains('This is a description with a [InterfaceRef](./InterfaceRef.md) reference'),
201
+ );
202
+ });
203
+
204
+ it('displays descriptions with emails', () => {
205
+ const input = `
206
+ /**
207
+ * @description This is a description with an {@email test@testerson.com} email
208
+ */
209
+ public interface MyInterface {}
210
+ `;
211
+
212
+ const result = generateDocs([input]);
213
+ expect(result).documentationBundleHasLength(1);
214
+ assertEither(result, (data) =>
215
+ expect(data).firstDocContains(
216
+ 'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
217
+ ),
218
+ );
219
+ });
220
+
221
+ it('displays sees with accurately resolved links', () => {
222
+ const input1 = `
223
+ /**
224
+ * @see InterfaceRef
225
+ */
226
+ public interface MyInterface {}
227
+ `;
228
+
229
+ const input2 = 'public interface InterfaceRef {}';
230
+
231
+ const result = generateDocs([input1, input2]);
232
+ expect(result).documentationBundleHasLength(2);
233
+ assertEither(result, (data) => expect(data).firstDocContains('See'));
234
+ assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](./InterfaceRef.md)'));
235
+ });
236
+
237
+ it('displays sees without links when the reference is not found', () => {
238
+ const input = `
239
+ /**
240
+ * @see InterfaceRef
241
+ */
242
+ public interface MyInterface {}
243
+ `;
244
+
245
+ const result = generateDocs([input]);
246
+ expect(result).documentationBundleHasLength(1);
247
+ assertEither(result, (data) => expect(data).firstDocContains('See'));
248
+ assertEither(result, (data) => expect(data).firstDocContains('InterfaceRef'));
249
+ });
250
+
251
+ it('displays the namespace if present in the config', () => {
252
+ const input = 'public interface MyInterface {}';
253
+
254
+ const result = generateDocs([input], { namespace: 'MyNamespace' });
255
+ expect(result).documentationBundleHasLength(1);
256
+ assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
257
+ assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
258
+ });
259
+
260
+ it('does not display the namespace if not present in the config', () => {
261
+ const input = 'public interface MyInterface {}';
262
+
263
+ const result = generateDocs([input]);
264
+ expect(result).documentationBundleHasLength(1);
265
+ assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
266
+ });
267
+
268
+ it('displays a mermaid diagram', () => {
269
+ const input = `
270
+ /**
271
+ * @mermaid
272
+ * graph TD
273
+ * A[Square Rect] -- Link text --> B((Circle))
274
+ * A --> C(Round Rect)
275
+ * B --> D{Rhombus}
276
+ * C --> D
277
+ */
278
+ public interface MyInterface {}
279
+ `;
280
+
281
+ const result = generateDocs([input]);
282
+ expect(result).documentationBundleHasLength(1);
283
+ assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
284
+ assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
285
+ });
286
+
287
+ it('displays an example code block', () => {
288
+ const input = `
289
+ /**
290
+ * @example
291
+ * public class MyClass {
292
+ * public void myMethod() {
293
+ * System.debug('Hello, World!');
294
+ * }
295
+ * }
296
+ */
297
+ public interface MyInterface {}`;
298
+
299
+ const result = generateDocs([input]);
300
+ expect(result).documentationBundleHasLength(1);
301
+ assertEither(result, (data) => expect(data).firstDocContains('```apex'));
302
+ assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
303
+ });
304
+ });
305
+
306
+ describe('method information', () => {
307
+ it('displays the Method heading', () => {
308
+ const input = `
309
+ public interface MyInterface {
310
+ void myMethod();
311
+ }
312
+ `;
313
+
314
+ const result = generateDocs([input]);
315
+ expect(result).documentationBundleHasLength(1);
316
+ assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
317
+ });
318
+
319
+ it('supports having mermaid diagrams in method descriptions', () => {
320
+ const input = `
321
+ public interface MyInterface {
322
+ /**
323
+ * @mermaid
324
+ * graph TD
325
+ * A[Square Rect] -- Link text --> B((Circle))
326
+ * A --> C(Round Rect)
327
+ * B --> D{Rhombus}
328
+ * C --> D
329
+ */
330
+ void myMethod();
331
+ }
332
+ `;
333
+
334
+ const result = generateDocs([input]);
335
+ expect(result).documentationBundleHasLength(1);
336
+ assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
337
+ assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
338
+ });
339
+
340
+ it('supports having example code blocks in method descriptions', () => {
341
+ const input = `
342
+ public interface MyInterface {
343
+ /**
344
+ * @example
345
+ * public class MyClass {
346
+ * public void myMethod() {
347
+ * System.debug('Hello, World!');
348
+ * }
349
+ * }
350
+ */
351
+ void myMethod();
352
+ }
353
+ `;
354
+
355
+ const result = generateDocs([input]);
356
+ expect(result).documentationBundleHasLength(1);
357
+ assertEither(result, (data) => expect(data).firstDocContains('```apex'));
358
+ assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
359
+ });
360
+
361
+ it('has a signature section', () => {
362
+ const input = `
363
+ public interface MyInterface {
364
+ void myMethod();
365
+ }
366
+ `;
367
+
368
+ const result = generateDocs([input]);
369
+ expect(result).documentationBundleHasLength(1);
370
+ assertEither(result, (data) => expect(data).firstDocContains('### Signature'));
371
+ });
372
+
373
+ it('has a parameters section', () => {
374
+ const input = `
375
+ public interface MyInterface {
376
+ void myMethod(String param1, Integer param2);
377
+ }
378
+ `;
379
+
380
+ const result = generateDocs([input]);
381
+ expect(result).documentationBundleHasLength(1);
382
+ assertEither(result, (data) => expect(data).firstDocContains('### Parameters'));
383
+ });
384
+
385
+ it('has a return type section', () => {
386
+ const input = `
387
+ public interface MyInterface {
388
+ String myMethod();
389
+ }
390
+ `;
391
+
392
+ const result = generateDocs([input]);
393
+ expect(result).documentationBundleHasLength(1);
394
+ assertEither(result, (data) => expect(data).firstDocContains('### Return Type'));
395
+ });
396
+
397
+ it('has a throws section', () => {
398
+ const input = `
399
+ public interface MyInterface {
400
+ /**
401
+ * @throws MyException
402
+ */
403
+ void myMethod();
404
+ }
405
+ `;
406
+
407
+ const result = generateDocs([input]);
408
+ expect(result).documentationBundleHasLength(1);
409
+ assertEither(result, (data) => expect(data).firstDocContains('### Throws'));
410
+ });
411
+
412
+ it('displays an "inherited" tag if the method was inherited from a different interface', () => {
413
+ const input1 = `
414
+ public interface MyInterface {
415
+ void myMethod();
416
+ }
417
+ `;
418
+
419
+ const input2 = `
420
+ public interface AnotherInterface extends MyInterface {}
421
+ `;
422
+
423
+ const result = generateDocs([input1, input2]);
424
+ expect(result).documentationBundleHasLength(2);
425
+ assertEither(result, (data) =>
426
+ expect(data.docs.find((doc) => doc.typeName === 'AnotherInterface')?.docContents).toContain('Inherited'),
427
+ );
428
+ });
429
+ });
430
+ });
431
+ });
@@ -0,0 +1,163 @@
1
+ import { assertEither, extendExpect } from './expect-extensions';
2
+ import { generateDocs } from '../../core/generate-docs';
3
+ import { pipe } from 'fp-ts/function';
4
+ import * as E from 'fp-ts/Either';
5
+
6
+ describe('Generates a Reference Guide', () => {
7
+ beforeAll(() => {
8
+ extendExpect();
9
+ });
10
+
11
+ it('returns a reference guide with links to all other files', () => {
12
+ const input1 = `
13
+ public enum MyEnum {
14
+ VALUE1,
15
+ VALUE2
16
+ }
17
+ `;
18
+
19
+ const input2 = `
20
+ public class MyClass {}
21
+ `;
22
+
23
+ const result = generateDocs([input1, input2]);
24
+ expect(result).documentationBundleHasLength(2);
25
+
26
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('[MyEnum](./Miscellaneous/MyEnum.md)'));
27
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('[MyClass](./Miscellaneous/MyClass.md)'));
28
+ });
29
+
30
+ it('groups things under Miscellaneous if no group is provided', () => {
31
+ const input = `
32
+ public enum MyEnum {
33
+ VALUE1,
34
+ VALUE2
35
+ }
36
+ `;
37
+
38
+ const result = generateDocs([input]);
39
+ expect(result).documentationBundleHasLength(1);
40
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('## Miscellaneous'));
41
+ });
42
+
43
+ it('group things under the provided group', () => {
44
+ const input = `
45
+ /**
46
+ * @group MyGroup
47
+ */
48
+ public enum MyEnum {
49
+ VALUE1,
50
+ VALUE2
51
+ }
52
+ `;
53
+
54
+ const result = generateDocs([input]);
55
+ expect(result).documentationBundleHasLength(1);
56
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('## MyGroup'));
57
+ });
58
+
59
+ it('displays groups in alphabetical order', () => {
60
+ const input1 = `
61
+ /**
62
+ * @group ZGroup
63
+ */
64
+ public enum MyEnum {
65
+ VALUE1,
66
+ VALUE2
67
+ }
68
+ `;
69
+
70
+ const input2 = `
71
+ /**
72
+ * @group AGroup
73
+ */
74
+ public class MyClass {}
75
+ `;
76
+
77
+ const result = generateDocs([input1, input2]);
78
+ expect(result).documentationBundleHasLength(2);
79
+ pipe(
80
+ result,
81
+ E.map((data) => ({
82
+ aGroupIndex: data.referenceGuide.indexOf('## AGroup'),
83
+ zGroupIndex: data.referenceGuide.indexOf('## ZGroup'),
84
+ })),
85
+ E.match(
86
+ () => fail('Expected data'),
87
+ (data) => expect(data.aGroupIndex).toBeLessThan(data.zGroupIndex),
88
+ ),
89
+ );
90
+ });
91
+
92
+ it('displays references within groups in alphabetical order', () => {
93
+ const input1 = `
94
+ /**
95
+ * @group Group1
96
+ */
97
+ public enum MyEnum {
98
+ VALUE1,
99
+ VALUE2
100
+ }
101
+ `;
102
+
103
+ const input2 = `
104
+ /**
105
+ * @group Group1
106
+ */
107
+ public class MyClass {}
108
+ `;
109
+
110
+ const result = generateDocs([input1, input2]);
111
+ expect(result).documentationBundleHasLength(2);
112
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('## Group1'));
113
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('MyClass'));
114
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('MyEnum'));
115
+ });
116
+
117
+ it('returns a reference guide with descriptions', () => {
118
+ const input1 = `
119
+ /**
120
+ * @description This is a description
121
+ */
122
+ public enum MyEnum {
123
+ VALUE1,
124
+ VALUE2
125
+ }
126
+ `;
127
+
128
+ const input2 = `
129
+ /**
130
+ * @description This is a description
131
+ */
132
+ public class MyClass {}
133
+ `;
134
+
135
+ const result = generateDocs([input1, input2]);
136
+ expect(result).documentationBundleHasLength(2);
137
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('This is a description'));
138
+ });
139
+
140
+ it('returns a reference guide with descriptions with links to all other files', () => {
141
+ const input1 = `
142
+ /**
143
+ * @description This is a description with a {@link MyClass}
144
+ * @group Group1
145
+ */
146
+ public enum MyEnum {
147
+ VALUE1,
148
+ VALUE2
149
+ }
150
+ `;
151
+
152
+ const input2 = `
153
+ /**
154
+ * @group Group2
155
+ */
156
+ public class MyClass {}
157
+ `;
158
+
159
+ const result = generateDocs([input1, input2]);
160
+ expect(result).documentationBundleHasLength(2);
161
+ assertEither(result, (data) => expect(data.referenceGuide).toContain('with a [MyClass](./Group2/MyClass.md)'));
162
+ });
163
+ });
@@ -3,28 +3,32 @@ import { AnnotationBuilder } from '../../test-helpers/AnnotationBuilder';
3
3
  import { MethodMirrorBuilder, ParameterBuilder } from '../../test-helpers/MethodMirrorBuilder';
4
4
  import { interfaceTypeToInterfaceSource } from '../apex-types';
5
5
 
6
+ function linkGenerator(type: string): string {
7
+ return type;
8
+ }
9
+
6
10
  describe('Conversion from InterfaceMirror to InterfaceSource understandable by the templating engine', () => {
7
11
  it('converts the name', () => {
8
12
  const interfaceMirror = new InterfaceMirrorBuilder().withName('SampleInterface').build();
9
- const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
13
+ const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror, linkGenerator);
10
14
 
11
15
  expect(interfaceSource.name).toBe('SampleInterface');
12
16
  });
13
17
 
14
18
  it('converts the access modifier', () => {
15
19
  const interfaceMirror = new InterfaceMirrorBuilder().build();
16
- const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
20
+ const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror, linkGenerator);
17
21
 
18
- expect(interfaceSource.accessModifier).toBe('public');
22
+ expect(interfaceSource.meta.accessModifier).toBe('public');
19
23
  });
20
24
 
21
25
  it('converts annotations', () => {
22
26
  const interfaceMirror = new InterfaceMirrorBuilder()
23
27
  .addAnnotation(new AnnotationBuilder().withName('MyAnnotation').build())
24
28
  .build();
25
- const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
29
+ const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror, linkGenerator);
26
30
 
27
- expect(interfaceSource.annotations).toEqual(['MYANNOTATION']);
31
+ expect(interfaceSource.doc.annotations).toEqual(['MYANNOTATION']);
28
32
  });
29
33
 
30
34
  it('converts method declarations. Method with no parameters', () => {
@@ -40,10 +44,10 @@ describe('Conversion from InterfaceMirror to InterfaceSource understandable by t
40
44
  )
41
45
  .build();
42
46
 
43
- const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
47
+ const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror, linkGenerator);
44
48
 
45
- expect(interfaceSource.methods).toHaveLength(1);
46
- expect(interfaceSource.methods![0].signature).toBe('public String sampleMethod()');
49
+ expect(interfaceSource.methods.value).toHaveLength(1);
50
+ expect(interfaceSource.methods.value[0].signature.value[0]).toBe('public String sampleMethod()');
47
51
  });
48
52
 
49
53
  it('converts method declarations. Method with parameters', () => {
@@ -68,9 +72,9 @@ describe('Conversion from InterfaceMirror to InterfaceSource understandable by t
68
72
  )
69
73
  .build();
70
74
 
71
- const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
75
+ const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror, linkGenerator);
72
76
 
73
- expect(interfaceSource.methods).toHaveLength(1);
74
- expect(interfaceSource.methods![0].signature).toBe('public String sampleMethod(String param1)');
77
+ expect(interfaceSource.methods.value).toHaveLength(1);
78
+ expect(interfaceSource.methods.value[0].signature.value[0]).toBe('public String sampleMethod(String param1)');
75
79
  });
76
80
  });
@@ -1,5 +1,5 @@
1
1
  import { replaceInlineReferences } from '../references';
2
- import { Link } from '../../templating/types';
2
+ import { Link } from '../../core/renderable/types';
3
3
 
4
4
  function getFileLink(typeName: string): Link {
5
5
  return {