@cparra/apexdocs 2.25.0-alpha.4 → 2.25.0-alpha.6

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 (189) hide show
  1. package/dist/cli/generate.js +2745 -39
  2. package/dist/defaults-DUwru49Q.js +12 -0
  3. package/dist/defaults-SH0Rsi5E.js +11 -0
  4. package/dist/index.d.ts +62 -2
  5. package/dist/index.js +36 -1
  6. package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +1 -1
  7. package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +1 -1
  8. package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +1 -1
  9. package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +1 -1
  10. package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +1 -1
  11. package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +1 -1
  12. package/examples/plain-markdown/docs/Miscellaneous/ns.Url.md +1 -1
  13. package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +1 -1
  14. package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +1 -1
  15. package/examples/plain-markdown/docs/index.md +1 -1
  16. package/examples/plain-markdown/package.json +3 -4
  17. package/examples/vitepress/.forceignore +12 -0
  18. package/examples/vitepress/apexdocs.config.ts +108 -0
  19. package/examples/vitepress/config/project-scratch-def.json +13 -0
  20. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +259 -0
  21. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
  22. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +40 -0
  23. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +11474 -0
  24. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +7 -0
  25. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +9172 -0
  26. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +7 -0
  27. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +3 -0
  28. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4339 -0
  29. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  30. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
  31. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  32. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +323 -0
  33. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +7 -0
  34. package/examples/vitepress/docs/.vitepress/config.mts +21 -0
  35. package/examples/vitepress/docs/.vitepress/sidebar.json +119 -0
  36. package/examples/vitepress/docs/Miscellaneous/apexdocs.BaseClass.md +20 -0
  37. package/examples/vitepress/docs/Miscellaneous/apexdocs.MultiInheritanceClass.md +78 -0
  38. package/examples/vitepress/docs/Miscellaneous/apexdocs.ParentInterface.md +19 -0
  39. package/examples/vitepress/docs/Miscellaneous/apexdocs.ReferencedEnum.md +15 -0
  40. package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleException.md +28 -0
  41. package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleInterface.md +122 -0
  42. package/examples/vitepress/docs/Miscellaneous/apexdocs.Url.md +318 -0
  43. package/examples/vitepress/docs/Sample-Enums/apexdocs.SampleEnum.md +41 -0
  44. package/examples/vitepress/docs/SampleGroup/apexdocs.SampleClass.md +178 -0
  45. package/examples/vitepress/docs/api-examples.md +49 -0
  46. package/examples/vitepress/docs/index-frontmatter.md +16 -0
  47. package/examples/vitepress/docs/index.md +127 -0
  48. package/examples/vitepress/docs/markdown-examples.md +85 -0
  49. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +3 -0
  50. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +1 -0
  51. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +3 -0
  52. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +5 -0
  53. package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +72 -0
  54. package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +30 -0
  55. package/examples/vitepress/force-app/main/default/classes/SampleException.cls +17 -0
  56. package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +46 -0
  57. package/examples/vitepress/force-app/main/default/classes/Url.cls +195 -0
  58. package/examples/vitepress/package-lock.json +2574 -0
  59. package/examples/vitepress/package.json +18 -0
  60. package/examples/vitepress/sfdx-project.json +12 -0
  61. package/jest.config.js +1 -0
  62. package/package.json +11 -10
  63. package/src/application/Apexdocs.ts +16 -104
  64. package/src/application/__tests__/apex-file-reader.spec.ts +104 -0
  65. package/src/application/apex-file-reader.ts +42 -0
  66. package/src/application/file-writer.ts +25 -0
  67. package/src/application/generators/markdown.ts +53 -0
  68. package/src/application/generators/openapi.ts +56 -0
  69. package/src/cli/args.ts +17 -112
  70. package/src/cli/commands/markdown.ts +58 -0
  71. package/src/cli/generate.ts +7 -5
  72. package/src/{model/__tests__ → core/__test__}/manifest.spec.ts +1 -1
  73. package/src/core/manifest.ts +57 -51
  74. package/src/{__spec__/core → core/markdown/__test__}/expect-extensions.ts +5 -5
  75. package/src/core/markdown/__test__/generating-class-docs.spec.ts +727 -0
  76. package/src/{__spec__/core → core/markdown/__test__}/generating-enum-docs.spec.ts +82 -59
  77. package/src/{__spec__/core → core/markdown/__test__}/generating-interface-docs.spec.ts +94 -75
  78. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +184 -0
  79. package/src/core/{__test__ → markdown/__test__}/inheritance-chain.test.ts +2 -2
  80. package/src/core/markdown/__test__/test-helpers.ts +22 -0
  81. package/src/core/{adapters → markdown/adapters}/__tests__/interface-adapter.spec.ts +38 -8
  82. package/src/core/{adapters → markdown/adapters}/apex-types.ts +7 -4
  83. package/src/core/{adapters → markdown/adapters}/inline.ts +1 -1
  84. package/src/core/markdown/adapters/renderable-bundle.ts +144 -0
  85. package/src/core/markdown/adapters/renderable-to-page-data.ts +92 -0
  86. package/src/core/{adapters → markdown/adapters}/types.d.ts +16 -2
  87. package/src/core/markdown/generate-docs.ts +158 -0
  88. package/src/core/markdown/reflection/error-handling.ts +37 -0
  89. package/src/core/markdown/reflection/filter-scope.ts +13 -0
  90. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +22 -0
  91. package/src/core/markdown/reflection/inherited-member-expansion.ts +105 -0
  92. package/src/core/markdown/reflection/reflect-source.ts +41 -0
  93. package/src/core/markdown/reflection/sort-members.ts +59 -0
  94. package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/class-template.ts +2 -0
  95. package/src/core/markdown/templates/hookable.ts +7 -0
  96. package/src/core/{template.ts → markdown/templates/template.ts} +12 -12
  97. package/src/core/markdown/utils.ts +3 -0
  98. package/src/{transpiler → core}/openapi/__tests__/open-api-docs-processor.spec.ts +1 -1
  99. package/src/{model → core/openapi}/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +3 -3
  100. package/src/core/openapi/file-container.ts +13 -0
  101. package/src/{service → core/openapi}/manifest-factory.ts +3 -3
  102. package/src/{transpiler → core}/openapi/open-api-docs-processor.ts +9 -10
  103. package/src/core/openapi/openapi-type-file.ts +14 -0
  104. package/src/{service → core/openapi}/parser.ts +8 -8
  105. package/src/{transpiler → core}/openapi/parsers/Builder.ts +2 -2
  106. package/src/{transpiler → core}/openapi/parsers/MethodParser.ts +5 -5
  107. package/src/{transpiler → core}/openapi/parsers/ParameterObjectBuilder.ts +2 -2
  108. package/src/{transpiler → core}/openapi/parsers/ReferenceBuilder.ts +3 -3
  109. package/src/{transpiler → core}/openapi/parsers/RequestBodyBuilder.ts +2 -2
  110. package/src/{transpiler → core}/openapi/parsers/ResponsesBuilder.ts +2 -2
  111. package/src/{transpiler → core}/openapi/parsers/__tests__/MethodParser.spec.ts +1 -1
  112. package/src/{transpiler → core}/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +2 -2
  113. package/src/{transpiler → core}/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +2 -2
  114. package/src/{transpiler → core}/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +2 -2
  115. package/src/{transpiler → core}/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +1 -1
  116. package/src/{transpiler → core/openapi}/transpiler.ts +2 -6
  117. package/src/{model → core/openapi}/types-repository.ts +0 -9
  118. package/src/core/parse-apex-metadata.ts +14 -0
  119. package/src/core/settings.ts +56 -0
  120. package/src/core/shared/types.d.ts +92 -0
  121. package/src/core/shared/utils.ts +5 -0
  122. package/src/defaults.ts +8 -0
  123. package/src/index.ts +34 -2
  124. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -5
  125. package/src/test-helpers/SettingsBuilder.ts +1 -3
  126. package/src/util/logger.ts +2 -2
  127. package/src/util/string-utils.ts +0 -4
  128. package/tsconfig.json +5 -1
  129. package/apexdocs.config.ts +0 -13
  130. package/examples/plain-markdown/template.md +0 -3
  131. package/src/__spec__/core/generating-class-docs.spec.ts +0 -531
  132. package/src/__spec__/core/generating-reference-guide.spec.ts +0 -164
  133. package/src/__spec__/core/test-helpers.ts +0 -9
  134. package/src/application/generators/generate-markdown-files.ts +0 -53
  135. package/src/core/apex-bundle.ts +0 -3
  136. package/src/core/generate-docs.ts +0 -432
  137. package/src/model/markdown-file.ts +0 -122
  138. package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +0 -50
  139. package/src/model/markdown-generation-util/field-declaration-util.ts +0 -71
  140. package/src/model/markdown-generation-util/index.ts +0 -3
  141. package/src/model/markdown-generation-util/method-declaration-util.ts +0 -166
  142. package/src/model/markdown-generation-util/type-declaration-util.ts +0 -91
  143. package/src/model/markdown-home-file.ts +0 -58
  144. package/src/model/markdown-type-file.ts +0 -169
  145. package/src/model/openapi/openapi-type-file.ts +0 -14
  146. package/src/model/outputFile.ts +0 -20
  147. package/src/service/__tests__/apex-file-reader.spec.ts +0 -93
  148. package/src/service/apex-file-reader.ts +0 -47
  149. package/src/service/file-writer.ts +0 -34
  150. package/src/service/metadata-processor.ts +0 -16
  151. package/src/service/state.ts +0 -24
  152. package/src/service/walkers/class-walker.ts +0 -30
  153. package/src/service/walkers/enum-walker.ts +0 -7
  154. package/src/service/walkers/interface-walker.ts +0 -12
  155. package/src/service/walkers/walker-factory.ts +0 -19
  156. package/src/service/walkers/walker.ts +0 -42
  157. package/src/settings.ts +0 -143
  158. package/src/transpiler/factory.ts +0 -31
  159. package/src/transpiler/file-container.ts +0 -13
  160. package/src/transpiler/generator-choices.ts +0 -1
  161. package/src/transpiler/markdown/class-file-generatorHelper.ts +0 -61
  162. package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +0 -12
  163. package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +0 -50
  164. package/src/transpiler/markdown/markdown-transpiler-base.ts +0 -28
  165. package/src/transpiler/processor-type-transpiler.ts +0 -18
  166. /package/src/{service → application}/file-system.ts +0 -0
  167. /package/src/core/{adapters → markdown/adapters}/__tests__/documentables.spec.ts +0 -0
  168. /package/src/core/{adapters → markdown/adapters}/__tests__/references.spec.ts +0 -0
  169. /package/src/core/{adapters → markdown/adapters}/documentables.ts +0 -0
  170. /package/src/core/{adapters → markdown/adapters}/fields-and-properties.ts +0 -0
  171. /package/src/core/{adapters → markdown/adapters}/methods-and-constructors.ts +0 -0
  172. /package/src/core/{adapters → markdown/adapters}/type-utils.ts +0 -0
  173. /package/src/core/{inheritance-chain.ts → markdown/reflection/inheritance-chain.ts} +0 -0
  174. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/constructors-partial-template.ts +0 -0
  175. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/documentable-partial-template.ts +0 -0
  176. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/enum-template.ts +0 -0
  177. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/fieldsPartialTemplate.ts +0 -0
  178. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/grouped-members-partial-template.ts +0 -0
  179. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/interface-template.ts +0 -0
  180. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/methods-partial-template.ts +0 -0
  181. /package/src/core/{templates → markdown/templates}/reference-guide.ts +0 -0
  182. /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/type-doc-partial.ts +0 -0
  183. /package/src/{service → core/openapi}/__tests__/manifest-factory.spec.ts +0 -0
  184. /package/src/{model → core}/openapi/__tests__/open-api.spec.ts +0 -0
  185. /package/src/{model → core}/openapi/apex-doc-types.ts +0 -0
  186. /package/src/{model → core/openapi}/apex-type-wrappers/ClassMirrorWrapper.ts +0 -0
  187. /package/src/{model → core/openapi}/apex-type-wrappers/MethodMirrorWrapper.ts +0 -0
  188. /package/src/{model → core}/openapi/open-api-types.ts +0 -0
  189. /package/src/{model → core}/openapi/open-api.ts +0 -0
