@cparra/apexdocs 2.1.4 → 2.2.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 (39) hide show
  1. package/README.md +2 -1
  2. package/ROADMAP.md +7 -7
  3. package/docs/Misc/SampleClassWithoutModifier.md +11 -11
  4. package/docs/README.md +16 -16
  5. package/docs/Sample-Classes/SampleClass.md +169 -165
  6. package/docs/Sample-Interfaces/SampleInterface.md +27 -27
  7. package/examples/force-app/main/default/classes/SampleClass.cls-meta.xml +5 -0
  8. package/lib/cli/generate.js +6 -0
  9. package/lib/cli/generate.js.map +1 -1
  10. package/lib/model/apex-bundle.d.ts +5 -0
  11. package/lib/model/apex-bundle.js +10 -0
  12. package/lib/model/apex-bundle.js.map +1 -0
  13. package/lib/service/apex-file-reader.d.ts +2 -1
  14. package/lib/service/apex-file-reader.js +5 -2
  15. package/lib/service/apex-file-reader.js.map +1 -1
  16. package/lib/service/file-system.d.ts +2 -0
  17. package/lib/service/file-system.js +3 -0
  18. package/lib/service/file-system.js.map +1 -1
  19. package/lib/service/metadata-processor.d.ts +3 -0
  20. package/lib/service/metadata-processor.js +15 -0
  21. package/lib/service/metadata-processor.js.map +1 -0
  22. package/lib/service/parser.d.ts +3 -2
  23. package/lib/service/parser.js +20 -4
  24. package/lib/service/parser.js.map +1 -1
  25. package/lib/settings.d.ts +2 -0
  26. package/lib/settings.js +3 -0
  27. package/lib/settings.js.map +1 -1
  28. package/lib/transpiler/transpiler.js +4 -0
  29. package/lib/transpiler/transpiler.js.map +1 -1
  30. package/package.json +4 -2
  31. package/src/cli/generate.ts +6 -0
  32. package/src/model/apex-bundle.ts +3 -0
  33. package/src/service/__tests__/apex-file-reader.spec.ts +11 -1
  34. package/src/service/apex-file-reader.ts +7 -4
  35. package/src/service/file-system.ts +5 -0
  36. package/src/service/metadata-processor.ts +13 -0
  37. package/src/service/parser.ts +20 -3
  38. package/src/settings.ts +5 -0
  39. package/src/transpiler/transpiler.ts +6 -0
package/README.md CHANGED
@@ -110,12 +110,13 @@ apexdocs-generate
110
110
  The CLI supports the following parameters:
111
111
 
112
112
  | Parameter | Alias | Description | Default | Required |
113
- | ----------------- | ----- |--------------------------------------------------------------------------------------------------------------------------| ----------------------------------- | -------- |
113
+ |-------------------|-------|--------------------------------------------------------------------------------------------------------------------------|-------------------------------------|----------|
114
114
  | --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
115
115
  | --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
116
116
  | --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
117
117
  | --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private | `global namespaceaccessible public` | No |
118
118
  | --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports jekyll and docsify. | `jekyll` | No |
119
+ | --indexOnly | N/A | Defines whether only the index file should be generated. | `false` | No |
119
120
  | --configPath | -c | (Only versions 1.X) The path to the JSON configuration file that defines the structure of the documents to docGenerator. | N/A | No |
120
121
  | --group | -o | (Only versions 1.X) Define whether the generated files should be grouped by the @group tag on the top level classes. | `true` | No |
121
122
 
package/ROADMAP.md CHANGED
@@ -1,16 +1,16 @@
1
- [] Respect access modifiers where the properties/methods are different from the class declaration. For example,
1
+ [ ] Respect access modifiers where the properties/methods are different from the class declaration. For example,
2
2
  AuraEnabled properties do not live in an AuraEnabled class, so there's no way to just generate docs to showcase the
3
3
  AuraEnabled properties of a class without some sort of combination of also exposing other public/globals
4
4
 
5
- [] Versioning capabilities. When creating the doc you specify a version number, and a new directory is created for the
5
+ [ ] Versioning capabilities. When creating the doc you specify a version number, and a new directory is created for the
6
6
  files, instead of just overriding
7
7
 
8
- [] New generatortype: To JsDocs from AuraEnabled
8
+ [ ] New generatortype: To JsDocs from AuraEnabled
9
9
 
10
- [] More unit tests
10
+ [ ] More unit tests
11
11
 
12
- [] config.js support to allow for injections, home header, etc.
12
+ [ ] config.js support to allow for injections, home header, etc.
13
13
 
14
- [] Add configuration setting that allows someone to set the "namespace"
14
+ [ ] Add configuration setting that allows someone to set the "namespace"
15
15
 
