@cparra/apexdocs 3.17.0-beta.5 → 3.17.0-beta.7
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.
- package/README.md +31 -17
- package/dist/cli/generate.js +21 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +1 -1
- package/dist/{logger-D8cfCwLW.js → logger-H9NRKPFV.js} +44 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,6 +89,14 @@ Here are some live projects using ApexDocs:
|
|
|
89
89
|
* Custom tag support
|
|
90
90
|
* And much, much more!
|
|
91
91
|
|
|
92
|
+
## ⚡ Parallel reflection (performance)
|
|
93
|
+
|
|
94
|
+
ApexDocs can speed up documentation generation by running reflection work in parallel (enabled by default).
|
|
95
|
+
If you run into issues or want deterministic behavior, you can disable it with:
|
|
96
|
+
|
|
97
|
+
- `--parallelReflection false`
|
|
98
|
+
- or via config: `parallelReflection: false`
|
|
99
|
+
|
|
92
100
|
## 💿 Installation
|
|
93
101
|
|
|
94
102
|
```bash
|
|
@@ -157,6 +165,8 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
|
|
|
157
165
|
| `--lwcGroupName` | N/A | The name under which Lightning Web Components will be grouped in the Reference Guide | `Lightning Web Components` | No |
|
|
158
166
|
| `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification for fields in the generated files. | `false` | No |
|
|
159
167
|
| `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |
|
|
168
|
+
| `--parallelReflection` | N/A | Parallelize CPU-heavy reflection via worker threads. | `true` | No |
|
|
169
|
+
| `--parallelReflectionMaxWorkers` | N/A | Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count. | N/A | No |
|
|
160
170
|
|
|
161
171
|
> **Note:** The `*` in the Required column indicates that **one** of the source directory options must be specified:
|
|
162
172
|
> - `--sourceDir` (single directory or array of directories)
|
|
@@ -204,14 +214,16 @@ apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n M
|
|
|
204
214
|
|
|
205
215
|
#### Flags
|
|
206
216
|
|
|
207
|
-
| Flag
|
|
208
|
-
|
|
209
|
-
| `--sourceDir`
|
|
210
|
-
| `--targetDir`
|
|
211
|
-
| `--fileName`
|
|
212
|
-
| `--namespace`
|
|
213
|
-
| `--title`
|
|
214
|
-
| `--apiVersion`
|
|
217
|
+
| Flag | Alias | Description | Default | Required |
|
|
218
|
+
|--------------------------------|-------|----------------------------------------------------------------------------------------------------------|-----------------|----------|
|
|
219
|
+
| `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
|
|
220
|
+
| `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
|
|
221
|
+
| `--fileName` | N/A | The name of the OpenApi file. | `openapi.json` | No |
|
|
222
|
+
| `--namespace` | N/A | The package namespace, if any. This will be added to the API file Server Url. | N/A | No |
|
|
223
|
+
| `--title` | N/A | The title of the OpenApi file. | `Apex REST API` | No |
|
|
224
|
+
| `--apiVersion` | N/A | The version of the API. | `1.0.0` | No |
|
|
225
|
+
| `--parallelReflection` | N/A | Parallelize CPU-heavy reflection via worker threads. | `true` | No |
|
|
226
|
+
| `--parallelReflectionMaxWorkers` | N/A | Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value. | N/A | No |
|
|
215
227
|
|
|
216
228
|
#### Sample Usage
|
|
217
229
|
|
|
@@ -225,15 +237,17 @@ apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi
|
|
|
225
237
|
|
|
226
238
|
#### Flags
|
|
227
239
|
|
|
228
|
-
| Flag
|
|
229
|
-
|
|
230
|
-
| `--previousVersionDir`
|
|
231
|
-
| `--currentVersionDir`
|
|
232
|
-
| `--targetDir`
|
|
233
|
-
| `--fileName`
|
|
234
|
-
| `--scope`
|
|
235
|
-
| `--customObjectVisibility`
|
|
236
|
-
| `--skipIfNoChanges`
|
|
240
|
+
| Flag | Alias | Description | Default | Required |
|
|
241
|
+
|--------------------------------|-------|----------------------------------------------------------------------------------------------------------|-------------|----------|
|
|
242
|
+
| `--previousVersionDir` | `-p` | The directory location of the previous version of the source code. | N/A | Yes |
|
|
243
|
+
| `--currentVersionDir` | `-t` | The directory location of the current version of the source code. | N/A | Yes |
|
|
244
|
+
| `--targetDir` | `-t` | The directory location where the changelog file will be generated. | `./docs/` | No |
|
|
245
|
+
| `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
|
|
246
|
+
| `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
|
|
247
|
+
| `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | ['public'] | No |
|
|
248
|
+
| `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
|
|
249
|
+
| `--parallelReflection` | N/A | Parallelize CPU-heavy reflection via worker threads. | `true` | No |
|
|
250
|
+
| `--parallelReflectionMaxWorkers` | N/A | Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value. | N/A | No |
|
|
237
251
|
|
|
238
252
|
#### Sample Usage
|
|
239
253
|
|
package/dist/cli/generate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var logger$1 = require('../logger-
|
|
4
|
+
var logger$1 = require('../logger-H9NRKPFV.js');
|
|
5
5
|
var cosmiconfig = require('cosmiconfig');
|
|
6
6
|
var yargs = require('yargs');
|
|
7
7
|
var E = require('fp-ts/Either');
|
|
@@ -221,6 +221,16 @@ const openApiOptions = {
|
|
|
221
221
|
type: "string",
|
|
222
222
|
default: logger$1.openApiDefaults.apiVersion,
|
|
223
223
|
describe: "The version of the OpenApi file."
|
|
224
|
+
},
|
|
225
|
+
parallelReflection: {
|
|
226
|
+
type: "boolean",
|
|
227
|
+
describe: "Parallelize CPU-heavy reflection via worker threads.",
|
|
228
|
+
default: logger$1.openApiDefaults.parallelReflection
|
|
229
|
+
},
|
|
230
|
+
parallelReflectionMaxWorkers: {
|
|
231
|
+
type: "number",
|
|
232
|
+
describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
|
|
233
|
+
default: logger$1.openApiDefaults.parallelReflectionMaxWorkers
|
|
224
234
|
}
|
|
225
235
|
};
|
|
226
236
|
|
|
@@ -236,6 +246,16 @@ function validateChangelogArgs(argv) {
|
|
|
236
246
|
return true;
|
|
237
247
|
}
|
|
238
248
|
const changeLogOptions = {
|
|
249
|
+
parallelReflection: {
|
|
250
|
+
type: "boolean",
|
|
251
|
+
describe: "Parallelize CPU-heavy reflection via worker threads.",
|
|
252
|
+
default: logger$1.markdownDefaults.parallelReflection
|
|
253
|
+
},
|
|
254
|
+
parallelReflectionMaxWorkers: {
|
|
255
|
+
type: "number",
|
|
256
|
+
describe: "Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value based on CPU count.",
|
|
257
|
+
default: logger$1.markdownDefaults.parallelReflectionMaxWorkers
|
|
258
|
+
},
|
|
239
259
|
previousVersionDir: {
|
|
240
260
|
type: "string",
|
|
241
261
|
array: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -433,6 +433,18 @@ type UserDefinedOpenApiConfig = {
|
|
|
433
433
|
title: string;
|
|
434
434
|
apiVersion: string;
|
|
435
435
|
exclude: string[];
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Parallelize CPU-heavy reflection via worker threads.
|
|
439
|
+
* Defaults to true.
|
|
440
|
+
*/
|
|
441
|
+
parallelReflection: boolean;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Maximum number of worker threads to use for parallel reflection.
|
|
445
|
+
* Defaults to a reasonable value based on CPU count.
|
|
446
|
+
*/
|
|
447
|
+
parallelReflectionMaxWorkers?: number;
|
|
436
448
|
};
|
|
437
449
|
|
|
438
450
|
type UserDefinedChangelogConfig = {
|
|
@@ -446,6 +458,18 @@ type UserDefinedChangelogConfig = {
|
|
|
446
458
|
exclude: string[];
|
|
447
459
|
skipIfNoChanges: boolean;
|
|
448
460
|
translations?: UserTranslations['changelog'];
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Parallelize CPU-heavy reflection via worker threads.
|
|
464
|
+
* Defaults to true.
|
|
465
|
+
*/
|
|
466
|
+
parallelReflection: boolean;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Maximum number of worker threads to use for parallel reflection.
|
|
470
|
+
* Defaults to a reasonable value based on CPU count.
|
|
471
|
+
*/
|
|
472
|
+
parallelReflectionMaxWorkers?: number;
|
|
449
473
|
} & Partial<ChangelogConfigurableHooks>;
|
|
450
474
|
|
|
451
475
|
type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig | UserDefinedChangelogConfig;
|
package/dist/index.js
CHANGED
|
@@ -1465,7 +1465,7 @@ function isWorkerReflectionEnabled(config) {
|
|
|
1465
1465
|
return (_b = config == null ? void 0 : config.parallelReflection) != null ? _b : true;
|
|
1466
1466
|
}
|
|
1467
1467
|
function getWorkerEntrypointPath() {
|
|
1468
|
-
const candidate = path$1.resolve(__dirname, "
|
|
1468
|
+
const candidate = path$1.resolve(__dirname, "./apex-reflection.worker.js");
|
|
1469
1469
|
if (fs.existsSync(candidate)) {
|
|
1470
1470
|
return candidate;
|
|
1471
1471
|
}
|
|
@@ -2193,11 +2193,19 @@ const openApiDefaults = __spreadProps$j(__spreadValues$k({}, commonDefaults), {
|
|
|
2193
2193
|
fileName: "openapi",
|
|
2194
2194
|
title: "Apex REST API",
|
|
2195
2195
|
apiVersion: "1.0.0",
|
|
2196
|
-
exclude: []
|
|
2196
|
+
exclude: [],
|
|
2197
|
+
// Performance: parallel reflection via worker threads (enabled by default).
|
|
2198
|
+
parallelReflection: true,
|
|
2199
|
+
// Default is computed at runtime if not provided.
|
|
2200
|
+
parallelReflectionMaxWorkers: void 0
|
|
2197
2201
|
});
|
|
2198
2202
|
const changeLogDefaults = __spreadProps$j(__spreadValues$k({}, markdownAndChangelogDefaults), {
|
|
2199
2203
|
fileName: "changelog",
|
|
2200
|
-
skipIfNoChanges: true
|
|
2204
|
+
skipIfNoChanges: true,
|
|
2205
|
+
// Performance: parallel reflection via worker threads (enabled by default).
|
|
2206
|
+
parallelReflection: true,
|
|
2207
|
+
// Default is computed at runtime if not provided.
|
|
2208
|
+
parallelReflectionMaxWorkers: void 0
|
|
2201
2209
|
});
|
|
2202
2210
|
|
|
2203
2211
|
const customObjectTemplate = `
|
|
@@ -4758,7 +4766,32 @@ function openApi(logger, fileBodies, config) {
|
|
|
4758
4766
|
namespace: config.namespace,
|
|
4759
4767
|
version: config.apiVersion
|
|
4760
4768
|
});
|
|
4761
|
-
const
|
|
4769
|
+
const parsedFilesEither = yield reflectApexSource(fileBodies, {
|
|
4770
|
+
parallelReflection: config.parallelReflection,
|
|
4771
|
+
parallelReflectionMaxWorkers: config.parallelReflectionMaxWorkers
|
|
4772
|
+
})();
|
|
4773
|
+
if (E__namespace.isLeft(parsedFilesEither)) {
|
|
4774
|
+
const errors = parsedFilesEither.left;
|
|
4775
|
+
logger.error(errors);
|
|
4776
|
+
return;
|
|
4777
|
+
}
|
|
4778
|
+
const parsedFiles = parsedFilesEither.right;
|
|
4779
|
+
const reflectionByPath = /* @__PURE__ */ new Map();
|
|
4780
|
+
for (const parsed of parsedFiles) {
|
|
4781
|
+
if (!("filePath" in parsed.source)) {
|
|
4782
|
+
continue;
|
|
4783
|
+
}
|
|
4784
|
+
reflectionByPath.set(parsed.source.filePath, { typeMirror: parsed.type });
|
|
4785
|
+
}
|
|
4786
|
+
function reflectFromMap(apexBundle) {
|
|
4787
|
+
const result = reflectionByPath.get(apexBundle.filePath);
|
|
4788
|
+
if (result) {
|
|
4789
|
+
return result;
|
|
4790
|
+
}
|
|
4791
|
+
logger.error(`${apexBundle.filePath} - Parsing error Unknown error`);
|
|
4792
|
+
return { typeMirror: null, error: new Error("Unknown error") };
|
|
4793
|
+
}
|
|
4794
|
+
const manifest = createManifest(new RawBodyParser(logger, fileBodies), reflectFromMap);
|
|
4762
4795
|
TypesRepository.getInstance().populateAll(manifest.types);
|
|
4763
4796
|
const filteredTypes = filterByScopes(logger, manifest);
|
|
4764
4797
|
const processor = new OpenApiDocsProcessor(logger);
|
|
@@ -4773,14 +4806,6 @@ function openApi(logger, fileBodies, config) {
|
|
|
4773
4806
|
ErrorLogger.logErrors(logger, filteredTypes);
|
|
4774
4807
|
});
|
|
4775
4808
|
}
|
|
4776
|
-
function reflectionWithLogger(logger, apexBundle) {
|
|
4777
|
-
var _a;
|
|
4778
|
-
const result = apexReflection.reflect(apexBundle.content);
|
|
4779
|
-
if (result.error) {
|
|
4780
|
-
logger.error(`${apexBundle.filePath} - Parsing error ${(_a = result.error) == null ? void 0 : _a.message}`);
|
|
4781
|
-
}
|
|
4782
|
-
return result;
|
|
4783
|
-
}
|
|
4784
4809
|
function filterByScopes(logger, manifest) {
|
|
4785
4810
|
const filteredTypes = manifest.filteredByAccessModifierAndAnnotations([
|
|
4786
4811
|
"restresource",
|
|
@@ -5434,9 +5459,12 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
5434
5459
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
5435
5460
|
});
|
|
5436
5461
|
};
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5462
|
+
function changelogReflectionConfig(config) {
|
|
5463
|
+
return {
|
|
5464
|
+
parallelReflection: config.parallelReflection,
|
|
5465
|
+
parallelReflectionMaxWorkers: config.parallelReflectionMaxWorkers
|
|
5466
|
+
};
|
|
5467
|
+
}
|
|
5440
5468
|
function generateChangeLog(oldBundles, newBundles, config) {
|
|
5441
5469
|
const convertToPageData = apply(toPageData, config.fileName);
|
|
5442
5470
|
function handleConversion({ changelog, newManifest }) {
|
|
@@ -5467,7 +5495,7 @@ function generateChangeLog(oldBundles, newBundles, config) {
|
|
|
5467
5495
|
function reflect(bundles, config) {
|
|
5468
5496
|
const filterOutOfScopeApex = apply(filterScope, config.scope);
|
|
5469
5497
|
function reflectApexFiles(sourceFiles) {
|
|
5470
|
-
return _function.pipe(reflectApexSource(sourceFiles, changelogReflectionConfig), TE__namespace.map(filterOutOfScopeApex));
|
|
5498
|
+
return _function.pipe(reflectApexSource(sourceFiles, changelogReflectionConfig(config)), TE__namespace.map(filterOutOfScopeApex));
|
|
5471
5499
|
}
|
|
5472
5500
|
return _function.pipe(
|
|
5473
5501
|
// Filter out LWC. These will be implemented at a later date
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.17.0-beta.
|
|
3
|
+
"version": "3.17.0-beta.7",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
]
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@cparra/apex-reflection": "2.
|
|
99
|
+
"@cparra/apex-reflection": "2.22.0",
|
|
100
100
|
"@salesforce/source-deploy-retrieve": "^12.20.1",
|
|
101
101
|
"@types/js-yaml": "^4.0.9",
|
|
102
102
|
"@types/yargs": "^17.0.32",
|