@cparra/apexdocs 3.13.0 โ†’ 3.15.0-alpha.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
@@ -12,6 +12,26 @@ ApexDocs is a non-opinionated documentation generator for Salesforce Apex classe
12
12
  It can output documentation in Markdown format, which allows you to use the Static Site Generator of your choice to
13
13
  create a documentation site that fits your needs, hosted in any static web hosting service.
14
14
 
15
+ ## Table of Contents
16
+
17
+ - [๐Ÿ‘€ Examples](#-examples)
18
+ - [๐Ÿš€ Features](#-features)
19
+ - [๐Ÿ’ฟ Installation](#-installation)
20
+ - [โšก Quick Start](#-quick-start)
21
+ - [CLI](#cli)
22
+ - [Markdown](#markdown)
23
+ - [OpenApi](#openapi)
24
+ - [Changelog](#changelog)
25
+ - [โ–ถ๏ธ Available Commands](#๏ธ-available-commands)
26
+ - [Markdown](#markdown-1)
27
+ - [OpenApi](#openapi-1)
28
+ - [Changelog](#changelog-1)
29
+ - [๐Ÿ”ฌ Defining a configuration file](#-defining-a-configuration-file)
30
+ - [๐ŸŒ Translation](#-translation)
31
+ - [โคต๏ธŽ Importing to your project](#๏ธŽ-importing-to-your-project)
32
+ - [๐Ÿ“– Documentation Guide](#-documentation-guide)
33
+ - [๐Ÿ“„ Generating OpenApi REST Definitions](#-generating-openapi-rest-definitions)
34
+
15
35
  ## ๐Ÿ‘€ Examples
16
36
 
17
37
  ApexDocs generates Markdown files, which can be integrated into any Static Site Generation (SSG) engine,
@@ -64,6 +84,7 @@ Here are some live projects using ApexDocs:
64
84
  * Support for ignoring files and members from being documented
65
85
  * Namespace support
66
86
  * Configuration file support
87
+ * Translation support for different languages and custom terminology
67
88
  * Single line ApexDoc Blocks
68
89
  * Custom tag support
69
90
  * And much, much more!
@@ -134,7 +155,9 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
134
155
  | `--customObjectsGroupName` | N/A | The name under which custom objects will be grouped in the Reference Guide | `Custom Objects` | No |
135
156
  | `--triggersGroupName` | N/A | The name under which triggers will be grouped in the Reference Guide | `Triggers` | No |
136
157
  | `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification for fields in the generated files. | `false` | No |
137
- | `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |
158
+ || `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |
159
+ || `--parallelProcessing` | N/A | Whether to use parallel processing for reflection operations. | `true` | No |
160
+ || `--workerThreads` | N/A | Number of worker threads to use for parallel processing (defaults to number of CPU cores). | CPU cores | No |
138
161
 
139
162
  > **Note:** The `*` in the Required column indicates that **one** of the source directory options must be specified:
140
163
  > - `--sourceDir` (single directory)
@@ -212,7 +235,9 @@ apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi
212
235
  | `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
213
236
  | `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
214
237
  | `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | ['public'] | No |
215
- | `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
238
+ || `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
239
+ || `--parallelProcessing` | N/A | Whether to use parallel processing for reflection operations. | `true` | No |
240
+ || `--workerThreads` | N/A | Number of worker threads to use for parallel processing (defaults to number of CPU cores). | CPU cores | No |
216
241
 
217
242
  #### Sample Usage
218
243
 
@@ -222,6 +247,62 @@ apexdocs changelog -p force-app-previous -t force-app
222
247
 
223
248
  ---
224
249
 
250
+ ## โšก Parallel Processing
251
+
252
+ ApexDocs supports parallel processing for reflection operations, significantly improving performance when processing large numbers of Apex files. This feature uses Node.js Worker Threads to process files in parallel while maintaining full compatibility with existing configurations.
253
+
254
+ ### Key Features
255
+
256
+ - **Automatic**: Enabled by default in production environments
257
+ - **Adaptive**: Automatically chooses between parallel and sequential processing based on file count and environment
258
+ - **Configurable**: Control the number of worker threads used
259
+ - **Safe**: Automatically disabled during tests to prevent interference
260
+
261
+ ### Configuration
262
+
263
+ ```typescript
264
+ import { defineMarkdownConfig } from '@cparra/apexdocs';
265
+
266
+ export default defineMarkdownConfig({
267
+ sourceDir: 'force-app',
268
+ targetDir: 'docs',
269
+
270
+ // Enable/disable parallel processing (default: true in production)
271
+ parallelProcessing: true,
272
+
273
+ // Set number of worker threads (default: CPU cores)
274
+ workerThreads: 4,
275
+ });
276
+ ```
277
+
278
+ ### CLI Usage
279
+
280
+ ```bash
281
+ # Use parallel processing (default)
282
+ apexdocs markdown -s force-app
283
+
284
+ # Disable parallel processing
285
+ apexdocs markdown -s force-app --parallelProcessing false
286
+
287
+ # Set custom worker thread count
288
+ apexdocs markdown -s force-app --workerThreads 8
289
+ ```
290
+
291
+ ### Performance Benefits
292
+
293
+ - **Large codebases**: Significant performance improvements for projects with many files
294
+ - **Multi-core systems**: Better utilization of available CPU cores
295
+ - **CI/CD pipelines**: Faster documentation generation in automated environments
296
+
297
+ ### When It's Used
298
+
299
+ - **Parallel**: Multiple files + production environment + parallel enabled
300
+ - **Sequential**: Single file OR test environment OR parallel disabled
301
+
302
+ For more detailed information, see [PARALLEL_PROCESSING.md](PARALLEL_PROCESSING.md).
303
+
304
+ ---
305
+
225
306
  ## ๐Ÿ”ฌ Defining a configuration file
226
307
 
227
308
  You can also use a configuration file to define the parameters that will be used when generating the documentation.
@@ -274,6 +355,12 @@ export default defineMarkdownConfig({
274
355
  sourceDir: 'force-app',
275
356
  targetDir: 'docs',
276
357
  scope: ['global', 'public'],
358
+ translations: {
359
+ sections: {
360
+ methods: 'Methods',
361
+ properties: 'Properties',
362
+ },
363
+ },
277
364
  ...
278
365
  });
279
366
  ```
@@ -595,6 +682,74 @@ export default {
595
682
  };
596
683
  ```
597
684
 
685
+ ## ๐ŸŒ Translation
686
+
687
+ ApexDocs supports translations to customize the language and terminology used in the generated documentation.
688
+ This feature allows you to:
689
+
690
+ - **Translate documentation to different languages** (Spanish, French, etc.)
691
+ - **Use custom business terminology** (e.g., "Business Operations" instead of "Methods")
692
+ - **Partially override specific terms** while keeping the rest in English
693
+
694
+ ### How It Works
695
+
696
+ The translation system uses:
697
+
698
+ - **Default English translations** built into the system
699
+ - **User-provided overrides** that can be partial or complete
700
+
701
+ ### Configuration
702
+
703
+ Add a `translations` property to your ApexDocs configuration (JS or TS file) and pass
704
+ the appropriate translation object, depending on the generator you're using:
705
+
706
+ ```javascript
707
+ import { defineMarkdownConfig } from '@cparra/apexdocs';
708
+
709
+ export default defineMarkdownConfig({
710
+ sourceDir: 'src',
711
+ targetDir: 'docs',
712
+ scope: ['public', 'global'],
713
+ translations: {
714
+ sections: {
715
+ methods: 'Mรฉtodos',
716
+ properties: 'Propiedades',
717
+ fields: 'Campos',
718
+ },
719
+ },
720
+ });
721
+ ```
722
+
723
+ ### TypeScript Support
724
+
725
+ For TypeScript projects, import the translation types for better autocomplete and type safety:
726
+
727
+ ```typescript
728
+ import { defineMarkdownConfig } from '@cparra/apexdocs';
729
+ import type { UserTranslations } from '@cparra/apexdocs';
730
+
731
+ const markdownTranslations: UserTranslations['markdown'] = {
732
+ sections: {
733
+ methods: 'Functions',
734
+ },
735
+ // ...other translation keys as needed
736
+ };
737
+
738
+ export default defineMarkdownConfig({
739
+ sourceDir: 'src',
740
+ targetDir: 'docs',
741
+ scope: ['public', 'global'],
742
+ translations: markdownTranslations,
743
+ });
744
+ ```
745
+
746
+ ### Notes
747
+
748
+ - Only the **markdown** and **changelog** generators support translations
749
+ - All translations are optional - anything not specified uses the English default
750
+
751
+ For a complete example, see the [translation example](examples/translation/) in this repository.
752
+
598
753
  ## โคต๏ธŽ Importing to your project
599
754
 
600
755
  ### Reflection
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var logger$1 = require('../logger-BiPQ_i9-.js');
4
+ var logger$1 = require('../logger-BbAtfln6.js');
5
5
  var require$$0 = require('yargs');
6
6
  var cosmiconfig = require('cosmiconfig');
7
7
  var E = require('fp-ts/Either');
@@ -10,14 +10,17 @@ var _function = require('fp-ts/function');
10
10
  require('fp-ts/TaskEither');
11
11
  require('js-yaml');
12
12
  require('path');
13
- require('fp-ts/Task');
14
- require('fp-ts/lib/Array');
15
- require('@cparra/apex-reflection');
16
13
  require('fp-ts/Option');
17
- require('fast-xml-parser');
18
14
  require('handlebars');
19
15
  require('fp-ts/boolean');
16
+ require('fast-xml-parser');
17
+ require('fp-ts/Task');
20
18
  require('fp-ts/Array');
19
+ require('worker_threads');
20
+ require('os');
21
+ require('fp-ts/lib/Array');
22
+ require('@cparra/apex-reflection');
23
+ require('uuid');
21
24
  require('fs');
22
25
  require('fp-ts/lib/TaskEither');
23
26
  require('minimatch');
@@ -141,6 +144,15 @@ const markdownOptions = {
141
144
  includeInlineHelpTextMetadata: {
142
145
  type: "boolean",
143
146
  describe: "Whether to include the inline help text for fields in the generated files."
147
+ },
148
+ parallelProcessing: {
149
+ type: "boolean",
150
+ describe: "Whether to use parallel processing for reflection operations.",
151
+ default: logger$1.markdownDefaults.parallelProcessing
152
+ },
153
+ workerThreads: {
154
+ type: "number",
155
+ describe: "Number of worker threads to use for parallel processing (defaults to number of CPU cores)."
144
156
  }
145
157
  };
146
158
 
@@ -256,6 +268,15 @@ const changeLogOptions = {
256
268
  type: "boolean",
257
269
  default: logger$1.changeLogDefaults.skipIfNoChanges,
258
270
  describe: "Skip the changelog generation if there are no changes between the previous and current version."
271
+ },
272
+ parallelProcessing: {
273
+ type: "boolean",
274
+ describe: "Whether to use parallel processing for reflection operations.",
275
+ default: logger$1.changeLogDefaults.parallelProcessing
276
+ },
277
+ workerThreads: {
278
+ type: "number",
279
+ describe: "Number of worker threads to use for parallel processing (defaults to number of CPU cores)."
259
280
  }
260
281
  };
261
282
 
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const worker_threads_1 = require("worker_threads");
13
+ const apex_reflection_1 = require("@cparra/apex-reflection");
14
+ function processReflectionTask(task) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ let result;
18
+ if (task.type === 'apex') {
19
+ const reflectionResult = (0, apex_reflection_1.reflect)(task.content);
20
+ if (reflectionResult.error) {
21
+ throw reflectionResult.error;
22
+ }
23
+ result = reflectionResult.typeMirror;
24
+ }
25
+ else if (task.type === 'trigger') {
26
+ const reflectionResult = yield (0, apex_reflection_1.reflectTriggerAsync)(task.content);
27
+ if (reflectionResult.error) {
28
+ throw reflectionResult.error;
29
+ }
30
+ result = reflectionResult.triggerMirror;
31
+ }
32
+ else {
33
+ throw new Error(`Unknown reflection type: ${task.type}`);
34
+ }
35
+ return {
36
+ id: task.id,
37
+ success: true,
38
+ result,
39
+ };
40
+ }
41
+ catch (error) {
42
+ return {
43
+ id: task.id,
44
+ success: false,
45
+ error: {
46
+ message: error.message,
47
+ filePath: task.filePath,
48
+ },
49
+ };
50
+ }
51
+ });
52
+ }
53
+ if (worker_threads_1.parentPort) {
54
+ worker_threads_1.parentPort.on('message', (task) => __awaiter(void 0, void 0, void 0, function* () {
55
+ const result = yield processReflectionTask(task);
56
+ worker_threads_1.parentPort.postMessage(result);
57
+ }));
58
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,140 @@
1
+ /**
2
+ * Default English translations for ApexDocs.
3
+ * These can be overridden by users in their configuration.
4
+ */
5
+ type Translations = {
6
+ changelog: {
7
+ title: string;
8
+ newClasses: {
9
+ heading: string;
10
+ description: string;
11
+ };
12
+ newInterfaces: {
13
+ heading: string;
14
+ description: string;
15
+ };
16
+ newEnums: {
17
+ heading: string;
18
+ description: string;
19
+ };
20
+ newCustomObjects: {
21
+ heading: string;
22
+ description: string;
23
+ };
24
+ newTriggers: {
25
+ heading: string;
26
+ description: string;
27
+ };
28
+ removedTypes: {
29
+ heading: string;
30
+ description: string;
31
+ };
32
+ removedCustomObjects: {
33
+ heading: string;
34
+ description: string;
35
+ };
36
+ removedTriggers: {
37
+ heading: string;
38
+ description: string;
39
+ };
40
+ newOrModifiedMembers: {
41
+ heading: string;
42
+ description: string;
43
+ };
44
+ newOrRemovedCustomFields: {
45
+ heading: string;
46
+ description: string;
47
+ };
48
+ newOrRemovedCustomMetadataTypeRecords: {
49
+ heading: string;
50
+ description: string;
51
+ };
52
+ memberModifications: {
53
+ newEnumValue: string;
54
+ removedEnumValue: string;
55
+ newMethod: string;
56
+ removedMethod: string;
57
+ newProperty: string;
58
+ removedProperty: string;
59
+ newField: string;
60
+ removedField: string;
61
+ newType: string;
62
+ removedType: string;
63
+ newCustomMetadataRecord: string;
64
+ removedCustomMetadataRecord: string;
65
+ newTrigger: string;
66
+ removedTrigger: string;
67
+ };
68
+ };
69
+ markdown: {
70
+ sections: {
71
+ methods: string;
72
+ properties: string;
73
+ fields: string;
74
+ constructors: string;
75
+ values: string;
76
+ classes: string;
77
+ enums: string;
78
+ interfaces: string;
79
+ namespace: string;
80
+ records: string;
81
+ publishBehavior: string;
82
+ };
83
+ details: {
84
+ type: string;
85
+ signature: string;
86
+ group: string;
87
+ author: string;
88
+ date: string;
89
+ see: string;
90
+ possibleValues: string;
91
+ parameters: string;
92
+ throws: string;
93
+ returnType: string;
94
+ apiName: string;
95
+ required: string;
96
+ inlineHelpText: string;
97
+ complianceGroup: string;
98
+ securityClassification: string;
99
+ protected: string;
100
+ };
101
+ typeSuffixes: {
102
+ class: string;
103
+ interface: string;
104
+ enum: string;
105
+ trigger: string;
106
+ };
107
+ triggerEvents: {
108
+ beforeInsert: string;
109
+ beforeUpdate: string;
110
+ beforeDelete: string;
111
+ afterInsert: string;
112
+ afterUpdate: string;
113
+ afterDelete: string;
114
+ afterUndelete: string;
115
+ };
116
+ publishBehaviors: {
117
+ publishImmediately: string;
118
+ publishAfterCommit: string;
119
+ };
120
+ inheritance: {
121
+ inheritance: string;
122
+ implements: string;
123
+ };
124
+ };
125
+ };
126
+
127
+ /**
128
+ * User-provided partial translations that can override the defaults.
129
+ */
130
+ type UserTranslations = DeepPartial<Translations>;
131
+ /**
132
+ * Utility type to make all properties in T optional recursively.
133
+ */
134
+ type DeepPartial<T> = {
135
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
136
+ };
137
+
1
138
  type Generators = 'markdown' | 'openapi' | 'changelog';
2
139
 
3
140
  type LinkingStrategy =
@@ -36,12 +173,15 @@ type CliConfigurableMarkdownConfig = {
36
173
  referenceGuideTitle: string;
37
174
  includeFieldSecurityMetadata: boolean;
38
175
  includeInlineHelpTextMetadata: boolean;
176
+ parallelProcessing?: boolean;
177
+ workerThreads?: number;
39
178
  };
40
179
 
41
180
  type UserDefinedMarkdownConfig = {
42
181
  targetGenerator: 'markdown';
43
182
  excludeTags: string[];
44
183
  exclude: string[];
184
+ translations?: UserTranslations['markdown'];
45
185
  } & CliConfigurableMarkdownConfig &
46
186
  Partial<MarkdownConfigurableHooks>;
47
187
 
@@ -68,6 +208,9 @@ type UserDefinedChangelogConfig = {
68
208
  customObjectVisibility: string[];
69
209
  exclude: string[];
70
210
  skipIfNoChanges: boolean;
211
+ translations?: UserTranslations['changelog'];
212
+ parallelProcessing?: boolean;
213
+ workerThreads?: number;
71
214
  } & Partial<ChangelogConfigurableHooks>;
72
215
 
73
216
  type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig | UserDefinedChangelogConfig;
@@ -247,4 +390,4 @@ type ConfigurableChangelogConfig = Omit<Partial<UserDefinedChangelogConfig>, 'ta
247
390
  */
248
391
  declare function defineChangelogConfig(config: ConfigurableChangelogConfig): Partial<UserDefinedChangelogConfig>;
249
392
 
250
- export { type ChangeLogPageData, type ChangelogConfigurableHooks, type ConfigurableChangelogConfig, type ConfigurableDocPageData, type ConfigurableDocPageReference, type ConfigurableMarkdownConfig, type ConfigurableOpenApiConfig, type DocPageData, type DocPageReference, type MacroFunction, type MacroSourceMetadata, type MarkdownConfigurableHooks, type ReferenceGuidePageData, type Skip, type SourceChangelog, type TransformChangelogPage, type TransformDocPage, type TransformDocs, type TransformReference, type TransformReferenceGuide, defineChangelogConfig, defineMarkdownConfig, defineOpenApiConfig, process, skip };
393
+ export { type ChangeLogPageData, type ChangelogConfigurableHooks, type ConfigurableChangelogConfig, type ConfigurableDocPageData, type ConfigurableDocPageReference, type ConfigurableMarkdownConfig, type ConfigurableOpenApiConfig, type DocPageData, type DocPageReference, type MacroFunction, type MacroSourceMetadata, type MarkdownConfigurableHooks, type ReferenceGuidePageData, type Skip, type SourceChangelog, type TransformChangelogPage, type TransformDocPage, type TransformDocs, type TransformReference, type TransformReferenceGuide, type Translations, type UserTranslations, defineChangelogConfig, defineMarkdownConfig, defineOpenApiConfig, process, skip };
package/dist/index.js CHANGED
@@ -1,19 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var logger = require('./logger-BiPQ_i9-.js');
3
+ var logger = require('./logger-BbAtfln6.js');
4
4
  var E = require('fp-ts/Either');
5
5
  require('fp-ts/function');
6
6
  require('fp-ts/TaskEither');
7
7
  require('js-yaml');
8
8
  require('path');
9
- require('fp-ts/Task');
10
- require('fp-ts/lib/Array');
11
- require('@cparra/apex-reflection');
12
9
  require('fp-ts/Option');
13
- require('fast-xml-parser');
14
10
  require('handlebars');
15
11
  require('fp-ts/boolean');
12
+ require('fast-xml-parser');
13
+ require('fp-ts/Task');
16
14
  require('fp-ts/Array');
15
+ require('worker_threads');
16
+ require('os');
17
+ require('fp-ts/lib/Array');
18
+ require('@cparra/apex-reflection');
19
+ require('uuid');
17
20
  require('fs');
18
21
  require('fp-ts/lib/TaskEither');
19
22
  require('minimatch');