@cparra/apexdocs 3.0.0-alpha.9 → 3.0.0-rc.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 (82) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +442 -325
  3. package/dist/cli/generate.js +295 -205
  4. package/dist/index.d.ts +15 -17
  5. package/examples/markdown/docs/miscellaneous/Url.md +10 -8
  6. package/examples/markdown/force-app/classes/Url.cls +3 -1
  7. package/examples/markdown-jsconfig/.forceignore +12 -0
  8. package/examples/markdown-jsconfig/apexdocs.config.mjs +21 -0
  9. package/examples/markdown-jsconfig/config/project-scratch-def.json +5 -0
  10. package/examples/markdown-jsconfig/docs/index.md +12 -0
  11. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +315 -0
  12. package/examples/markdown-jsconfig/force-app/classes/Url.cls +196 -0
  13. package/examples/markdown-jsconfig/package-lock.json +665 -0
  14. package/examples/markdown-jsconfig/package.json +15 -0
  15. package/examples/markdown-jsconfig/sfdx-project.json +12 -0
  16. package/examples/open-api/config/project-scratch-def.json +13 -0
  17. package/examples/open-api/docs/openapi.json +582 -0
  18. package/examples/{force-app → open-api/force-app}/main/default/classes/SampleClass.cls +1 -0
  19. package/examples/open-api/package-lock.json +724 -0
  20. package/examples/open-api/package.json +20 -0
  21. package/examples/open-api/sfdx-project.json +12 -0
  22. package/examples/vitepress/apexdocs.config.ts +7 -2
  23. package/examples/vitepress/docs/index.md +11 -11
  24. package/examples/vitepress/docs/miscellaneous/BaseClass.md +1 -1
  25. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +2 -2
  26. package/examples/vitepress/docs/miscellaneous/SampleException.md +1 -1
  27. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +6 -6
  28. package/examples/vitepress/docs/miscellaneous/Url.md +3 -3
  29. package/examples/vitepress/docs/sample-enums/SampleEnum.md +3 -3
  30. package/examples/vitepress/docs/samplegroup/SampleClass.md +5 -5
  31. package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +1 -1
  32. package/package.json +2 -2
  33. package/src/application/Apexdocs.ts +39 -7
  34. package/src/application/__tests__/apex-file-reader.spec.ts +0 -17
  35. package/src/application/file-writer.ts +37 -15
  36. package/src/application/generators/markdown.ts +10 -39
  37. package/src/application/generators/openapi.ts +22 -6
  38. package/src/cli/args.ts +4 -1
  39. package/src/cli/commands/markdown.ts +1 -3
  40. package/src/cli/commands/openapi.ts +36 -0
  41. package/src/core/markdown/__test__/generating-class-docs.spec.ts +1 -129
  42. package/src/core/markdown/__test__/generating-docs.spec.ts +111 -0
  43. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -64
  44. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -64
  45. package/src/core/markdown/adapters/documentables.ts +0 -1
  46. package/src/core/markdown/generate-docs.ts +2 -5
  47. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +306 -0
  48. package/src/core/markdown/reflection/reflect-source.ts +51 -50
  49. package/src/core/openApiSettings.ts +41 -0
  50. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +2 -2
  51. package/src/core/openapi/open-api-docs-processor.ts +8 -4
  52. package/src/core/openapi/open-api.ts +5 -1
  53. package/src/core/openapi/openapi-type-file.ts +1 -1
  54. package/src/core/openapi/parser.ts +1 -15
  55. package/src/core/openapi/transpiler.ts +0 -5
  56. package/src/core/parse-apex-metadata.ts +21 -5
  57. package/src/core/shared/types.d.ts +18 -17
  58. package/src/index.ts +23 -10
  59. package/src/test-helpers/SettingsBuilder.ts +2 -6
  60. package/examples/force-app/main/default/classes/AnotherInterface.cls +0 -16
  61. package/examples/force-app/main/default/classes/EscapedAnnotations.cls +0 -5
  62. package/examples/force-app/main/default/classes/GrandparentClass.cls +0 -5
  63. package/examples/force-app/main/default/classes/GroupedClass.cls +0 -8
  64. package/examples/force-app/main/default/classes/InterfaceWithInheritance.cls +0 -1
  65. package/examples/force-app/main/default/classes/MemberGrouping.cls +0 -17
  66. package/examples/force-app/main/default/classes/ParentClass.cls +0 -16
  67. package/examples/force-app/main/default/classes/SampleClass.cls-meta.xml +0 -5
  68. package/examples/force-app/main/default/classes/SampleClassWithoutModifier.cls +0 -9
  69. package/examples/force-app/main/default/classes/SampleInterface.cls +0 -16
  70. package/src/core/settings.ts +0 -56
  71. /package/examples/{force-app → open-api/force-app}/main/default/classes/ChildClass.cls +0 -0
  72. /package/examples/{force-app → open-api/force-app}/main/default/restapi/SampleRestResource.cls +0 -0
  73. /package/examples/{force-app → open-api/force-app}/main/default/restapi/SampleRestResourceToSkip.cls +0 -0
  74. /package/examples/{force-app → open-api/force-app}/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -0
  75. /package/examples/{force-app → open-api/force-app}/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -0
  76. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference1.cls +0 -0
  77. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference2.cls +0 -0
  78. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference3.cls +0 -0
  79. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference4.cls +0 -0
  80. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference5.cls +0 -0
  81. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference6.cls +0 -0
  82. /package/examples/{force-app → open-api/force-app}/main/default/restapi/references/Reference7.cls +0 -0
