@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,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
- # {{referenceGuideTitle}}
3
-
4
- {{#each references}}
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
- });
@@ -1,59 +0,0 @@
1
- import { OpenApiDocsProcessor } from '../open-api-docs-processor';
2
- import { OpenApiSettings } from '../../openApiSettings';
3
- import { SettingsBuilder } from '../../../test-helpers/SettingsBuilder';
4
- import { DocCommentBuilder } from '../../../test-helpers/DocCommentBuilder';
5
- import { AnnotationBuilder } from '../../../test-helpers/AnnotationBuilder';
6
- import { ClassMirrorBuilder } from '../../../test-helpers/ClassMirrorBuilder';
7
- import { NoLogger } from '../../../util/logger';
8
-
9
- const noLogger = new NoLogger();
10
-
11
- beforeEach(() => {
12
- OpenApiSettings.build(new SettingsBuilder().build());
13
- });
14
-
15
- it('should add a path based on the @UrlResource annotation on the class', function () {
16
- const annotationElementValue = {
17
- key: 'urlMapping',
18
- value: "'/Account/*'",
19
- };
20
- const classMirror = new ClassMirrorBuilder()
21
- .addAnnotation(new AnnotationBuilder().addElementValue(annotationElementValue).build())
22
- .build();
23
-
24
- const processor = new OpenApiDocsProcessor(noLogger);
25
- processor.onProcess(classMirror);
26
-
27
- expect(processor.openApiModel.paths).toHaveProperty('Account/');
28
- });
29
-
30
- it('should respect slashes', function () {
31
- const annotationElementValue = {
32
- key: 'urlMapping',
33
- value: "'v1/Account/*'",
34
- };
35
- const classMirror = new ClassMirrorBuilder()
36
- .addAnnotation(new AnnotationBuilder().addElementValue(annotationElementValue).build())
37
- .build();
38
-
39
- const processor = new OpenApiDocsProcessor(noLogger);
40
- processor.onProcess(classMirror);
41
-
42
- expect(processor.openApiModel.paths).toHaveProperty('v1/Account/');
43
- });
44
-
45
- it('should contain a path with a description when the class has an ApexDoc comment', function () {
46
- const annotationElementValue = {
47
- key: 'urlMapping',
48
- value: "'/Account/*'",
49
- };
50
- const classMirror = new ClassMirrorBuilder()
51
- .addAnnotation(new AnnotationBuilder().addElementValue(annotationElementValue).build())
52
- .withDocComment(new DocCommentBuilder().withDescription('My Description').build())
53
- .build();
54
-
55
- const processor = new OpenApiDocsProcessor(noLogger);
56
- processor.onProcess(classMirror);
57
-
58
- expect(processor.openApiModel.paths['Account/'].description).toBe('My Description');
59
- });
@@ -1,22 +0,0 @@
1
- import { OpenApi } from '../open-api';
2
-
3
- it('should get created with a title and a version', function () {
4
- const openApi = new OpenApi('Test Spec', '1.0.0');
5
-
6
- expect(openApi.info.title).toBe('Test Spec');
7
- expect(openApi.info.version).toBe('1.0.0');
8
- });
9
-
10
- it('should contain a single server, which points to the correct server URL', function () {
11
- const openApi = new OpenApi('Test Spec', '1.0.0');
12
-
13
- expect(openApi.servers.length).toBe(1);
14
- expect(openApi.servers[0].url).toBe('/services/apexrest/');
15
- });
16
-
17
- it('should optionally allow for a namespace to be passed in as part of the server', function () {
18
- const openApi = new OpenApi('Test Spec', '1.0.0', 'Namespace');
19
-
20
- expect(openApi.servers.length).toBe(1);
21
- expect(openApi.servers[0].url).toBe('/services/apexrest/Namespace/');
22
- });
@@ -1,26 +0,0 @@
1
- // These are types that represent how the data is expected to be created in the ApexDoc (as YAML), which
2
- // in some cases might be different from the official OpenApi spec for simplicity when writing the ApexDoc.
3
-
4
- import { SchemaObjectArray, SchemaObjectObject } from './open-api-types';
5
-
6
- export type ApexDocHttpResponse = {
7
- statusCode: number;
8
- description?: string;
9
- schema: ApexDocSchemaObject;
10
- };
11
-
12
- export type ApexDocHttpRequestBody = {
13
- description?: string;
14
- schema: ApexDocSchemaObject;
15
- required?: boolean;
16
- };
17
-
18
- export type ApexDocParameterObject = {
19
- name: string;
20
- in: 'query' | 'header' | 'path' | 'cookie';
21
- description?: string;
22
- required?: boolean;
23
- schema: ApexDocSchemaObject;
24
- };
25
-
26
- export type ApexDocSchemaObject = SchemaObjectObject | SchemaObjectArray | string;
@@ -1,12 +0,0 @@
1
- import { ClassMirror, MethodMirror } from '@cparra/apex-reflection';
2
-
3
- export class ClassMirrorWrapper {
4
- constructor(public classMirror: ClassMirror) {}
5
-
6
- getMethodsByAnnotation(annotation: string): MethodMirror[] {
7
- return this.classMirror.methods.filter((method) => this.hasAnnotation(method, annotation));
8
- }
9
-
10
- private hasAnnotation = (method: MethodMirror, annotationName: string) =>
11
- method.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName);
12
- }
@@ -1,11 +0,0 @@
1
- import { DocCommentAnnotation, MethodMirror } from '@cparra/apex-reflection';
2
-
3
- export class MethodMirrorWrapper {
4
- constructor(public methodMirror: MethodMirror) {}
5
-
6
- public hasDocCommentAnnotation = (annotationName: string) =>
7
- this.methodMirror.docComment?.annotations.some((annotation) => annotation.name.toLowerCase() === annotationName);
8
-
9
- public getDocCommentAnnotation = (annotationName: string): DocCommentAnnotation | undefined =>
10
- this.methodMirror.docComment?.annotations.find((annotation) => annotation.name.toLowerCase() === annotationName);
11
- }
@@ -1,15 +0,0 @@
1
- import { ClassMirrorWrapper } from '../ClassMirrorWrapper';
2
- import { ClassMirrorBuilder } from '../../../../test-helpers/ClassMirrorBuilder';
3
- import { MethodMirrorBuilder } from '../../../../test-helpers/MethodMirrorBuilder';
4
- import { AnnotationBuilder } from '../../../../test-helpers/AnnotationBuilder';
5
-
6
- it('should return methods by annotation when they exist', function () {
7
- const classMirror = new ClassMirrorBuilder()
8
- .addMethod(new MethodMirrorBuilder().addAnnotation(new AnnotationBuilder().withName('httpget').build()).build())
9
- .build();
10
-
11
- const classMirrorWrapper = new ClassMirrorWrapper(classMirror);
12
- const foundMethods = classMirrorWrapper.getMethodsByAnnotation('httpget');
13
-
14
- expect(foundMethods.length).toBe(1);
15
- });
@@ -1,13 +0,0 @@
1
- import { PageData } from '../shared/types';
2
-
3
- export class FileContainer {
4
- _files: PageData[] = [];
5
-
6
- files(): PageData[] {
7
- return this._files;
8
- }
9
-
10
- pushFile(file: PageData): void {
11
- this._files.push(file);
12
- }
13
- }
@@ -1,16 +0,0 @@
1
- import Manifest from '../manifest';
2
- import { TypeParser } from './parser';
3
- import { ReflectionResult } from '@cparra/apex-reflection';
4
- import { UnparsedSourceFile } from '../shared/types';
5
-
6
- /**
7
- * Builds a new Manifest object, sourcing its types from the received TypeParser.
8
- * @param typeParser In charge of returning the list of reflected types.
9
- * @param reflect Reflection function.
10
- */
11
- export function createManifest(
12
- typeParser: TypeParser,
13
- reflect: (apexBundle: UnparsedSourceFile) => ReflectionResult,
14
- ): Manifest {
15
- return new Manifest(typeParser.parse(reflect));
16
- }
@@ -1,93 +0,0 @@
1
- import { FileContainer } from './file-container';
2
- import { ClassMirror, Type } from '@cparra/apex-reflection';
3
- import { Logger } from '#utils/logger';
4
- import { OpenApi } from './open-api';
5
- import { OpenApiSettings } from '../openApiSettings';
6
- import { MethodParser } from './parsers/MethodParser';
7
- import { camel2title } from '#utils/string-utils';
8
- import { createOpenApiFile } from './openapi-type-file';
9
-
10
- export class OpenApiDocsProcessor {
11
- protected readonly _fileContainer: FileContainer;
12
- openApiModel: OpenApi;
13
-
14
- constructor(private logger: Logger) {
15
- this._fileContainer = new FileContainer();
16
- const title = OpenApiSettings.getInstance().getOpenApiTitle();
17
- if (!title) {
18
- throw Error('No OpenApi title was provided.');
19
- }
20
- this.openApiModel = new OpenApi(
21
- title,
22
- OpenApiSettings.getInstance().getVersion(),
23
- OpenApiSettings.getInstance().getNamespace(),
24
- );
25
- }
26
-
27
- fileBuilder(): FileContainer {
28
- return this._fileContainer;
29
- }
30
-
31
- onProcess(type: Type): void {
32
- this.logger.logSingle(`Processing ${type.name}`, 'green');
33
-
34
- const endpointPath = this.getEndpointPath(type);
35
- if (!endpointPath) {
36
- return;
37
- }
38
-
39
- this.openApiModel.paths[endpointPath] = {};
40
- if (type.docComment?.description) {
41
- this.openApiModel.paths[endpointPath].description = type.docComment.description;
42
- }
43
-
44
- // We can safely cast to a ClassMirror, since only these support the @RestResource annotation
45
- const typeAsClass = type as ClassMirror;
46
-
47
- // Add tags for this Apex class to the OpenApi model
48
- const tagName = camel2title(endpointPath);
49
- this.openApiModel.tags.push({
50
- name: tagName,
51
- description: type.docComment?.description,
52
- });
53
-
54
- const parser = new MethodParser(this.openApiModel);
55
-
56
- // GET
57
- parser.parseMethod(typeAsClass, endpointPath, 'get', tagName);
58
-
59
- // PATCH
60
- parser.parseMethod(typeAsClass, endpointPath, 'patch', tagName);
61
-
62
- // POST
63
- parser.parseMethod(typeAsClass, endpointPath, 'post', tagName);
64
-
65
- // PUT
66
- parser.parseMethod(typeAsClass, endpointPath, 'put', tagName);
67
-
68
- // DELETE
69
- parser.parseMethod(typeAsClass, endpointPath, 'delete', tagName);
70
- }
71
-
72
- onAfterProcess: ((types: Type[]) => void) | undefined = () => {
73
- const page = createOpenApiFile(OpenApiSettings.getInstance().openApiFileName(), this.openApiModel);
74
- this._fileContainer.pushFile(page);
75
- };
76
-
77
- private getEndpointPath(type: Type): string | null {
78
- const restResourceAnnotation = type.annotations.find((element) => element.name.toLowerCase() === 'restresource');
79
- const urlMapping = restResourceAnnotation?.elementValues?.find(
80
- (element) => element.key.toLowerCase() === 'urlmapping',
81
- );
82
- if (!urlMapping) {
83
- this.logger.error(`Type does not contain urlMapping annotation ${type.name}`);
84
- return null;
85
- }
86
-
87
- let endpointPath = urlMapping.value.replaceAll('"', '').replaceAll("'", '').replaceAll('/*', '/');
88
- if (endpointPath.startsWith('/')) {
89
- endpointPath = endpointPath.substring(1);
90
- }
91
- return endpointPath;
92
- }
93
- }