@cparra/apexdocs 3.12.2 โ 3.14.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 +133 -19
- package/dist/cli/generate.js +141 -19
- package/dist/index.d.ts +148 -5
- package/dist/index.js +1 -1
- package/dist/{logger-B8yR_O0h.js โ logger-D4Q3KA6D.js} +695 -290
- package/package.json +1 -1
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!
|
|
@@ -84,6 +105,12 @@ Run the following command to generate markdown files for your global Salesforce
|
|
|
84
105
|
|
|
85
106
|
```bash
|
|
86
107
|
apexdocs markdown -s force-app
|
|
108
|
+
|
|
109
|
+
# Use sfdx-project.json as the source of directories
|
|
110
|
+
apexdocs markdown --useSfdxProjectJson
|
|
111
|
+
|
|
112
|
+
# Specify multiple source directories
|
|
113
|
+
apexdocs markdown --sourceDirs force-app force-lwc force-utils
|
|
87
114
|
```
|
|
88
115
|
|
|
89
116
|
#### OpenApi
|
|
@@ -111,21 +138,31 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
|
|
|
111
138
|
|
|
112
139
|
#### Flags
|
|
113
140
|
|
|
114
|
-
| Flag
|
|
115
|
-
|
|
116
|
-
| `--sourceDir`
|
|
117
|
-
| `--
|
|
118
|
-
| `--
|
|
119
|
-
| `--
|
|
120
|
-
| `--
|
|
121
|
-
| `--
|
|
122
|
-
| `--
|
|
123
|
-
| `--
|
|
124
|
-
| `--
|
|
125
|
-
| `--
|
|
126
|
-
| `--
|
|
127
|
-
| `--
|
|
128
|
-
| `--
|
|
141
|
+
| Flag | Alias | Description | Default | Required |
|
|
142
|
+
|-----------------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|----------|
|
|
143
|
+
| `--sourceDir` | `-s` | The directory where the source files are located. | N/A | * |
|
|
144
|
+
| `--sourceDirs` | N/A | Multiple source directories (space-separated). Cannot be used with `--sourceDir` or `--useSfdxProjectJson`. | N/A | * |
|
|
145
|
+
| `--useSfdxProjectJson` | N/A | Read source directories from `sfdx-project.json` packageDirectories. Cannot be used with `--sourceDir` or `--sourceDirs`. | `false` | * |
|
|
146
|
+
| `--sfdxProjectPath` | N/A | Path to directory containing `sfdx-project.json` (defaults to current directory). Only used with `--useSfdxProjectJson`. | `process.cwd()` | No |
|
|
147
|
+
| `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
|
|
148
|
+
| `--scope` | `-p` | A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. | `[global]` | No |
|
|
149
|
+
| `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | `[public]` | No |
|
|
150
|
+
| `--defaultGroupName` | N/A | The default group name to use when a group is not specified. | `Miscellaneous` | No |
|
|
151
|
+
| `--namespace` | N/A | The package namespace, if any. If provided, it will be added to the generated files. | N/A | No |
|
|
152
|
+
| `--sortAlphabetically` | N/A | Sorts files appearing in the Reference Guide alphabetically, as well as the members of a class, interface or enum alphabetically. If false, the members will be displayed in the same order as the code. | `false` | No |
|
|
153
|
+
| `--includeMetadata ` | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | `false` | No |
|
|
154
|
+
| `--linkingStrategy` | N/A | The strategy to use when linking to other classes. Possible values are `relative`, `no-link`, and `none` | `relative` | No |
|
|
155
|
+
| `--customObjectsGroupName` | N/A | The name under which custom objects will be grouped in the Reference Guide | `Custom Objects` | No |
|
|
156
|
+
| `--triggersGroupName` | N/A | The name under which triggers will be grouped in the Reference Guide | `Triggers` | No |
|
|
157
|
+
| `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification 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
|
+
|
|
160
|
+
> **Note:** The `*` in the Required column indicates that **one** of the source directory options must be specified:
|
|
161
|
+
> - `--sourceDir` (single directory)
|
|
162
|
+
> - `--sourceDirs` (multiple directories)
|
|
163
|
+
> - `--useSfdxProjectJson` (read from sfdx-project.json)
|
|
164
|
+
>
|
|
165
|
+
> These options are mutually exclusive - you cannot use more than one at the same time.
|
|
129
166
|
|
|
130
167
|
##### Linking Strategy
|
|
131
168
|
|
|
@@ -258,6 +295,12 @@ export default defineMarkdownConfig({
|
|
|
258
295
|
sourceDir: 'force-app',
|
|
259
296
|
targetDir: 'docs',
|
|
260
297
|
scope: ['global', 'public'],
|
|
298
|
+
translations: {
|
|
299
|
+
sections: {
|
|
300
|
+
methods: 'Methods',
|
|
301
|
+
properties: 'Properties',
|
|
302
|
+
},
|
|
303
|
+
},
|
|
261
304
|
...
|
|
262
305
|
});
|
|
263
306
|
```
|
|
@@ -365,7 +408,8 @@ having to copy-paste the same text across multiple classes, polluting your
|
|
|
365
408
|
source code.
|
|
366
409
|
|
|
367
410
|
A macro can be defined in your documentation using the `{{macro_name}}` syntax.
|
|
368
|
-
In the configuration file, you can then define the macro behavior as a key-value pair, where the key is the name of the
|
|
411
|
+
In the configuration file, you can then define the macro behavior as a key-value pair, where the key is the name of the
|
|
412
|
+
macro, and the value is a function that returns the text to inject in place of the macro.
|
|
369
413
|
|
|
370
414
|
**Type**
|
|
371
415
|
|
|
@@ -379,7 +423,8 @@ type MacroSourceMetadata = {
|
|
|
379
423
|
type MacroFunction = (metadata: MacroSourceMetadata) => string;
|
|
380
424
|
```
|
|
381
425
|
|
|
382
|
-
Notice that the `metadata` object contains information about the source of the file for which the macro is being
|
|
426
|
+
Notice that the `metadata` object contains information about the source of the file for which the macro is being
|
|
427
|
+
injected. This allows you to optionally
|
|
383
428
|
return different text based on the source of the file.
|
|
384
429
|
|
|
385
430
|
Example: Injecting a copyright notice
|
|
@@ -402,13 +447,14 @@ And then in your source code, you can use the macro like this:
|
|
|
402
447
|
* @description This is a class
|
|
403
448
|
*/
|
|
404
449
|
public class MyClass {
|
|
405
|
-
|
|
450
|
+
//...
|
|
406
451
|
}
|
|
407
452
|
```
|
|
408
453
|
|
|
409
454
|
##### **transformReferenceGuide**
|
|
410
455
|
|
|
411
|
-
Allows changing the frontmatter and content of the reference guide, or if creating a reference guide page altogether
|
|
456
|
+
Allows changing the frontmatter and content of the reference guide, or if creating a reference guide page altogether
|
|
457
|
+
should be skipped.
|
|
412
458
|
|
|
413
459
|
**Type**
|
|
414
460
|
|
|
@@ -576,6 +622,74 @@ export default {
|
|
|
576
622
|
};
|
|
577
623
|
```
|
|
578
624
|
|
|
625
|
+
## ๐ Translation
|
|
626
|
+
|
|
627
|
+
ApexDocs supports translations to customize the language and terminology used in the generated documentation.
|
|
628
|
+
This feature allows you to:
|
|
629
|
+
|
|
630
|
+
- **Translate documentation to different languages** (Spanish, French, etc.)
|
|
631
|
+
- **Use custom business terminology** (e.g., "Business Operations" instead of "Methods")
|
|
632
|
+
- **Partially override specific terms** while keeping the rest in English
|
|
633
|
+
|
|
634
|
+
### How It Works
|
|
635
|
+
|
|
636
|
+
The translation system uses:
|
|
637
|
+
|
|
638
|
+
- **Default English translations** built into the system
|
|
639
|
+
- **User-provided overrides** that can be partial or complete
|
|
640
|
+
|
|
641
|
+
### Configuration
|
|
642
|
+
|
|
643
|
+
Add a `translations` property to your ApexDocs configuration (JS or TS file) and pass
|
|
644
|
+
the appropriate translation object, depending on the generator you're using:
|
|
645
|
+
|
|
646
|
+
```javascript
|
|
647
|
+
import { defineMarkdownConfig } from '@cparra/apexdocs';
|
|
648
|
+
|
|
649
|
+
export default defineMarkdownConfig({
|
|
650
|
+
sourceDir: 'src',
|
|
651
|
+
targetDir: 'docs',
|
|
652
|
+
scope: ['public', 'global'],
|
|
653
|
+
translations: {
|
|
654
|
+
sections: {
|
|
655
|
+
methods: 'Mรฉtodos',
|
|
656
|
+
properties: 'Propiedades',
|
|
657
|
+
fields: 'Campos',
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
});
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### TypeScript Support
|
|
664
|
+
|
|
665
|
+
For TypeScript projects, import the translation types for better autocomplete and type safety:
|
|
666
|
+
|
|
667
|
+
```typescript
|
|
668
|
+
import { defineMarkdownConfig } from '@cparra/apexdocs';
|
|
669
|
+
import type { UserTranslations } from '@cparra/apexdocs';
|
|
670
|
+
|
|
671
|
+
const markdownTranslations: UserTranslations['markdown'] = {
|
|
672
|
+
sections: {
|
|
673
|
+
methods: 'Functions',
|
|
674
|
+
},
|
|
675
|
+
// ...other translation keys as needed
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
export default defineMarkdownConfig({
|
|
679
|
+
sourceDir: 'src',
|
|
680
|
+
targetDir: 'docs',
|
|
681
|
+
scope: ['public', 'global'],
|
|
682
|
+
translations: markdownTranslations,
|
|
683
|
+
});
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### Notes
|
|
687
|
+
|
|
688
|
+
- Only the **markdown** and **changelog** generators support translations
|
|
689
|
+
- All translations are optional - anything not specified uses the English default
|
|
690
|
+
|
|
691
|
+
For a complete example, see the [translation example](examples/translation/) in this repository.
|
|
692
|
+
|
|
579
693
|
## โคต๏ธ Importing to your project
|
|
580
694
|
|
|
581
695
|
### Reflection
|
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-D4Q3KA6D.js');
|
|
5
5
|
var require$$0 = require('yargs');
|
|
6
6
|
var cosmiconfig = require('cosmiconfig');
|
|
7
7
|
var E = require('fp-ts/Either');
|
|
@@ -43,12 +43,34 @@ function _interopNamespaceDefault(e) {
|
|
|
43
43
|
|
|
44
44
|
var E__namespace = /*#__PURE__*/_interopNamespaceDefault(E);
|
|
45
45
|
|
|
46
|
+
function validateMarkdownArgs(argv) {
|
|
47
|
+
const hasSourceDir = argv.sourceDir && (typeof argv.sourceDir === "string" || Array.isArray(argv.sourceDir) && argv.sourceDir.length > 0);
|
|
48
|
+
const hasUseSfdxProjectJson = argv.useSfdxProjectJson;
|
|
49
|
+
if (!hasSourceDir && !hasUseSfdxProjectJson) {
|
|
50
|
+
throw new Error("Must specify one of: --sourceDir or --useSfdxProjectJson");
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
46
54
|
const markdownOptions = {
|
|
47
55
|
sourceDir: {
|
|
48
56
|
type: "string",
|
|
57
|
+
array: true,
|
|
49
58
|
alias: "s",
|
|
50
|
-
demandOption:
|
|
51
|
-
describe: "The directory location which
|
|
59
|
+
demandOption: false,
|
|
60
|
+
describe: "The directory location(s) which contain your apex .cls classes. Can specify a single directory or multiple directories. Cannot be used with useSfdxProjectJson.",
|
|
61
|
+
conflicts: ["useSfdxProjectJson"]
|
|
62
|
+
},
|
|
63
|
+
useSfdxProjectJson: {
|
|
64
|
+
type: "boolean",
|
|
65
|
+
demandOption: false,
|
|
66
|
+
describe: "Read source directories from sfdx-project.json packageDirectories. Cannot be used with sourceDir.",
|
|
67
|
+
conflicts: ["sourceDir"]
|
|
68
|
+
},
|
|
69
|
+
sfdxProjectPath: {
|
|
70
|
+
type: "string",
|
|
71
|
+
demandOption: false,
|
|
72
|
+
describe: "Path to the directory containing sfdx-project.json (defaults to current working directory). Only used with useSfdxProjectJson.",
|
|
73
|
+
implies: "useSfdxProjectJson"
|
|
52
74
|
},
|
|
53
75
|
targetDir: {
|
|
54
76
|
type: "string",
|
|
@@ -122,12 +144,34 @@ const markdownOptions = {
|
|
|
122
144
|
}
|
|
123
145
|
};
|
|
124
146
|
|
|
147
|
+
function validateOpenApiArgs(argv) {
|
|
148
|
+
const hasSourceDir = argv.sourceDir && (typeof argv.sourceDir === "string" || Array.isArray(argv.sourceDir) && argv.sourceDir.length > 0);
|
|
149
|
+
const hasUseSfdxProjectJson = argv.useSfdxProjectJson;
|
|
150
|
+
if (!hasSourceDir && !hasUseSfdxProjectJson) {
|
|
151
|
+
throw new Error("Must specify one of: --sourceDir or --useSfdxProjectJson");
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
125
155
|
const openApiOptions = {
|
|
126
156
|
sourceDir: {
|
|
127
157
|
type: "string",
|
|
158
|
+
array: true,
|
|
128
159
|
alias: "s",
|
|
129
|
-
demandOption:
|
|
130
|
-
describe: "The directory location which
|
|
160
|
+
demandOption: false,
|
|
161
|
+
describe: "The directory location(s) which contain your apex .cls classes. Can specify a single directory or multiple directories. Cannot be used with useSfdxProjectJson.",
|
|
162
|
+
conflicts: ["useSfdxProjectJson"]
|
|
163
|
+
},
|
|
164
|
+
useSfdxProjectJson: {
|
|
165
|
+
type: "boolean",
|
|
166
|
+
demandOption: false,
|
|
167
|
+
describe: "Read source directories from sfdx-project.json packageDirectories. Cannot be used with sourceDir.",
|
|
168
|
+
conflicts: ["sourceDir"]
|
|
169
|
+
},
|
|
170
|
+
sfdxProjectPath: {
|
|
171
|
+
type: "string",
|
|
172
|
+
demandOption: false,
|
|
173
|
+
describe: "Path to the directory containing sfdx-project.json (defaults to current working directory). Only used with useSfdxProjectJson.",
|
|
174
|
+
implies: "useSfdxProjectJson"
|
|
131
175
|
},
|
|
132
176
|
targetDir: {
|
|
133
177
|
type: "string",
|
|
@@ -156,18 +200,31 @@ const openApiOptions = {
|
|
|
156
200
|
}
|
|
157
201
|
};
|
|
158
202
|
|
|
203
|
+
function validateChangelogArgs(argv) {
|
|
204
|
+
const hasPreviousVersionDir = argv.previousVersionDir && (typeof argv.previousVersionDir === "string" || Array.isArray(argv.previousVersionDir) && argv.previousVersionDir.length > 0);
|
|
205
|
+
const hasCurrentVersionDir = argv.currentVersionDir && (typeof argv.currentVersionDir === "string" || Array.isArray(argv.currentVersionDir) && argv.currentVersionDir.length > 0);
|
|
206
|
+
if (!hasPreviousVersionDir) {
|
|
207
|
+
throw new Error("Must specify --previousVersionDir");
|
|
208
|
+
}
|
|
209
|
+
if (!hasCurrentVersionDir) {
|
|
210
|
+
throw new Error("Must specify --currentVersionDir");
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
159
214
|
const changeLogOptions = {
|
|
160
215
|
previousVersionDir: {
|
|
161
216
|
type: "string",
|
|
217
|
+
array: true,
|
|
162
218
|
alias: "p",
|
|
163
|
-
demandOption:
|
|
164
|
-
describe: "The directory location of the previous version of the source code."
|
|
219
|
+
demandOption: false,
|
|
220
|
+
describe: "The directory location(s) of the previous version of the source code. Can specify a single directory or multiple directories."
|
|
165
221
|
},
|
|
166
222
|
currentVersionDir: {
|
|
167
223
|
type: "string",
|
|
224
|
+
array: true,
|
|
168
225
|
alias: "c",
|
|
169
|
-
demandOption:
|
|
170
|
-
describe: "The directory location of the current version of the source code."
|
|
226
|
+
demandOption: false,
|
|
227
|
+
describe: "The directory location(s) of the current version of the source code. Can specify a single directory or multiple directories."
|
|
171
228
|
},
|
|
172
229
|
targetDir: {
|
|
173
230
|
type: "string",
|
|
@@ -297,11 +354,23 @@ function extractArgsForCommandProvidedThroughCli(extractFromProcessFn, config) {
|
|
|
297
354
|
const mergedConfig = __spreadProps(__spreadValues(__spreadValues({}, config.config), cliArgs), { targetGenerator: commandName });
|
|
298
355
|
switch (mergedConfig.targetGenerator) {
|
|
299
356
|
case "markdown":
|
|
300
|
-
return
|
|
357
|
+
return _function.pipe(
|
|
358
|
+
logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
|
|
359
|
+
E__namespace.mapLeft((error) => new Error(`Invalid markdown configuration: ${error.message}`)),
|
|
360
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), mergedConfig))
|
|
361
|
+
);
|
|
301
362
|
case "openapi":
|
|
302
|
-
return
|
|
363
|
+
return _function.pipe(
|
|
364
|
+
logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
|
|
365
|
+
E__namespace.mapLeft((error) => new Error(`Invalid openapi configuration: ${error.message}`)),
|
|
366
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), mergedConfig))
|
|
367
|
+
);
|
|
303
368
|
case "changelog":
|
|
304
|
-
return
|
|
369
|
+
return _function.pipe(
|
|
370
|
+
validateChangelogConfig(mergedConfig),
|
|
371
|
+
E__namespace.mapLeft((error) => new Error(`Invalid changelog configuration: ${error.message}`)),
|
|
372
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyChangelogDefaults), mergedConfig))
|
|
373
|
+
);
|
|
305
374
|
default:
|
|
306
375
|
return E__namespace.left(new Error(`Invalid command provided: ${mergedConfig.targetGenerator}`));
|
|
307
376
|
}
|
|
@@ -317,12 +386,26 @@ function extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config) {
|
|
|
317
386
|
E__namespace.map((cliArgs) => {
|
|
318
387
|
return cliArgs;
|
|
319
388
|
}),
|
|
320
|
-
E__namespace.
|
|
389
|
+
E__namespace.flatMap((cliArgs) => {
|
|
390
|
+
const mergedConfig = __spreadValues(__spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), generatorConfig), cliArgs);
|
|
391
|
+
return _function.pipe(
|
|
392
|
+
logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
|
|
393
|
+
E__namespace.mapLeft((error) => new Error(`Invalid markdown configuration: ${error.message}`)),
|
|
394
|
+
E__namespace.map(() => mergedConfig)
|
|
395
|
+
);
|
|
396
|
+
})
|
|
321
397
|
);
|
|
322
398
|
case "openapi":
|
|
323
399
|
return _function.pipe(
|
|
324
400
|
extractMultiCommandConfig(extractFromProcessFn, "openapi", generatorConfig),
|
|
325
|
-
E__namespace.
|
|
401
|
+
E__namespace.flatMap((cliArgs) => {
|
|
402
|
+
const mergedConfig = __spreadValues(__spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), generatorConfig), cliArgs);
|
|
403
|
+
return _function.pipe(
|
|
404
|
+
logger$1.validateSourceDirectoryConfig(extractSourceDirectoryConfig(mergedConfig)),
|
|
405
|
+
E__namespace.mapLeft((error) => new Error(`Invalid openapi configuration: ${error.message}`)),
|
|
406
|
+
E__namespace.map(() => mergedConfig)
|
|
407
|
+
);
|
|
408
|
+
})
|
|
326
409
|
);
|
|
327
410
|
case "changelog":
|
|
328
411
|
return _function.pipe(
|
|
@@ -330,7 +413,14 @@ function extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config) {
|
|
|
330
413
|
E__namespace.map((cliArgs) => {
|
|
331
414
|
return cliArgs;
|
|
332
415
|
}),
|
|
333
|
-
E__namespace.
|
|
416
|
+
E__namespace.flatMap((cliArgs) => {
|
|
417
|
+
const mergedConfig = __spreadValues(__spreadValues(__spreadValues({}, configOnlyChangelogDefaults), generatorConfig), cliArgs);
|
|
418
|
+
return _function.pipe(
|
|
419
|
+
validateChangelogConfig(mergedConfig),
|
|
420
|
+
E__namespace.mapLeft((error) => new Error(`Invalid changelog configuration: ${error.message}`)),
|
|
421
|
+
E__namespace.map(() => mergedConfig)
|
|
422
|
+
);
|
|
423
|
+
})
|
|
334
424
|
);
|
|
335
425
|
}
|
|
336
426
|
});
|
|
@@ -360,15 +450,15 @@ function extractYargsDemandingCommand(extractFromProcessFn, config) {
|
|
|
360
450
|
return yargs.config(config.config).command(
|
|
361
451
|
"markdown",
|
|
362
452
|
"Generate documentation from Apex classes as a Markdown site.",
|
|
363
|
-
(yargs2) => yargs2.options(markdownOptions)
|
|
453
|
+
(yargs2) => yargs2.options(markdownOptions).check(validateMarkdownArgs)
|
|
364
454
|
).command(
|
|
365
455
|
"openapi",
|
|
366
456
|
"Generate an OpenApi REST specification from Apex classes.",
|
|
367
|
-
() =>
|
|
457
|
+
(yargs2) => yargs2.options(openApiOptions).check(validateOpenApiArgs)
|
|
368
458
|
).command(
|
|
369
459
|
"changelog",
|
|
370
460
|
"Generate a changelog from 2 versions of the source code.",
|
|
371
|
-
() =>
|
|
461
|
+
(yargs2) => yargs2.options(changeLogOptions).check(validateChangelogArgs)
|
|
372
462
|
).demandCommand().parseSync(extractFromProcessFn());
|
|
373
463
|
}
|
|
374
464
|
function extractMultiCommandConfig(extractFromProcessFn, command, config) {
|
|
@@ -382,13 +472,45 @@ function extractMultiCommandConfig(extractFromProcessFn, command, config) {
|
|
|
382
472
|
return changeLogOptions;
|
|
383
473
|
}
|
|
384
474
|
}
|
|
475
|
+
function getValidationFunction(generator) {
|
|
476
|
+
switch (generator) {
|
|
477
|
+
case "markdown":
|
|
478
|
+
return validateMarkdownArgs;
|
|
479
|
+
case "openapi":
|
|
480
|
+
return validateOpenApiArgs;
|
|
481
|
+
case "changelog":
|
|
482
|
+
return validateChangelogArgs;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
385
485
|
const options = getOptions(command);
|
|
486
|
+
const validator = getValidationFunction(command);
|
|
386
487
|
return E__namespace.tryCatch(() => {
|
|
387
|
-
return yargs(extractFromProcessFn()).config(config).options(options).fail((msg) => {
|
|
488
|
+
return yargs(extractFromProcessFn()).config(config).options(options).check(validator).fail((msg) => {
|
|
388
489
|
throw new Error(`Invalid configuration for command "${command}": ${msg}`);
|
|
389
490
|
}).parseSync();
|
|
390
491
|
}, E__namespace.toError);
|
|
391
492
|
}
|
|
493
|
+
function extractSourceDirectoryConfig(config) {
|
|
494
|
+
return {
|
|
495
|
+
sourceDir: config.sourceDir,
|
|
496
|
+
useSfdxProjectJson: config.useSfdxProjectJson,
|
|
497
|
+
sfdxProjectPath: config.sfdxProjectPath
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function validateChangelogConfig(config) {
|
|
501
|
+
const previousVersionConfig = {
|
|
502
|
+
sourceDir: config.previousVersionDir
|
|
503
|
+
};
|
|
504
|
+
const currentVersionConfig = {
|
|
505
|
+
sourceDir: config.currentVersionDir
|
|
506
|
+
};
|
|
507
|
+
return _function.pipe(
|
|
508
|
+
E__namespace.Do,
|
|
509
|
+
E__namespace.bind("previousValid", () => logger$1.validateSourceDirectoryConfig(previousVersionConfig)),
|
|
510
|
+
E__namespace.bind("currentValid", () => logger$1.validateSourceDirectoryConfig(currentVersionConfig)),
|
|
511
|
+
E__namespace.map(() => config)
|
|
512
|
+
);
|
|
513
|
+
}
|
|
392
514
|
|
|
393
515
|
var __async = (__this, __arguments, generator) => {
|
|
394
516
|
return new Promise((resolve, reject) => {
|
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 =
|
|
@@ -20,7 +157,9 @@ type MacroSourceMetadata = {
|
|
|
20
157
|
type MacroFunction = (metadata: MacroSourceMetadata) => string;
|
|
21
158
|
|
|
22
159
|
type CliConfigurableMarkdownConfig = {
|
|
23
|
-
sourceDir
|
|
160
|
+
sourceDir?: string | string[];
|
|
161
|
+
useSfdxProjectJson?: boolean;
|
|
162
|
+
sfdxProjectPath?: string;
|
|
24
163
|
targetDir: string;
|
|
25
164
|
scope: string[];
|
|
26
165
|
customObjectVisibility: string[];
|
|
@@ -40,12 +179,15 @@ type UserDefinedMarkdownConfig = {
|
|
|
40
179
|
targetGenerator: 'markdown';
|
|
41
180
|
excludeTags: string[];
|
|
42
181
|
exclude: string[];
|
|
182
|
+
translations?: UserTranslations['markdown'];
|
|
43
183
|
} & CliConfigurableMarkdownConfig &
|
|
44
184
|
Partial<MarkdownConfigurableHooks>;
|
|
45
185
|
|
|
46
186
|
type UserDefinedOpenApiConfig = {
|
|
47
187
|
targetGenerator: 'openapi';
|
|
48
|
-
sourceDir
|
|
188
|
+
sourceDir?: string | string[];
|
|
189
|
+
useSfdxProjectJson?: boolean;
|
|
190
|
+
sfdxProjectPath?: string;
|
|
49
191
|
targetDir: string;
|
|
50
192
|
fileName: string;
|
|
51
193
|
namespace?: string;
|
|
@@ -56,14 +198,15 @@ type UserDefinedOpenApiConfig = {
|
|
|
56
198
|
|
|
57
199
|
type UserDefinedChangelogConfig = {
|
|
58
200
|
targetGenerator: 'changelog';
|
|
59
|
-
previousVersionDir
|
|
60
|
-
currentVersionDir
|
|
201
|
+
previousVersionDir?: string | string[];
|
|
202
|
+
currentVersionDir?: string | string[];
|
|
61
203
|
targetDir: string;
|
|
62
204
|
fileName: string;
|
|
63
205
|
scope: string[];
|
|
64
206
|
customObjectVisibility: string[];
|
|
65
207
|
exclude: string[];
|
|
66
208
|
skipIfNoChanges: boolean;
|
|
209
|
+
translations?: UserTranslations['changelog'];
|
|
67
210
|
} & Partial<ChangelogConfigurableHooks>;
|
|
68
211
|
|
|
69
212
|
type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig | UserDefinedChangelogConfig;
|
|
@@ -243,4 +386,4 @@ type ConfigurableChangelogConfig = Omit<Partial<UserDefinedChangelogConfig>, 'ta
|
|
|
243
386
|
*/
|
|
244
387
|
declare function defineChangelogConfig(config: ConfigurableChangelogConfig): Partial<UserDefinedChangelogConfig>;
|
|
245
388
|
|
|
246
|
-
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 };
|
|
389
|
+
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 };
|