@@ -1,17 +1,5 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
 
3
- export type Generator = 'markdown' | 'openapi';
4
-
5
- /**
6
- * The configurable hooks that can be used to modify the output of the generator.
7
- */
8
- export type ConfigurableHooks = {
9
- transformReferenceGuide: TransformReferenceGuide;
10
- transformDocs: TransformDocs;
11
- transformDocPage: TransformDocPage;
12
- transformReference: TransformReference;
13
- };
14
-
15
3
  type LinkingStrategy =
16
4
  // Links will be generated using relative paths.
17
5
  | 'relative'
@@ -24,8 +12,8 @@ type LinkingStrategy =
24
12
  | 'none';
25
13
 
26
14
  export type UserDefinedMarkdownConfig = {
27
- targetGenerator: 'markdown';
28
15
  sourceDir: string;
16
+ targetGenerator: 'markdown';
29
17
  targetDir: string;
30
18
  scope: string[];
31
19
  defaultGroupName: string;
@@ -39,7 +27,10 @@ export type UserDefinedOpenApiConfig = {
39
27
  targetGenerator: 'openapi';
40
28
  sourceDir: string;
41
29
  targetDir: string;
42
- includeMetadata: boolean;
30
+ fileName: string;
31
+ namespace?: string;
32
+ title: string;
33
+ apiVersion: string;
43
34
  };
44
35
 
45
36
  export type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig;
@@ -112,11 +103,21 @@ export type PostHookDocumentationBundle = {
112
103
  docs: DocPageData[];
113
104
  };
114
105
 
115
- // Configurable Hooks
106
+ // CONFIGURABLE HOOKS
107
+
108
+ /**
109
+ * The configurable hooks that can be used to modify the output of the generator.
110
+ */
111
+ export type ConfigurableHooks = {
112
+ transformReferenceGuide: TransformReferenceGuide;
113
+ transformDocs: TransformDocs;
114
+ transformDocPage: TransformDocPage;
115
+ transformReference: TransformReference;
116
+ };
116
117
 
117
- type ConfigurableDocPageReference = Omit<DocPageReference, 'source'>;
118
+ export type ConfigurableDocPageReference = Omit<DocPageReference, 'source'>;
118
119
 
119
- type ConfigurableDocPageData = Omit<DocPageData, 'source' | 'outputDocPath'>;
120
+ export type ConfigurableDocPageData = Omit<DocPageData, 'source' | 'outputDocPath'>;
120
121
 
121
122
  /**
122
123
  * Allows changing where the files are written to.
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { SetOptional } from 'type-fest';
2
1
  import type {
3
2
  ConfigurableHooks,
4
3
  Skip,
@@ -6,18 +5,18 @@ import type {
6
5
  ReferenceGuidePageData,
7
6
  DocPageData,
8
7
  DocPageReference,
8
+ ConfigurableDocPageData,
9
+ TransformReferenceGuide,
10
+ TransformDocs,
11
+ TransformDocPage,
12
+ TransformReference,
13
+ ConfigurableDocPageReference,
9
14
  } from './core/shared/types';
10
15
  import { defaults } from './defaults';
11
16
 
12
- type ConfigurableMarkdownConfig = Omit<
13
- SetOptional<
14
- UserDefinedMarkdownConfig,
15
- 'targetDir' | 'scope' | 'defaultGroupName' | 'includeMetadata' | 'sortMembersAlphabetically' | 'linkingStrategy'
16
- >,
17
- 'targetGenerator'
18
- >;
17
+ type ConfigurableMarkdownConfig = Omit<Partial<UserDefinedMarkdownConfig>, 'targetGenerator'>;
19
18
 
20
- function defineMarkdownConfig(config: ConfigurableMarkdownConfig): UserDefinedMarkdownConfig {
19
+ function defineMarkdownConfig(config: ConfigurableMarkdownConfig): Partial<UserDefinedMarkdownConfig> {
21
20
  return {
22
21
  ...defaults,
23
22
  ...config,
@@ -33,4 +32,18 @@ function skip(): Skip {
33
32
 
34
33
  // Exports
35
34
 
36
- export { defineMarkdownConfig, skip, ConfigurableHooks, ReferenceGuidePageData, DocPageData, DocPageReference };
35
+ export {
36
+ defineMarkdownConfig,
37
+ skip,
38
+ TransformReferenceGuide,
39
+ TransformDocs,
40
+ TransformDocPage,
41
+ TransformReference,
42
+ ConfigurableHooks,
43
+ ReferenceGuidePageData,
44
+ DocPageData,
45
+ DocPageReference,
46
+ Skip,
47
+ ConfigurableDocPageData,
48
+ ConfigurableDocPageReference,
49
+ };
@@ -1,4 +1,4 @@
1
- import { SettingsConfig } from '../core/settings';
1
+ import { SettingsConfig } from '../core/openApiSettings';
2
2
 
3
3
  /**
4
4
  * Builder class to create SettingsConfig objects.
@@ -8,14 +8,10 @@ export class SettingsBuilder {
8
8
  build(): SettingsConfig {
9
9
  return {
10
10
  sourceDirectory: './',
11
- scope: [],
12
11
  outputDir: './',
13
- targetGenerator: 'openapi',
14
- indexOnly: false,
15
- defaultGroupName: 'Misc',
16
12
  openApiTitle: 'Apex API',
17
13
  openApiFileName: 'openapi',
18
- includeMetadata: false,
14
+ version: '1.0.0',
19
15
  };
20
16
  }
21
17
  }
@@ -1,16 +0,0 @@
1
- /**
2
- * @description Some desc
3
- * @group Classes
4
- * @mermaid
5
- * sequenceDiagram
6
- * participant dotcom
7
- * participant iframe
8
- * participant viewscreen
9
- * dotcom->>iframe: loads html w/ iframe url
10
- * iframe->>viewscreen: request template
11
- * viewscreen->>iframe: html & javascript
12
- * iframe->>dotcom: iframe ready
13
- * dotcom->>iframe: set mermaid data on iframe
14
- * iframe->>iframe: render mermaid
15
- */
16
- public interface AnotherInterface{}
@@ -1,5 +0,0 @@
1
- /**
2
- * @description This sentence has an `@embedded` annotation.
3
- */
4
- public with sharing class EscapedAnnotations {
5
- }
@@ -1,5 +0,0 @@
1
- public virtual class GrandparentClass {
2
- protected String protectedGrandParentField;
3
-
4
- protected String AProp { get; set; }
5
- }
@@ -1,8 +0,0 @@
1
- /**********************************************************
2
- Uses a block style apex doc
3
- @group Main
4
- @test-class {@link SampleClass}
5
- ***********************************************************/
6
- public class GroupedClass {
7
-
8
- }
@@ -1 +0,0 @@
1
- public interface InterfaceWithInheritance extends SampleInterface, AnotherInterface {}
@@ -1,17 +0,0 @@
1
- public class MemberGrouping {
2
- // @start-group Group old syntax
3
- public static final String inGroup1;
4
- public static final String anotherInGroup1;
5
- // @end-group
6
-
7
- /**
8
- * @start-group Group new syntax
9
- * @description Group's description
10
- */
11
-
12
- /** @description Description for constant in group 2 */
13
- public static final String inGroup2;
14
- /** @description Description for another constant in group 2 @future annotation */
15
- public static final String anotherInGroup2;
16
- /** @end-group */
17
- }
@@ -1,16 +0,0 @@
1
- public abstract class ParentClass extends GrandparentClass{
2
- private String privateStringFromParent;
3
- /**
4
- * @description This is a protected string, use carefully.
5
- */
6
- protected String protectedStringFromParent;
7
- public String publicStringFromParent;
8
-
9
- public virtual String overridableMethod() {
10
- return '';
11
- }
12
-
13
- public virtual String overridableMethodOverridden() {
14
- return '';
15
- }
16
- }
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3
- <apiVersion>54.0</apiVersion>
4
- <status>Active</status>
5
- </ApexClass>
@@ -1,9 +0,0 @@
1
- @IsTest
2
- class SampleClassWithoutModifier {
3
- /**
4
- * @description This is a test method
5
- */
6
- @IsTest
7
- private static void thisIsAClassWithoutAModifier() {
8
- }
9
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * @description This is an interface description.
3
- * @group Sample Interfaces
4
- */
5
- global interface SampleInterface {
6
- /**
7
- * @description Executes the command.
8
- */
9
- void execute();
10
-
11
- /**
12
- * @description Returns a value based on the executed command.
13
- * @return The value
14
- */
15
- String getValue();
16
- }
@@ -1,56 +0,0 @@
1
- import { Generator } from './shared/types';
2
-
3
- export interface SettingsConfig {
4
- sourceDirectory: string;
5
- scope: string[];
6
- outputDir: string;
7
- targetGenerator: Generator;
8
- indexOnly: boolean;
9
- defaultGroupName: string;
10
- openApiTitle?: string;
11
- namespace?: string;
12
- openApiFileName: string;
13
- includeMetadata: boolean;
14
- sortMembersAlphabetically?: boolean;
15
- }
16
-
17
- export class Settings {
18
- private static instance: Settings;
19
-
20
- private constructor(public config: SettingsConfig) {}
21
-
22
- public static build(config: SettingsConfig) {
23
- Settings.instance = new Settings(config);
24
- }
25
-
26
- public static getInstance(): Settings {
27
- if (!Settings.instance) {
28
- throw new Error('Settings has not been initialized');
29
- }
30
- return Settings.instance;
31
- }
32
-
33
- get scope(): string[] {
34
- return this.config.scope;
35
- }
36
-
37
- get targetGenerator(): Generator {
38
- return this.config.targetGenerator;
39
- }
40
-
41
- get indexOnly(): boolean {
42
- return this.config.indexOnly;
43
- }
44
-
45
- public getOpenApiTitle(): string | undefined {
46
- return this.config.openApiTitle;
47
- }
48
-
49
- public getNamespace(): string | undefined {
50
- return this.config.namespace;
51
- }
52
-
53
- public openApiFileName(): string {
54
- return this.config.openApiFileName;
55
- }
56
- }