@@ -1,531 +0,0 @@
1
- import { assertEither, extendExpect } from './expect-extensions';
2
- import { generateDocs } from '../../core/generate-docs';
3
- import { apexBundleFromRawString } from './test-helpers';
4
-
5
- describe('Generates interface documentation', () => {
6
- beforeAll(() => {
7
- extendExpect();
8
- });
9
-
10
- describe('documentation output', () => {
11
- it('always returns markdown as the format', () => {
12
- const input = 'public class MyClass {}';
13
-
14
- const result = generateDocs([apexBundleFromRawString(input)]);
15
- assertEither(result, (data) => expect(data.format).toBe('markdown'));
16
- });
17
-
18
- it('returns the name of the class', () => {
19
- const input = 'public class MyClass {}';
20
-
21
- const result = generateDocs([apexBundleFromRawString(input)]);
22
- expect(result).documentationBundleHasLength(1);
23
- assertEither(result, (data) => expect(data.docs[0].typeName).toBe('MyClass'));
24
- });
25
-
26
- it('returns the type as class', () => {
27
- const input = 'public class MyClass {}';
28
-
29
- const result = generateDocs([apexBundleFromRawString(input)]);
30
- expect(result).documentationBundleHasLength(1);
31
- assertEither(result, (data) => expect(data.docs[0].type).toBe('class'));
32
- });
33
-
34
- it('does not return classes out of scope', () => {
35
- const input1 = `
36
- global class MyClass {}
37
- `;
38
-
39
- const input2 = `
40
- public class AnotherClass {}
41
- `;
42
-
43
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
44
- scope: ['global'],
45
- });
46
- expect(result).documentationBundleHasLength(1);
47
- });
48
-
49
- it('does not return classes that have an @ignore in the docs', () => {
50
- const input = `
51
- /**
52
- * @ignore
53
- */
54
- public class MyClass {}`;
55
-
56
- const result = generateDocs([apexBundleFromRawString(input)]);
57
- expect(result).documentationBundleHasLength(0);
58
- });
59
-
60
- it('does not return class methods that have @ignore in the docs', () => {
61
- const input = `
62
- public class MyClass {
63
- /**
64
- * @ignore
65
- */
66
- public void myMethod() {}
67
- }`;
68
-
69
- const result = generateDocs([apexBundleFromRawString(input)]);
70
- expect(result).documentationBundleHasLength(1);
71
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('myMethod'));
72
- });
73
-
74
- it('does not return class properties that have @ignore in the docs', () => {
75
- const input = `
76
- public class MyClass {
77
- /**
78
- * @ignore
79
- */
80
- public String myProperty { get; set; }
81
- }`;
82
-
83
- const result = generateDocs([apexBundleFromRawString(input)]);
84
- expect(result).documentationBundleHasLength(1);
85
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('myProperty'));
86
- });
87
-
88
- it('does not return class fields that have @ignore in the docs', () => {
89
- const input = `
90
- public class MyClass {
91
- /**
92
- * @ignore
93
- */
94
- public String myField;
95
- }`;
96
-
97
- const result = generateDocs([apexBundleFromRawString(input)]);
98
- expect(result).documentationBundleHasLength(1);
99
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('myField'));
100
- });
101
-
102
- it('does not return class inner classes that have @ignore in the docs', () => {
103
- const input = `
104
- public class MyClass {
105
- /**
106
- * @ignore
107
- */
108
- public class InnerClass {}
109
- }`;
110
-
111
- const result = generateDocs([apexBundleFromRawString(input)]);
112
- expect(result).documentationBundleHasLength(1);
113
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('InnerClass'));
114
- });
115
-
116
- it('does not return class inner interfaces that have @ignore in the docs', () => {
117
- const input = `
118
- public class MyClass {
119
- /**
120
- * @ignore
121
- */
122
- public interface InnerInterface {}
123
- }`;
124
-
125
- const result = generateDocs([apexBundleFromRawString(input)]);
126
- expect(result).documentationBundleHasLength(1);
127
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('InnerInterface'));
128
- });
129
-
130
- it('does not return class inner enums that have @ignore in the docs', () => {
131
- const input = `
132
- public class MyClass {
133
- /**
134
- * @ignore
135
- */
136
- public enum InnerEnum {}
137
- }`;
138
-
139
- const result = generateDocs([apexBundleFromRawString(input)]);
140
- expect(result).documentationBundleHasLength(1);
141
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('InnerEnum'));
142
- });
143
- });
144
-
145
- describe('documentation content', () => {
146
- describe('type level information', () => {
147
- it('generates a heading with the class name', () => {
148
- const input = 'public class MyClass {}';
149
-
150
- const output = `# MyClass Class`;
151
- const result = generateDocs([apexBundleFromRawString(input)]);
152
- expect(result).documentationBundleHasLength(1);
153
- assertEither(result, (data) => expect(data).firstDocContains(output));
154
- });
155
-
156
- it('displays type level annotations', () => {
157
- const input = `
158
- @NamespaceAccessible
159
- public class MyClass {
160
- @Deprecated
161
- public void myMethod() {}
162
- }
163
- `;
164
-
165
- const result = generateDocs([apexBundleFromRawString(input)]);
166
- expect(result).documentationBundleHasLength(1);
167
- assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
168
- assertEither(result, (data) => expect(data).firstDocContains('DEPRECATED'));
169
- });
170
-
171
- it('displays metadata as annotations', () => {
172
- const input = 'public class MyClass {}';
173
- const metadata = `
174
- <?xml version="1.0" encoding="UTF-8"?>
175
- <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
176
- <apiVersion>59.0</apiVersion>
177
- <status>Active</status>
178
- </ApexClass>
179
- `;
180
-
181
- const result = generateDocs([apexBundleFromRawString(input, metadata)]);
182
-
183
- expect(result).documentationBundleHasLength(1);
184
- assertEither(result, (data) => expect(data).firstDocContains('APIVERSION'));
185
- assertEither(result, (data) => expect(data).firstDocContains('STATUS'));
186
- });
187
-
188
- it('displays the description', () => {
189
- const input = `
190
- /**
191
- * This is a description
192
- */
193
- public class MyClass {}
194
- `;
195
-
196
- const result = generateDocs([apexBundleFromRawString(input)]);
197
- expect(result).documentationBundleHasLength(1);
198
- assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
199
- });
200
-
201
- it('display custom documentation tags', () => {
202
- const input = `
203
- /**
204
- * @custom-tag My Value
205
- */
206
- public class MyClass {}
207
- `;
208
-
209
- const result = generateDocs([apexBundleFromRawString(input)]);
210
- expect(result).documentationBundleHasLength(1);
211
- assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
212
- assertEither(result, (data) => expect(data).firstDocContains('My Value'));
213
- });
214
-
215
- it('displays the group', () => {
216
- const input = `
217
- /**
218
- * @group MyGroup
219
- */
220
- public class MyClass {}`;
221
-
222
- const result = generateDocs([apexBundleFromRawString(input)]);
223
- expect(result).documentationBundleHasLength(1);
224
- assertEither(result, (data) => expect(data).firstDocContains('Group'));
225
- assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
226
- });
227
-
228
- it('displays the author', () => {
229
- const input = `
230
- /**
231
- * @author John Doe
232
- */
233
- public class MyClass {}`;
234
-
235
- const result = generateDocs([apexBundleFromRawString(input)]);
236
- expect(result).documentationBundleHasLength(1);
237
- assertEither(result, (data) => expect(data).firstDocContains('Author'));
238
- assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
239
- });
240
-
241
- it('displays the date', () => {
242
- const input = `
243
- /**
244
- * @date 2021-01-01
245
- */
246
- public class MyClass {}`;
247
-
248
- const result = generateDocs([apexBundleFromRawString(input)]);
249
- expect(result).documentationBundleHasLength(1);
250
- assertEither(result, (data) => expect(data).firstDocContains('Date'));
251
- assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
252
- });
253
-
254
- it('displays descriptions', () => {
255
- const input = `
256
- /**
257
- * @description This is a description
258
- */
259
- public class MyClass {}`;
260
-
261
- const result = generateDocs([apexBundleFromRawString(input)]);
262
- expect(result).documentationBundleHasLength(1);
263
- assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
264
- });
265
-
266
- it('displays descriptions with links', () => {
267
- const input1 = `
268
- /**
269
- * @description This is a description with a {@link ClassRef} reference
270
- */
271
- public enum MyClass {}
272
- `;
273
-
274
- const input2 = 'public class ClassRef {}';
275
-
276
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
277
- expect(result).documentationBundleHasLength(2);
278
- assertEither(result, (data) =>
279
- expect(data).firstDocContains('This is a description with a [ClassRef](./ClassRef.md) reference'),
280
- );
281
- });
282
-
283
- it('displays descriptions with emails', () => {
284
- const input = `
285
- /**
286
- * @description This is a description with an {@email test@testerson.com} email
287
- */
288
- public class MyClass {}
289
- `;
290
-
291
- const result = generateDocs([apexBundleFromRawString(input)]);
292
- expect(result).documentationBundleHasLength(1);
293
- assertEither(result, (data) =>
294
- expect(data).firstDocContains(
295
- 'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
296
- ),
297
- );
298
- });
299
-
300
- it('displays sees with accurately resolved links', () => {
301
- const input1 = `
302
- /**
303
- * @see ClassRef
304
- */
305
- public class MyClass {}
306
- `;
307
-
308
- const input2 = 'public class ClassRef {}';
309
-
310
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
311
- expect(result).documentationBundleHasLength(2);
312
- assertEither(result, (data) => expect(data).firstDocContains('See'));
313
- assertEither(result, (data) => expect(data).firstDocContains('[ClassRef](./ClassRef.md)'));
314
- });
315
-
316
- it('displays sees without links when the reference is not found', () => {
317
- const input = `
318
- /**
319
- * @see ClassRef
320
- */
321
- public class MyClass {}
322
- `;
323
-
324
- const result = generateDocs([apexBundleFromRawString(input)]);
325
- expect(result).documentationBundleHasLength(1);
326
- assertEither(result, (data) => expect(data).firstDocContains('See'));
327
- assertEither(result, (data) => expect(data).firstDocContains('ClassRef'));
328
- });
329
-
330
- it('displays the namespace if present in the config', () => {
331
- const input = 'public class MyClass {}';
332
-
333
- const result = generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' });
334
- expect(result).documentationBundleHasLength(1);
335
- assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
336
- assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
337
- });
338
-
339
- it('does not display the namespace if not present in the config', () => {
340
- const input = 'public class MyClass {}';
341
-
342
- const result = generateDocs([apexBundleFromRawString(input)]);
343
- expect(result).documentationBundleHasLength(1);
344
- assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
345
- });
346
-
347
- it('displays a mermaid diagram', () => {
348
- const input = `
349
- /**
350
- * @mermaid
351
- * graph TD
352
- * A[Square Rect] -- Link text --> B((Circle))
353
- * A --> C(Round Rect)
354
- * B --> D{Rhombus}
355
- * C --> D
356
- */
357
- public class MyClass {}
358
- `;
359
-
360
- const result = generateDocs([apexBundleFromRawString(input)]);
361
- expect(result).documentationBundleHasLength(1);
362
- assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
363
- assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
364
- });
365
-
366
- it('displays an example code block', () => {
367
- const input = `
368
- /**
369
- * @example
370
- * public class MyClass {
371
- * public void myMethod() {
372
- * System.debug('Hello, World!');
373
- * }
374
- * }
375
- */
376
- public class MyClass {}`;
377
-
378
- const result = generateDocs([apexBundleFromRawString(input)]);
379
- expect(result).documentationBundleHasLength(1);
380
- assertEither(result, (data) => expect(data).firstDocContains('```apex'));
381
- assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
382
- });
383
- });
384
- });
385
-
386
- describe('member information', () => {
387
- it('displays the Method heading', () => {
388
- const input = `
389
- public class MyClass {
390
- public void myMethod() {}
391
- }
392
- `;
393
-
394
- const result = generateDocs([apexBundleFromRawString(input)]);
395
- expect(result).documentationBundleHasLength(1);
396
- assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
397
- });
398
-
399
- it('displays the Property heading', () => {
400
- const input = `
401
- public class MyClass {
402
- public String myProperty { get; set; }
403
- }
404
- `;
405
-
406
- const result = generateDocs([apexBundleFromRawString(input)]);
407
- expect(result).documentationBundleHasLength(1);
408
- assertEither(result, (data) => expect(data).firstDocContains('## Properties'));
409
- });
410
-
411
- it('displays the Field heading', () => {
412
- const input = `
413
- public class MyClass {
414
- public String myField;
415
- }
416
- `;
417
-
418
- const result = generateDocs([apexBundleFromRawString(input)]);
419
- expect(result).documentationBundleHasLength(1);
420
- assertEither(result, (data) => expect(data).firstDocContains('## Fields'));
421
- });
422
-
423
- it('displays the Constructor heading', () => {
424
- const input = `
425
- public class MyClass {
426
- public MyClass() {}
427
- }
428
- `;
429
-
430
- const result = generateDocs([apexBundleFromRawString(input)]);
431
- expect(result).documentationBundleHasLength(1);
432
- assertEither(result, (data) => expect(data).firstDocContains('## Constructors'));
433
- });
434
-
435
- it('displays the Inner Class heading', () => {
436
- const input = `
437
- public class MyClass {
438
- public class InnerClass {}
439
- }
440
- `;
441
-
442
- const result = generateDocs([apexBundleFromRawString(input)]);
443
- expect(result).documentationBundleHasLength(1);
444
- assertEither(result, (data) => expect(data).firstDocContains('## Classes'));
445
- });
446
-
447
- it('displays the Inner Interface heading', () => {
448
- const input = `
449
- public class MyClass {
450
- public interface InnerInterface {}
451
- }
452
- `;
453
-
454
- const result = generateDocs([apexBundleFromRawString(input)]);
455
- expect(result).documentationBundleHasLength(1);
456
- assertEither(result, (data) => expect(data).firstDocContains('## Interfaces'));
457
- });
458
-
459
- it('displays the Inner Enum heading', () => {
460
- const input = `
461
- public class MyClass {
462
- public enum InnerEnum {}
463
- }
464
- `;
465
-
466
- const result = generateDocs([apexBundleFromRawString(input)]);
467
- expect(result).documentationBundleHasLength(1);
468
- assertEither(result, (data) => expect(data).firstDocContains('## Enums'));
469
- });
470
-
471
- it('supports having mermaid diagrams in descriptions', () => {
472
- const input = `
473
- public class MyClass {
474
- /**
475
- * @mermaid
476
- * graph TD
477
- * A[Square Rect] -- Link text --> B((Circle))
478
- * A --> C(Round Rect)
479
- * B --> D{Rhombus}
480
- * C --> D
481
- */
482
- public void myMethod() {}
483
- }
484
- `;
485
-
486
- const result = generateDocs([apexBundleFromRawString(input)]);
487
- expect(result).documentationBundleHasLength(1);
488
- assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
489
- assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
490
- });
491
-
492
- it('supports having example code blocks in method descriptions', () => {
493
- const input = `
494
- public class MyClass {
495
- /**
496
- * @example
497
- * public class MyClass {
498
- * public void myMethod() {
499
- * System.debug('Hello, World!');
500
- * }
501
- * }
502
- */
503
- public void myMethod() {}
504
- }
505
- `;
506
-
507
- const result = generateDocs([apexBundleFromRawString(input)]);
508
- expect(result).documentationBundleHasLength(1);
509
- assertEither(result, (data) => expect(data).firstDocContains('```apex'));
510
- assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
511
- });
512
-
513
- it('displays an "inherited" tag if the method was inherited from a different interface', () => {
514
- const input1 = `
515
- public virtual class MyClass {
516
- public void myMethod() {}
517
- }
518
- `;
519
-
520
- const input2 = `
521
- public class AnotherClass extends MyClass {}
522
- `;
523
-
524
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
525
- expect(result).documentationBundleHasLength(2);
526
- assertEither(result, (data) =>
527
- expect(data.docs.find((doc) => doc.typeName === 'AnotherClass')?.docContents).toContain('Inherited'),
528
- );
529
- });
530
- });
531
- });
@@ -1,164 +0,0 @@
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
- import { apexBundleFromRawString } from './test-helpers';
6
-
7
- describe('Generates a Reference Guide', () => {
8
- beforeAll(() => {
9
- extendExpect();
10
- });
11
-
12
- it('returns a reference guide with links to all other files', () => {
13
- const input1 = `
14
- public enum MyEnum {
15
- VALUE1,
16
- VALUE2
17
- }
18
- `;
19
-
20
- const input2 = `
21
- public class MyClass {}
22
- `;
23
-
24
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
25
- expect(result).documentationBundleHasLength(2);
26
-
27
- assertEither(result, (data) => expect(data.referenceGuide).toContain('[MyEnum](./Miscellaneous/MyEnum.md)'));
28
- assertEither(result, (data) => expect(data.referenceGuide).toContain('[MyClass](./Miscellaneous/MyClass.md)'));
29
- });
30
-
31
- it('groups things under Miscellaneous if no group is provided', () => {
32
- const input = `
33
- public enum MyEnum {
34
- VALUE1,
35
- VALUE2
36
- }
37
- `;
38
-
39
- const result = generateDocs([apexBundleFromRawString(input)]);
40
- expect(result).documentationBundleHasLength(1);
41
- assertEither(result, (data) => expect(data.referenceGuide).toContain('## Miscellaneous'));
42
- });
43
-
44
- it('group things under the provided group', () => {
45
- const input = `
46
- /**
47
- * @group MyGroup
48
- */
49
- public enum MyEnum {
50
- VALUE1,
51
- VALUE2
52
- }
53
- `;
54
-
55
- const result = generateDocs([apexBundleFromRawString(input)]);
56
- expect(result).documentationBundleHasLength(1);
57
- assertEither(result, (data) => expect(data.referenceGuide).toContain('## MyGroup'));
58
- });
59
-
60
- it('displays groups in alphabetical order', () => {
61
- const input1 = `
62
- /**
63
- * @group ZGroup
64
- */
65
- public enum MyEnum {
66
- VALUE1,
67
- VALUE2
68
- }
69
- `;
70
-
71
- const input2 = `
72
- /**
73
- * @group AGroup
74
- */
75
- public class MyClass {}
76
- `;
77
-
78
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
79
- expect(result).documentationBundleHasLength(2);
80
- pipe(
81
- result,
82
- E.map((data) => ({
83
- aGroupIndex: data.referenceGuide.indexOf('## AGroup'),
84
- zGroupIndex: data.referenceGuide.indexOf('## ZGroup'),
85
- })),
86
- E.match(
87
- () => fail('Expected data'),
88
- (data) => expect(data.aGroupIndex).toBeLessThan(data.zGroupIndex),
89
- ),
90
- );
91
- });
92
-
93
- it('displays references within groups in alphabetical order', () => {
94
- const input1 = `
95
- /**
96
- * @group Group1
97
- */
98
- public enum MyEnum {
99
- VALUE1,
100
- VALUE2
101
- }
102
- `;
103
-
104
- const input2 = `
105
- /**
106
- * @group Group1
107
- */
108
- public class MyClass {}
109
- `;
110
-
111
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
112
- expect(result).documentationBundleHasLength(2);
113
- assertEither(result, (data) => expect(data.referenceGuide).toContain('## Group1'));
114
- assertEither(result, (data) => expect(data.referenceGuide).toContain('MyClass'));
115
- assertEither(result, (data) => expect(data.referenceGuide).toContain('MyEnum'));
116
- });
117
-
118
- it('returns a reference guide with descriptions', () => {
119
- const input1 = `
120
- /**
121
- * @description This is a description
122
- */
123
- public enum MyEnum {
124
- VALUE1,
125
- VALUE2
126
- }
127
- `;
128
-
129
- const input2 = `
130
- /**
131
- * @description This is a description
132
- */
133
- public class MyClass {}
134
- `;
135
-
136
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
137
- expect(result).documentationBundleHasLength(2);
138
- assertEither(result, (data) => expect(data.referenceGuide).toContain('This is a description'));
139
- });
140
-
141
- it('returns a reference guide with descriptions with links to all other files', () => {
142
- const input1 = `
143
- /**
144
- * @description This is a description with a {@link MyClass}
145
- * @group Group1
146
- */
147
- public enum MyEnum {
148
- VALUE1,
149
- VALUE2
150
- }
151
- `;
152
-
153
- const input2 = `
154
- /**
155
- * @group Group2
156
- */
157
- public class MyClass {}
158
- `;
159
-
160
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
161
- expect(result).documentationBundleHasLength(2);
162
- assertEither(result, (data) => expect(data.referenceGuide).toContain('with a [MyClass](./Group2/MyClass.md)'));
163
- });
164
- });
@@ -1,9 +0,0 @@
1
- import ApexBundle from '../../core/apex-bundle';
2
-
3
- export function apexBundleFromRawString(raw: string, rawMetadata?: string): ApexBundle {
4
- return {
5
- filePath: 'test.cls',
6
- rawTypeContent: raw,
7
- rawMetadataContent: rawMetadata ?? null,
8
- };
9
- }