16
- [] Homepage support similar to what docsify does
16
+ [ ] Homepage support similar to what docsify does
@@ -1,11 +1,11 @@
1
- # SampleClassWithoutModifier
2
-
3
- `ISTEST`
4
- ## Methods
5
- ### `static thisIsAClassWithoutAModifier()`
6
-
7
- `ISTEST`
8
-
9
- This is a test method
10
-
11
- ---
1
+ # SampleClassWithoutModifier
2
+
3
+ `ISTEST`
4
+ ## Methods
5
+ ### `static thisIsAClassWithoutAModifier()`
6
+
7
+ `ISTEST`
8
+
9
+ This is a test method
10
+
11
+ ---
package/docs/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # Classes
2
- ## Sample Classes
3
-
4
- ### [SampleClass](/Sample-Classes/SampleClass.md)
5
-
6
- This is a class description. This class relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md) But this ClassThatDoesNotExist does not exist. You can also link using this syntax [SampleInterface](/Sample-Interfaces/SampleInterface.md)
7
- ## Miscellaneous
8
-
9
- ### [SampleClassWithoutModifier](/Misc/SampleClassWithoutModifier.md)
10
-
11
-
12
- ## Sample Interfaces
13
-
14
- ### [SampleInterface](/Sample-Interfaces/SampleInterface.md)
15
-
16
- This is an interface description.
1
+ # Classes
2
+ ## Sample Classes
3
+
4
+ ### [SampleClass](/Sample-Classes/SampleClass.md)
5
+
6
+ This is a class description. This class relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md) But this ClassThatDoesNotExist does not exist. You can also link using this syntax [SampleInterface](/Sample-Interfaces/SampleInterface.md)
7
+ ## Miscellaneous
8
+
9
+ ### [SampleClassWithoutModifier](/Misc/SampleClassWithoutModifier.md)
10
+
11
+
12
+ ## Sample Interfaces
13
+
14
+ ### [SampleInterface](/Sample-Interfaces/SampleInterface.md)
15
+
16
+ This is an interface description.
@@ -1,165 +1,169 @@
1
- # SampleClass
2
-
3
- `NAMESPACEACCESSIBLE`
4
-
5
- This is a class description. This class relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md) But this ClassThatDoesNotExist does not exist. You can also link using this syntax [SampleInterface](/Sample-Interfaces/SampleInterface.md)
6
-
7
-
8
- **Group** Sample Classes
9
-
10
-
11
- **CustomAnnotation** A Custom annotation
12
-
13
-
14
- **Author** Cesar Parra
15
-
16
-
17
- **See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
18
-
19
- ## Constructors
20
- ### My Super Group
21
- ##### `SampleClass()`
22
-
23
- `NAMESPACEACCESSIBLE`
24
-
25
- Constructs a SampleClass without any arguments. This relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md)
26
-
27
- ###### Throws
28
- |Exception|Description|
29
- |---|---|
30
- |`ExcName`|some exception|
31
-
32
-
33
- **CustomAnnotation** A Custom method annotation
34
-
35
-
36
- **See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
37
-
38
- ###### Example
39
- ```apex
40
- // Example
41
- SampleClass sampleInstance = new SampleClass();
42
- ```
43
-
44
- ---
45
- ### Other
46
- ##### `SampleClass(String argument1, String argument2)`
47
-
48
- Constructs a SampleClass with an argument.
49
-
50
- ###### Parameters
51
- |Param|Description|
52
- |---|---|
53
- |`argument1`|Argument1 definition|
54
- |`argument2`|Argument2 definition|
55
-
56
- ---
57
- ## Fields
58
- ### Common Constants
59
-
60
- * `ANOTHER_CONSTANT` → `String`
61
- * `A_CONSTANT` → `String` [`NAMESPACEACCESSIBLE` ] - This is a constant.
62
- ---
63
- ### Other variables
64
-
65
- * `someVariable` → `String`
66
- ---
67
- ## Properties
68
-
69
- ### `AnotherProp` → `Decimal`
70
-
71
- `AURAENABLED`
72
-
73
- This is a Decimal property.
74
-
75
- ### `MyProp` → `String`
76
-
77
- `AURAENABLED`
78
- `DEPRECATED`
79
-
80
- This is a String property.
81
-
82
- ---
83
- ## Methods
84
- ### `static sampleMethod(String argument1, String argument2)`
85
-
86
- `NAMESPACEACCESSIBLE`
87
-
88
- Executes commands based on the passed in argument.
89
-
90
- #### Parameters
91
- |Param|Description|
92
- |---|---|
93
- |`argument1`|Argument1 to debug|
94
- |`argument2`|Argument2 to debug|
95
-
96
- #### Return
97
-
98
- **Type**
99
-
100
- String
101
-
102
- **Description**
103
-
104
- Empty string
105
-
106
- #### Example
107
- ```apex
108
- String result = SampleClass.testMethod();
109
- System.debug(result);
110
- ```
111
-
112
- ### `static call()`
113
-
114
- Calls the method. This methods allows you to call it.
115
-
116
- ---
117
- ## Enums
118
- ### InnerEnum
119
-
120
- `NAMESPACEACCESSIBLE`
121
-
122
- This is a namespace accessible enum
123
-
124
-
125
- ---
126
- ## Classes
127
- ### AnotherInnerClass
128
-
129
- Inner class belonging to SampleClass.
130
-
131
- #### Properties
132
-
133
- ##### `InnerProp` `String`
134
-
135
-
136
- Description of the inner property.
137
-
138
- ---
139
- #### Methods
140
- ##### `innerMethod()`
141
-
142
- Executes from the inner class.
143
-
144
- ---
145
-
146
- ### InnerClass
147
-
148
- Inner class belonging to SampleClass.
149
-
150
- #### Properties
151
-
152
- ##### `InnerProp` `String`
153
-
154
-
155
- Description of the inner property.
156
-
157
- ---
158
- #### Methods
159
- ##### `innerMethod()`
160
-
161
- Executes from the inner class.
162
-
163
- ---
164
-
165
- ---
1
+ # SampleClass
2
+
3
+ `NAMESPACEACCESSIBLE`
4
+
5
+ `APIVERSION: 54`
6
+
7
+ `STATUS: ACTIVE`
8
+
9
+ This is a class description. This class relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md) But this ClassThatDoesNotExist does not exist. You can also link using this syntax [SampleInterface](/Sample-Interfaces/SampleInterface.md)
10
+
11
+
12
+ **Group** Sample Classes
13
+
14
+
15
+ **CustomAnnotation** A Custom annotation
16
+
17
+
18
+ **Author** Cesar Parra
19
+
20
+
21
+ **See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
22
+
23
+ ## Constructors
24
+ ### My Super Group
25
+ ##### `SampleClass()`
26
+
27
+ `NAMESPACEACCESSIBLE`
28
+
29
+ Constructs a SampleClass without any arguments. This relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md)
30
+
31
+ ###### Throws
32
+ |Exception|Description|
33
+ |---|---|
34
+ |`ExcName`|some exception|
35
+
36
+
37
+ **CustomAnnotation** A Custom method annotation
38
+
39
+
40
+ **See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
41
+
42
+ ###### Example
43
+ ```apex
44
+ // Example
45
+ SampleClass sampleInstance = new SampleClass();
46
+ ```
47
+
48
+ ---
49
+ ### Other
50
+ ##### `SampleClass(String argument1, String argument2)`
51
+
52
+ Constructs a SampleClass with an argument.
53
+
54
+ ###### Parameters
55
+ |Param|Description|
56
+ |---|---|
57
+ |`argument1`|Argument1 definition|
58
+ |`argument2`|Argument2 definition|
59
+
60
+ ---
61
+ ## Fields
62
+ ### Common Constants
63
+
64
+ * `ANOTHER_CONSTANT` → `String`
65
+ * `A_CONSTANT` → `String` [`NAMESPACEACCESSIBLE` ] - This is a constant.
66
+ ---
67
+ ### Other variables
68
+
69
+ * `someVariable` → `String`
70
+ ---
71
+ ## Properties
72
+
73
+ ### `AnotherProp` `Decimal`
74
+
75
+ `AURAENABLED`
76
+
77
+ This is a Decimal property.
78
+
79
+ ### `MyProp` → `String`
80
+
81
+ `AURAENABLED`
82
+ `DEPRECATED`
83
+
84
+ This is a String property.
85
+
86
+ ---
87
+ ## Methods
88
+ ### `static sampleMethod(String argument1, String argument2)`
89
+
90
+ `NAMESPACEACCESSIBLE`
91
+
92
+ Executes commands based on the passed in argument.
93
+
94
+ #### Parameters
95
+ |Param|Description|
96
+ |---|---|
97
+ |`argument1`|Argument1 to debug|
98
+ |`argument2`|Argument2 to debug|
99
+
100
+ #### Return
101
+
102
+ **Type**
103
+
104
+ String
105
+
106
+ **Description**
107
+
108
+ Empty string
109
+
110
+ #### Example
111
+ ```apex
112
+ String result = SampleClass.testMethod();
113
+ System.debug(result);
114
+ ```
115
+
116
+ ### `static call()`
117
+
118
+ Calls the method. This methods allows you to call it.
119
+
120
+ ---
121
+ ## Enums
122
+ ### InnerEnum
123
+
124
+ `NAMESPACEACCESSIBLE`
125
+
126
+ This is a namespace accessible enum
127
+
128
+
129
+ ---
130
+ ## Classes
131
+ ### AnotherInnerClass
132
+
133
+ Inner class belonging to SampleClass.
134
+
135
+ #### Properties
136
+
137
+ ##### `InnerProp` → `String`
138
+
139
+
140
+ Description of the inner property.
141
+
142
+ ---
143
+ #### Methods
144
+ ##### `innerMethod()`
145
+
146
+ Executes from the inner class.
147
+
148
+ ---
149
+
150
+ ### InnerClass
151
+
152
+ Inner class belonging to SampleClass.
153
+
154
+ #### Properties
155
+
156
+ ##### `InnerProp` → `String`
157
+
158
+
159
+ Description of the inner property.
160
+
161
+ ---
162
+ #### Methods
163
+ ##### `innerMethod()`
164
+
165
+ Executes from the inner class.
166
+
167
+ ---
168
+
169
+ ---
@@ -1,27 +1,27 @@
1
- # SampleInterface
2
-
3
- This is an interface description.
4
-
5
-
6
- **Group** Sample Interfaces
7
-
8
- ## Methods
9
- ### `execute()`
10
-
11
- Executes the command.
12
-
13
- ### `getValue()`
14
-
15
- Returns a value based on the executed command.
16
-
17
- #### Return
18
-
19
- **Type**
20
-
21
- String
22
-
23
- **Description**
24
-
25
- The value
26
-
27
- ---
1
+ # SampleInterface
2
+
3
+ This is an interface description.
4
+
5
+
6
+ **Group** Sample Interfaces
7
+
8
+ ## Methods
9
+ ### `execute()`
10
+
11
+ Executes the command.
12
+
13
+ ### `getValue()`
14
+
15
+ Returns a value based on the executed command.
16
+
17
+ #### Return
18
+
19
+ **Type**
20
+
21
+ String
22
+
23
+ **Description**
24
+
25
+ The value
26
+
27
+ ---
@@ -0,0 +1,5 @@
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>
@@ -37,6 +37,11 @@ const argv = yargs.options({
37
37
  choices: ['jekyll', 'docsify'],
38
38
  describe: 'Define the static file generator for which the documents will be created. Currently supports jekyll, and docsify.',
39
39
  },
40
+ indexOnly: {
41
+ type: 'boolean',
42
+ default: false,
43
+ describe: 'Defines whether only the index file should be generated.',
44
+ },
40
45
  }).argv;
