@cparra/apexdocs 3.0.0-rc.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 (226) hide show
  1. package/README.md +61 -576
  2. package/dist/cli/generate.js +73 -3094
  3. package/dist/defaults-BcE8DTat.js +13 -0
  4. package/dist/defaults-D07y_bq4.js +40 -0
  5. package/dist/defaults-gPzwP66p.js +14 -0
  6. package/dist/index.d.ts +35 -3
  7. package/dist/index.js +90 -2
  8. package/dist/logger-BEbUIfqN.js +3282 -0
  9. package/dist/logger-BGuf1PnL.js +3281 -0
  10. package/dist/logger-CWBRF2za.js +3284 -0
  11. package/dist/logger-CdBmDEN1.js +3283 -0
  12. package/dist/logger-Ce4QqPFR.js +3278 -0
  13. package/dist/logger-CyEVYaAC.js +3284 -0
  14. package/dist/logger-D7a83ycP.js +3277 -0
  15. package/dist/logger-DGaHeBKk.js +3279 -0
  16. package/dist/logger-Dqhl_lO_.js +3278 -0
  17. package/dist/logger-aySSWi0G.js +3280 -0
  18. package/dist/logger-qLCcAtiy.js +3284 -0
  19. package/package.json +5 -2
  20. package/.github/workflows/ci.yaml +0 -22
  21. package/.github/workflows/close_stale.yml +0 -22
  22. package/.prettierrc.js +0 -7
  23. package/__mocks__/chalk.js +0 -12
  24. package/__mocks__/log-update.js +0 -6
  25. package/eslint.config.mjs +0 -10
  26. package/examples/markdown/.forceignore +0 -12
  27. package/examples/markdown/config/project-scratch-def.json +0 -5
  28. package/examples/markdown/docs/index.md +0 -109
  29. package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
  30. package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
  31. package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
  32. package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
  33. package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
  34. package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
  35. package/examples/markdown/docs/miscellaneous/Url.md +0 -311
  36. package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
  37. package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
  38. package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
  39. package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
  40. package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
  41. package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
  42. package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
  43. package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
  44. package/examples/markdown/force-app/classes/SampleException.cls +0 -17
  45. package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
  46. package/examples/markdown/force-app/classes/Url.cls +0 -196
  47. package/examples/markdown/package-lock.json +0 -665
  48. package/examples/markdown/package.json +0 -20
  49. package/examples/markdown/sfdx-project.json +0 -12
  50. package/examples/markdown-jsconfig/.forceignore +0 -12
  51. package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -21
  52. package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
  53. package/examples/markdown-jsconfig/docs/index.md +0 -12
  54. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
  55. package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
  56. package/examples/markdown-jsconfig/package-lock.json +0 -665
  57. package/examples/markdown-jsconfig/package.json +0 -15
  58. package/examples/markdown-jsconfig/sfdx-project.json +0 -12
  59. package/examples/open-api/config/project-scratch-def.json +0 -13
  60. package/examples/open-api/docs/openapi.json +0 -582
  61. package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
  62. package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
  63. package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
  64. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
  65. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
  66. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
  67. package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
  68. package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
  69. package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
  70. package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
  71. package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
  72. package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
  73. package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
  74. package/examples/open-api/package-lock.json +0 -724
  75. package/examples/open-api/package.json +0 -20
  76. package/examples/open-api/sfdx-project.json +0 -12
  77. package/examples/vitepress/.forceignore +0 -12
  78. package/examples/vitepress/apexdocs.config.ts +0 -111
  79. package/examples/vitepress/config/project-scratch-def.json +0 -13
  80. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
  81. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  82. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
  83. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
  84. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
  85. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
  86. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
  87. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
  88. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
  89. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  90. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
  91. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  92. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
  93. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
  94. package/examples/vitepress/docs/.vitepress/config.mts +0 -21
  95. package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
  96. package/examples/vitepress/docs/api-examples.md +0 -49
  97. package/examples/vitepress/docs/index-frontmatter.md +0 -16
  98. package/examples/vitepress/docs/index.md +0 -56
  99. package/examples/vitepress/docs/markdown-examples.md +0 -85
  100. package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
  101. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
  102. package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
  103. package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
  104. package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
  105. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
  106. package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
  107. package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
  108. package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
  109. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
  110. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
  111. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
  112. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
  113. package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +0 -72
  114. package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +0 -30
  115. package/examples/vitepress/force-app/main/default/classes/SampleException.cls +0 -17
  116. package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +0 -46
  117. package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
  118. package/examples/vitepress/package-lock.json +0 -2574
  119. package/examples/vitepress/package.json +0 -18
  120. package/examples/vitepress/sfdx-project.json +0 -12
  121. package/jest.config.js +0 -10
  122. package/jest.d.ts +0 -7
  123. package/src/application/Apexdocs.ts +0 -72
  124. package/src/application/__tests__/apex-file-reader.spec.ts +0 -87
  125. package/src/application/apex-file-reader.ts +0 -55
  126. package/src/application/file-system.ts +0 -69
  127. package/src/application/file-writer.ts +0 -43
  128. package/src/application/generators/markdown.ts +0 -45
  129. package/src/application/generators/openapi.ts +0 -71
  130. package/src/cli/args.ts +0 -46
  131. package/src/cli/commands/markdown.ts +0 -51
  132. package/src/cli/commands/openapi.ts +0 -36
  133. package/src/cli/generate.ts +0 -16
  134. package/src/core/__test__/manifest.spec.ts +0 -16
  135. package/src/core/manifest.ts +0 -90
  136. package/src/core/markdown/__test__/expect-extensions.ts +0 -32
  137. package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -605
  138. package/src/core/markdown/__test__/generating-docs.spec.ts +0 -111
  139. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -321
  140. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -397
  141. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -180
  142. package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
  143. package/src/core/markdown/__test__/test-helpers.ts +0 -23
  144. package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
  145. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -148
  146. package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
  147. package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
  148. package/src/core/markdown/adapters/apex-types.ts +0 -238
  149. package/src/core/markdown/adapters/documentables.ts +0 -115
  150. package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
  151. package/src/core/markdown/adapters/generate-link.ts +0 -82
  152. package/src/core/markdown/adapters/inline.ts +0 -143
  153. package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
  154. package/src/core/markdown/adapters/reference-guide.ts +0 -37
  155. package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
  156. package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -89
  157. package/src/core/markdown/adapters/type-utils.ts +0 -13
  158. package/src/core/markdown/adapters/types.d.ts +0 -180
  159. package/src/core/markdown/generate-docs.ts +0 -212
  160. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -306
  161. package/src/core/markdown/reflection/filter-scope.ts +0 -13
  162. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
  163. package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
  164. package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
  165. package/src/core/markdown/reflection/reflect-source.ts +0 -123
  166. package/src/core/markdown/reflection/sort-members.ts +0 -59
  167. package/src/core/markdown/templates/class-template.ts +0 -75
  168. package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
  169. package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
  170. package/src/core/markdown/templates/enum-template.ts +0 -12
  171. package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
  172. package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
  173. package/src/core/markdown/templates/hookable.ts +0 -7
  174. package/src/core/markdown/templates/interface-template.ts +0 -16
  175. package/src/core/markdown/templates/methods-partial-template.ts +0 -43
  176. package/src/core/markdown/templates/reference-guide.ts +0 -14
  177. package/src/core/markdown/templates/template.ts +0 -114
  178. package/src/core/markdown/templates/type-doc-partial.ts +0 -27
  179. package/src/core/markdown/utils.ts +0 -3
  180. package/src/core/openApiSettings.ts +0 -41
  181. package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
  182. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -56
  183. package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
  184. package/src/core/openapi/apex-doc-types.ts +0 -26
  185. package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
  186. package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
  187. package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
  188. package/src/core/openapi/file-container.ts +0 -13
  189. package/src/core/openapi/manifest-factory.ts +0 -16
  190. package/src/core/openapi/open-api-docs-processor.ts +0 -93
  191. package/src/core/openapi/open-api-types.ts +0 -119
  192. package/src/core/openapi/open-api.ts +0 -45
  193. package/src/core/openapi/openapi-type-file.ts +0 -12
  194. package/src/core/openapi/parser.ts +0 -160
  195. package/src/core/openapi/parsers/Builder.ts +0 -40
  196. package/src/core/openapi/parsers/MethodParser.ts +0 -249
  197. package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
  198. package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
  199. package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
  200. package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
  201. package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
  202. package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
  203. package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
  204. package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
  205. package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
  206. package/src/core/openapi/transpiler.ts +0 -17
  207. package/src/core/openapi/types-repository.ts +0 -54
  208. package/src/core/parse-apex-metadata.ts +0 -30
  209. package/src/core/shared/types.d.ts +0 -148
  210. package/src/core/shared/utils.ts +0 -5
  211. package/src/defaults.ts +0 -9
  212. package/src/index.ts +0 -49
  213. package/src/test-helpers/AnnotationBuilder.ts +0 -29
  214. package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
  215. package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
  216. package/src/test-helpers/DocCommentBuilder.ts +0 -36
  217. package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
  218. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
  219. package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
  220. package/src/test-helpers/SettingsBuilder.ts +0 -17
  221. package/src/util/error-logger.ts +0 -92
  222. package/src/util/fp.ts +0 -3
  223. package/src/util/logger.ts +0 -44
  224. package/src/util/string-utils.ts +0 -7
  225. package/tsconfig.json +0 -25
  226. package/tslint.json +0 -6
