@cparra/apexdocs 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/README.md +11 -5
  2. package/package.json +4 -1
  3. package/.github/workflows/ci.yaml +0 -22
  4. package/.github/workflows/close_stale.yml +0 -22
  5. package/.prettierrc.js +0 -7
  6. package/__mocks__/chalk.js +0 -12
  7. package/__mocks__/log-update.js +0 -6
  8. package/eslint.config.mjs +0 -10
  9. package/examples/README.md +0 -5
  10. package/examples/docsify/README.md +0 -17
  11. package/examples/docsify/apexdocs.config.ts +0 -13
  12. package/examples/docsify/classes/ASampleClass.cls +0 -57
  13. package/examples/docsify/classes/CodeControl.cls +0 -19
  14. package/examples/docsify/classes/SampleClass.cls +0 -95
  15. package/examples/docsify/classes/SampleInterface.cls +0 -17
  16. package/examples/docsify/classes/SomeDto.cls +0 -122
  17. package/examples/docsify/docs/.nojekyll +0 -0
  18. package/examples/docsify/docs/README.md +0 -25
  19. package/examples/docsify/docs/_config.yml +0 -1
  20. package/examples/docsify/docs/index.html +0 -22
  21. package/examples/docsify/docs/miscellaneous/ASampleClass.md +0 -88
  22. package/examples/docsify/docs/miscellaneous/CodeControl.md +0 -107
  23. package/examples/docsify/docs/miscellaneous/SomeDto.md +0 -244
  24. package/examples/docsify/docs/sample-classes/SampleClass.md +0 -171
  25. package/examples/docsify/docs/sample-interfaces/SampleInterface.md +0 -36
  26. package/examples/docsify/package-lock.json +0 -2459
  27. package/examples/docsify/package.json +0 -14
  28. package/examples/imported/.forceignore +0 -12
  29. package/examples/imported/README.md +0 -6
  30. package/examples/imported/config/project-scratch-def.json +0 -5
  31. package/examples/imported/docs/index.md +0 -109
  32. package/examples/imported/docs/miscellaneous/BaseClass.md +0 -13
  33. package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +0 -69
  34. package/examples/imported/docs/miscellaneous/ParentInterface.md +0 -12
  35. package/examples/imported/docs/miscellaneous/ReferencedEnum.md +0 -5
  36. package/examples/imported/docs/miscellaneous/SampleException.md +0 -21
  37. package/examples/imported/docs/miscellaneous/SampleInterface.md +0 -113
  38. package/examples/imported/docs/miscellaneous/Url.md +0 -308
  39. package/examples/imported/docs/sample-enums/SampleEnum.md +0 -33
  40. package/examples/imported/docs/samplegroup/SampleClass.md +0 -167
  41. package/examples/imported/force-app/classes/BaseClass.cls +0 -3
  42. package/examples/imported/force-app/classes/MultiInheritanceClass.cls +0 -1
  43. package/examples/imported/force-app/classes/ParentInterface.cls +0 -3
  44. package/examples/imported/force-app/classes/ReferencedEnum.cls +0 -3
  45. package/examples/imported/force-app/classes/SampleClass.cls +0 -72
  46. package/examples/imported/force-app/classes/SampleEnum.cls +0 -30
  47. package/examples/imported/force-app/classes/SampleException.cls +0 -17
  48. package/examples/imported/force-app/classes/SampleInterface.cls +0 -50
  49. package/examples/imported/force-app/classes/Url.cls +0 -196
  50. package/examples/imported/package-lock.json +0 -665
  51. package/examples/imported/package.json +0 -6
  52. package/examples/imported/scripts/process-docs.mjs +0 -16
  53. package/examples/imported/sfdx-project.json +0 -12
  54. package/examples/markdown/.forceignore +0 -12
  55. package/examples/markdown/README.md +0 -7
  56. package/examples/markdown/config/project-scratch-def.json +0 -5
  57. package/examples/markdown/docs/index.md +0 -109
  58. package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
  59. package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
  60. package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
  61. package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
  62. package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
  63. package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
  64. package/examples/markdown/docs/miscellaneous/Url.md +0 -311
  65. package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
  66. package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
  67. package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
  68. package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
  69. package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
  70. package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
  71. package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
  72. package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
  73. package/examples/markdown/force-app/classes/SampleException.cls +0 -17
  74. package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
  75. package/examples/markdown/force-app/classes/Url.cls +0 -196
  76. package/examples/markdown/package-lock.json +0 -665
  77. package/examples/markdown/package.json +0 -20
  78. package/examples/markdown/sfdx-project.json +0 -12
  79. package/examples/markdown-jsconfig/.forceignore +0 -12
  80. package/examples/markdown-jsconfig/README.md +0 -9
  81. package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -22
  82. package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
  83. package/examples/markdown-jsconfig/docs/index.md +0 -12
  84. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
  85. package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
  86. package/examples/markdown-jsconfig/package-lock.json +0 -665
  87. package/examples/markdown-jsconfig/package.json +0 -15
  88. package/examples/markdown-jsconfig/sfdx-project.json +0 -12
  89. package/examples/open-api/README.md +0 -5
  90. package/examples/open-api/config/project-scratch-def.json +0 -13
  91. package/examples/open-api/docs/openapi.json +0 -14
  92. package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
  93. package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
  94. package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
  95. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
  96. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
  97. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
  98. package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
  99. package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
  100. package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
  101. package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
  102. package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
  103. package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
  104. package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
  105. package/examples/open-api/package-lock.json +0 -724
  106. package/examples/open-api/package.json +0 -20
  107. package/examples/open-api/sfdx-project.json +0 -12
  108. package/examples/vitepress/.forceignore +0 -12
  109. package/examples/vitepress/README.md +0 -25
  110. package/examples/vitepress/apexdocs.config.ts +0 -113
  111. package/examples/vitepress/config/project-scratch-def.json +0 -13
  112. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
  113. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  114. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
  115. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
  116. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
  117. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
  118. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
  119. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
  120. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
  121. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  122. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
  123. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  124. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
  125. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
  126. package/examples/vitepress/docs/.vitepress/config.mts +0 -21
  127. package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
  128. package/examples/vitepress/docs/api-examples.md +0 -49
  129. package/examples/vitepress/docs/index-frontmatter.md +0 -16
  130. package/examples/vitepress/docs/index.md +0 -56
  131. package/examples/vitepress/docs/markdown-examples.md +0 -85
  132. package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
  133. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
  134. package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
  135. package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
  136. package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
  137. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
  138. package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
  139. package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
  140. package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
  141. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
  142. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
  143. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
  144. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
  145. package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
  146. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +0 -73
  147. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +0 -30
  148. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +0 -17
  149. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleInterface.cls +0 -46
  150. package/examples/vitepress/package-lock.json +0 -2574
  151. package/examples/vitepress/package.json +0 -18
  152. package/examples/vitepress/sfdx-project.json +0 -12
  153. package/jest.config.js +0 -10
  154. package/jest.d.ts +0 -7
  155. package/src/application/Apexdocs.ts +0 -69
  156. package/src/application/__tests__/apex-file-reader.spec.ts +0 -128
  157. package/src/application/apex-file-reader.ts +0 -56
  158. package/src/application/file-system.ts +0 -69
  159. package/src/application/file-writer.ts +0 -43
  160. package/src/application/generators/markdown.ts +0 -45
  161. package/src/application/generators/openapi.ts +0 -75
  162. package/src/cli/args.ts +0 -55
  163. package/src/cli/commands/markdown.ts +0 -56
  164. package/src/cli/commands/openapi.ts +0 -36
  165. package/src/cli/generate.ts +0 -32
  166. package/src/core/__test__/manifest.spec.ts +0 -16
  167. package/src/core/manifest.ts +0 -90
  168. package/src/core/markdown/__test__/expect-extensions.ts +0 -32
  169. package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -362
  170. package/src/core/markdown/__test__/generating-docs.spec.ts +0 -378
  171. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -61
  172. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -169
  173. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -196
  174. package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
  175. package/src/core/markdown/__test__/test-helpers.ts +0 -25
  176. package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
  177. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -150
  178. package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
  179. package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
  180. package/src/core/markdown/adapters/apex-types.ts +0 -238
  181. package/src/core/markdown/adapters/documentables.ts +0 -115
  182. package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
  183. package/src/core/markdown/adapters/generate-link.ts +0 -82
  184. package/src/core/markdown/adapters/inline.ts +0 -143
  185. package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
  186. package/src/core/markdown/adapters/reference-guide.ts +0 -37
  187. package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
  188. package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -91
  189. package/src/core/markdown/adapters/type-utils.ts +0 -13
  190. package/src/core/markdown/adapters/types.d.ts +0 -180
  191. package/src/core/markdown/generate-docs.ts +0 -210
  192. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -290
  193. package/src/core/markdown/reflection/__test__/helpers.ts +0 -18
  194. package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +0 -200
  195. package/src/core/markdown/reflection/filter-scope.ts +0 -13
  196. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
  197. package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
  198. package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
  199. package/src/core/markdown/reflection/reflect-source.ts +0 -123
  200. package/src/core/markdown/reflection/remove-excluded-tags.ts +0 -168
  201. package/src/core/markdown/reflection/sort-types-and-members.ts +0 -61
  202. package/src/core/markdown/templates/class-template.ts +0 -75
  203. package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
  204. package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
  205. package/src/core/markdown/templates/enum-template.ts +0 -12
  206. package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
  207. package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
  208. package/src/core/markdown/templates/hookable.ts +0 -7
  209. package/src/core/markdown/templates/interface-template.ts +0 -16
  210. package/src/core/markdown/templates/methods-partial-template.ts +0 -43
  211. package/src/core/markdown/templates/reference-guide.ts +0 -14
  212. package/src/core/markdown/templates/template.ts +0 -114
  213. package/src/core/markdown/templates/type-doc-partial.ts +0 -27
  214. package/src/core/markdown/utils.ts +0 -3
  215. package/src/core/openApiSettings.ts +0 -41
  216. package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
  217. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -59
  218. package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
  219. package/src/core/openapi/apex-doc-types.ts +0 -26
  220. package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
  221. package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
  222. package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
  223. package/src/core/openapi/file-container.ts +0 -13
  224. package/src/core/openapi/manifest-factory.ts +0 -16
  225. package/src/core/openapi/open-api-docs-processor.ts +0 -93
  226. package/src/core/openapi/open-api-types.ts +0 -119
  227. package/src/core/openapi/open-api.ts +0 -45
  228. package/src/core/openapi/openapi-type-file.ts +0 -12
  229. package/src/core/openapi/parser.ts +0 -163
  230. package/src/core/openapi/parsers/Builder.ts +0 -40
  231. package/src/core/openapi/parsers/MethodParser.ts +0 -249
  232. package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
  233. package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
  234. package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
  235. package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
  236. package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
  237. package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
  238. package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
  239. package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
  240. package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
  241. package/src/core/openapi/transpiler.ts +0 -17
  242. package/src/core/openapi/types-repository.ts +0 -54
  243. package/src/core/parse-apex-metadata.ts +0 -30
  244. package/src/core/shared/types.d.ts +0 -150
  245. package/src/core/shared/utils.ts +0 -5
  246. package/src/defaults.ts +0 -21
  247. package/src/index.ts +0 -110
  248. package/src/test-helpers/AnnotationBuilder.ts +0 -29
  249. package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
  250. package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
  251. package/src/test-helpers/DocCommentBuilder.ts +0 -36
  252. package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
  253. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
  254. package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
  255. package/src/test-helpers/SettingsBuilder.ts +0 -17
  256. package/src/util/error-logger.ts +0 -92
  257. package/src/util/fp.ts +0 -3
  258. package/src/util/logger.ts +0 -51
  259. package/src/util/string-utils.ts +0 -7
  260. package/tsconfig.json +0 -25
  261. package/tslint.json +0 -6