41
46
  settings_1.Settings.build({
42
47
  sourceDirectory: argv.sourceDir,
@@ -44,6 +49,7 @@ settings_1.Settings.build({
44
49
  scope: argv.scope,
45
50
  outputDir: argv.targetDir,
46
51
  targetGenerator: argv.targetGenerator,
52
+ indexOnly: argv.indexOnly,
47
53
  });
48
54
  Apexdocs_1.Apexdocs.generate();
49
55
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/cli/generate.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B,0CAAyD;AACzD,sDAAmD;AAEnD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;IACzB,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,+DAA+D;KAC1E;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,kEAAkE;KAC7E;IACD,SAAS,EAAE;QACT,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,kFAAkF;KAC7F;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,CAAC,QAAQ,CAAC;QACnB,QAAQ,EACN,sHAAsH;YACtH,0HAA0H;KAC7H;IACD,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC9B,QAAQ,EACN,mHAAmH;KACtH;CACF,CAAC,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CACF,CAAC,CAAC,IAAI,CAAC;AAER,mBAAQ,CAAC,KAAK,CAAC;IACb,eAAe,EAAE,IAAI,CAAC,SAAS;IAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,eAAe,EAAE,IAAI,CAAC,eAAmC;IACzD,SAAS,EAAE,IAAI,CAAC,SAAS;CAC1B,CAAC,CAAC;AAEH,mBAAQ,CAAC,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export default class ApexBundle {
2
+ rawTypeContent: string;
3
+ rawMetadataContent: string | null;
4
+ constructor(rawTypeContent: string, rawMetadataContent: string | null);
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ApexBundle {
4
+ constructor(rawTypeContent, rawMetadataContent) {
5
+ this.rawTypeContent = rawTypeContent;
6
+ this.rawMetadataContent = rawMetadataContent;
7
+ }
8
+ }
9
+ exports.default = ApexBundle;
10
+ //# sourceMappingURL=apex-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apex-bundle.js","sourceRoot":"","sources":["../../src/model/apex-bundle.ts"],"names":[],"mappings":";;AAAA,MAAqB,UAAU;IAC7B,YAAmB,cAAsB,EAAS,kBAAiC;QAAhE,mBAAc,GAAd,cAAc,CAAQ;QAAS,uBAAkB,GAAlB,kBAAkB,CAAe;IAAG,CAAC;CACxF;AAFD,6BAEC"}
@@ -1,4 +1,5 @@
1
1
  import { FileSystem } from './file-system';
2
+ import ApexBundle from '../model/apex-bundle';
2
3
  /**
3
4
  * Reads from .cls files and returns their raw body.
4
5
  */
@@ -6,7 +7,7 @@ export declare class ApexFileReader {
6
7
  /**
7
8
  * Reads from .cls files and returns their raw body.
8
9
  */
9
- static processFiles(fileSystem: FileSystem, rootPath?: string): string[];
10
+ static processFiles(fileSystem: FileSystem, rootPath?: string): ApexBundle[];
10
11
  private static isApexFile;
11
12
  private static get sourceDirectory();
12
13
  private static get readRecursively();
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApexFileReader = void 0;
4
4
  const settings_1 = require("../settings");
5
+ const apex_bundle_1 = require("../model/apex-bundle");
5
6
  const APEX_FILE_EXTENSION = '.cls';
6
7
  /**
7
8
  * Reads from .cls files and returns their raw body.
@@ -21,8 +22,10 @@ class ApexFileReader {
21
22
  if (!this.isApexFile(currentFilePath)) {
22
23
  return;
23
24
  }
24
- const rawFile = fileSystem.readFile(currentPath);
25
- bodies.push(rawFile);
25
+ const rawApexFile = fileSystem.readFile(currentPath);
26
+ const metadataPath = fileSystem.joinPath(rootPath, `${currentFilePath}-meta.xml`);
27
+ const rawMetadataFile = fileSystem.exists(metadataPath) ? fileSystem.readFile(metadataPath) : null;
28
+ bodies.push(new apex_bundle_1.default(rawApexFile, rawMetadataFile));
26
29
  });
27
30
  return bodies;
28
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"apex-file-reader.js","sourceRoot":"","sources":["../../src/service/apex-file-reader.ts"],"names":[],"mappings":";;;AAAA,0CAAuC;AAGvC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC;;GAEG;AACH,MAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,UAAsB,EAAE,WAAmB,IAAI,CAAC,eAAe;QACjF,IAAI,MAAM,GAAa,EAAE,CAAC;QAE1B,MAAM,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC7D,iBAAiB,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YAC5C,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;YACnE,IAAI,IAAI,CAAC,eAAe,IAAI,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE;gBAC/D,MAAM,GAAG,MAA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CAAC,EAAE;gBAC/D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;aACpE;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;gBACrC,OAAO;aACR;YAED,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACrD,MAAM,YAAY,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,eAAe,WAAW,CAAC,CAAC;YAClF,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACnG,MAAM,CAAC,IAAI,CAAC,IAAI,qBAAU,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,WAAmB;QAC3C,OAAO,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAEO,MAAM,KAAK,eAAe;QAChC,OAAO,mBAAQ,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC;IAChD,CAAC;IAEO,MAAM,KAAK,eAAe;QAChC,OAAO,mBAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC;IAC1C,CAAC;CACF;AArCD,wCAqCC"}
@@ -3,10 +3,12 @@ export interface FileSystem {
3
3
  isDirectory: (path: string) => boolean;
4
4
  readFile: (path: string) => string;
5
5
  joinPath: (...paths: string[]) => string;
6
+ exists: (path: string) => boolean;
6
7
  }
7
8
  export declare class DefaultFileSystem implements FileSystem {
8
9
  isDirectory(pathToRead: string): boolean;
9
10
  readDirectory(sourceDirectory: string): string[];
10
11
  readFile(pathToRead: string): string;
11
12
  joinPath(...paths: string[]): string;
13
+ exists(path: string): boolean;
12
14
  }
@@ -17,6 +17,9 @@ class DefaultFileSystem {
17
17
  joinPath(...paths) {
18
18
  return path.join(...paths);
19
19
  }
20
+ exists(path) {
21
+ return fs.existsSync(path);
22
+ }
20
23
  }
21
24
  exports.DefaultFileSystem = DefaultFileSystem;
22
25
  //# sourceMappingURL=file-system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-system.js","sourceRoot":"","sources":["../../src/service/file-system.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAS7B,MAAa,iBAAiB;IAC5B,WAAW,CAAC,UAAkB;QAC5B,OAAO,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IAED,aAAa,CAAC,eAAuB;QACnC,OAAO,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ,CAAC,UAAkB;QACzB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,GAAG,KAAe;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAjBD,8CAiBC"}
1
+ {"version":3,"file":"file-system.js","sourceRoot":"","sources":["../../src/service/file-system.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAU7B,MAAa,iBAAiB;IAC5B,WAAW,CAAC,UAAkB;QAC5B,OAAO,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IAED,aAAa,CAAC,eAAuB;QACnC,OAAO,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ,CAAC,UAAkB;QACzB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,GAAG,KAAe;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AArBD,8CAqBC"}
@@ -0,0 +1,3 @@
1
+ export default class MetadataProcessor {
2
+ static process(input: string): Map<string, string>;
3
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fast_xml_parser_1 = require("fast-xml-parser");
4
+ class MetadataProcessor {
5
+ static process(input) {
6
+ var _a, _b;
7
+ const map = new Map();
8
+ const xml = new fast_xml_parser_1.XMLParser().parse(input);
9
+ map.set('apiVersion', (_a = xml.ApexClass.apiVersion) !== null && _a !== void 0 ? _a : '');
10
+ map.set('status', (_b = xml.ApexClass.status) !== null && _b !== void 0 ? _b : '');
11
+ return map;
12
+ }
13
+ }
14
+ exports.default = MetadataProcessor;
15
+ //# sourceMappingURL=metadata-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-processor.js","sourceRoot":"","sources":["../../src/service/metadata-processor.ts"],"names":[],"mappings":";;AAAA,qDAA4C;AAE5C,MAAqB,iBAAiB;IAC7B,MAAM,CAAC,OAAO,CAAC,KAAa;;QACjC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,2BAAS,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEzC,GAAG,CAAC,GAAG,CAAC,YAAY,QAAE,GAAG,CAAC,SAAS,CAAC,UAAU,mCAAI,EAAE,CAAC,CAAC;QAEtD,GAAG,CAAC,GAAG,CAAC,QAAQ,QAAE,GAAG,CAAC,SAAS,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAVD,oCAUC"}
@@ -1,9 +1,10 @@
1
1
  import { Type, ReflectionResult } from '@cparra/apex-reflection';
2
+ import ApexBundle from '../model/apex-bundle';
2
3
  export interface TypeParser {
3
4
  parse(reflect: (typeBody: string) => ReflectionResult): Type[];
4
5
  }
5
6
  export declare class RawBodyParser implements TypeParser {
6
- typeBodies: string[];
7
- constructor(typeBodies: string[]);
7
+ typeBundles: ApexBundle[];
8
+ constructor(typeBundles: ApexBundle[]);
8
9
  parse(reflect: (typeBody: string) => ReflectionResult): Type[];
9
10
  }
@@ -1,13 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RawBodyParser = void 0;
4
+ const metadata_processor_1 = require("./metadata-processor");
4
5
  class RawBodyParser {
5
- constructor(typeBodies) {
6
- this.typeBodies = typeBodies;
6
+ constructor(typeBundles) {
7
+ this.typeBundles = typeBundles;
7
8
  }
8
9
  parse(reflect) {
9
- return this.typeBodies
10
- .map((rawBody) => reflect(rawBody))
10
+ return this.typeBundles
11
+ .map((currentBundle) => {
12
+ const result = reflect(currentBundle.rawTypeContent);
13
+ if (!!result.typeMirror && !!currentBundle.rawMetadataContent) {
14
+ // If successful and there is a metadata file
15
+ const metadataParams = metadata_processor_1.default.process(currentBundle.rawMetadataContent);
16
+ metadataParams.forEach((value, key) => {
17
+ const declaration = `${key}: ${value}`;
18
+ result.typeMirror.annotations.push({
19
+ rawDeclaration: declaration,
20
+ name: declaration,
21
+ type: declaration,
22
+ });
23
+ });
24
+ }
25
+ return result;
26
+ })
11
27
  .filter((reflectionResult) => {
12
28
  return reflectionResult.typeMirror;
13
29
  })
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/service/parser.ts"],"names":[],"mappings":";;;AAMA,MAAa,aAAa;IACxB,YAAmB,UAAoB;QAApB,eAAU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,CAAC;QAChB,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,gBAAgB,EAAE,EAAE;YAC3B,OAAO,gBAAgB,CAAC,UAAU,CAAC;QACrC,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,UAAW,CAAC,CAAC;IAC7D,CAAC;CACF;AA1BD,sCA0BC"}
package/lib/settings.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface SettingsConfig {
6
6
  scope: string[];
7
7
  outputDir: string;
8
8
  targetGenerator: GeneratorChoices;
9
+ indexOnly: boolean;
9
10
  }
10
11
  export declare class Settings {
11
12
  config: SettingsConfig;
@@ -18,4 +19,5 @@ export declare class Settings {
18
19
  get scope(): string[];
19
20
  get outputDir(): string;
20
21
  get typeTranspiler(): ProcessorTypeTranspiler;
22
+ get indexOnly(): boolean;
21
23
  }
package/lib/settings.js CHANGED
@@ -38,6 +38,9 @@ class Settings {
38
38
  throw Error('Invalid target generator');
39
39
  }
40
40
  }
41
+ get indexOnly() {
42
+ return this.config.indexOnly;
43
+ }
41
44
  }
42
45
  exports.Settings = Settings;
43
46
  //# sourceMappingURL=settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AACA,4FAAwF;AACxF,iGAAwF;AAYxF,MAAa,QAAQ;IAGnB,YAA2B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAE9C,MAAM,CAAC,KAAK,CAAC,MAAsB;QACxC,QAAQ,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QACD,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI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AAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,cAAc;QAChB,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;YACnC,KAAK,QAAQ;gBACX,OAAO,IAAI,0CAAmB,EAAE,CAAC;YACnC,KAAK,SAAS;gBACZ,OAAO,IAAI,gCAAoB,EAAE,CAAC;YACpC;gBACE,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;CACF;AA9CD,4BA8CC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const settings_1 = require("../settings");
3
4
  class Transpiler {
4
5
  static generate(types, processor) {
5
6
  var _a, _b;
@@ -11,6 +12,9 @@ class Transpiler {
11
12
  return 0;
12
13
  });
13
14
  (_a = processor.onBeforeProcess) === null || _a === void 0 ? void 0 : _a.call(processor, sortedTypes);
15
+ if (settings_1.Settings.getInstance().indexOnly === true) {
16
+ return;
17
+ }
14
18
  sortedTypes.forEach((currentType) => {
15
19
  processor.onProcess(currentType);
16
20
  });
@@ -1 +1 @@
1
- {"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../src/transpiler/transpiler.ts"],"names":[],"mappings":";;AAGA,MAAqB,UAAU;IAC7B,MAAM,CAAC,QAAQ,CAAC,KAAa,EAAE,SAAkC;;QAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACtD,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC,CAAC;YAC/C,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAA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  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "keywords": [
6
6
  "apex",
@@ -24,7 +24,8 @@
24
24
  "postversion": "git push && git push --tags",
25
25
  "docs:init": "docsify init docs",
26
26
  "docs:serve": "docsify serve docs",
27
- "execute:example": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify"
27
+ "execute:example": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify",
28
+ "execute:example:index:only": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --indexOnly"
28
29
  },
29
30
  "author": "Cesar Parra",
30
31
  "license": "MIT",
@@ -64,6 +65,7 @@
64
65
  },
65
66
  "dependencies": {
66
67
  "@cparra/apex-reflection": "^1.1.3",
68
+ "fast-xml-parser": "^4.0.1",
67
69
  "chalk": "^4.1.2",
68
70
  "html-entities": "^2.3.2",
69
71
  "yargs": "^16.0.3"
@@ -39,6 +39,11 @@ const argv = yargs.options({
39
39
  describe:
40
40
  'Define the static file generator for which the documents will be created. Currently supports jekyll, and docsify.',
41
41
  },
42
+ indexOnly: {
43
+ type: 'boolean',
44
+ default: false,
45
+ describe: 'Defines whether only the index file should be generated.',
46
+ },
42
47
  }).argv;
43
48
 
44
49
  Settings.build({
@@ -47,6 +52,7 @@ Settings.build({
47
52
  scope: argv.scope,
48
53
  outputDir: argv.targetDir,
49
54
  targetGenerator: argv.targetGenerator as GeneratorChoices,
55
+ indexOnly: argv.indexOnly,
50
56
  });
51
57
 
52
58
  Apexdocs.generate();
@@ -0,0 +1,3 @@
1
+ export default class ApexBundle {
2
+ constructor(public rawTypeContent: string, public rawMetadataContent: string | null) {}
3
+ }
@@ -11,6 +11,7 @@ describe('File Reader', () => {
11
11
  group: true,
12
12
  outputDir: '',
13
13
  scope: [],
14
+ indexOnly: false,
14
15
  } as SettingsConfig);
15
16
  });
16
17
 
@@ -32,6 +33,9 @@ describe('File Reader', () => {
32
33
  readFile(_: string): string {
33
34
  return '';
34
35
  },
36
+ exists(): boolean {
37
+ return true;
38
+ },
35
39
  });
36
40
  expect(result.length).toBe(0);
37
41
  });
@@ -50,6 +54,9 @@ describe('File Reader', () => {
50
54
  readFile(_: string): string {
51
55
  return '';
52
56
  },
57
+ exists(): boolean {
58
+ return true;
59
+ },
53
60
  });
54
61
  expect(result.length).toBe(0);
55
62
  });
@@ -72,8 +79,11 @@ describe('File Reader', () => {
72
79
  readFile(_: string): string {
73
80
  return 'public class MyClass{}';
74
81
  },
82
+ exists(): boolean {
83
+ return true;
84
+ },
75
85
  });
76
86
  expect(result.length).toBe(1);
77
- expect(result[0]).toBe('public class MyClass{}');
87
+ expect(result[0].rawTypeContent).toBe('public class MyClass{}');
78
88
  });
79
89
  });
@@ -1,5 +1,6 @@
1
1
  import { Settings } from '../settings';
2
2
  import { FileSystem } from './file-system';
3
+ import ApexBundle from '../model/apex-bundle';
3
4
 
4
5
  const APEX_FILE_EXTENSION = '.cls';
5
6
 
@@ -10,8 +11,8 @@ export class ApexFileReader {
10
11
  /**
11
12
  * Reads from .cls files and returns their raw body.
12
13
  */
13
- static processFiles(fileSystem: FileSystem, rootPath: string = this.sourceDirectory): string[] {
14
- let bodies: string[] = [];
14
+ static processFiles(fileSystem: FileSystem, rootPath: string = this.sourceDirectory): ApexBundle[] {
15
+ let bodies: ApexBundle[] = [];
15
16
 
16
17
  const directoryContents = fileSystem.readDirectory(rootPath);
17
18
  directoryContents.forEach((currentFilePath) => {
@@ -24,8 +25,10 @@ export class ApexFileReader {
24
25
  return;
25
26
  }
26
27
 
27
- const rawFile = fileSystem.readFile(currentPath);
28
- bodies.push(rawFile);
28
+ const rawApexFile = fileSystem.readFile(currentPath);
29
+ const metadataPath = fileSystem.joinPath(rootPath, `${currentFilePath}-meta.xml`);
30
+ const rawMetadataFile = fileSystem.exists(metadataPath) ? fileSystem.readFile(metadataPath) : null;
31
+ bodies.push(new ApexBundle(rawApexFile, rawMetadataFile));
29
32
  });
30
33
  return bodies;
31
34
  }
@@ -6,6 +6,7 @@ export interface FileSystem {
6
6
  isDirectory: (path: string) => boolean;
7
7
  readFile: (path: string) => string;
8
8
  joinPath: (...paths: string[]) => string;
9
+ exists: (path: string) => boolean;
9
10
  }
10
11
 
11
12
  export class DefaultFileSystem implements FileSystem {
@@ -25,4 +26,8 @@ export class DefaultFileSystem implements FileSystem {
25
26
  joinPath(...paths: string[]): string {
26
27
  return path.join(...paths);
27
28
  }
29
+
30
+ exists(path: string): boolean {
31
+ return fs.existsSync(path);
32
+ }
28
33
  }
@@ -0,0 +1,13 @@
1
+ import { XMLParser } from 'fast-xml-parser';
2
+
3
+ export default class MetadataProcessor {
4
+ public static process(input: string) {
5
+ const map = new Map<string, string>();
6
+ const xml = new XMLParser().parse(input);
7
+
8
+ map.set('apiVersion', xml.ApexClass.apiVersion ?? '');
9
+
10
+ map.set('status', xml.ApexClass.status ?? '');
11
+ return map;
12
+ }
13
+ }
@@ -1,15 +1,32 @@
1
1
  import { Type, ReflectionResult } from '@cparra/apex-reflection';
2
+ import ApexBundle from '../model/apex-bundle';
3
+ import MetadataProcessor from './metadata-processor';
2
4
 
3
5
  export interface TypeParser {
4
6
  parse(reflect: (typeBody: string) => ReflectionResult): Type[];
5
7
  }
6
8
 
7
9
  export class RawBodyParser implements TypeParser {
8
- constructor(public typeBodies: string[]) {}
10
+ constructor(public typeBundles: ApexBundle[]) {}
9
11
 
10
12
  parse(reflect: (typeBody: string) => ReflectionResult): Type[] {
11
- return this.typeBodies
12
- .map((rawBody) => reflect(rawBody))
13
+ return this.typeBundles
14
+ .map((currentBundle) => {
15
+ const result = reflect(currentBundle.rawTypeContent);
16
+ if (!!result.typeMirror && !!currentBundle.rawMetadataContent) {
17
+ // If successful and there is a metadata file
18
+ const metadataParams = MetadataProcessor.process(currentBundle.rawMetadataContent);
19
+ metadataParams.forEach((value, key) => {
20
+ const declaration = `${key}: ${value}`;
21
+ result.typeMirror!.annotations.push({
22
+ rawDeclaration: declaration,
23
+ name: declaration,
24
+ type: declaration,
25
+ });
26
+ });
27
+ }
28
+ return result;
29
+ })
13
30
  .filter((reflectionResult) => {
14
31
  return reflectionResult.typeMirror;
15
32
  })
package/src/settings.ts CHANGED
@@ -10,6 +10,7 @@ export interface SettingsConfig {
10
10
  scope: string[];
11
11
  outputDir: string;
12
12
  targetGenerator: GeneratorChoices;
13
+ indexOnly: boolean;
13
14
  }
14
15
 
15
16
  export class Settings {
@@ -54,4 +55,8 @@ export class Settings {
54
55
  throw Error('Invalid target generator');
55
56
  }
56
57
  }
58
+
59
+ get indexOnly(): boolean {
60
+ return this.config.indexOnly;
61
+ }
57
62
  }
@@ -1,5 +1,6 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
  import ProcessorTypeTranspiler from './processor-type-transpiler';
3
+ import { Settings } from '../settings';
3
4
 
4
5
  export default class Transpiler {
5
6
  static generate(types: Type[], processor: ProcessorTypeTranspiler): void {
@@ -10,6 +11,11 @@ export default class Transpiler {
10
11
  });
11
12
 
12
13
  processor.onBeforeProcess?.(sortedTypes);
14
+
15
+ if (Settings.getInstance().indexOnly === true) {
16
+ return;
17
+ }
18
+
13
19
  sortedTypes.forEach((currentType) => {
14
20
  processor.onProcess(currentType);
15
21
  });