@@ -1,123 +0,0 @@
1
- import { ParsedFile, UnparsedSourceFile } from '../../shared/types';
2
- import * as TE from 'fp-ts/TaskEither';
3
- import * as E from 'fp-ts/Either';
4
- import * as T from 'fp-ts/Task';
5
- import * as A from 'fp-ts/lib/Array';
6
- import { Annotation, reflect as mirrorReflection, Type } from '@cparra/apex-reflection';
7
- import { pipe } from 'fp-ts/function';
8
- import * as O from 'fp-ts/Option';
9
- import { parseApexMetadata } from '../../parse-apex-metadata';
10
- import { ParsingError } from '@cparra/apex-reflection';
11
- import { apply } from '#utils/fp';
12
- import { Semigroup } from 'fp-ts/Semigroup';
13
-
14
- export class ReflectionErrors {
15
- readonly _tag = 'ReflectionErrors';
16
-
17
- constructor(public errors: ReflectionError[]) {}
18
- }
19
-
20
- export class ReflectionError {
21
- constructor(
22
- public file: string,
23
- public message: string,
24
- ) {}
25
- }
26
-
27
- async function reflectAsync(rawSource: string): Promise<Type> {
28
- return new Promise((resolve, reject) => {
29
- const result = mirrorReflection(rawSource);
30
- if (result.typeMirror) {
31
- return resolve(result.typeMirror);
32
- } else if (result.error) {
33
- return reject(result.error);
34
- } else {
35
- return reject(new Error('Unknown error'));
36
- }
37
- });
38
- }
39
-
40
- export function reflectBundles(apexBundles: UnparsedSourceFile[]) {
41
- const semiGroupReflectionError: Semigroup<ReflectionErrors> = {
42
- concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors]),
43
- };
44
- const Ap = TE.getApplicativeTaskValidation(T.ApplyPar, semiGroupReflectionError);
45
-
46
- return pipe(apexBundles, A.traverse(Ap)(reflectBundle));
47
- }
48
-
49
- function reflectBundle(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, ParsedFile> {
50
- const convertToParsedFile: (typeMirror: Type) => ParsedFile = apply(toParsedFile, apexBundle.filePath);
51
- const withMetadata = apply(addMetadata, apexBundle.metadataContent);
52
-
53
- return pipe(apexBundle, reflectAsTask, TE.map(convertToParsedFile), TE.flatMap(withMetadata));
54
- }
55
-
56
- function reflectAsTask(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, Type> {
57
- return TE.tryCatch(
58
- () => reflectAsync(apexBundle.content),
59
- (error) =>
60
- new ReflectionErrors([new ReflectionError(apexBundle.filePath, (error as ParsingError | Error).message)]),
61
- );
62
- }
63
-
64
- function toParsedFile(filePath: string, typeMirror: Type): ParsedFile {
65
- return {
66
- source: {
67
- filePath: filePath,
68
- name: typeMirror.name,
69
- type: typeMirror.type_name,
70
- },
71
- type: typeMirror,
72
- };
73
- }
74
-
75
- function addMetadata(
76
- rawMetadataContent: string | null,
77
- parsedFile: ParsedFile,
78
- ): TE.TaskEither<ReflectionErrors, ParsedFile> {
79
- return TE.fromEither(
80
- pipe(
81
- parsedFile.type,
82
- (type) => addFileMetadataToTypeAnnotation(type, rawMetadataContent),
83
- E.map((type) => ({ ...parsedFile, type })),
84
- E.mapLeft((error) => errorToReflectionErrors(error, parsedFile.source.filePath)),
85
- ),
86
- );
87
- }
88
-
89
- function errorToReflectionErrors(error: Error, filePath: string): ReflectionErrors {
90
- return new ReflectionErrors([new ReflectionError(filePath, error.message)]);
91
- }
92
-
93
- function addFileMetadataToTypeAnnotation(type: Type, metadata: string | null): E.Either<Error, Type> {
94
- const concatAnnotationToType = apply(concatAnnotations, type);
95
-
96
- return pipe(
97
- O.fromNullable(metadata),
98
- O.map(concatAnnotationToType),
99
- O.getOrElse(() => E.right(type)),
100
- );
101
- }
102
-
103
- function concatAnnotations(type: Type, metadataInput: string): E.Either<Error, Type> {
104
- return pipe(
105
- metadataInput,
106
- parseApexMetadata,
107
- E.map((metadataMap) => ({
108
- ...type,
109
- annotations: [...type.annotations, ...mapToAnnotations(metadataMap)],
110
- })),
111
- );
112
- }
113
-
114
- function mapToAnnotations(metadata: Map<string, string>): Annotation[] {
115
- return Array.from(metadata.entries()).map(([key, value]) => {
116
- const declaration = `${key}: ${value}`;
117
- return {
118
- name: declaration,
119
- type: declaration,
120
- rawDeclaration: declaration,
121
- };
122
- });
123
- }
@@ -1,59 +0,0 @@
1
- import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
2
- import { ParsedFile } from '../../shared/types';
3
-
4
- type Named = { name: string };
5
-
6
- export function sortMembers(shouldSortMembers: boolean, parsedFiles: ParsedFile[]): ParsedFile[] {
7
- return parsedFiles.map((parsedFile) => ({
8
- ...parsedFile,
9
- type: sortTypeMember(parsedFile.type, shouldSortMembers),
10
- }));
11
- }
12
-
13
- function sortByNames<T extends Named>(shouldSort: boolean, a: T, b: T): number {
14
- if (shouldSort) {
15
- return a.name.localeCompare(b.name);
16
- }
17
- return 0;
18
- }
19
-
20
- function sortNamed<T extends Named>(shouldSort: boolean, items: T[]): T[] {
21
- return items.sort((a, b) => sortByNames(shouldSort, a, b));
22
- }
23
-
24
- function sortTypeMember(type: Type, shouldSort: boolean): Type {
25
- switch (type.type_name) {
26
- case 'enum':
27
- return sortEnumValues(shouldSort, type as EnumMirror);
28
- case 'interface':
29
- return sortInterfaceMethods(shouldSort, type as InterfaceMirror);
30
- case 'class':
31
- return sortClassMembers(shouldSort, type as ClassMirror);
32
- }
33
- }
34
-
35
- function sortEnumValues(shouldSort: boolean, enumType: EnumMirror): EnumMirror {
36
- return {
37
- ...enumType,
38
- values: sortNamed(shouldSort, enumType.values),
39
- };
40
- }
41
-
42
- function sortInterfaceMethods(shouldSort: boolean, interfaceType: InterfaceMirror): InterfaceMirror {
43
- return {
44
- ...interfaceType,
45
- methods: sortNamed(shouldSort, interfaceType.methods),
46
- };
47
- }
48
-
49
- function sortClassMembers(shouldSort: boolean, classType: ClassMirror): ClassMirror {
50
- return {
51
- ...classType,
52
- fields: sortNamed(shouldSort, classType.fields),
53
- classes: sortNamed(shouldSort, classType.classes),
54
- enums: sortNamed(shouldSort, classType.enums),
55
- interfaces: sortNamed(shouldSort, classType.interfaces),
56
- methods: sortNamed(shouldSort, classType.methods),
57
- properties: sortNamed(shouldSort, classType.properties),
58
- };
59
- }
@@ -1,75 +0,0 @@
1
- export const classMarkdownTemplate = `
2
- {{ heading headingLevel heading }}
3
- {{#if classModifier}}
4
- \`{{classModifier}}\`
5
- {{/if}}
6
-
7
- {{> typeDocumentation}}
8
-
9
- {{#if extends.length}}
10
- **Inheritance**
11
-
12
- {{#each extends}}{{link this}}{{#unless @last}} < {{/unless}}{{/each}}
13
- {{/if}}
14
-
15
- {{#if implements}}
16
- **Implements**
17
-
18
- {{#each implements}}
19
- {{link this}}{{#unless @last}}, {{/unless}}
20
- {{/each}}
21
- {{/if}}
22
-
23
- {{#if fields.value}}
24
- {{#if fields.isGrouped}}
25
- {{> groupedMembersPartialTemplate fields subTemplate="fieldsPartialTemplate"}}
26
- {{else}}
27
- {{> fieldsPartialTemplate fields}}
28
- {{/if}}
29
- {{/if}}
30
-
31
- {{#if properties.value}}
32
- {{#if properties.isGrouped}}
33
- {{> groupedMembersPartialTemplate properties subTemplate="fieldsPartialTemplate"}}
34
- {{else}}
35
- {{> fieldsPartialTemplate properties}}
36
- {{/if}}
37
- {{/if}}
38
-
39
- {{#if constructors.value}}
40
- {{#if constructors.isGrouped}}
41
- {{> groupedMembersPartialTemplate constructors subTemplate="constructorsPartialTemplate"}}
42
- {{else}}
43
- {{> constructorsPartialTemplate constructors}}
44
- {{/if}}
45
- {{/if}}
46
-
47
- {{#if methods.value}}
48
- {{#if methods.isGrouped}}
49
- {{> groupedMembersPartialTemplate methods subTemplate="methodsPartialTemplate"}}
50
- {{else}}
51
- {{> methodsPartialTemplate methods}}
52
- {{/if}}
53
- {{/if}}
54
-
55
- {{#if innerClasses.value}}
56
- {{ heading innerClasses.headingLevel innerClasses.heading }}
57
- {{#each innerClasses.value}}
58
- {{> classTemplate this}}
59
- {{/each}}
60
- {{/if}}
61
-
62
- {{#if innerEnums.value}}
63
- {{ heading innerEnums.headingLevel innerEnums.heading }}
64
- {{#each innerEnums.value}}
65
- {{> enumTemplate this}}
66
- {{/each}}
67
- {{/if}}
68
-
69
- {{#if innerInterfaces.value}}
70
- {{ heading innerInterfaces.headingLevel innerInterfaces.heading }}
71
- {{#each innerInterfaces.value}}
72
- {{> interfaceTemplate this}}
73
- {{/each}}
74
- {{/if}}
75
- `.trim();
@@ -1,32 +0,0 @@
1
- export const constructorsPartialTemplate = `
2
- {{ heading headingLevel heading }}
3
- {{#each value}}
4
- {{{ heading headingLevel (inlineCode heading) }}}
5
-
6
- {{#> documentablePartialTemplate}}
7
-
8
- {{ heading signature.headingLevel signature.heading }}
9
- {{ code signature.value }}
10
-
11
- {{#if parameters.value}}
12
- {{ heading parameters.headingLevel parameters.heading }}
13
- | Name | Type | Description |
14
- |------|------|-------------|
15
- {{#each parameters.value}}
16
- | {{name}} | {{link type}} | {{description}} |
17
- {{/each}}
18
- {{/if}}
19
-
20
- {{#if throws.value}}
21
- {{ heading throws.headingLevel throws.heading }}
22
- {{#each throws.value}}
23
- {{link this.type}}: {{this.description}}
24
-
25
- {{/each}}
26
- {{/if}}
27
- {{/documentablePartialTemplate}}
28
-
29
- {{#unless @last}}---{{/unless}}
30
-
31
- {{/each}}
32
- `.trim();
@@ -1,26 +0,0 @@
1
- export const documentablePartialTemplate = `
2
- {{#each doc.annotations}}
3
- \`{{this}}\`
4
- {{/each}}
5
-
6
- {{{renderContent doc.description}}}
7
-
8
- {{#each doc.customTags}}
9
- **{{splitAndCapitalize name}}**
10
-
11
- {{{renderContent description}}}
12
-
13
- {{/each}}
14
-
15
- {{> @partial-block}}
16
-
17
- {{#if doc.mermaid.value}}
18
- {{ heading doc.mermaid.headingLevel doc.mermaid.heading }}
19
- {{code doc.mermaid.value}}
20
- {{/if}}
21
-
22
- {{#if doc.example.value}}
23
- {{ heading doc.example.headingLevel doc.example.heading }}
24
- {{{renderContent doc.example.value}}}
25
- {{/if}}
26
- `.trim();
@@ -1,12 +0,0 @@
1
- export const enumMarkdownTemplate = `
2
- {{ heading headingLevel heading }}
3
-
4
- {{> typeDocumentation }}
5
-
6
- {{ heading values.headingLevel values.heading }}
7
- | Value | Description |
8
- |-------|-------------|
9
- {{#each values.value}}
10
- | {{value}} | {{description}} |
11
- {{/each}}
12
- `.trim();
@@ -1,23 +0,0 @@
1
- export const fieldsPartialTemplate = `
2
- {{ heading headingLevel heading }}
3
- {{#each value}}
4
- {{{ heading headingLevel (inlineCode heading) }}}
5
-
6
- {{#if inherited}}
7
- *Inherited*
8
- {{/if}}
9
-
10
- {{#> documentablePartialTemplate }}
11
-
12
- {{ heading signature.headingLevel signature.heading }}
13
- {{ code signature.value }}
14
-
15
- {{ heading type.headingLevel type.heading }}
16
- {{link type.value}}
17
-
18
- {{/documentablePartialTemplate}}
19
-
20
- {{#unless @last}}---{{/unless}}
21
-
22
- {{/each}}
23
- `.trim();
@@ -1,6 +0,0 @@
1
- export const groupedMembersPartialTemplate = `
2
- {{ heading headingLevel heading }}
3
- {{#each value}}
4
- {{> (lookup .. "subTemplate") this}}
5
- {{/each}}
6
- `.trim();
@@ -1,7 +0,0 @@
1
- export const hookableTemplate = `
2
- {{#if frontmatter}}
3
- {{{frontmatter}}}
4
- {{/if}}
5
-
6
- {{{content}}}
7
- `.trim();
@@ -1,16 +0,0 @@
1
- export const interfaceMarkdownTemplate = `
2
- {{ heading headingLevel heading }}
3
-
4
- {{> typeDocumentation }}
5
-
6
- {{#if extends}}
7
- **Extends**
8
- {{#each extends}}
9
- {{link this}}{{#unless @last}}, {{/unless}}
10
- {{/each}}
11
- {{/if}}
12
-
13
- {{#if methods}}
14
- {{> methodsPartialTemplate methods}}
15
- {{/if}}
16
- `.trim();
@@ -1,43 +0,0 @@
1
- export const methodsPartialTemplate = `
2
- {{ heading headingLevel heading }}
3
- {{#each value}}
4
- {{{ heading headingLevel (inlineCode heading) }}}
5
-
6
- {{#if inherited}}
7
- *Inherited*
8
- {{/if}}
9
-
10
- {{#> documentablePartialTemplate}}
11
-
12
- {{ heading signature.headingLevel signature.heading }}
13
- {{ code signature.value }}
14
-
15
- {{#if parameters.value}}
16
- {{ heading parameters.headingLevel parameters.heading }}
17
- | Name | Type | Description |
18
- |------|------|-------------|
19
- {{#each parameters.value}}
20
- | {{name}} | {{link type}} | {{{renderContent description}}} |
21
- {{/each}}
22
- {{/if}}
23
-
24
- {{ heading returnType.headingLevel returnType.heading }}
25
- **{{link returnType.value.type}}**
26
-
27
- {{#if returnType.value.description}}
28
- {{returnType.value.description}}
29
- {{/if}}
30
-
31
- {{#if throws.value}}
32
- {{ heading throws.headingLevel throws.heading }}
33
- {{#each throws.value}}
34
- {{link this.type}}: {{this.description}}
35
-
36
- {{/each}}
37
- {{/if}}
38
- {{/documentablePartialTemplate}}
39
-
40
- {{#unless @last}}---{{/unless}}
41
-
42
- {{/each}}
43
- `.trim();
@@ -1,14 +0,0 @@
1
- export const referenceGuideTemplate = `
2
- # Apex Reference Guide
3
-
4
- {{#each this}}
5
- ## {{@key}}
6
-
7
- {{#each this}}
8
- ### {{link title}}
9
-
10
- {{{renderContent description}}}
11
-
12
- {{/each}}
13
- {{/each}}
14
- `.trim();
@@ -1,114 +0,0 @@
1
- import Handlebars from 'handlebars';
2
- import { CodeBlock, RenderableContent, StringOrLink } from '../adapters/types';
3
- import { isCodeBlock, isEmptyLine, isInlineCode } from '../adapters/type-utils';
4
- import { typeDocPartial } from './type-doc-partial';
5
- import { documentablePartialTemplate } from './documentable-partial-template';
6
- import { methodsPartialTemplate } from './methods-partial-template';
7
- import { groupedMembersPartialTemplate } from './grouped-members-partial-template';
8
- import { constructorsPartialTemplate } from './constructors-partial-template';
9
- import { fieldsPartialTemplate } from './fieldsPartialTemplate';
10
- import { classMarkdownTemplate } from './class-template';
11
- import { enumMarkdownTemplate } from './enum-template';
12
- import { interfaceMarkdownTemplate } from './interface-template';
13
-
14
- export type CompilationRequest = {
15
- template: string;
16
- source: unknown;
17
- };
18
-
19
- export class Template {
20
- private static instance: Template;
21
-
22
- private constructor() {
23
- Handlebars.registerPartial('typeDocumentation', typeDocPartial);
24
- Handlebars.registerPartial('documentablePartialTemplate', documentablePartialTemplate);
25
- Handlebars.registerPartial('methodsPartialTemplate', methodsPartialTemplate);
26
- Handlebars.registerPartial('constructorsPartialTemplate', constructorsPartialTemplate);
27
- Handlebars.registerPartial('groupedMembersPartialTemplate', groupedMembersPartialTemplate);
28
- Handlebars.registerPartial('fieldsPartialTemplate', fieldsPartialTemplate);
29
- Handlebars.registerPartial('classTemplate', classMarkdownTemplate);
30
- Handlebars.registerPartial('enumTemplate', enumMarkdownTemplate);
31
- Handlebars.registerPartial('interfaceTemplate', interfaceMarkdownTemplate);
32
-
33
- Handlebars.registerHelper('link', link);
34
- Handlebars.registerHelper('code', convertCodeBlock);
35
- Handlebars.registerHelper('renderContent', resolveRenderableContent);
36
- Handlebars.registerHelper('heading', heading);
37
- Handlebars.registerHelper('inlineCode', inlineCode);
38
- Handlebars.registerHelper('splitAndCapitalize', splitAndCapitalize);
39
- }
40
-
41
- public static getInstance(): Template {
42
- if (!Template.instance) {
43
- Template.instance = new Template();
44
- }
45
- return Template.instance;
46
- }
47
-
48
- compile(request: CompilationRequest): string {
49
- const compiled = Handlebars.compile(request.template);
50
- return (
51
- compiled(request.source)
52
- .trim()
53
- // clean up extra newlines
54
- .replace(/\n{3,}/g, '\n\n')
55
- );
56
- }
57
- }
58
-
59
- const splitAndCapitalize = (text: string) => {
60
- const words = text.split(/[-_]+/);
61
- const capitalizedWords = [];
62
- for (const word of words) {
63
- capitalizedWords.push(word.charAt(0).toUpperCase() + word.slice(1));
64
- }
65
- return capitalizedWords.join(' ');
66
- };
67
-
68
- const heading = (level: number, text: string) => {
69
- return `${'#'.repeat(level)} ${text}`;
70
- };
71
-
72
- const inlineCode = (text: string) => {
73
- return new Handlebars.SafeString(`\`${text}\``);
74
- };
75
-
76
- const convertCodeBlock = (codeBlock: CodeBlock): Handlebars.SafeString => {
77
- return new Handlebars.SafeString(
78
- `
79
- \`\`\`${codeBlock.language}
80
- ${codeBlock.content.join('\n')}
81
- \`\`\`
82
- `.trim(),
83
- );
84
- };
85
-
86
- const resolveRenderableContent = (description?: RenderableContent[]): string => {
87
- if (!description) {
88
- return '';
89
- }
90
-
91
- function reduceDescription(acc: string, curr: RenderableContent) {
92
- if (isEmptyLine(curr)) {
93
- return acc + '\n';
94
- }
95
- if (isCodeBlock(curr)) {
96
- return acc + convertCodeBlock(curr) + '\n';
97
- }
98
- if (isInlineCode(curr)) {
99
- return acc + inlineCode(curr.content).toString() + ' ';
100
- } else {
101
- return acc + Handlebars.escapeExpression(link(curr)).trim() + ' ';
102
- }
103
- }
104
-
105
- return description.reduce(reduceDescription, '').trim();
106
- };
107
-
108
- const link = (source: StringOrLink): string => {
109
- if (typeof source === 'string') {
110
- return source;
111
- } else {
112
- return `[${source.title}](${source.url})`;
113
- }
114
- };
@@ -1,27 +0,0 @@
1
- export const typeDocPartial = `
2
- {{#> documentablePartialTemplate}}
3
-
4
- {{#if doc.group}}
5
- **Group** {{doc.group}}
6
- {{/if}}
7
-
8
- {{#if doc.author}}
9
- **Author** {{doc.author}}
10
- {{/if}}
11
-
12
- {{#if doc.date}}
13
- **Date** {{doc.date}}
14
- {{/if}}
15
-
16
- {{#each doc.sees}}
17
- **See** {{link this}}
18
-
19
- {{/each}}
20
-
21
- {{#if namespace}}
22
- ## Namespace
23
- {{namespace}}
24
- {{/if}}
25
-
26
- {{/documentablePartialTemplate}}
27
- `.trim();
@@ -1,3 +0,0 @@
1
- import { ParsedFile } from '../shared/types';
2
-
3
- export const parsedFilesToTypes = (parsedFiles: ParsedFile[]) => parsedFiles.map((parsedFile) => parsedFile.type);
@@ -1,41 +0,0 @@
1
- export interface SettingsConfig {
2
- sourceDirectory: string;
3
- outputDir: string;
4
- openApiFileName: string;
5
- namespace?: string;
6
- openApiTitle?: string;
7
- version: string;
8
- }
9
-
10
- export class OpenApiSettings {
11
- private static instance: OpenApiSettings;
12
-
13
- private constructor(public config: SettingsConfig) {}
14
-
15
- public static build(config: SettingsConfig) {
16
- OpenApiSettings.instance = new OpenApiSettings(config);
17
- }
18
-
19
- public static getInstance(): OpenApiSettings {
20
- if (!OpenApiSettings.instance) {
21
- throw new Error('Settings has not been initialized');
22
- }
23
- return OpenApiSettings.instance;
24
- }
25
-
26
- public getOpenApiTitle(): string | undefined {
27
- return this.config.openApiTitle;
28
- }
29
-
30
- public getNamespace(): string | undefined {
31
- return this.config.namespace;
32
- }
33
-
34
- public openApiFileName(): string {
35
- return this.config.openApiFileName;
36
- }
37
-
38
- public getVersion(): string {
39
- return this.config.version;
40
- }
41
- }
@@ -1,16 +0,0 @@
1
- import { createManifest } from '../manifest-factory';
2
- import { Type } from '@cparra/apex-reflection';
3
- import { TypeParser } from '../parser';
4
-
5
- class TestParser implements TypeParser {
6
- parse(): Type[] {
7
- return [];
8
- }
9
- }
10
-
11
- it('creates a manifest from the result of a type parser', () => {
12
- const manifest = createManifest(new TestParser(), () => {
13
- return {};
14
- });
15
- expect(manifest.types.length).toBe(0);
16
- });