@cparra/apexdocs 3.1.1 → 3.2.1
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 +87 -3
- package/dist/cli/generate.js +205 -37
- package/dist/index.d.ts +32 -7
- package/dist/index.js +58 -32
- package/dist/logger-B2A8nHRs.js +3606 -0
- package/dist/logger-B5u-6nWE.js +3591 -0
- package/dist/logger-BXUC1ahq.js +3286 -0
- package/dist/logger-BcdDreNr.js +3530 -0
- package/dist/logger-BfBICfFT.js +3563 -0
- package/dist/logger-Bgcwkvk-.js +3285 -0
- package/dist/logger-BkOBDUBk.js +3285 -0
- package/dist/logger-Bzta93eQ.js +3585 -0
- package/dist/logger-CI-X0fAY.js +3557 -0
- package/dist/logger-CJkeJmPo.js +3587 -0
- package/dist/logger-CWGrKpqK.js +3563 -0
- package/dist/logger-Caah2QkF.js +3655 -0
- package/dist/logger-CnilRXR3.js +3582 -0
- package/dist/logger-Co5Tpv_S.js +3590 -0
- package/dist/logger-DACnhhgx.js +3556 -0
- package/dist/logger-DIyKhj0a.js +3658 -0
- package/dist/logger-DQcjS-4R.js +3551 -0
- package/dist/logger-DY_QM8Kh.js +3284 -0
- package/dist/logger-DiWszgHt.js +3559 -0
- package/dist/logger-azR-eh1k.js +3290 -0
- package/dist/logger-sq_8g3m0.js +3286 -0
- package/dist/logger-ym_OFInF.js +3582 -0
- package/dist/logger-zIT1H0bw.js +3595 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -41,10 +41,19 @@ annotated with `@RestResource`:
|
|
|
41
41
|
apexdocs openapi -s force-app
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
#### Changelog
|
|
45
|
+
|
|
46
|
+
Run the following command to generate a changelog for your Salesforce Apex classes:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir force-app
|
|
50
|
+
```
|
|
51
|
+
|
|
44
52
|
## 🚀 Features
|
|
45
53
|
|
|
46
54
|
* Generate documentation for Salesforce Apex classes as Markdown files
|
|
47
55
|
* Generate an OpenApi REST specification based on `@RestResource` classes
|
|
56
|
+
* Generate a changelog based on the differences between two versions of your Salesforce Apex classes
|
|
48
57
|
* Support for grouping blocks of related code within a class
|
|
49
58
|
* Support for ignoring files and members from being documented
|
|
50
59
|
* Namespace support
|
|
@@ -146,6 +155,28 @@ apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n M
|
|
|
146
155
|
apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi Title"
|
|
147
156
|
```
|
|
148
157
|
|
|
158
|
+
### Changelog
|
|
159
|
+
|
|
160
|
+
`changelog`
|
|
161
|
+
|
|
162
|
+
#### Flags
|
|
163
|
+
|
|
164
|
+
| Flag | Alias | Description | Default | Required |
|
|
165
|
+
|------------------------|-------|--------------------------------------------------------------------|-------------|----------|
|
|
166
|
+
| `--previousVersionDir` | `-p` | The directory location of the previous version of the source code. | N/A | Yes |
|
|
167
|
+
| `--currentVersionDir` | `-t` | The directory location of the current version of the source code. | N/A | Yes |
|
|
168
|
+
| `--targetDir` | `-t` | The directory location where the changelog file will be generated. | `./docs/` | No |
|
|
169
|
+
| `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
|
|
170
|
+
| `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
|
|
171
|
+
|
|
172
|
+
#### Sample Usage
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
apexdocs changelog -p force-app-previous -t force-app
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
149
180
|
## 🔬 Defining a configuration file
|
|
150
181
|
|
|
151
182
|
You can also use a configuration file to define the parameters that will be used when generating the documentation.
|
|
@@ -187,7 +218,7 @@ CLI will be used, or the default value will be used.
|
|
|
187
218
|
|
|
188
219
|
### Config Intellisense
|
|
189
220
|
|
|
190
|
-
Using the `defineMarkdownConfig` (or the `defineOpenApiConfig` for OpenApi documentation)
|
|
221
|
+
Using the `defineMarkdownConfig` (or the `defineOpenApiConfig` for OpenApi documentation)
|
|
191
222
|
helper will provide Typescript-powered intellisense
|
|
192
223
|
for the configuration file options. This should work with both Javascript and Typescript files.
|
|
193
224
|
|
|
@@ -202,8 +233,44 @@ export default defineMarkdownConfig({
|
|
|
202
233
|
});
|
|
203
234
|
```
|
|
204
235
|
|
|
236
|
+
### Generating Different Types of Documentation
|
|
237
|
+
|
|
238
|
+
You might want to generate different types of documentation using a single command. For example, if you are releasing
|
|
239
|
+
a new version of your project, you might want to generate updated documentation Markdown files, and at the
|
|
240
|
+
same time generate a changelog listing everything new.
|
|
241
|
+
|
|
242
|
+
You can do this by providing a configuration file that exports a configuration object which keys are the type of
|
|
243
|
+
documentation you want to generate.
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { defineMarkdownConfig, defineChangelogConfig } from '@cparra/apexdocs';
|
|
247
|
+
|
|
248
|
+
export default {
|
|
249
|
+
markdown: defineMarkdownConfig({
|
|
250
|
+
sourceDir: 'force-app',
|
|
251
|
+
targetDir: 'docs',
|
|
252
|
+
scope: ['global', 'public'],
|
|
253
|
+
...
|
|
254
|
+
}),
|
|
255
|
+
changelog: defineChangelogConfig({
|
|
256
|
+
previousVersionDir: 'force-app-previous',
|
|
257
|
+
currentVersionDir: 'force-app',
|
|
258
|
+
targetDir: 'docs',
|
|
259
|
+
scope: ['global', 'public'],
|
|
260
|
+
})
|
|
261
|
+
};
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Then you only need to run the top level `apexdocs` command, and it will generate both types of documentation.
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
apexdocs
|
|
268
|
+
```
|
|
269
|
+
|
|
205
270
|
### Excluding Tags from Appearing in the Documentation
|
|
206
271
|
|
|
272
|
+
Note: Only works for Markdown documentation.
|
|
273
|
+
|
|
207
274
|
You can exclude tags from appearing in the documentation by using the `excludeTags` property in the configuration file,
|
|
208
275
|
which allow you to pass a list of tags that you want to exclude from the documentation.
|
|
209
276
|
|
|
@@ -219,6 +286,23 @@ export default defineMarkdownConfig({
|
|
|
219
286
|
});
|
|
220
287
|
```
|
|
221
288
|
|
|
289
|
+
### Excluding Files from Being Documented
|
|
290
|
+
|
|
291
|
+
You can exclude one or multiple files from being documented by providing a list of glob patterns to
|
|
292
|
+
the `exclude` property in the configuration file.
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { defineMarkdownConfig } from "@cparra/apexdocs";
|
|
296
|
+
|
|
297
|
+
export default defineMarkdownConfig({
|
|
298
|
+
sourceDir: 'force-app',
|
|
299
|
+
targetDir: 'docs',
|
|
300
|
+
scope: ['global', 'public'],
|
|
301
|
+
exclude: ['**/MyClass.cls', '**/MyOtherClass.cls'],
|
|
302
|
+
...
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
222
306
|
### Configuration Hooks
|
|
223
307
|
|
|
224
308
|
When defining a `.js` or `.ts` configuration file, your object export can also make use
|
|
@@ -370,12 +454,12 @@ If using Typescript, ApexDocs provides all necessary type definitions.
|
|
|
370
454
|
|
|
371
455
|
## 📖 Documentation Guide
|
|
372
456
|
|
|
373
|
-
See the [wiki](https://github.com/cesarParra/apexdocs/wiki
|
|
457
|
+
See the [wiki](https://github.com/cesarParra/apexdocs/wiki/2.-%F0%9F%93%96-Documenting-Apex-code)
|
|
374
458
|
for an in-depth guide on how to document your Apex code to get the most out of ApexDocs.
|
|
375
459
|
|
|
376
460
|
## 📄 Generating OpenApi REST Definitions
|
|
377
461
|
|
|
378
462
|
ApexDocs can also generate OpenApi REST definitions for your Salesforce Apex classes annotated with `@RestResource`.
|
|
379
463
|
|
|
380
|
-
See the [wiki](https://github.com/cesarParra/apexdocs/wiki
|
|
464
|
+
See the [wiki](https://github.com/cesarParra/apexdocs/wiki/3.-%F0%9F%93%84-Generating-OpenApi-REST-Definitions)
|
|
381
465
|
for more information.
|
package/dist/cli/generate.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var logger$1 = require('../logger-
|
|
4
|
+
var logger$1 = require('../logger-DIyKhj0a.js');
|
|
5
5
|
var cosmiconfig = require('cosmiconfig');
|
|
6
6
|
var yargs = require('yargs');
|
|
7
|
-
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
|
|
8
7
|
var E = require('fp-ts/Either');
|
|
9
|
-
require('
|
|
8
|
+
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
|
|
9
|
+
var _function = require('fp-ts/function');
|
|
10
10
|
require('fp-ts/TaskEither');
|
|
11
11
|
require('js-yaml');
|
|
12
12
|
require('path');
|
|
@@ -19,6 +19,7 @@ require('handlebars');
|
|
|
19
19
|
require('fp-ts/boolean');
|
|
20
20
|
require('fs');
|
|
21
21
|
require('fp-ts/lib/TaskEither');
|
|
22
|
+
require('minimatch');
|
|
22
23
|
require('chalk');
|
|
23
24
|
|
|
24
25
|
function _interopNamespaceDefault(e) {
|
|
@@ -103,7 +104,7 @@ const openApiOptions = {
|
|
|
103
104
|
targetDir: {
|
|
104
105
|
type: "string",
|
|
105
106
|
alias: "t",
|
|
106
|
-
default: logger$1.
|
|
107
|
+
default: logger$1.openApiDefaults.targetDir,
|
|
107
108
|
describe: "The directory location where the OpenApi file will be generated."
|
|
108
109
|
},
|
|
109
110
|
fileName: {
|
|
@@ -127,6 +128,39 @@ const openApiOptions = {
|
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
130
|
|
|
131
|
+
const changeLogOptions = {
|
|
132
|
+
previousVersionDir: {
|
|
133
|
+
type: "string",
|
|
134
|
+
alias: "p",
|
|
135
|
+
demandOption: true,
|
|
136
|
+
describe: "The directory location of the previous version of the source code."
|
|
137
|
+
},
|
|
138
|
+
currentVersionDir: {
|
|
139
|
+
type: "string",
|
|
140
|
+
alias: "c",
|
|
141
|
+
demandOption: true,
|
|
142
|
+
describe: "The directory location of the current version of the source code."
|
|
143
|
+
},
|
|
144
|
+
targetDir: {
|
|
145
|
+
type: "string",
|
|
146
|
+
alias: "t",
|
|
147
|
+
default: logger$1.changeLogDefaults.targetDir,
|
|
148
|
+
describe: "The directory location where the changelog file will be generated."
|
|
149
|
+
},
|
|
150
|
+
fileName: {
|
|
151
|
+
type: "string",
|
|
152
|
+
default: logger$1.changeLogDefaults.fileName,
|
|
153
|
+
describe: "The name of the changelog file to be generated."
|
|
154
|
+
},
|
|
155
|
+
scope: {
|
|
156
|
+
type: "string",
|
|
157
|
+
array: true,
|
|
158
|
+
alias: "s",
|
|
159
|
+
default: logger$1.changeLogDefaults.scope,
|
|
160
|
+
describe: "The list of scope to respect when generating the changelog. Values should be separated by a space, e.g --scope global public namespaceaccessible. Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled."
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
130
164
|
var __defProp = Object.defineProperty;
|
|
131
165
|
var __defProps = Object.defineProperties;
|
|
132
166
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -146,7 +180,7 @@ var __spreadValues = (a, b) => {
|
|
|
146
180
|
return a;
|
|
147
181
|
};
|
|
148
182
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
149
|
-
var __async = (__this, __arguments, generator) => {
|
|
183
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
150
184
|
return new Promise((resolve, reject) => {
|
|
151
185
|
var fulfilled = (value) => {
|
|
152
186
|
try {
|
|
@@ -166,18 +200,114 @@ var __async = (__this, __arguments, generator) => {
|
|
|
166
200
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
167
201
|
});
|
|
168
202
|
};
|
|
169
|
-
const
|
|
170
|
-
|
|
203
|
+
const configOnlyMarkdownDefaults = {
|
|
204
|
+
targetGenerator: "markdown",
|
|
205
|
+
excludeTags: [],
|
|
206
|
+
exclude: []
|
|
207
|
+
};
|
|
208
|
+
const configOnlyOpenApiDefaults = {
|
|
209
|
+
targetGenerator: "openapi",
|
|
210
|
+
exclude: []
|
|
211
|
+
};
|
|
212
|
+
const configOnlyChangelogDefaults = {
|
|
213
|
+
targetGenerator: "changelog",
|
|
214
|
+
exclude: []
|
|
171
215
|
};
|
|
172
|
-
function
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
216
|
+
function getArgumentsFromProcess() {
|
|
217
|
+
return process.argv.slice(2);
|
|
218
|
+
}
|
|
219
|
+
function extractConfigFromPackageJsonOrFile() {
|
|
220
|
+
return __async$1(this, null, function* () {
|
|
221
|
+
var _a;
|
|
222
|
+
const result = yield cosmiconfig.cosmiconfig("apexdocs", {
|
|
223
|
+
loaders: {
|
|
224
|
+
".ts": cosmiconfigTypescriptLoader.TypeScriptLoader()
|
|
225
|
+
}
|
|
226
|
+
}).search();
|
|
227
|
+
return { config: (_a = result == null ? void 0 : result.config) != null ? _a : {} };
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function extractArgs() {
|
|
231
|
+
return __async$1(this, arguments, function* (extractFromProcessFn = getArgumentsFromProcess, extractConfigFn = extractConfigFromPackageJsonOrFile) {
|
|
232
|
+
const config = yield extractConfigFn();
|
|
233
|
+
function handle(configType) {
|
|
234
|
+
switch (configType._type) {
|
|
235
|
+
case "no-config":
|
|
236
|
+
case "single-command-config":
|
|
237
|
+
return handleSingleCommand(extractFromProcessFn, config);
|
|
238
|
+
case "multi-command-config":
|
|
239
|
+
return extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config.config);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return _function.pipe(getConfigType(config), E__namespace.flatMap(handle));
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function handleSingleCommand(extractFromProcessFn, config) {
|
|
246
|
+
return _function.pipe(
|
|
247
|
+
E__namespace.right(config),
|
|
248
|
+
E__namespace.flatMap((config2) => extractArgsForCommandProvidedThroughCli(extractFromProcessFn, config2)),
|
|
249
|
+
E__namespace.map((config2) => [config2])
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
function extractArgsForCommandProvidedThroughCli(extractFromProcessFn, config) {
|
|
253
|
+
const cliArgs = extractYargsDemandingCommand(extractFromProcessFn, config);
|
|
254
|
+
const commandName = cliArgs._[0];
|
|
255
|
+
const mergedConfig = __spreadProps(__spreadValues(__spreadValues({}, config.config), cliArgs), { targetGenerator: commandName });
|
|
256
|
+
switch (mergedConfig.targetGenerator) {
|
|
257
|
+
case "markdown":
|
|
258
|
+
return E__namespace.right(__spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), mergedConfig));
|
|
259
|
+
case "openapi":
|
|
260
|
+
return E__namespace.right(__spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), mergedConfig));
|
|
261
|
+
case "changelog":
|
|
262
|
+
return E__namespace.right(__spreadValues(__spreadValues({}, configOnlyChangelogDefaults), mergedConfig));
|
|
263
|
+
default:
|
|
264
|
+
return E__namespace.left(new Error(`Invalid command provided: ${mergedConfig.targetGenerator}`));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function extractArgsForCommandsProvidedInConfig(extractFromProcessFn, config) {
|
|
268
|
+
const configs = Object.entries(config).map(([generator, generatorConfig]) => {
|
|
269
|
+
switch (generator) {
|
|
270
|
+
case "markdown":
|
|
271
|
+
return _function.pipe(
|
|
272
|
+
validateMultiCommandConfig(extractFromProcessFn, "markdown", generatorConfig),
|
|
273
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyMarkdownDefaults), generatorConfig))
|
|
274
|
+
);
|
|
275
|
+
case "openapi":
|
|
276
|
+
return _function.pipe(
|
|
277
|
+
validateMultiCommandConfig(extractFromProcessFn, "openapi", generatorConfig),
|
|
278
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyOpenApiDefaults), generatorConfig))
|
|
279
|
+
);
|
|
280
|
+
case "changelog":
|
|
281
|
+
return _function.pipe(
|
|
282
|
+
validateMultiCommandConfig(extractFromProcessFn, "changelog", generatorConfig),
|
|
283
|
+
E__namespace.map(() => __spreadValues(__spreadValues({}, configOnlyChangelogDefaults), generatorConfig))
|
|
284
|
+
);
|
|
176
285
|
}
|
|
177
|
-
})
|
|
286
|
+
});
|
|
287
|
+
return E__namespace.sequenceArray(configs);
|
|
288
|
+
}
|
|
289
|
+
function getConfigType(config) {
|
|
290
|
+
if (!config) {
|
|
291
|
+
return E__namespace.right({ _type: "no-config" });
|
|
292
|
+
}
|
|
293
|
+
const rootKeys = Object.keys(config.config);
|
|
294
|
+
const validRootKeys = ["markdown", "openapi", "changelog"];
|
|
295
|
+
const containsAnyValidRootKey = rootKeys.some((key) => validRootKeys.includes(key));
|
|
296
|
+
if (containsAnyValidRootKey) {
|
|
297
|
+
const commands = rootKeys.filter((key) => validRootKeys.includes(key));
|
|
298
|
+
const hasInvalidCommands = rootKeys.some((key) => !validRootKeys.includes(key));
|
|
299
|
+
if (hasInvalidCommands) {
|
|
300
|
+
return E__namespace.left(new Error(`Invalid command(s) provided in the configuration file: ${rootKeys}`));
|
|
301
|
+
}
|
|
302
|
+
return E__namespace.right({
|
|
303
|
+
_type: "multi-command-config",
|
|
304
|
+
commands
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return E__namespace.right({ _type: "single-command-config" });
|
|
178
308
|
}
|
|
179
|
-
function
|
|
180
|
-
return yargs__namespace.config(config
|
|
309
|
+
function extractYargsDemandingCommand(extractFromProcessFn, config) {
|
|
310
|
+
return yargs__namespace.config(config.config).command(
|
|
181
311
|
"markdown",
|
|
182
312
|
"Generate documentation from Apex classes as a Markdown site.",
|
|
183
313
|
(yargs2) => yargs2.options(markdownOptions)
|
|
@@ -185,39 +315,77 @@ function _extractYargs(config) {
|
|
|
185
315
|
"openapi",
|
|
186
316
|
"Generate an OpenApi REST specification from Apex classes.",
|
|
187
317
|
() => yargs__namespace.options(openApiOptions)
|
|
188
|
-
).
|
|
318
|
+
).command(
|
|
319
|
+
"changelog",
|
|
320
|
+
"Generate a changelog from 2 versions of the source code.",
|
|
321
|
+
() => yargs__namespace.options(changeLogOptions)
|
|
322
|
+
).demandCommand().parseSync(extractFromProcessFn());
|
|
189
323
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return mergedConfig;
|
|
324
|
+
function validateMultiCommandConfig(extractFromProcessFn, command, config) {
|
|
325
|
+
function getOptions(generator) {
|
|
326
|
+
switch (generator) {
|
|
327
|
+
case "markdown":
|
|
328
|
+
return markdownOptions;
|
|
329
|
+
case "openapi":
|
|
330
|
+
return openApiOptions;
|
|
331
|
+
case "changelog":
|
|
332
|
+
return changeLogOptions;
|
|
200
333
|
}
|
|
201
|
-
}
|
|
334
|
+
}
|
|
335
|
+
const options = getOptions(command);
|
|
336
|
+
return E__namespace.tryCatch(() => {
|
|
337
|
+
yargs__namespace.config(config).options(options).check((argv) => {
|
|
338
|
+
if (argv._.length > 0) {
|
|
339
|
+
throw new Error(
|
|
340
|
+
`Unexpected command "${argv._[0]}".
|
|
341
|
+
The command name should be provided in the configuration when using the current configuration format.`
|
|
342
|
+
);
|
|
343
|
+
} else {
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
}).fail((msg) => {
|
|
347
|
+
throw new Error(`Invalid configuration for command "${command}": ${msg}`);
|
|
348
|
+
}).parse(extractFromProcessFn());
|
|
349
|
+
}, E__namespace.toError);
|
|
202
350
|
}
|
|
203
351
|
|
|
352
|
+
var __async = (__this, __arguments, generator) => {
|
|
353
|
+
return new Promise((resolve, reject) => {
|
|
354
|
+
var fulfilled = (value) => {
|
|
355
|
+
try {
|
|
356
|
+
step(generator.next(value));
|
|
357
|
+
} catch (e) {
|
|
358
|
+
reject(e);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var rejected = (value) => {
|
|
362
|
+
try {
|
|
363
|
+
step(generator.throw(value));
|
|
364
|
+
} catch (e) {
|
|
365
|
+
reject(e);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
369
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
370
|
+
});
|
|
371
|
+
};
|
|
204
372
|
const logger = new logger$1.StdOutLogger();
|
|
205
373
|
function main() {
|
|
206
374
|
function parseResult(result) {
|
|
207
|
-
E__namespace.match(
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
process.exit(1);
|
|
211
|
-
},
|
|
212
|
-
(successMessage) => {
|
|
213
|
-
logger.logSingle(successMessage);
|
|
214
|
-
}
|
|
215
|
-
)(result);
|
|
375
|
+
E__namespace.match(catchUnexpectedError, (successMessage) => {
|
|
376
|
+
logger.logSingle(successMessage);
|
|
377
|
+
})(result);
|
|
216
378
|
}
|
|
217
379
|
function catchUnexpectedError(error) {
|
|
218
|
-
logger.error(`\u274C An
|
|
380
|
+
logger.error(`\u274C An error occurred while processing the request: ${error}`);
|
|
219
381
|
process.exit(1);
|
|
220
382
|
}
|
|
221
|
-
extractArgs().then((
|
|
383
|
+
extractArgs().then((maybeConfigs) => __async(this, null, function* () {
|
|
384
|
+
E__namespace.match(catchUnexpectedError, (configs) => __async(this, null, function* () {
|
|
385
|
+
for (const config of configs) {
|
|
386
|
+
yield logger$1.Apexdocs.generate(config, logger).then(parseResult);
|
|
387
|
+
}
|
|
388
|
+
}))(maybeConfigs);
|
|
389
|
+
})).catch(catchUnexpectedError);
|
|
222
390
|
}
|
|
223
391
|
main();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type Generators = 'markdown' | 'openapi' | 'changelog';
|
|
2
|
+
|
|
1
3
|
type LinkingStrategy =
|
|
2
4
|
// Links will be generated using relative paths.
|
|
3
5
|
| 'relative'
|
|
@@ -21,6 +23,7 @@ type UserDefinedMarkdownConfig = {
|
|
|
21
23
|
linkingStrategy: LinkingStrategy;
|
|
22
24
|
excludeTags: string[];
|
|
23
25
|
referenceGuideTitle: string;
|
|
26
|
+
exclude: string[];
|
|
24
27
|
} & Partial<ConfigurableHooks>;
|
|
25
28
|
|
|
26
29
|
type UserDefinedOpenApiConfig = {
|
|
@@ -31,9 +34,20 @@ type UserDefinedOpenApiConfig = {
|
|
|
31
34
|
namespace?: string;
|
|
32
35
|
title: string;
|
|
33
36
|
apiVersion: string;
|
|
37
|
+
exclude: string[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type UserDefinedChangelogConfig = {
|
|
41
|
+
targetGenerator: 'changelog';
|
|
42
|
+
previousVersionDir: string;
|
|
43
|
+
currentVersionDir: string;
|
|
44
|
+
targetDir: string;
|
|
45
|
+
fileName: string;
|
|
46
|
+
scope: string[];
|
|
47
|
+
exclude: string[];
|
|
34
48
|
};
|
|
35
49
|
|
|
36
|
-
type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig;
|
|
50
|
+
type UserDefinedConfig = UserDefinedMarkdownConfig | UserDefinedOpenApiConfig | UserDefinedChangelogConfig;
|
|
37
51
|
|
|
38
52
|
type SourceFileMetadata = {
|
|
39
53
|
filePath: string;
|
|
@@ -122,6 +136,16 @@ type TransformDocPage = (
|
|
|
122
136
|
doc: DocPageData,
|
|
123
137
|
) => Partial<ConfigurableDocPageData> | Promise<Partial<ConfigurableDocPageData>>;
|
|
124
138
|
|
|
139
|
+
type CallableConfig = Partial<UserDefinedConfig> & {
|
|
140
|
+
sourceDir: string;
|
|
141
|
+
targetGenerator: Generators;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Processes the documentation generation, similar to the main function in the CLI.
|
|
145
|
+
* @param config The configuration to use.
|
|
146
|
+
*/
|
|
147
|
+
declare function process(config: CallableConfig): Promise<void>;
|
|
148
|
+
|
|
125
149
|
type ConfigurableMarkdownConfig = Omit<Partial<UserDefinedMarkdownConfig>, 'targetGenerator'>;
|
|
126
150
|
/**
|
|
127
151
|
* Helper function to define a configuration to generate Markdown documentation.
|
|
@@ -134,14 +158,15 @@ type ConfigurableOpenApiConfig = Omit<Partial<UserDefinedOpenApiConfig>, 'target
|
|
|
134
158
|
* @param config The configuration to use.
|
|
135
159
|
*/
|
|
136
160
|
declare function defineOpenApiConfig(config: ConfigurableOpenApiConfig): Partial<UserDefinedOpenApiConfig>;
|
|
161
|
+
type ConfigurableChangelogConfig = Omit<Partial<UserDefinedChangelogConfig>, 'targetGenerator'>;
|
|
162
|
+
/**
|
|
163
|
+
* Helper function to define a configuration to generate a changelog.
|
|
164
|
+
* @param config The configuration to use.
|
|
165
|
+
*/
|
|
166
|
+
declare function defineChangelogConfig(config: ConfigurableChangelogConfig): Partial<UserDefinedChangelogConfig>;
|
|
137
167
|
/**
|
|
138
168
|
* Represents a file to be skipped.
|
|
139
169
|
*/
|
|
140
170
|
declare function skip(): Skip;
|
|
141
|
-
type CallableConfig = Partial<UserDefinedConfig> & {
|
|
142
|
-
sourceDir: string;
|
|
143
|
-
targetGenerator: 'markdown' | 'openapi';
|
|
144
|
-
};
|
|
145
|
-
declare function process(config: CallableConfig): Promise<void>;
|
|
146
171
|
|
|
147
|
-
export { type ConfigurableDocPageData, type ConfigurableDocPageReference, type ConfigurableHooks, type ConfigurableMarkdownConfig, type ConfigurableOpenApiConfig, type DocPageData, type DocPageReference, type ReferenceGuidePageData, type Skip, type TransformDocPage, type TransformDocs, type TransformReference, type TransformReferenceGuide, defineMarkdownConfig, defineOpenApiConfig, process, skip };
|
|
172
|
+
export { type ConfigurableChangelogConfig, type ConfigurableDocPageData, type ConfigurableDocPageReference, type ConfigurableHooks, type ConfigurableMarkdownConfig, type ConfigurableOpenApiConfig, type DocPageData, type DocPageReference, type ReferenceGuidePageData, type Skip, type TransformDocPage, type TransformDocs, type TransformReference, type TransformReferenceGuide, defineChangelogConfig, defineMarkdownConfig, defineOpenApiConfig, process, skip };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var logger = require('./logger-
|
|
3
|
+
var logger = require('./logger-DIyKhj0a.js');
|
|
4
4
|
var E = require('fp-ts/Either');
|
|
5
5
|
require('fp-ts/function');
|
|
6
6
|
require('fp-ts/TaskEither');
|
|
@@ -15,6 +15,7 @@ require('handlebars');
|
|
|
15
15
|
require('fp-ts/boolean');
|
|
16
16
|
require('fs');
|
|
17
17
|
require('fp-ts/lib/TaskEither');
|
|
18
|
+
require('minimatch');
|
|
18
19
|
require('chalk');
|
|
19
20
|
|
|
20
21
|
function _interopNamespaceDefault(e) {
|
|
@@ -36,25 +37,22 @@ function _interopNamespaceDefault(e) {
|
|
|
36
37
|
|
|
37
38
|
var E__namespace = /*#__PURE__*/_interopNamespaceDefault(E);
|
|
38
39
|
|
|
39
|
-
var __defProp = Object.defineProperty;
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
46
|
-
var __spreadValues = (a, b) => {
|
|
40
|
+
var __defProp$1 = Object.defineProperty;
|
|
41
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
42
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
43
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
44
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
45
|
+
var __spreadValues$1 = (a, b) => {
|
|
47
46
|
for (var prop in b || (b = {}))
|
|
48
|
-
if (__hasOwnProp.call(b, prop))
|
|
49
|
-
__defNormalProp(a, prop, b[prop]);
|
|
50
|
-
if (__getOwnPropSymbols)
|
|
51
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
52
|
-
if (__propIsEnum.call(b, prop))
|
|
53
|
-
__defNormalProp(a, prop, b[prop]);
|
|
47
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
48
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
49
|
+
if (__getOwnPropSymbols$1)
|
|
50
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
51
|
+
if (__propIsEnum$1.call(b, prop))
|
|
52
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
54
53
|
}
|
|
55
54
|
return a;
|
|
56
55
|
};
|
|
57
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
58
56
|
var __async = (__this, __arguments, generator) => {
|
|
59
57
|
return new Promise((resolve, reject) => {
|
|
60
58
|
var fulfilled = (value) => {
|
|
@@ -75,25 +73,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
75
73
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
74
|
});
|
|
77
75
|
};
|
|
78
|
-
function defineMarkdownConfig(config) {
|
|
79
|
-
return __spreadProps(__spreadValues(__spreadValues({}, logger.markdownDefaults), config), {
|
|
80
|
-
targetGenerator: "markdown"
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function defineOpenApiConfig(config) {
|
|
84
|
-
return __spreadProps(__spreadValues(__spreadValues({}, logger.openApiDefaults), config), {
|
|
85
|
-
targetGenerator: "openapi"
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function skip() {
|
|
89
|
-
return {
|
|
90
|
-
_tag: "Skip"
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
76
|
function process(config) {
|
|
94
77
|
return __async(this, null, function* () {
|
|
95
78
|
const logger$1 = new logger.NoLogger();
|
|
96
|
-
const configWithDefaults = __spreadValues(__spreadValues({}, getDefault(config)), config);
|
|
79
|
+
const configWithDefaults = __spreadValues$1(__spreadValues$1({}, getDefault(config)), config);
|
|
97
80
|
if (!configWithDefaults.sourceDir) {
|
|
98
81
|
throw new Error("sourceDir is required");
|
|
99
82
|
}
|
|
@@ -113,11 +96,54 @@ function getDefault(config) {
|
|
|
113
96
|
return logger.markdownDefaults;
|
|
114
97
|
case "openapi":
|
|
115
98
|
return logger.openApiDefaults;
|
|
99
|
+
case "changelog":
|
|
100
|
+
return logger.changeLogDefaults;
|
|
116
101
|
default:
|
|
117
102
|
throw new Error("Unknown target generator");
|
|
118
103
|
}
|
|
119
104
|
}
|
|
120
105
|
|
|
106
|
+
var __defProp = Object.defineProperty;
|
|
107
|
+
var __defProps = Object.defineProperties;
|
|
108
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
109
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
110
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
111
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
112
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
113
|
+
var __spreadValues = (a, b) => {
|
|
114
|
+
for (var prop in b || (b = {}))
|
|
115
|
+
if (__hasOwnProp.call(b, prop))
|
|
116
|
+
__defNormalProp(a, prop, b[prop]);
|
|
117
|
+
if (__getOwnPropSymbols)
|
|
118
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
119
|
+
if (__propIsEnum.call(b, prop))
|
|
120
|
+
__defNormalProp(a, prop, b[prop]);
|
|
121
|
+
}
|
|
122
|
+
return a;
|
|
123
|
+
};
|
|
124
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
125
|
+
function defineMarkdownConfig(config) {
|
|
126
|
+
return __spreadProps(__spreadValues(__spreadValues({}, logger.markdownDefaults), config), {
|
|
127
|
+
targetGenerator: "markdown"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function defineOpenApiConfig(config) {
|
|
131
|
+
return __spreadProps(__spreadValues(__spreadValues({}, logger.openApiDefaults), config), {
|
|
132
|
+
targetGenerator: "openapi"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function defineChangelogConfig(config) {
|
|
136
|
+
return __spreadProps(__spreadValues(__spreadValues({}, logger.changeLogDefaults), config), {
|
|
137
|
+
targetGenerator: "changelog"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function skip() {
|
|
141
|
+
return {
|
|
142
|
+
_tag: "Skip"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
exports.defineChangelogConfig = defineChangelogConfig;
|
|
121
147
|
exports.defineMarkdownConfig = defineMarkdownConfig;
|
|
122
148
|
exports.defineOpenApiConfig = defineOpenApiConfig;
|
|
123
149
|
exports.process = process;
|