@cparra/apexdocs 3.17.0-beta.7 → 3.17.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.
package/README.md CHANGED
@@ -89,14 +89,6 @@ 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
-
100
92
  ## 💿 Installation
101
93
 
102
94
  ```bash
@@ -166,7 +158,7 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
166
158
  | `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification for fields in the generated files. | `false` | No |
167
159
  | `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |
168
160
  | `--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 |
161
+ | `--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 |
170
162
 
171
163
  > **Note:** The `*` in the Required column indicates that **one** of the source directory options must be specified:
172
164
  > - `--sourceDir` (single directory or array of directories)
@@ -214,16 +206,16 @@ apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n M
214
206
 
215
207
  #### Flags
216
208
 
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 |
209
+ | Flag | Alias | Description | Default | Required |
210
+ |----------------------------------|-------|--------------------------------------------------------------------------------------------------|-----------------|----------|
211
+ | `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
212
+ | `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
213
+ | `--fileName` | N/A | The name of the OpenApi file. | `openapi.json` | No |
214
+ | `--namespace` | N/A | The package namespace, if any. This will be added to the API file Server Url. | N/A | No |
215
+ | `--title` | N/A | The title of the OpenApi file. | `Apex REST API` | No |
216
+ | `--apiVersion` | N/A | The version of the API. | `1.0.0` | No |
217
+ | `--parallelReflection` | N/A | Parallelize CPU-heavy reflection via worker threads. | `true` | No |
218
+ | `--parallelReflectionMaxWorkers` | N/A | Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value. | N/A | No |
227
219
 
228
220
  #### Sample Usage
229
221
 
@@ -237,17 +229,17 @@ apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi
237
229
 
238
230
  #### Flags
239
231
 
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 |
232
+ | Flag | Alias | Description | Default | Required |
233
+ |----------------------------------|-------|--------------------------------------------------------------------------------------------------|-------------|----------|
234
+ | `--previousVersionDir` | `-p` | The directory location of the previous version of the source code. | N/A | Yes |
235
+ | `--currentVersionDir` | `-t` | The directory location of the current version of the source code. | N/A | Yes |
236
+ | `--targetDir` | `-t` | The directory location where the changelog file will be generated. | `./docs/` | No |
237
+ | `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
238
+ | `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
239
+ | `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | ['public'] | No |
240
+ | `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
241
+ | `--parallelReflection` | N/A | Parallelize CPU-heavy reflection via worker threads. | `true` | No |
242
+ | `--parallelReflectionMaxWorkers` | N/A | Maximum number of worker threads to use for parallel reflection. Defaults to a reasonable value. | N/A | No |
251
243
 
252
244
  #### Sample Usage
253
245
 
@@ -591,12 +583,14 @@ public class MyClass {
591
583
 
592
584
  ##### **templates**
593
585
 
594
- Allows providing custom templates for generating Markdown documentation, giving you control over the output format.
586
+ Allows providing custom templates for generating Markdown documentation, giving you control over the output format.
595
587
  You can define templates for each type of metadata
596
588
  supported by the `markdown` command (class, interface, enum, trigger, LWC, custom object, and reference guide) .
597
589
 
598
- For detailed information about creating custom templates, including examples, available helpers, and configuration options,
599
- please refer to the [wiki documentation](https://github.com/cesarParra/apexdocs/wiki/5.-Custom-Templates). You can also find a working example in the
590
+ For detailed information about creating custom templates, including examples, available helpers, and configuration
591
+ options,
592
+ please refer to the [wiki documentation](https://github.com/cesarParra/apexdocs/wiki/5.-Custom-Templates). You can also
593
+ find a working example in the
600
594
  `examples/markdown-custom-templates` directory.
601
595
 
602
596
  #### Changelog Hooks
@@ -2,23 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_worker_threads_1 = require("node:worker_threads");
4
4
  const apex_reflection_1 = require("@cparra/apex-reflection");
5
- function isRequestMessage(msg) {
6
- if (!msg || typeof msg !== 'object')
5
+ function isRequestMessage(message) {
6
+ if (!message || typeof message !== 'object') {
7
7
  return false;
8
- const m = msg;
9
- if (typeof m.id !== 'number')
8
+ }
9
+ const candidateMessage = message;
10
+ if (typeof candidateMessage.id !== 'number') {
10
11
  return false;
11
- if (!m.payload || typeof m.payload !== 'object')
12
+ }
13
+ if (!candidateMessage.payload || typeof candidateMessage.payload !== 'object') {
12
14
  return false;
13
- const p = m.payload;
14
- return typeof p.content === 'string';
15
+ }
16
+ const candidatePayload = candidateMessage.payload;
17
+ return typeof candidatePayload.content === 'string';
15
18
  }
16
- function post(msg) {
19
+ function post(responseMessage) {
17
20
  // `parentPort` should always exist in a worker, but guard anyway.
18
21
  if (!node_worker_threads_1.parentPort) {
19
22
  return;
20
23
  }
21
- node_worker_threads_1.parentPort.postMessage(msg);
24
+ node_worker_threads_1.parentPort.postMessage(responseMessage);
22
25
  }
23
26
  function reflectOrThrow(rawSource) {
24
27
  const result = (0, apex_reflection_1.reflect)(rawSource);
@@ -33,25 +36,23 @@ function reflectOrThrow(rawSource) {
33
36
  if (!node_worker_threads_1.parentPort) {
34
37
  throw new Error('apex-reflection.worker started without a parentPort');
35
38
  }
36
- node_worker_threads_1.parentPort.on('message', (msg) => {
37
- if (!isRequestMessage(msg)) {
39
+ node_worker_threads_1.parentPort.on('message', (message) => {
40
+ if (!isRequestMessage(message)) {
38
41
  // Can't correlate without a valid id; ignore.
39
42
  return;
40
43
  }
41
- const { id, payload } = msg;
44
+ const { id, payload } = message;
42
45
  try {
43
46
  const typeMirror = reflectOrThrow(payload.content);
44
47
  post({ id, ok: true, result: typeMirror });
45
48
  }
46
- catch (e) {
47
- const message = (e === null || e === void 0 ? void 0 : e.message) &&
48
- typeof e.message === 'string'
49
- ? e.message
50
- : 'Unknown error';
49
+ catch (caughtError) {
50
+ const candidateMessage = caughtError === null || caughtError === void 0 ? void 0 : caughtError.message;
51
+ const errorMessage = typeof candidateMessage === 'string' ? candidateMessage : 'Unknown error';
51
52
  post({
52
53
  id,
53
54
  ok: false,
54
- error: { message },
55
+ error: { message: errorMessage },
55
56
  });
56
57
  }
57
58
  });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var logger$1 = require('../logger-H9NRKPFV.js');
4
+ var logger$1 = require('../logger-Cr1iCXZc.js');
5
5
  var cosmiconfig = require('cosmiconfig');
6
6
  var yargs = require('yargs');
7
7
  var E = require('fp-ts/Either');
package/dist/index.d.ts CHANGED
@@ -400,17 +400,7 @@ type CliConfigurableMarkdownConfig = {
400
400
  includeFieldSecurityMetadata: boolean;
401
401
  includeInlineHelpTextMetadata: boolean;
402
402
  experimentalLwcSupport: boolean;
403
-
404
- /**
405
- * Whether to parallelize CPU-heavy reflection steps via worker threads.
406
- * Defaults to true.
407
- */
408
403
  parallelReflection: boolean;
409
-
410
- /**
411
- * Max number of worker threads to use for parallel reflection.
412
- * Defaults to a reasonable value based on CPU count.
413
- */
414
404
  parallelReflectionMaxWorkers?: number;
415
405
  };
416
406
 
@@ -433,17 +423,7 @@ type UserDefinedOpenApiConfig = {
433
423
  title: string;
434
424
  apiVersion: string;
435
425
  exclude: string[];
436
-
437
- /**
438
- * Parallelize CPU-heavy reflection via worker threads.
439
- * Defaults to true.
440
- */
441
426
  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
427
  parallelReflectionMaxWorkers?: number;
448
428
  };
449
429
 
@@ -458,17 +438,7 @@ type UserDefinedChangelogConfig = {
458
438
  exclude: string[];
459
439
  skipIfNoChanges: boolean;
460
440
  translations?: UserTranslations['changelog'];
461
-
462
- /**
463
- * Parallelize CPU-heavy reflection via worker threads.
464
- * Defaults to true.
465
- */
466
441
  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
442
  parallelReflectionMaxWorkers?: number;
473
443
  } & Partial<ChangelogConfigurableHooks>;
474
444
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var logger = require('./logger-H9NRKPFV.js');
4
+ var logger = require('./logger-Cr1iCXZc.js');
5
5
  var E = require('fp-ts/Either');
6
6
  require('fp-ts/function');
7
7
  require('fp-ts/TaskEither');
@@ -1198,21 +1198,6 @@ class WorkerPool {
1198
1198
  this.pump();
1199
1199
  });
1200
1200
  }
1201
- /**
1202
- * Returns current pool stats.
1203
- */
1204
- stats() {
1205
- return {
1206
- maxWorkers: this.maxWorkers,
1207
- activeWorkers: this.allWorkers.size,
1208
- idleWorkers: this.idleWorkers.length,
1209
- queuedTasks: this.queue.length,
1210
- inFlightTasks: this.inFlightByWorker.size,
1211
- createdWorkers: this.createdWorkers,
1212
- completedTasks: this.completedTasks,
1213
- failedTasks: this.failedTasks
1214
- };
1215
- }
1216
1201
  /**
1217
1202
  * Terminates all workers and rejects queued tasks (unless drainOnTerminate=true).
1218
1203
  *
@@ -1277,8 +1262,7 @@ class WorkerPool {
1277
1262
  const idleWorker = this.idleWorkers.pop();
1278
1263
  if (idleWorker) return idleWorker;
1279
1264
  if (this.allWorkers.size < this.maxWorkers) {
1280
- const spawnedWorker = this.spawnWorker();
1281
- return spawnedWorker;
1265
+ return this.spawnWorker();
1282
1266
  }
1283
1267
  return null;
1284
1268
  }
@@ -1460,8 +1444,12 @@ function supportsWorkerThreads() {
1460
1444
  function isWorkerReflectionEnabled(config) {
1461
1445
  var _a, _b;
1462
1446
  const env = ((_a = process.env.APEXDOCS_WORKER_REFLECTION) != null ? _a : "").toLowerCase();
1463
- if (env === "true" || env === "1") return true;
1464
- if (env === "false" || env === "0") return false;
1447
+ if (env === "true" || env === "1") {
1448
+ return true;
1449
+ }
1450
+ if (env === "false" || env === "0") {
1451
+ return false;
1452
+ }
1465
1453
  return (_b = config == null ? void 0 : config.parallelReflection) != null ? _b : true;
1466
1454
  }
1467
1455
  function getWorkerEntrypointPath() {
@@ -1480,16 +1468,13 @@ function reflectAsTaskParallel(apexBundles, config) {
1480
1468
  const maxWorkers = Math.max(1, (_c = config == null ? void 0 : config.parallelReflectionMaxWorkers) != null ? _c : defaultMax);
1481
1469
  const pool = new WorkerPool(() => new node_worker_threads.Worker(getWorkerEntrypointPath()), {
1482
1470
  maxWorkers
1483
- // Keep default queue size (Infinity) unless we later decide to bound it via config.
1484
1471
  });
1485
1472
  try {
1486
- const results = yield Promise.all(
1473
+ return yield Promise.all(
1487
1474
  apexBundles.map((bundle) => __async$5(null, null, function* () {
1488
- const typeMirror = yield pool.run({ content: bundle.content });
1489
- return typeMirror;
1475
+ return yield pool.run({ content: bundle.content });
1490
1476
  }))
1491
1477
  );
1492
- return results;
1493
1478
  } finally {
1494
1479
  yield pool.terminate();
1495
1480
  }
@@ -2184,9 +2169,7 @@ const markdownDefaults = __spreadProps$j(__spreadValues$k({}, markdownAndChangel
2184
2169
  includeFieldSecurityMetadata: false,
2185
2170
  includeInlineHelpTextMetadata: false,
2186
2171
  experimentalLwcSupport: false,
2187
- // Performance: parallel reflection via worker threads (enabled by default).
2188
2172
  parallelReflection: true,
2189
- // Default is computed at runtime if not provided.
2190
2173
  parallelReflectionMaxWorkers: void 0
2191
2174
  });
2192
2175
  const openApiDefaults = __spreadProps$j(__spreadValues$k({}, commonDefaults), {
@@ -2194,17 +2177,13 @@ const openApiDefaults = __spreadProps$j(__spreadValues$k({}, commonDefaults), {
2194
2177
  title: "Apex REST API",
2195
2178
  apiVersion: "1.0.0",
2196
2179
  exclude: [],
2197
- // Performance: parallel reflection via worker threads (enabled by default).
2198
2180
  parallelReflection: true,
2199
- // Default is computed at runtime if not provided.
2200
2181
  parallelReflectionMaxWorkers: void 0
2201
2182
  });
2202
2183
  const changeLogDefaults = __spreadProps$j(__spreadValues$k({}, markdownAndChangelogDefaults), {
2203
2184
  fileName: "changelog",
2204
2185
  skipIfNoChanges: true,
2205
- // Performance: parallel reflection via worker threads (enabled by default).
2206
2186
  parallelReflection: true,
2207
- // Default is computed at runtime if not provided.
2208
2187
  parallelReflectionMaxWorkers: void 0
2209
2188
  });
2210
2189
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "3.17.0-beta.7",
3
+ "version": "3.17.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "engines": {
6
6
  "node": ">=18"