@cparra/apexdocs 3.0.0 → 3.1.1

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 (264) hide show
  1. package/README.md +11 -5
  2. package/dist/cli/generate.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/logger-BATX7-be.js +3278 -0
  5. package/package.json +4 -1
  6. package/.github/workflows/ci.yaml +0 -22
  7. package/.github/workflows/close_stale.yml +0 -22
  8. package/.prettierrc.js +0 -7
  9. package/__mocks__/chalk.js +0 -12
  10. package/__mocks__/log-update.js +0 -6
  11. package/eslint.config.mjs +0 -10
  12. package/examples/README.md +0 -5
  13. package/examples/docsify/README.md +0 -17
  14. package/examples/docsify/apexdocs.config.ts +0 -13
  15. package/examples/docsify/classes/ASampleClass.cls +0 -57
  16. package/examples/docsify/classes/CodeControl.cls +0 -19
  17. package/examples/docsify/classes/SampleClass.cls +0 -95
  18. package/examples/docsify/classes/SampleInterface.cls +0 -17
  19. package/examples/docsify/classes/SomeDto.cls +0 -122
  20. package/examples/docsify/docs/.nojekyll +0 -0
  21. package/examples/docsify/docs/README.md +0 -25
  22. package/examples/docsify/docs/_config.yml +0 -1
  23. package/examples/docsify/docs/index.html +0 -22
  24. package/examples/docsify/docs/miscellaneous/ASampleClass.md +0 -88
  25. package/examples/docsify/docs/miscellaneous/CodeControl.md +0 -107
  26. package/examples/docsify/docs/miscellaneous/SomeDto.md +0 -244
  27. package/examples/docsify/docs/sample-classes/SampleClass.md +0 -171
  28. package/examples/docsify/docs/sample-interfaces/SampleInterface.md +0 -36
  29. package/examples/docsify/package-lock.json +0 -2459
  30. package/examples/docsify/package.json +0 -14
  31. package/examples/imported/.forceignore +0 -12
  32. package/examples/imported/README.md +0 -6
  33. package/examples/imported/config/project-scratch-def.json +0 -5
  34. package/examples/imported/docs/index.md +0 -109
  35. package/examples/imported/docs/miscellaneous/BaseClass.md +0 -13
  36. package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +0 -69
  37. package/examples/imported/docs/miscellaneous/ParentInterface.md +0 -12
  38. package/examples/imported/docs/miscellaneous/ReferencedEnum.md +0 -5
  39. package/examples/imported/docs/miscellaneous/SampleException.md +0 -21
  40. package/examples/imported/docs/miscellaneous/SampleInterface.md +0 -113
  41. package/examples/imported/docs/miscellaneous/Url.md +0 -308
  42. package/examples/imported/docs/sample-enums/SampleEnum.md +0 -33
  43. package/examples/imported/docs/samplegroup/SampleClass.md +0 -167
  44. package/examples/imported/force-app/classes/BaseClass.cls +0 -3
  45. package/examples/imported/force-app/classes/MultiInheritanceClass.cls +0 -1
  46. package/examples/imported/force-app/classes/ParentInterface.cls +0 -3
  47. package/examples/imported/force-app/classes/ReferencedEnum.cls +0 -3
  48. package/examples/imported/force-app/classes/SampleClass.cls +0 -72
  49. package/examples/imported/force-app/classes/SampleEnum.cls +0 -30
  50. package/examples/imported/force-app/classes/SampleException.cls +0 -17
  51. package/examples/imported/force-app/classes/SampleInterface.cls +0 -50
  52. package/examples/imported/force-app/classes/Url.cls +0 -196
  53. package/examples/imported/package-lock.json +0 -665
  54. package/examples/imported/package.json +0 -6
  55. package/examples/imported/scripts/process-docs.mjs +0 -16
  56. package/examples/imported/sfdx-project.json +0 -12
  57. package/examples/markdown/.forceignore +0 -12
  58. package/examples/markdown/README.md +0 -7
  59. package/examples/markdown/config/project-scratch-def.json +0 -5
  60. package/examples/markdown/docs/index.md +0 -109
  61. package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
  62. package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
  63. package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
  64. package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
  65. package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
  66. package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
  67. package/examples/markdown/docs/miscellaneous/Url.md +0 -311
  68. package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
  69. package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
  70. package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
  71. package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
  72. package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
  73. package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
  74. package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
  75. package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
  76. package/examples/markdown/force-app/classes/SampleException.cls +0 -17
  77. package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
  78. package/examples/markdown/force-app/classes/Url.cls +0 -196
  79. package/examples/markdown/package-lock.json +0 -665
  80. package/examples/markdown/package.json +0 -20
  81. package/examples/markdown/sfdx-project.json +0 -12
  82. package/examples/markdown-jsconfig/.forceignore +0 -12
  83. package/examples/markdown-jsconfig/README.md +0 -9
  84. package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -22
  85. package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
  86. package/examples/markdown-jsconfig/docs/index.md +0 -12
  87. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
  88. package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
  89. package/examples/markdown-jsconfig/package-lock.json +0 -665
  90. package/examples/markdown-jsconfig/package.json +0 -15
  91. package/examples/markdown-jsconfig/sfdx-project.json +0 -12
  92. package/examples/open-api/README.md +0 -5
  93. package/examples/open-api/config/project-scratch-def.json +0 -13
  94. package/examples/open-api/docs/openapi.json +0 -14
  95. package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
  96. package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
  97. package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
  98. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
  99. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
  100. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
  101. package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
  102. package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
  103. package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
  104. package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
  105. package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
  106. package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
  107. package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
  108. package/examples/open-api/package-lock.json +0 -724
  109. package/examples/open-api/package.json +0 -20
  110. package/examples/open-api/sfdx-project.json +0 -12
  111. package/examples/vitepress/.forceignore +0 -12
  112. package/examples/vitepress/README.md +0 -25
  113. package/examples/vitepress/apexdocs.config.ts +0 -113
  114. package/examples/vitepress/config/project-scratch-def.json +0 -13
  115. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
  116. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  117. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
  118. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
  119. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
  120. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
  121. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
  122. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
  123. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
  124. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  125. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
  126. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  127. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
  128. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
  129. package/examples/vitepress/docs/.vitepress/config.mts +0 -21
  130. package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
  131. package/examples/vitepress/docs/api-examples.md +0 -49
  132. package/examples/vitepress/docs/index-frontmatter.md +0 -16
  133. package/examples/vitepress/docs/index.md +0 -56
  134. package/examples/vitepress/docs/markdown-examples.md +0 -85
  135. package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
  136. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
  137. package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
  138. package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
  139. package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
  140. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
  141. package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
  142. package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
  143. package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
  144. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
  145. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
  146. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
  147. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
  148. package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
  149. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +0 -73
  150. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +0 -30
  151. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +0 -17
  152. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleInterface.cls +0 -46
  153. package/examples/vitepress/package-lock.json +0 -2574
  154. package/examples/vitepress/package.json +0 -18
  155. package/examples/vitepress/sfdx-project.json +0 -12
  156. package/jest.config.js +0 -10
  157. package/jest.d.ts +0 -7
  158. package/src/application/Apexdocs.ts +0 -69
  159. package/src/application/__tests__/apex-file-reader.spec.ts +0 -128
  160. package/src/application/apex-file-reader.ts +0 -56
  161. package/src/application/file-system.ts +0 -69
  162. package/src/application/file-writer.ts +0 -43
  163. package/src/application/generators/markdown.ts +0 -45
  164. package/src/application/generators/openapi.ts +0 -75
  165. package/src/cli/args.ts +0 -55
  166. package/src/cli/commands/markdown.ts +0 -56
  167. package/src/cli/commands/openapi.ts +0 -36
  168. package/src/cli/generate.ts +0 -32
  169. package/src/core/__test__/manifest.spec.ts +0 -16
  170. package/src/core/manifest.ts +0 -90
  171. package/src/core/markdown/__test__/expect-extensions.ts +0 -32
  172. package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -362
  173. package/src/core/markdown/__test__/generating-docs.spec.ts +0 -378
  174. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -61
  175. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -169
  176. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -196
  177. package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
  178. package/src/core/markdown/__test__/test-helpers.ts +0 -25
  179. package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
  180. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -150
  181. package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
  182. package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
  183. package/src/core/markdown/adapters/apex-types.ts +0 -238
  184. package/src/core/markdown/adapters/documentables.ts +0 -115
  185. package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
  186. package/src/core/markdown/adapters/generate-link.ts +0 -82
  187. package/src/core/markdown/adapters/inline.ts +0 -143
  188. package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
  189. package/src/core/markdown/adapters/reference-guide.ts +0 -37
  190. package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
  191. package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -91
  192. package/src/core/markdown/adapters/type-utils.ts +0 -13
  193. package/src/core/markdown/adapters/types.d.ts +0 -180
  194. package/src/core/markdown/generate-docs.ts +0 -210
  195. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -290
  196. package/src/core/markdown/reflection/__test__/helpers.ts +0 -18
  197. package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +0 -200
  198. package/src/core/markdown/reflection/filter-scope.ts +0 -13
  199. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
  200. package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
  201. package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
  202. package/src/core/markdown/reflection/reflect-source.ts +0 -123
  203. package/src/core/markdown/reflection/remove-excluded-tags.ts +0 -168
  204. package/src/core/markdown/reflection/sort-types-and-members.ts +0 -61
  205. package/src/core/markdown/templates/class-template.ts +0 -75
  206. package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
  207. package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
  208. package/src/core/markdown/templates/enum-template.ts +0 -12
  209. package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
  210. package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
  211. package/src/core/markdown/templates/hookable.ts +0 -7
  212. package/src/core/markdown/templates/interface-template.ts +0 -16
  213. package/src/core/markdown/templates/methods-partial-template.ts +0 -43
  214. package/src/core/markdown/templates/reference-guide.ts +0 -14
  215. package/src/core/markdown/templates/template.ts +0 -114
  216. package/src/core/markdown/templates/type-doc-partial.ts +0 -27
  217. package/src/core/markdown/utils.ts +0 -3
  218. package/src/core/openApiSettings.ts +0 -41
  219. package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
  220. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -59
  221. package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
  222. package/src/core/openapi/apex-doc-types.ts +0 -26
  223. package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
  224. package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
  225. package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
  226. package/src/core/openapi/file-container.ts +0 -13
  227. package/src/core/openapi/manifest-factory.ts +0 -16
  228. package/src/core/openapi/open-api-docs-processor.ts +0 -93
  229. package/src/core/openapi/open-api-types.ts +0 -119
  230. package/src/core/openapi/open-api.ts +0 -45
  231. package/src/core/openapi/openapi-type-file.ts +0 -12
  232. package/src/core/openapi/parser.ts +0 -163
  233. package/src/core/openapi/parsers/Builder.ts +0 -40
  234. package/src/core/openapi/parsers/MethodParser.ts +0 -249
  235. package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
  236. package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
  237. package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
  238. package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
  239. package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
  240. package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
  241. package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
  242. package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
  243. package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
  244. package/src/core/openapi/transpiler.ts +0 -17
  245. package/src/core/openapi/types-repository.ts +0 -54
  246. package/src/core/parse-apex-metadata.ts +0 -30
  247. package/src/core/shared/types.d.ts +0 -150
  248. package/src/core/shared/utils.ts +0 -5
  249. package/src/defaults.ts +0 -21
  250. package/src/index.ts +0 -110
  251. package/src/test-helpers/AnnotationBuilder.ts +0 -29
  252. package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
  253. package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
  254. package/src/test-helpers/DocCommentBuilder.ts +0 -36
  255. package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
  256. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
  257. package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
  258. package/src/test-helpers/SettingsBuilder.ts +0 -17
  259. package/src/util/error-logger.ts +0 -92
  260. package/src/util/fp.ts +0 -3
  261. package/src/util/logger.ts +0 -51
  262. package/src/util/string-utils.ts +0 -7
  263. package/tsconfig.json +0 -25
  264. package/tslint.json +0 -6
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Apexdocs } from '../application/Apexdocs';
3
- import { extractArgs } from './args';
4
- import { StdOutLogger } from '#utils/logger';
5
- import * as E from 'fp-ts/Either';
6
-
7
- const logger = new StdOutLogger();
8
-
9
- function main() {
10
- function parseResult(result: E.Either<unknown, string>) {
11
- E.match(
12
- (error) => {
13
- logger.error(`❌ An error occurred while generating the documentation: ${error}`);
14
- process.exit(1);
15
- },
16
- (successMessage: string) => {
17
- logger.logSingle(successMessage);
18
- },
19
- )(result);
20
- }
21
-
22
- function catchUnexpectedError(error: Error) {
23
- logger.error(`❌ An unexpected error occurred: ${error.message}`);
24
- process.exit(1);
25
- }
26
-
27
- extractArgs()
28
- .then((config) => Apexdocs.generate(config, logger).then(parseResult))
29
- .catch(catchUnexpectedError);
30
- }
31
-
32
- main();
@@ -1,16 +0,0 @@
1
- import Manifest from '../manifest';
2
- import { EnumMirror } from '@cparra/apex-reflection';
3
-
4
- const sampleEnum: EnumMirror = {
5
- annotations: [],
6
- name: 'SampleEnum',
7
- type_name: 'enum',
8
- access_modifier: 'public',
9
- values: [],
10
- };
11
-
12
- it('holds a list of types', () => {
13
- const types = [sampleEnum];
14
- const manifest = new Manifest(types);
15
- expect(manifest.types).toBe(types);
16
- });
@@ -1,90 +0,0 @@
1
- import {
2
- Annotation,
3
- ClassMirror,
4
- DocComment,
5
- DocCommentAnnotation,
6
- EnumMirror,
7
- InterfaceMirror,
8
- Type,
9
- } from '@cparra/apex-reflection';
10
-
11
- type AccessAndDocAware = { access_modifier: string; annotations: Annotation[]; docComment?: DocComment };
12
-
13
- /**
14
- * Represents the full library of Apex top-level types (classes, enums, and interface) for a Salesforce project.
15
- */
16
- export default class Manifest {
17
- /**
18
- * Constructs a new Manifest object.
19
- * @param types List of types to be wrapped by this object.
20
- * @param isForInnerTypes Whether this manifest represent an inner type or not.
21
- */
22
- constructor(
23
- public types: Type[],
24
- public isForInnerTypes: boolean = false,
25
- ) {}
26
-
27
- filteredByAccessModifierAndAnnotations(modifiers: string[]): Type[] {
28
- const filteredTypes = Manifest.filterAccessibleModifier(this.types, modifiers);
29
- const typesToReturn: Type[] = [];
30
- for (const filteredType of filteredTypes) {
31
- typesToReturn.push(Manifest.filterSingleType(filteredType, modifiers, this.isForInnerTypes));
32
- }
33
-
34
- return typesToReturn;
35
- }
36
-
37
- static filterSingleType(currentType: Type, modifiers: string[], isForInnerTypes: boolean): Type {
38
- if (currentType.type_name === 'enum') {
39
- // Ignoring enum values is not supported.
40
- return currentType;
41
- }
42
-
43
- if (currentType.type_name === 'interface') {
44
- const currentInterface = currentType as InterfaceMirror;
45
- return {
46
- ...currentType,
47
- methods: this.filterAccessibleModifier(currentInterface.methods, modifiers),
48
- } as InterfaceMirror;
49
- }
50
-
51
- const currentClass = currentType as ClassMirror;
52
- const filteredClass = {
53
- ...currentType,
54
- methods: this.filterAccessibleModifier(currentClass.methods, modifiers),
55
- properties: this.filterAccessibleModifier(currentClass.properties, modifiers),
56
- fields: this.filterAccessibleModifier(currentClass.fields, modifiers),
57
- constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers),
58
- } as ClassMirror;
59
-
60
- if (!isForInnerTypes) {
61
- return {
62
- ...filteredClass,
63
- enums: this.filterAccessibleModifier(currentClass.enums, modifiers) as EnumMirror[],
64
- interfaces: this.filterAccessibleModifier(currentClass.interfaces, modifiers) as InterfaceMirror[],
65
- classes: new Manifest(currentClass.classes, true).filteredByAccessModifierAndAnnotations(
66
- modifiers,
67
- ) as ClassMirror[],
68
- };
69
- }
70
-
71
- return filteredClass;
72
- }
73
-
74
- static filterAccessibleModifier<T extends AccessAndDocAware>(accessAndDocAware: T[], modifiers: string[]): T[] {
75
- return accessAndDocAware.filter((type) => this.shouldFilterType(type, modifiers));
76
- }
77
-
78
- static shouldFilterType(accessAndDocAware: AccessAndDocAware, modifiers: string[]) {
79
- const hasIgnoreDocAnnotation = accessAndDocAware.docComment?.annotations.some(
80
- (annotation: DocCommentAnnotation) => annotation.name.toLowerCase() === 'ignore',
81
- );
82
- if (hasIgnoreDocAnnotation) {
83
- return false;
84
- }
85
- return (
86
- modifiers.includes(accessAndDocAware.access_modifier) ||
87
- accessAndDocAware.annotations.some((annotation: Annotation) => modifiers.includes(annotation.type.toLowerCase()))
88
- );
89
- }
90
- }
@@ -1,32 +0,0 @@
1
- import * as E from 'fp-ts/Either';
2
- import { DocumentationBundle } from '../../shared/types';
3
-
4
- export function extendExpect() {
5
- expect.extend({
6
- documentationBundleHasLength(received: E.Either<string[], DocumentationBundle>, length: number) {
7
- return {
8
- pass: E.isRight(received) && received.right.docs.length === length,
9
- message: () => `Expected documentation bundle to have length ${length}`,
10
- };
11
- },
12
- firstDocContains(doc: DocumentationBundle, content: string) {
13
- return {
14
- pass: doc.docs[0].content.includes(content),
15
- message: () => `Expected documentation to contain ${content}. Got ${doc.docs[0].content}`,
16
- };
17
- },
18
- firstDocContainsNot(doc: DocumentationBundle, content: string) {
19
- return {
20
- pass: !doc.docs[0].content.includes(content),
21
- message: () => `Expected documentation to not contain ${content}. Got ${doc.docs[0].content}`,
22
- };
23
- },
24
- });
25
- }
26
-
27
- export function assertEither<T, U>(result: E.Either<T, U>, assertion: (data: U) => void): void {
28
- E.match<T, U, void>(
29
- (error) => fail(error),
30
- (data) => assertion(data),
31
- )(result);
32
- }
@@ -1,362 +0,0 @@
1
- import { assertEither, extendExpect } from './expect-extensions';
2
- import { apexBundleFromRawString, generateDocs } from './test-helpers';
3
-
4
- describe('When generating documentation for a class', () => {
5
- beforeAll(() => {
6
- extendExpect();
7
- });
8
-
9
- describe('member information', () => {
10
- it('displays the Method heading', async () => {
11
- const input = `
12
- public class MyClass {
13
- public void myMethod() {}
14
- }
15
- `;
16
-
17
- const result = await generateDocs([apexBundleFromRawString(input)])();
18
- expect(result).documentationBundleHasLength(1);
19
- assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
20
- });
21
-
22
- it('sorts methods when sorting members alphabetically', async () => {
23
- const input = `
24
- public class MyClass {
25
- public void zMethod() {}
26
- public void aMethod() {}
27
- }
28
- `;
29
-
30
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
31
- expect(result).documentationBundleHasLength(1);
32
- assertEither(result, (data) => {
33
- const aMethodIndex = data.docs[0].content.indexOf('aMethod');
34
- const zMethodIndex = data.docs[0].content.indexOf('zMethod');
35
- expect(aMethodIndex).toBeLessThan(zMethodIndex);
36
- });
37
- });
38
-
39
- it('does not sort methods when not sorting members alphabetically', async () => {
40
- const input = `
41
- public class MyClass {
42
- public void zMethod() {}
43
- public void aMethod() {}
44
- }
45
- `;
46
-
47
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
48
- expect(result).documentationBundleHasLength(1);
49
- assertEither(result, (data) => {
50
- const aMethodIndex = data.docs[0].content.indexOf('aMethod');
51
- const zMethodIndex = data.docs[0].content.indexOf('zMethod');
52
- expect(aMethodIndex).toBeGreaterThan(zMethodIndex);
53
- });
54
- });
55
-
56
- it('displays the Property heading', async () => {
57
- const input = `
58
- public class MyClass {
59
- public String myProperty { get; set; }
60
- }
61
- `;
62
-
63
- const result = await generateDocs([apexBundleFromRawString(input)])();
64
- expect(result).documentationBundleHasLength(1);
65
- assertEither(result, (data) => expect(data).firstDocContains('## Properties'));
66
- });
67
-
68
- it('sorts properties when sorting members alphabetically', async () => {
69
- const input = `
70
- public class MyClass {
71
- public String zProperty { get; set; }
72
- public String aProperty { get; set; }
73
- }
74
- `;
75
-
76
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
77
- expect(result).documentationBundleHasLength(1);
78
- assertEither(result, (data) => {
79
- const aPropertyIndex = data.docs[0].content.indexOf('aProperty');
80
- const zPropertyIndex = data.docs[0].content.indexOf('zProperty');
81
- expect(aPropertyIndex).toBeLessThan(zPropertyIndex);
82
- });
83
- });
84
-
85
- it('does not sort properties when not sorting members alphabetically', async () => {
86
- const input = `
87
- public class MyClass {
88
- public String zProperty { get; set; }
89
- public String aProperty { get; set; }
90
- }
91
- `;
92
-
93
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
94
- expect(result).documentationBundleHasLength(1);
95
- assertEither(result, (data) => {
96
- const aPropertyIndex = data.docs[0].content.indexOf('aProperty');
97
- const zPropertyIndex = data.docs[0].content.indexOf('zProperty');
98
- expect(aPropertyIndex).toBeGreaterThan(zPropertyIndex);
99
- });
100
- });
101
-
102
- it('displays the Field heading', async () => {
103
- const input = `
104
- public class MyClass {
105
- public String myField;
106
- }
107
- `;
108
-
109
- const result = await generateDocs([apexBundleFromRawString(input)])();
110
- expect(result).documentationBundleHasLength(1);
111
- assertEither(result, (data) => expect(data).firstDocContains('## Fields'));
112
- });
113
-
114
- it('sort fields when sorting members alphabetically', async () => {
115
- const input = `
116
- public class MyClass {
117
- public String zField;
118
- public String aField;
119
- }
120
- `;
121
-
122
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
123
- expect(result).documentationBundleHasLength(1);
124
- assertEither(result, (data) => {
125
- const aFieldIndex = data.docs[0].content.indexOf('aField');
126
- const zFieldIndex = data.docs[0].content.indexOf('zField');
127
- expect(aFieldIndex).toBeLessThan(zFieldIndex);
128
- });
129
- });
130
-
131
- it('does not sort fields when not sorting members alphabetically', async () => {
132
- const input = `
133
- public class MyClass {
134
- public String zField;
135
- public String aField;
136
- }
137
- `;
138
-
139
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
140
- expect(result).documentationBundleHasLength(1);
141
- assertEither(result, (data) => {
142
- const aFieldIndex = data.docs[0].content.indexOf('aField');
143
- const zFieldIndex = data.docs[0].content.indexOf('zField');
144
- expect(aFieldIndex).toBeGreaterThan(zFieldIndex);
145
- });
146
- });
147
-
148
- it('displays the Constructor heading', async () => {
149
- const input = `
150
- public class MyClass {
151
- public MyClass() {}
152
- }
153
- `;
154
-
155
- const result = await generateDocs([apexBundleFromRawString(input)])();
156
- expect(result).documentationBundleHasLength(1);
157
- assertEither(result, (data) => expect(data).firstDocContains('## Constructors'));
158
- });
159
-
160
- it('displays the Inner Class heading', async () => {
161
- const input = `
162
- public class MyClass {
163
- public class InnerClass {}
164
- }
165
- `;
166
-
167
- const result = await generateDocs([apexBundleFromRawString(input)])();
168
- expect(result).documentationBundleHasLength(1);
169
- assertEither(result, (data) => expect(data).firstDocContains('## Classes'));
170
- });
171
-
172
- it('sorts inner classes when sorting members alphabetically', async () => {
173
- const input = `
174
- public class MyClass {
175
- public class ZInnerClass {}
176
- public class AInnerClass {}
177
- }
178
- `;
179
-
180
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
181
- expect(result).documentationBundleHasLength(1);
182
- assertEither(result, (data) => {
183
- const aInnerClassIndex = data.docs[0].content.indexOf('AInnerClass');
184
- const zInnerClassIndex = data.docs[0].content.indexOf('ZInnerClass');
185
- expect(aInnerClassIndex).toBeLessThan(zInnerClassIndex);
186
- });
187
- });
188
-
189
- it('does not sort inner classes when not sorting members alphabetically', async () => {
190
- const input = `
191
- public class MyClass {
192
- public class ZInnerClass {}
193
- public class AInnerClass {}
194
- }
195
- `;
196
-
197
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
198
- expect(result).documentationBundleHasLength(1);
199
- assertEither(result, (data) => {
200
- const aInnerClassIndex = data.docs[0].content.indexOf('AInnerClass');
201
- const zInnerClassIndex = data.docs[0].content.indexOf('ZInnerClass');
202
- expect(aInnerClassIndex).toBeGreaterThan(zInnerClassIndex);
203
- });
204
- });
205
-
206
- it('displays the Inner Interface heading', async () => {
207
- const input = `
208
- public class MyClass {
209
- public interface InnerInterface {}
210
- }
211
- `;
212
-
213
- const result = await generateDocs([apexBundleFromRawString(input)])();
214
- expect(result).documentationBundleHasLength(1);
215
- assertEither(result, (data) => expect(data).firstDocContains('## Interfaces'));
216
- });
217
-
218
- it('sorts inner interfaces when sorting members alphabetically', async () => {
219
- const input = `
220
- public class MyClass {
221
- public interface ZInnerInterface {}
222
- public interface AInnerInterface {}
223
- }
224
- `;
225
-
226
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
227
- expect(result).documentationBundleHasLength(1);
228
- assertEither(result, (data) => {
229
- const aInnerInterfaceIndex = data.docs[0].content.indexOf('AInnerInterface');
230
- const zInnerInterfaceIndex = data.docs[0].content.indexOf('ZInnerInterface');
231
- expect(aInnerInterfaceIndex).toBeLessThan(zInnerInterfaceIndex);
232
- });
233
- });
234
-
235
- it('does not sort inner interfaces when not sorting members alphabetically', async () => {
236
- const input = `
237
- public class MyClass {
238
- public interface ZInnerInterface {}
239
- public interface AInnerInterface {}
240
- }
241
- `;
242
-
243
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
244
- expect(result).documentationBundleHasLength(1);
245
- assertEither(result, (data) => {
246
- const aInnerInterfaceIndex = data.docs[0].content.indexOf('AInnerInterface');
247
- const zInnerInterfaceIndex = data.docs[0].content.indexOf('ZInnerInterface');
248
- expect(aInnerInterfaceIndex).toBeGreaterThan(zInnerInterfaceIndex);
249
- });
250
- });
251
-
252
- it('displays the Inner Enum heading', async () => {
253
- const input = `
254
- public class MyClass {
255
- public enum InnerEnum {}
256
- }
257
- `;
258
-
259
- const result = await generateDocs([apexBundleFromRawString(input)])();
260
- expect(result).documentationBundleHasLength(1);
261
- assertEither(result, (data) => expect(data).firstDocContains('## Enums'));
262
- });
263
-
264
- it('sort inner enums when sorting members alphabetically', async () => {
265
- const input = `
266
- public class MyClass {
267
- public enum ZInnerEnum {}
268
- public enum AInnerEnum {}
269
- }
270
- `;
271
-
272
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
273
- expect(result).documentationBundleHasLength(1);
274
- assertEither(result, (data) => {
275
- const aInnerEnumIndex = data.docs[0].content.indexOf('AInnerEnum');
276
- const zInnerEnumIndex = data.docs[0].content.indexOf('ZInnerEnum');
277
- expect(aInnerEnumIndex).toBeLessThan(zInnerEnumIndex);
278
- });
279
- });
280
-
281
- it('does not sort inner enums when not sorting members alphabetically', async () => {
282
- const input = `
283
- public class MyClass {
284
- public enum ZInnerEnum {}
285
- public enum AInnerEnum {}
286
- }
287
- `;
288
-
289
- const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
290
- expect(result).documentationBundleHasLength(1);
291
- assertEither(result, (data) => {
292
- const aInnerEnumIndex = data.docs[0].content.indexOf('AInnerEnum');
293
- const zInnerEnumIndex = data.docs[0].content.indexOf('ZInnerEnum');
294
- expect(aInnerEnumIndex).toBeGreaterThan(zInnerEnumIndex);
295
- });
296
- });
297
-
298
- it('supports having mermaid diagrams in descriptions', async () => {
299
- const input = `
300
- public class MyClass {
301
- /**
302
- * @mermaid
303
- * \`\`\`mermaid
304
- * graph TD
305
- * A[Square Rect] -- Link text --> B((Circle))
306
- * A --> C(Round Rect)
307
- * B --> D{Rhombus}
308
- * C --> D
309
- * \`\`\`
310
- */
311
- public void myMethod() {}
312
- }
313
- `;
314
-
315
- const result = await generateDocs([apexBundleFromRawString(input)])();
316
- expect(result).documentationBundleHasLength(1);
317
- assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
318
- assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
319
- });
320
-
321
- it('supports having example code blocks in method descriptions', async () => {
322
- const input = `
323
- public class MyClass {
324
- /**
325
- * @example
326
- * public class MyClass {
327
- * public void myMethod() {
328
- * System.debug('Hello, World!');
329
- * }
330
- * }
331
- */
332
- public void myMethod() {}
333
- }
334
- `;
335
-
336
- const result = await generateDocs([apexBundleFromRawString(input)])();
337
- expect(result).documentationBundleHasLength(1);
338
- assertEither(result, (data) => expect(data).firstDocContains('```apex'));
339
- assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
340
- });
341
-
342
- it('displays an "inherited" tag if the method was inherited from a different interface', async () => {
343
- const input1 = `
344
- public virtual class MyClass {
345
- public void myMethod() {}
346
- }
347
- `;
348
-
349
- const input2 = `
350
- public class AnotherClass extends MyClass {}
351
- `;
352
-
353
- const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
354
- expect(result).documentationBundleHasLength(2);
355
- assertEither(result, (data) =>
356
- expect(data.docs.find((doc) => doc.source.name === 'AnotherClass')?.content).toContain('Inherited'),
357
- );
358
- });
359
- });
360
- });
361
-
362
- // TODO: Skips tags at the member level