@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,6 +1,5 @@
1
1
  import { assertEither, extendExpect } from './expect-extensions';
2
- import { generateDocs } from '../../core/generate-docs';
3
- import { apexBundleFromRawString } from './test-helpers';
2
+ import { apexBundleFromRawString, generateDocs } from './test-helpers';
4
3
 
5
4
  describe('Generates interface documentation', () => {
6
5
  beforeAll(() => {
@@ -8,39 +7,29 @@ describe('Generates interface documentation', () => {
8
7
  });
9
8
 
10
9
  describe('documentation output', () => {
11
- it('always returns markdown as the format', () => {
12
- const input = `
13
- public interface MyInterface {
14
- }
15
- `;
16
-
17
- const result = generateDocs([apexBundleFromRawString(input)]);
18
- assertEither(result, (data) => expect(data.format).toBe('markdown'));
19
- });
20
-
21
- it('returns the name of the interface', () => {
10
+ it('returns the name of the interface', async () => {
22
11
  const input = `
23
12
  public interface MyInterface {
24
13
  }
25
14
  `;
26
15
 
27
- const result = generateDocs([apexBundleFromRawString(input)]);
16
+ const result = await generateDocs([apexBundleFromRawString(input)])();
28
17
  expect(result).documentationBundleHasLength(1);
29
- assertEither(result, (data) => expect(data.docs[0].typeName).toBe('MyInterface'));
18
+ assertEither(result, (data) => expect(data.docs[0].source.name).toBe('MyInterface'));
30
19
  });
31
20
 
32
- it('returns the type as interface', () => {
21
+ it('returns the type as interface', async () => {
33
22
  const input = `
34
23
  public interface MyInterface {
35
24
  }
36
25
  `;
37
26
 
38
- const result = generateDocs([apexBundleFromRawString(input)]);
27
+ const result = await generateDocs([apexBundleFromRawString(input)])();
39
28
  expect(result).documentationBundleHasLength(1);
40
- assertEither(result, (data) => expect(data.docs[0].type).toBe('interface'));
29
+ assertEither(result, (data) => expect(data.docs[0].source.type).toBe('interface'));
41
30
  });
42
31
 
43
- it('does not return interfaces out of scope', () => {
32
+ it('does not return interfaces out of scope', async () => {
44
33
  const input1 = `
45
34
  global interface MyInterface {}
46
35
  `;
@@ -49,24 +38,24 @@ describe('Generates interface documentation', () => {
49
38
  public interface AnotherInterface {}
50
39
  `;
51
40
 
52
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
41
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
53
42
  scope: ['global'],
54
- });
43
+ })();
55
44
  expect(result).documentationBundleHasLength(1);
56
45
  });
57
46
 
58
- it('does not return interfaces that have an @ignore in the docs', () => {
47
+ it('does not return interfaces that have an @ignore in the docs', async () => {
59
48
  const input = `
60
49
  /**
61
50
  * @ignore
62
51
  */
63
52
  public interface MyInterface {}`;
64
53
 
65
- const result = generateDocs([apexBundleFromRawString(input)]);
54
+ const result = await generateDocs([apexBundleFromRawString(input)])();
66
55
  expect(result).documentationBundleHasLength(0);
67
56
  });
68
57
 
69
- it('does not return interface methods that have @ignore in the docs', () => {
58
+ it('does not return interface methods that have @ignore in the docs', async () => {
70
59
  const input = `
71
60
  public interface MyInterface {
72
61
  /**
@@ -75,26 +64,26 @@ describe('Generates interface documentation', () => {
75
64
  void myMethod();
76
65
  }`;
77
66
 
78
- const result = generateDocs([apexBundleFromRawString(input)]);
67
+ const result = await generateDocs([apexBundleFromRawString(input)])();
79
68
  expect(result).documentationBundleHasLength(1);
80
- assertEither(result, (data) => expect(data.docs[0].docContents).not.toContain('myMethod'));
69
+ assertEither(result, (data) => expect(data.docs[0].content).not.toContain('myMethod'));
81
70
  });
82
71
  });
83
72
 
84
73
  describe('documentation content', () => {
85
74
  describe('type level information', () => {
86
- it('generates a heading with the interface name', () => {
75
+ it('generates a heading with the interface name', async () => {
87
76
  const input = `
88
77
  public interface MyInterface {}
89
78
  `;
90
79
 
91
80
  const output = `# MyInterface Interface`;
92
- const result = generateDocs([apexBundleFromRawString(input)]);
81
+ const result = await generateDocs([apexBundleFromRawString(input)])();
93
82
  expect(result).documentationBundleHasLength(1);
94
83
  assertEither(result, (data) => expect(data).firstDocContains(output));
95
84
  });
96
85
 
97
- it('displays type level annotations', () => {
86
+ it('displays type level annotations', async () => {
98
87
  const input = `
99
88
  @NamespaceAccessible
100
89
  public interface MyInterface {
@@ -103,13 +92,13 @@ describe('Generates interface documentation', () => {
103
92
  }
104
93
  `;
105
94
 
106
- const result = generateDocs([apexBundleFromRawString(input)]);
95
+ const result = await generateDocs([apexBundleFromRawString(input)])();
107
96
  expect(result).documentationBundleHasLength(1);
108
97
  assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
109
98
  assertEither(result, (data) => expect(data).firstDocContains('DEPRECATED'));
110
99
  });
111
100
 
112
- it('displays the description', () => {
101
+ it('displays the description', async () => {
113
102
  const input = `
114
103
  /**
115
104
  * This is a description
@@ -117,12 +106,12 @@ describe('Generates interface documentation', () => {
117
106
  public interface MyInterface {}
118
107
  `;
119
108
 
120
- const result = generateDocs([apexBundleFromRawString(input)]);
109
+ const result = await generateDocs([apexBundleFromRawString(input)])();
121
110
  expect(result).documentationBundleHasLength(1);
122
111
  assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
123
112
  });
124
113
 
125
- it('display custom documentation tags', () => {
114
+ it('display custom documentation tags', async () => {
126
115
  const input = `
127
116
  /**
128
117
  * @custom-tag My Value
@@ -130,64 +119,64 @@ describe('Generates interface documentation', () => {
130
119
  public interface MyInterface {}
131
120
  `;
132
121
 
133
- const result = generateDocs([apexBundleFromRawString(input)]);
122
+ const result = await generateDocs([apexBundleFromRawString(input)])();
134
123
  expect(result).documentationBundleHasLength(1);
135
124
  assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
136
125
  assertEither(result, (data) => expect(data).firstDocContains('My Value'));
137
126
  });
138
127
 
139
- it('displays the group', () => {
128
+ it('displays the group', async () => {
140
129
  const input = `
141
130
  /**
142
131
  * @group MyGroup
143
132
  */
144
133
  public interface MyInterface {}`;
145
134
 
146
- const result = generateDocs([apexBundleFromRawString(input)]);
135
+ const result = await generateDocs([apexBundleFromRawString(input)])();
147
136
  expect(result).documentationBundleHasLength(1);
148
137
  assertEither(result, (data) => expect(data).firstDocContains('Group'));
149
138
  assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
150
139
  });
151
140
 
152
- it('displays the author', () => {
141
+ it('displays the author', async () => {
153
142
  const input = `
154
143
  /**
155
144
  * @author John Doe
156
145
  */
157
146
  public interface MyInterface {}`;
158
147
 
159
- const result = generateDocs([apexBundleFromRawString(input)]);
148
+ const result = await generateDocs([apexBundleFromRawString(input)])();
160
149
  expect(result).documentationBundleHasLength(1);
161
150
  assertEither(result, (data) => expect(data).firstDocContains('Author'));
162
151
  assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
163
152
  });
164
153
 
165
- it('displays the date', () => {
154
+ it('displays the date', async () => {
166
155
  const input = `
167
156
  /**
168
157
  * @date 2021-01-01
169
158
  */
170
159
  public interface MyInterface {}`;
171
160
 
172
- const result = generateDocs([apexBundleFromRawString(input)]);
161
+ const result = await generateDocs([apexBundleFromRawString(input)])();
173
162
  expect(result).documentationBundleHasLength(1);
174
163
  assertEither(result, (data) => expect(data).firstDocContains('Date'));
175
164
  assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
176
165
  });
177
166
 
178
- it('displays descriptions', () => {
167
+ it('displays descriptions', async () => {
179
168
  const input = `
180
169
  /**
181
170
  * @description This is a description
182
171
  */
183
172
  public interface MyInterface {}`;
184
173
 
185
- const result = generateDocs([apexBundleFromRawString(input)]);
174
+ const result = await generateDocs([apexBundleFromRawString(input)])();
186
175
  expect(result).documentationBundleHasLength(1);
187
176
  assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
188
177
  });
189
178
 
190
- it('displays descriptions with links', () => {
179
+ it('displays descriptions with links', async () => {
191
180
  const input1 = `
192
181
  /**
193
182
  * @description This is a description with a {@link InterfaceRef} reference
@@ -197,14 +186,14 @@ describe('Generates interface documentation', () => {
197
186
 
198
187
  const input2 = 'public interface InterfaceRef {}';
199
188
 
200
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
189
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
201
190
  expect(result).documentationBundleHasLength(2);
202
191
  assertEither(result, (data) =>
203
192
  expect(data).firstDocContains('This is a description with a [InterfaceRef](./InterfaceRef.md) reference'),
204
193
  );
205
194
  });
206
195
 
207
- it('displays descriptions with emails', () => {
196
+ it('displays descriptions with emails', async () => {
208
197
  const input = `
209
198
  /**
210
199
  * @description This is a description with an {@email test@testerson.com} email
@@ -212,7 +201,7 @@ describe('Generates interface documentation', () => {
212
201
  public interface MyInterface {}
213
202
  `;
214
203
 
215
- const result = generateDocs([apexBundleFromRawString(input)]);
204
+ const result = await generateDocs([apexBundleFromRawString(input)])();
216
205
  expect(result).documentationBundleHasLength(1);
217
206
  assertEither(result, (data) =>
218
207
  expect(data).firstDocContains(
@@ -221,7 +210,7 @@ describe('Generates interface documentation', () => {
221
210
  );
222
211
  });
223
212
 
224
- it('displays sees with accurately resolved links', () => {
213
+ it('displays sees with accurately resolved links', async () => {
225
214
  const input1 = `
226
215
  /**
227
216
  * @see InterfaceRef
@@ -231,13 +220,13 @@ describe('Generates interface documentation', () => {
231
220
 
232
221
  const input2 = 'public interface InterfaceRef {}';
233
222
 
234
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
223
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
235
224
  expect(result).documentationBundleHasLength(2);
236
225
  assertEither(result, (data) => expect(data).firstDocContains('See'));
237
226
  assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](./InterfaceRef.md)'));
238
227
  });
239
228
 
240
- it('displays sees without links when the reference is not found', () => {
229
+ it('displays sees without links when the reference is not found', async () => {
241
230
  const input = `
242
231
  /**
243
232
  * @see InterfaceRef
@@ -245,30 +234,30 @@ describe('Generates interface documentation', () => {
245
234
  public interface MyInterface {}
246
235
  `;
247
236
 
248
- const result = generateDocs([apexBundleFromRawString(input)]);
237
+ const result = await generateDocs([apexBundleFromRawString(input)])();
249
238
  expect(result).documentationBundleHasLength(1);
250
239
  assertEither(result, (data) => expect(data).firstDocContains('See'));
251
240
  assertEither(result, (data) => expect(data).firstDocContains('InterfaceRef'));
252
241
  });
253
242
 
254
- it('displays the namespace if present in the config', () => {
243
+ it('displays the namespace if present in the config', async () => {
255
244
  const input = 'public interface MyInterface {}';
256
245
 
257
- const result = generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' });
246
+ const result = await generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' })();
258
247
  expect(result).documentationBundleHasLength(1);
259
248
  assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
260
249
  assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
261
250
  });
262
251
 
263
- it('does not display the namespace if not present in the config', () => {
252
+ it('does not display the namespace if not present in the config', async () => {
264
253
  const input = 'public interface MyInterface {}';
265
254
 
266
- const result = generateDocs([apexBundleFromRawString(input)]);
255
+ const result = await generateDocs([apexBundleFromRawString(input)])();
267
256
  expect(result).documentationBundleHasLength(1);
268
257
  assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
269
258
  });
270
259
 
271
- it('displays a mermaid diagram', () => {
260
+ it('displays a mermaid diagram', async () => {
272
261
  const input = `
273
262
  /**
274
263
  * @mermaid
@@ -281,13 +270,13 @@ describe('Generates interface documentation', () => {
281
270
  public interface MyInterface {}
282
271
  `;
283
272
 
284
- const result = generateDocs([apexBundleFromRawString(input)]);
273
+ const result = await generateDocs([apexBundleFromRawString(input)])();
285
274
  expect(result).documentationBundleHasLength(1);
286
275
  assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
287
276
  assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
288
277
  });
289
278
 
290
- it('displays an example code block', () => {
279
+ it('displays an example code block', async () => {
291
280
  const input = `
292
281
  /**
293
282
  * @example
@@ -299,7 +288,7 @@ describe('Generates interface documentation', () => {
299
288
  */
300
289
  public interface MyInterface {}`;
301
290
 
302
- const result = generateDocs([apexBundleFromRawString(input)]);
291
+ const result = await generateDocs([apexBundleFromRawString(input)])();
303
292
  expect(result).documentationBundleHasLength(1);
304
293
  assertEither(result, (data) => expect(data).firstDocContains('```apex'));
305
294
  assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
@@ -307,19 +296,49 @@ describe('Generates interface documentation', () => {
307
296
  });
308
297
 
309
298
  describe('method information', () => {
310
- it('displays the Method heading', () => {
299
+ it('displays the Method heading', async () => {
311
300
  const input = `
312
301
  public interface MyInterface {
313
302
  void myMethod();
314
303
  }
315
304
  `;
316
305
 
317
- const result = generateDocs([apexBundleFromRawString(input)]);
306
+ const result = await generateDocs([apexBundleFromRawString(input)])();
318
307
  expect(result).documentationBundleHasLength(1);
319
308
  assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
320
309
  });
321
310
 
322
- it('supports having mermaid diagrams in method descriptions', () => {
311
+ it('displays methods sorted if sortMembersAlphabetically is true', async () => {
312
+ const input = `
313
+ public interface MyInterface {
314
+ void myMethod();
315
+ void anotherMethod();
316
+ }
317
+ `;
318
+
319
+ const result = await generateDocs([apexBundleFromRawString(input)], { sortMembersAlphabetically: true })();
320
+ expect(result).documentationBundleHasLength(1);
321
+ assertEither(result, (data) => {
322
+ expect(data.docs[0].content.indexOf('anotherMethod')).toBeLessThan(data.docs[0].content.indexOf('myMethod'));
323
+ });
324
+ });
325
+
326
+ it('does not display methods sorted if sortMembersAlphabetically is false', async () => {
327
+ const input = `
328
+ public interface MyInterface {
329
+ void myMethod();
330
+ void anotherMethod();
331
+ }
332
+ `;
333
+
334
+ const result = await generateDocs([apexBundleFromRawString(input)], { sortMembersAlphabetically: false })();
335
+ expect(result).documentationBundleHasLength(1);
336
+ assertEither(result, (data) => {
337
+ expect(data.docs[0].content.indexOf('myMethod')).toBeLessThan(data.docs[0].content.indexOf('anotherMethod'));
338
+ });
339
+ });
340
+
341
+ it('supports having mermaid diagrams in method descriptions', async () => {
323
342
  const input = `
324
343
  public interface MyInterface {
325
344
  /**
@@ -334,13 +353,13 @@ describe('Generates interface documentation', () => {
334
353
  }
335
354
  `;
336
355
 
337
- const result = generateDocs([apexBundleFromRawString(input)]);
356
+ const result = await generateDocs([apexBundleFromRawString(input)])();
338
357
  expect(result).documentationBundleHasLength(1);
339
358
  assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
340
359
  assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
341
360
  });
342
361
 
343
- it('supports having example code blocks in method descriptions', () => {
362
+ it('supports having example code blocks in method descriptions', async () => {
344
363
  const input = `
345
364
  public interface MyInterface {
346
365
  /**
@@ -355,49 +374,49 @@ describe('Generates interface documentation', () => {
355
374
  }
356
375
  `;
357
376
 
358
- const result = generateDocs([apexBundleFromRawString(input)]);
377
+ const result = await generateDocs([apexBundleFromRawString(input)])();
359
378
  expect(result).documentationBundleHasLength(1);
360
379
  assertEither(result, (data) => expect(data).firstDocContains('```apex'));
361
380
  assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
362
381
  });
363
382
 
364
- it('has a signature section', () => {
383
+ it('has a signature section', async () => {
365
384
  const input = `
366
385
  public interface MyInterface {
367
386
  void myMethod();
368
387
  }
369
388
  `;
370
389
 
371
- const result = generateDocs([apexBundleFromRawString(input)]);
390
+ const result = await generateDocs([apexBundleFromRawString(input)])();
372
391
  expect(result).documentationBundleHasLength(1);
373
392
  assertEither(result, (data) => expect(data).firstDocContains('### Signature'));
374
393
  });
375
394
 
376
- it('has a parameters section', () => {
395
+ it('has a parameters section', async () => {
377
396
  const input = `
378
397
  public interface MyInterface {
379
398
  void myMethod(String param1, Integer param2);
380
399
  }
381
400
  `;
382
401
 
383
- const result = generateDocs([apexBundleFromRawString(input)]);
402
+ const result = await generateDocs([apexBundleFromRawString(input)])();
384
403
  expect(result).documentationBundleHasLength(1);
385
404
  assertEither(result, (data) => expect(data).firstDocContains('### Parameters'));
386
405
  });
387
406
 
388
- it('has a return type section', () => {
407
+ it('has a return type section', async () => {
389
408
  const input = `
390
409
  public interface MyInterface {
391
410
  String myMethod();
392
411
  }
393
412
  `;
394
413
 
395
- const result = generateDocs([apexBundleFromRawString(input)]);
414
+ const result = await generateDocs([apexBundleFromRawString(input)])();
396
415
  expect(result).documentationBundleHasLength(1);
397
416
  assertEither(result, (data) => expect(data).firstDocContains('### Return Type'));
398
417
  });
399
418
 
400
- it('has a throws section', () => {
419
+ it('has a throws section', async () => {
401
420
  const input = `
402
421
  public interface MyInterface {
403
422
  /**
@@ -407,12 +426,12 @@ describe('Generates interface documentation', () => {
407
426
  }
408
427
  `;
409
428
 
410
- const result = generateDocs([apexBundleFromRawString(input)]);
429
+ const result = await generateDocs([apexBundleFromRawString(input)])();
411
430
  expect(result).documentationBundleHasLength(1);
412
431
  assertEither(result, (data) => expect(data).firstDocContains('### Throws'));
413
432
  });
414
433
 
415
- it('displays an "inherited" tag if the method was inherited from a different interface', () => {
434
+ it('displays an "inherited" tag if the method was inherited from a different interface', async () => {
416
435
  const input1 = `
417
436
  public interface MyInterface {
418
437
  void myMethod();
@@ -423,10 +442,10 @@ describe('Generates interface documentation', () => {
423
442
  public interface AnotherInterface extends MyInterface {}
424
443
  `;
425
444
 
426
- const result = generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)]);
445
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
427
446
  expect(result).documentationBundleHasLength(2);
428
447
  assertEither(result, (data) =>
429
- expect(data.docs.find((doc) => doc.typeName === 'AnotherInterface')?.docContents).toContain('Inherited'),
448
+ expect(data.docs.find((doc) => doc.fileName === 'AnotherInterface')?.content).toContain('Inherited'),
430
449
  );
431
450
  });
432
451
  });
@@ -0,0 +1,184 @@
1
+ import { assertEither, extendExpect } from './expect-extensions';
2
+ import { pipe } from 'fp-ts/function';
3
+ import * as E from 'fp-ts/Either';
4
+ import { apexBundleFromRawString, generateDocs } from './test-helpers';
5
+ import { ReferenceGuidePageData } from '../../shared/types';
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', async () => {
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 = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
25
+ expect(result).documentationBundleHasLength(2);
26
+
27
+ assertEither(result, (data) =>
28
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyEnum](./Miscellaneous/MyEnum.md)'),
29
+ );
30
+ assertEither(result, (data) =>
31
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain(
32
+ '[MyClass](./Miscellaneous/MyClass.md)',
33
+ ),
34
+ );
35
+ });
36
+
37
+ it('groups things under Miscellaneous if no group is provided', async () => {
38
+ const input = `
39
+ public enum MyEnum {
40
+ VALUE1,
41
+ VALUE2
42
+ }
43
+ `;
44
+
45
+ const result = await generateDocs([apexBundleFromRawString(input)])();
46
+ expect(result).documentationBundleHasLength(1);
47
+ assertEither(result, (data) =>
48
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## Miscellaneous'),
49
+ );
50
+ });
51
+
52
+ it('group things under the provided group', async () => {
53
+ const input = `
54
+ /**
55
+ * @group MyGroup
56
+ */
57
+ public enum MyEnum {
58
+ VALUE1,
59
+ VALUE2
60
+ }
61
+ `;
62
+
63
+ const result = await generateDocs([apexBundleFromRawString(input)])();
64
+ expect(result).documentationBundleHasLength(1);
65
+ assertEither(result, (data) =>
66
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## MyGroup'),
67
+ );
68
+ });
69
+
70
+ it('displays groups in alphabetical order', async () => {
71
+ const input1 = `
72
+ /**
73
+ * @group ZGroup
74
+ */
75
+ public enum MyEnum {
76
+ VALUE1,
77
+ VALUE2
78
+ }
79
+ `;
80
+
81
+ const input2 = `
82
+ /**
83
+ * @group AGroup
84
+ */
85
+ public class MyClass {}
86
+ `;
87
+
88
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
89
+ expect(result).documentationBundleHasLength(2);
90
+ pipe(
91
+ result,
92
+ E.map((data) => ({
93
+ aGroupIndex: (data.referenceGuide as ReferenceGuidePageData).content.indexOf('## AGroup'),
94
+ zGroupIndex: (data.referenceGuide as ReferenceGuidePageData).content.indexOf('## ZGroup'),
95
+ })),
96
+ E.match(
97
+ () => fail('Expected data'),
98
+ (data) => expect(data.aGroupIndex).toBeLessThan(data.zGroupIndex),
99
+ ),
100
+ );
101
+ });
102
+
103
+ it('displays references within groups in alphabetical order', async () => {
104
+ const input1 = `
105
+ /**
106
+ * @group Group1
107
+ */
108
+ public enum MyEnum {
109
+ VALUE1,
110
+ VALUE2
111
+ }
112
+ `;
113
+
114
+ const input2 = `
115
+ /**
116
+ * @group Group1
117
+ */
118
+ public class MyClass {}
119
+ `;
120
+
121
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
122
+ expect(result).documentationBundleHasLength(2);
123
+ assertEither(result, (data) =>
124
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## Group1'),
125
+ );
126
+ assertEither(result, (data) =>
127
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('MyClass'),
128
+ );
129
+ assertEither(result, (data) => expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('MyEnum'));
130
+ });
131
+
132
+ it('returns a reference guide with descriptions', async () => {
133
+ const input1 = `
134
+ /**
135
+ * @description This is a description
136
+ */
137
+ public enum MyEnum {
138
+ VALUE1,
139
+ VALUE2
140
+ }
141
+ `;
142
+
143
+ const input2 = `
144
+ /**
145
+ * @description This is a description
146
+ */
147
+ public class MyClass {}
148
+ `;
149
+
150
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
151
+ expect(result).documentationBundleHasLength(2);
152
+ assertEither(result, (data) =>
153
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('This is a description'),
154
+ );
155
+ });
156
+
157
+ it('returns a reference guide with descriptions with links to all other files', async () => {
158
+ const input1 = `
159
+ /**
160
+ * @description This is a description with a {@link MyClass}
161
+ * @group Group1
162
+ */
163
+ public enum MyEnum {
164
+ VALUE1,
165
+ VALUE2
166
+ }
167
+ `;
168
+
169
+ const input2 = `
170
+ /**
171
+ * @group Group2
172
+ */
173
+ public class MyClass {}
174
+ `;
175
+
176
+ const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
177
+ expect(result).documentationBundleHasLength(2);
178
+ assertEither(result, (data) =>
179
+ expect((data.referenceGuide as ReferenceGuidePageData).content).toContain(
180
+ 'with a [MyClass](./Group2/MyClass.md)',
181
+ ),
182
+ );
183
+ });
184
+ });
@@ -1,5 +1,5 @@
1
- import { ClassMirrorBuilder } from '../../test-helpers/ClassMirrorBuilder';
2
- import { createInheritanceChain } from '../inheritance-chain';
1
+ import { ClassMirrorBuilder } from '../../../test-helpers/ClassMirrorBuilder';
2
+ import { createInheritanceChain } from '../reflection/inheritance-chain';
3
3
 
4
4
  describe('inheritance chain for classes', () => {
5
5
  test('returns an empty list of the class does not extend any other class', () => {