@@ -1,196 +0,0 @@
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('When generating the Reference Guide', () => {
8
- beforeAll(() => {
9
- extendExpect();
10
- });
11
-
12
- it('contains the correct default title by default', async () => {
13
- const result = await generateDocs([])();
14
-
15
- assertEither(result, (data) =>
16
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('# Apex Reference Guide'),
17
- );
18
- });
19
-
20
- it('allows for the reference guide title to be configured', async () => {
21
- const result = await generateDocs([], { referenceGuideTitle: 'Custom Title' })();
22
-
23
- assertEither(result, (data) =>
24
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('# Custom Title'),
25
- );
26
- });
27
-
28
- it('returns a reference guide with links to all other files', async () => {
29
- const input1 = `
30
- public enum MyEnum {
31
- VALUE1,
32
- VALUE2
33
- }
34
- `;
35
-
36
- const input2 = `
37
- public class MyClass {}
38
- `;
39
-
40
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
41
- expect(result).documentationBundleHasLength(2);
42
-
43
- assertEither(result, (data) =>
44
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyEnum](miscellaneous/MyEnum.md)'),
45
- );
46
- assertEither(result, (data) =>
47
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyClass](miscellaneous/MyClass.md)'),
48
- );
49
- });
50
-
51
- it('groups things under Miscellaneous if no group is provided', async () => {
52
- const input = `
53
- public enum MyEnum {
54
- VALUE1,
55
- VALUE2
56
- }
57
- `;
58
-
59
- const result = await generateDocs([apexBundleFromRawString(input)])();
60
- expect(result).documentationBundleHasLength(1);
61
- assertEither(result, (data) =>
62
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## Miscellaneous'),
63
- );
64
- });
65
-
66
- it('group things under the provided group', async () => {
67
- const input = `
68
- /**
69
- * @group MyGroup
70
- */
71
- public enum MyEnum {
72
- VALUE1,
73
- VALUE2
74
- }
75
- `;
76
-
77
- const result = await generateDocs([apexBundleFromRawString(input)])();
78
- expect(result).documentationBundleHasLength(1);
79
- assertEither(result, (data) =>
80
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## MyGroup'),
81
- );
82
- });
83
-
84
- it('displays groups in alphabetical order', async () => {
85
- const input1 = `
86
- /**
87
- * @group ZGroup
88
- */
89
- public enum MyEnum {
90
- VALUE1,
91
- VALUE2
92
- }
93
- `;
94
-
95
- const input2 = `
96
- /**
97
- * @group AGroup
98
- */
99
- public class MyClass {}
100
- `;
101
-
102
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
103
- expect(result).documentationBundleHasLength(2);
104
- pipe(
105
- result,
106
- E.map((data) => ({
107
- aGroupIndex: (data.referenceGuide as ReferenceGuidePageData).content.indexOf('## AGroup'),
108
- zGroupIndex: (data.referenceGuide as ReferenceGuidePageData).content.indexOf('## ZGroup'),
109
- })),
110
- E.match(
111
- () => fail('Expected data'),
112
- (data) => expect(data.aGroupIndex).toBeLessThan(data.zGroupIndex),
113
- ),
114
- );
115
- });
116
-
117
- it('displays references within groups in alphabetical order', async () => {
118
- const input1 = `
119
- /**
120
- * @group Group1
121
- */
122
- public enum MyEnum {
123
- VALUE1,
124
- VALUE2
125
- }
126
- `;
127
-
128
- const input2 = `
129
- /**
130
- * @group Group1
131
- */
132
- public class MyClass {}
133
- `;
134
-
135
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
136
- expect(result).documentationBundleHasLength(2);
137
- assertEither(result, (data) =>
138
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('## Group1'),
139
- );
140
- assertEither(result, (data) =>
141
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('MyClass'),
142
- );
143
- assertEither(result, (data) => expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('MyEnum'));
144
- });
145
-
146
- it('returns a reference guide with descriptions', async () => {
147
- const input1 = `
148
- /**
149
- * @description This is a description
150
- */
151
- public enum MyEnum {
152
- VALUE1,
153
- VALUE2
154
- }
155
- `;
156
-
157
- const input2 = `
158
- /**
159
- * @description This is a description
160
- */
161
- public class MyClass {}
162
- `;
163
-
164
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
165
- expect(result).documentationBundleHasLength(2);
166
- assertEither(result, (data) =>
167
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('This is a description'),
168
- );
169
- });
170
-
171
- it('returns a reference guide with descriptions with links to all other files', async () => {
172
- const input1 = `
173
- /**
174
- * @description This is a description with a {@link MyClass}
175
- * @group Group1
176
- */
177
- public enum MyEnum {
178
- VALUE1,
179
- VALUE2
180
- }
181
- `;
182
-
183
- const input2 = `
184
- /**
185
- * @group Group2
186
- */
187
- public class MyClass {}
188
- `;
189
-
190
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
191
- expect(result).documentationBundleHasLength(2);
192
- assertEither(result, (data) =>
193
- expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('with a [MyClass](group2/MyClass.md)'),
194
- );
195
- });
196
- });
@@ -1,54 +0,0 @@
1
- import { ClassMirrorBuilder } from '../../../test-helpers/ClassMirrorBuilder';
2
- import { createInheritanceChain } from '../reflection/inheritance-chain';
3
-
4
- describe('inheritance chain for classes', () => {
5
- test('returns an empty list of the class does not extend any other class', () => {
6
- const classMirror = new ClassMirrorBuilder().build();
7
- const repository = [classMirror];
8
-
9
- const inheritanceChain = createInheritanceChain(repository, classMirror);
10
-
11
- expect(inheritanceChain).toEqual([]);
12
- });
13
-
14
- test('returns the name of the extended class if it is not found in the repository', () => {
15
- const classMirror = new ClassMirrorBuilder().withExtendedClass('ExtendedClass').build();
16
- const repository = [classMirror];
17
-
18
- const inheritanceChain = createInheritanceChain(repository, classMirror);
19
-
20
- expect(inheritanceChain).toEqual(['ExtendedClass']);
21
- });
22
-
23
- test('returns the extended class when it is present in the repository', () => {
24
- const classMirror = new ClassMirrorBuilder().withExtendedClass('ExtendedClass').build();
25
- const extendedClass = new ClassMirrorBuilder().withName('ExtendedClass').build();
26
- const repository = [classMirror, extendedClass];
27
-
28
- const inheritanceChain = createInheritanceChain(repository, classMirror);
29
-
30
- expect(inheritanceChain).toEqual(['ExtendedClass']);
31
- });
32
-
33
- test('returns the full inheritance chain when the extended class is also extended', () => {
34
- const classMirror = new ClassMirrorBuilder().withExtendedClass('ExtendedClass').build();
35
- const extendedClass = new ClassMirrorBuilder().withName('ExtendedClass').withExtendedClass('SuperClass').build();
36
- const superClass = new ClassMirrorBuilder().withName('SuperClass').build();
37
- const repository = [classMirror, extendedClass, superClass];
38
-
39
- const inheritanceChain = createInheritanceChain(repository, classMirror);
40
-
41
- expect(inheritanceChain).toEqual(['ExtendedClass', 'SuperClass']);
42
- });
43
-
44
- test('returns the inheritance for a class that extends an inner class', () => {
45
- const classMirror = new ClassMirrorBuilder().withExtendedClass('OuterClass.InnerClass').build();
46
- const innerClass = new ClassMirrorBuilder().withName('InnerClass').build();
47
- const outerClass = new ClassMirrorBuilder().withName('OuterClass').addInnerClass(innerClass).build();
48
- const repository = [classMirror, outerClass];
49
-
50
- const inheritanceChain = createInheritanceChain(repository, classMirror);
51
-
52
- expect(inheritanceChain).toEqual(['OuterClass.InnerClass']);
53
- });
54
- });
@@ -1,25 +0,0 @@
1
- import { UnparsedSourceFile } from '../../shared/types';
2
- import { generateDocs as gen, MarkdownGeneratorConfig } from '../generate-docs';
3
- import { referenceGuideTemplate } from '../templates/reference-guide';
4
-
5
- export function apexBundleFromRawString(raw: string, rawMetadata?: string): UnparsedSourceFile {
6
- return {
7
- filePath: 'test.cls',
8
- content: raw,
9
- metadataContent: rawMetadata ?? null,
10
- };
11
- }
12
-
13
- export function generateDocs(apexBundles: UnparsedSourceFile[], config?: Partial<MarkdownGeneratorConfig>) {
14
- return gen(apexBundles, {
15
- targetDir: 'target',
16
- scope: ['global', 'public'],
17
- defaultGroupName: 'Miscellaneous',
18
- sortAlphabetically: false,
19
- referenceGuideTemplate: referenceGuideTemplate,
20
- linkingStrategy: 'relative',
21
- excludeTags: [],
22
- referenceGuideTitle: 'Apex Reference Guide',
23
- ...config,
24
- });
25
- }
@@ -1,109 +0,0 @@
1
- import { adaptDescribable } from '../documentables';
2
-
3
- function linkGenerator(typeName: string) {
4
- return typeName;
5
- }
6
-
7
- describe('describable', () => {
8
- it('returns undefined if describable is undefined', () => {
9
- const result = adaptDescribable(undefined, linkGenerator);
10
-
11
- expect(result).toEqual({
12
- description: undefined,
13
- });
14
- });
15
-
16
- it('returns an empty array if describable is an empty array', () => {
17
- const result = adaptDescribable([], linkGenerator);
18
-
19
- expect(result).toEqual({
20
- description: [],
21
- });
22
- });
23
-
24
- it('returns a string if describable contains a string', () => {
25
- const describable = ['This is a test'];
26
-
27
- const result = adaptDescribable(describable, linkGenerator);
28
-
29
- expect(result).toEqual({
30
- description: ['This is a test'],
31
- });
32
- });
33
-
34
- it('separates strings with an empty line', () => {
35
- const describable = ['This is a test', 'This is another test'];
36
-
37
- const result = adaptDescribable(describable, linkGenerator);
38
-
39
- expect(result).toEqual({
40
- description: ['This is a test', { __type: 'empty-line' }, 'This is another test'],
41
- });
42
- });
43
-
44
- it('returns a code block if describable contains code', () => {
45
- const describable = ['```typescript', 'const a = 1;', '```'];
46
-
47
- const result = adaptDescribable(describable, linkGenerator);
48
-
49
- expect(result).toEqual({
50
- description: [
51
- {
52
- __type: 'code-block',
53
- language: 'typescript',
54
- content: ['const a = 1;'],
55
- },
56
- ],
57
- });
58
- });
59
-
60
- it('sets the code blocks language to apex if one is not provided', () => {
61
- const describable = ['```', 'const a = 1;', '```'];
62
-
63
- const result = adaptDescribable(describable, linkGenerator);
64
-
65
- expect(result).toEqual({
66
- description: [
67
- {
68
- __type: 'code-block',
69
- language: 'apex',
70
- content: ['const a = 1;'],
71
- },
72
- ],
73
- });
74
- });
75
-
76
- it('returns a code block followed by an empty line and then whatever content is in the describable', () => {
77
- const describable = ['```typescript', 'const a = 1;', '```', 'This is a test'];
78
-
79
- const result = adaptDescribable(describable, linkGenerator);
80
-
81
- expect(result).toEqual({
82
- description: [
83
- {
84
- __type: 'code-block',
85
- language: 'typescript',
86
- content: ['const a = 1;'],
87
- },
88
- { __type: 'empty-line' },
89
- 'This is a test',
90
- ],
91
- });
92
- });
93
-
94
- it('returns a code block even when there is no closing tag', () => {
95
- const describable = ['```typescript', 'const a = 1;'];
96
-
97
- const result = adaptDescribable(describable, linkGenerator);
98
-
99
- expect(result).toEqual({
100
- description: [
101
- {
102
- __type: 'code-block',
103
- language: 'typescript',
104
- content: ['const a = 1;'],
105
- },
106
- ],
107
- });
108
- });
109
- });
@@ -1,150 +0,0 @@
1
- import { typeToRenderable } from '../apex-types';
2
- import { InterfaceMirrorBuilder } from '../../../../test-helpers/InterfaceMirrorBuilder';
3
- import { AnnotationBuilder } from '../../../../test-helpers/AnnotationBuilder';
4
- import { MethodMirrorBuilder, ParameterBuilder } from '../../../../test-helpers/MethodMirrorBuilder';
5
- import { MarkdownGeneratorConfig } from '../../generate-docs';
6
-
7
- function linkGenerator(type: string): string {
8
- return type;
9
- }
10
-
11
- const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
12
- targetDir: '',
13
- scope: ['global', 'public'],
14
- namespace: '',
15
- defaultGroupName: 'Miscellaneous',
16
- referenceGuideTemplate: '',
17
- sortAlphabetically: false,
18
- linkingStrategy: 'relative',
19
- referenceGuideTitle: 'Apex Reference Guide',
20
- excludeTags: [],
21
- };
22
-
23
- describe('Conversion from InterfaceMirror to InterfaceSource understandable by the templating engine', () => {
24
- it('converts the name', () => {
25
- const interfaceMirror = new InterfaceMirrorBuilder().withName('SampleInterface').build();
26
- const interfaceSource = typeToRenderable(
27
- {
28
- source: {
29
- filePath: '',
30
- type: 'interface',
31
- name: 'SampleInterface',
32
- },
33
- type: interfaceMirror,
34
- },
35
- linkGenerator,
36
- defaultMarkdownGeneratorConfig,
37
- );
38
-
39
- expect(interfaceSource.name).toBe('SampleInterface');
40
- });
41
-
42
- it('converts the access modifier', () => {
43
- const interfaceMirror = new InterfaceMirrorBuilder().build();
44
- const interfaceSource = typeToRenderable(
45
- {
46
- source: {
47
- filePath: '',
48
- type: 'interface',
49
- name: 'SampleInterface',
50
- },
51
- type: interfaceMirror,
52
- },
53
- linkGenerator,
54
- defaultMarkdownGeneratorConfig,
55
- );
56
-
57
- expect(interfaceSource.meta.accessModifier).toBe('public');
58
- });
59
-
60
- it('converts annotations', () => {
61
- const interfaceMirror = new InterfaceMirrorBuilder()
62
- .addAnnotation(new AnnotationBuilder().withName('MyAnnotation').build())
63
- .build();
64
- const interfaceSource = typeToRenderable(
65
- {
66
- source: {
67
- filePath: '',
68
- type: 'interface',
69
- name: 'SampleInterface',
70
- },
71
- type: interfaceMirror,
72
- },
73
- linkGenerator,
74
- defaultMarkdownGeneratorConfig,
75
- );
76
-
77
- expect(interfaceSource.doc.annotations).toEqual(['MYANNOTATION']);
78
- });
79
-
80
- it('converts method declarations. Method with no parameters', () => {
81
- const interfaceMirror = new InterfaceMirrorBuilder()
82
- .addMethod(
83
- new MethodMirrorBuilder()
84
- .withName('sampleMethod')
85
- .withTypeReference({
86
- type: 'String',
87
- rawDeclaration: 'String',
88
- })
89
- .build(),
90
- )
91
- .build();
92
-
93
- const interfaceSource = typeToRenderable(
94
- {
95
- source: {
96
- filePath: '',
97
- type: 'interface',
98
- name: 'SampleInterface',
99
- },
100
- type: interfaceMirror,
101
- },
102
- linkGenerator,
103
- defaultMarkdownGeneratorConfig,
104
- );
105
-
106
- expect(interfaceSource.methods.value).toHaveLength(1);
107
- expect(interfaceSource.methods.value[0].signature.value.content[0]).toBe('public String sampleMethod()');
108
- });
109
-
110
- it('converts method declarations. Method with parameters', () => {
111
- const interfaceMirror = new InterfaceMirrorBuilder()
112
- .addMethod(
113
- new MethodMirrorBuilder()
114
- .withName('sampleMethod')
115
- .withTypeReference({
116
- type: 'String',
117
- rawDeclaration: 'String',
118
- })
119
- .addParameter(
120
- new ParameterBuilder()
121
- .withName('param1')
122
- .withTypeReference({
123
- type: 'String',
124
- rawDeclaration: 'String',
125
- })
126
- .build(),
127
- )
128
- .build(),
129
- )
130
- .build();
131
-
132
- const interfaceSource = typeToRenderable(
133
- {
134
- source: {
135
- filePath: '',
136
- type: 'interface',
137
- name: 'SampleInterface',
138
- },
139
- type: interfaceMirror,
140
- },
141
- linkGenerator,
142
- defaultMarkdownGeneratorConfig,
143
- );
144
-
145
- expect(interfaceSource.methods.value).toHaveLength(1);
146
- expect(interfaceSource.methods.value[0].signature.value.content[0]).toBe(
147
- 'public String sampleMethod(String param1)',
148
- );
149
- });
150
- });
@@ -1,130 +0,0 @@
1
- import { generateLink } from '../generate-link';
2
-
3
- describe('Generates links', () => {
4
- describe('relative', () => {
5
- it('generates relative links from the base when found', () => {
6
- const references = {
7
- referenceName: {
8
- referencePath: 'referencePath',
9
- displayName: 'displayName',
10
- },
11
- };
12
- const from = '__base__';
13
- const referenceName = 'referenceName';
14
-
15
- const result = generateLink('relative')(references, from, referenceName);
16
-
17
- expect(result).toEqual({
18
- __type: 'link',
19
- title: 'displayName',
20
- url: 'referencePath',
21
- });
22
- });
23
-
24
- it('returns the name of the reference when not found', () => {
25
- const references = {};
26
- const from = '__base__';
27
- const referenceName = 'referenceName';
28
-
29
- const result = generateLink('relative')(references, from, referenceName);
30
-
31
- expect(result).toEqual('referenceName');
32
- });
33
-
34
- it('returns a relative path when linking from a file', () => {
35
- const references = {
36
- referenceName: {
37
- referencePath: 'a/referencePath',
38
- displayName: 'displayName',
39
- },
40
- from: {
41
- referencePath: 'b/fromPath',
42
- displayName: 'fromName',
43
- },
44
- };
45
- const from = 'from';
46
- const referenceName = 'referenceName';
47
-
48
- const result = generateLink('relative')(references, from, referenceName);
49
-
50
- expect(result).toEqual({
51
- __type: 'link',
52
- title: 'displayName',
53
- url: '../a/referencePath',
54
- });
55
- });
56
-
57
- it('returns the display name when the from reference is not found', () => {
58
- const references = {
59
- referenceName: {
60
- referencePath: 'a/referencePath',
61
- displayName: 'displayName',
62
- },
63
- };
64
- const from = 'from';
65
- const referenceName = 'referenceName';
66
-
67
- const result = generateLink('relative')(references, from, referenceName);
68
-
69
- expect(result).toEqual('displayName');
70
- });
71
- });
72
-
73
- describe('no-link', () => {
74
- it('returns the name of the reference when the reference is not found', () => {
75
- const references = {};
76
- const from = '__base__';
77
- const referenceName = 'referenceName';
78
-
79
- const result = generateLink('no-link')(references, from, referenceName);
80
-
81
- expect(result).toEqual('referenceName');
82
- });
83
-
84
- it('returns the display name of the reference when the reference is found', () => {
85
- const references = {
86
- referenceName: {
87
- referencePath: 'referencePath',
88
- displayName: 'displayName',
89
- },
90
- };
91
- const from = '__base__';
92
- const referenceName = 'referenceName';
93
-
94
- const result = generateLink('no-link')(references, from, referenceName);
95
-
96
- expect(result).toEqual('displayName');
97
- });
98
- });
99
-
100
- describe('none', () => {
101
- it('returns the path as is when the reference is found', () => {
102
- const references = {
103
- referenceName: {
104
- referencePath: 'referencePath',
105
- displayName: 'displayName',
106
- },
107
- };
108
- const from = '__base__';
109
- const referenceName = 'referenceName';
110
-
111
- const result = generateLink('none')(references, from, referenceName);
112
-
113
- expect(result).toEqual({
114
- __type: 'link',
115
- title: 'displayName',
116
- url: 'referencePath',
117
- });
118
- });
119
-
120
- it('returns the name of the reference when the reference is not found', () => {
121
- const references = {};
122
- const from = '__base__';
123
- const referenceName = 'referenceName';
124
-
125
- const result = generateLink('none')(references, from, referenceName);
126
-
127
- expect(result).toEqual('referenceName');
128
- });
129
- });
130
- });