@cparra/apexdocs 3.10.0 → 3.12.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 +54 -2
- package/dist/cli/generate.js +6 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -1
- package/dist/{logger-D2kLvcfb.js → logger-DZpyHcLp.js} +49 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -351,10 +351,62 @@ There are hooks for both Markdown and Changelog operations (but not for OpenApi)
|
|
|
351
351
|
|
|
352
352
|
#### Markdown Hooks
|
|
353
353
|
|
|
354
|
+
##### **macros**
|
|
355
|
+
|
|
356
|
+
Allows defining custom macros that can be used in the documentation.
|
|
357
|
+
|
|
358
|
+
Macros are reusable pieces of text that can be injected into the documentation,
|
|
359
|
+
allowing you to define common pieces of text that you can use across multiple files.
|
|
360
|
+
|
|
361
|
+
A common use case is injecting copyright or license information, without
|
|
362
|
+
having to copy-paste the same text across multiple classes, polluting your
|
|
363
|
+
source code.
|
|
364
|
+
|
|
365
|
+
A macro can be defined in your documentation using the `{{macro_name}}` syntax.
|
|
366
|
+
In the configuration file, you can then define the macro behavior as a key-value pair, where the key is the name of the macro, and the value is a function that returns the text to inject in place of the macro.
|
|
367
|
+
|
|
368
|
+
**Type**
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
type MacroSourceMetadata = {
|
|
372
|
+
type: 'apex' | 'customobject' | 'customfield' | 'custommetadata' | 'trigger';
|
|
373
|
+
name: string;
|
|
374
|
+
filePath: string;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
type MacroFunction = (metadata: MacroSourceMetadata) => string;
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Notice that the `metadata` object contains information about the source of the file for which the macro is being injected. This allows you to optionally
|
|
381
|
+
return different text based on the source of the file.
|
|
382
|
+
|
|
383
|
+
Example: Injecting a copyright notice
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
//...
|
|
387
|
+
macros: {
|
|
388
|
+
copyright: () => {
|
|
389
|
+
return `@copyright Copyright (c) ${new Date().getFullYear()} My Name`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
//...
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
And then in your source code, you can use the macro like this:
|
|
396
|
+
|
|
397
|
+
```apex
|
|
398
|
+
/**
|
|
399
|
+
* {{copyright}}
|
|
400
|
+
* @description This is a class
|
|
401
|
+
*/
|
|
402
|
+
public class MyClass {
|
|
403
|
+
//...
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
354
407
|
##### **transformReferenceGuide**
|
|
355
408
|
|
|
356
|
-
Allows changing the
|
|
357
|
-
guide page should be skipped.
|
|
409
|
+
Allows changing the frontmatter and content of the reference guide, or if creating a reference guide page altogether should be skipped.
|
|
358
410
|
|
|
359
411
|
**Type**
|
|
360
412
|
|
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-DZpyHcLp.js');
|
|
5
5
|
var module$1 = require('module');
|
|
6
6
|
var cosmiconfig = require('cosmiconfig');
|
|
7
7
|
var E = require('fp-ts/Either');
|
|
@@ -117,6 +117,11 @@ const markdownOptions = {
|
|
|
117
117
|
type: "string",
|
|
118
118
|
describe: "The title of the reference guide.",
|
|
119
119
|
default: logger$1.markdownDefaults.referenceGuideTitle
|
|
120
|
+
},
|
|
121
|
+
includeFieldSecurityMetadata: {
|
|
122
|
+
type: "boolean",
|
|
123
|
+
describe: "Whether to include the compliance category and security classification for fields in the generated files.",
|
|
124
|
+
default: logger$1.markdownDefaults.includeFieldSecurityMetadata
|
|
120
125
|
}
|
|
121
126
|
};
|
|
122
127
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ type LinkingStrategy =
|
|
|
11
11
|
// No logic will be applied, the reference path will be used as is.
|
|
12
12
|
| 'none';
|
|
13
13
|
|
|
14
|
+
type MacroSourceMetadata = {
|
|
15
|
+
type: 'apex' | 'customobject' | 'customfield' | 'custommetadata' | 'trigger';
|
|
16
|
+
name: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type MacroFunction = (metadata: MacroSourceMetadata) => string;
|
|
21
|
+
|
|
14
22
|
type CliConfigurableMarkdownConfig = {
|
|
15
23
|
sourceDir: string;
|
|
16
24
|
targetDir: string;
|
|
@@ -24,6 +32,7 @@ type CliConfigurableMarkdownConfig = {
|
|
|
24
32
|
includeMetadata: boolean;
|
|
25
33
|
linkingStrategy: LinkingStrategy;
|
|
26
34
|
referenceGuideTitle: string;
|
|
35
|
+
includeFieldSecurityMetadata: boolean;
|
|
27
36
|
};
|
|
28
37
|
|
|
29
38
|
type UserDefinedMarkdownConfig = {
|
|
@@ -152,6 +161,7 @@ type Skip = {
|
|
|
152
161
|
* The configurable hooks that can be used to modify the output of the Markdown generator.
|
|
153
162
|
*/
|
|
154
163
|
type MarkdownConfigurableHooks = {
|
|
164
|
+
macros: Record<string, MacroFunction>;
|
|
155
165
|
transformReferenceGuide: TransformReferenceGuide;
|
|
156
166
|
transformDocs: TransformDocs;
|
|
157
167
|
transformDocPage: TransformDocPage;
|
|
@@ -232,4 +242,4 @@ type ConfigurableChangelogConfig = Omit<Partial<UserDefinedChangelogConfig>, 'ta
|
|
|
232
242
|
*/
|
|
233
243
|
declare function defineChangelogConfig(config: ConfigurableChangelogConfig): Partial<UserDefinedChangelogConfig>;
|
|
234
244
|
|
|
235
|
-
export { type ChangeLogPageData, type ChangelogConfigurableHooks, type ConfigurableChangelogConfig, type ConfigurableDocPageData, type ConfigurableDocPageReference, type ConfigurableMarkdownConfig, type ConfigurableOpenApiConfig, type DocPageData, type DocPageReference, type MarkdownConfigurableHooks, type ReferenceGuidePageData, type Skip, type SourceChangelog, type TransformChangelogPage, type TransformDocPage, type TransformDocs, type TransformReference, type TransformReferenceGuide, defineChangelogConfig, defineMarkdownConfig, defineOpenApiConfig, process, skip };
|
|
245
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -714,6 +714,8 @@ function fieldMetadataToRenderable(field, config, headingLevel) {
|
|
|
714
714
|
apiName: getApiName(field.name, config),
|
|
715
715
|
fieldType: field.type,
|
|
716
716
|
required: field.required,
|
|
717
|
+
complianceCategory: renderComplianceCategory(field.complianceCategory, config),
|
|
718
|
+
securityClassification: renderComplianceCategory(field.securityClassification, config),
|
|
717
719
|
pickListValues: field.pickListValues ? {
|
|
718
720
|
headingLevel: headingLevel + 1,
|
|
719
721
|
heading: "Possible values are",
|
|
@@ -742,6 +744,13 @@ function getApiName(currentName, config) {
|
|
|
742
744
|
}
|
|
743
745
|
return currentName;
|
|
744
746
|
}
|
|
747
|
+
function renderComplianceCategory(complianceCategory, config) {
|
|
748
|
+
if (config.includeFieldSecurityMetadata) {
|
|
749
|
+
return complianceCategory;
|
|
750
|
+
} else {
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
745
754
|
|
|
746
755
|
const generateLink = (strategy) => {
|
|
747
756
|
switch (strategy) {
|
|
@@ -1527,7 +1536,8 @@ const markdownDefaults = __spreadProps$i(__spreadValues$i({}, markdownAndChangel
|
|
|
1527
1536
|
sortAlphabetically: false,
|
|
1528
1537
|
linkingStrategy: "relative",
|
|
1529
1538
|
referenceGuideTitle: "Reference Guide",
|
|
1530
|
-
excludeTags: []
|
|
1539
|
+
excludeTags: [],
|
|
1540
|
+
includeFieldSecurityMetadata: false
|
|
1531
1541
|
});
|
|
1532
1542
|
const openApiDefaults = __spreadProps$i(__spreadValues$i({}, commonDefaults), {
|
|
1533
1543
|
fileName: "openapi",
|
|
@@ -1566,6 +1576,16 @@ const customObjectTemplate = `
|
|
|
1566
1576
|
{{{renderContent description}}}
|
|
1567
1577
|
{{/if}}
|
|
1568
1578
|
|
|
1579
|
+
{{#if complianceCategory}}
|
|
1580
|
+
**Compliance Category**
|
|
1581
|
+
{{complianceCategory}}
|
|
1582
|
+
{{/if}}
|
|
1583
|
+
|
|
1584
|
+
{{#if securityClassification}}
|
|
1585
|
+
**Security Classification**
|
|
1586
|
+
{{securityClassification}}
|
|
1587
|
+
{{/if}}
|
|
1588
|
+
|
|
1569
1589
|
**API Name**
|
|
1570
1590
|
|
|
1571
1591
|
\`{{{apiName}}}\`
|
|
@@ -2162,6 +2182,8 @@ function convertInlineFieldsToCustomFieldMetadata(inlineField, parentName) {
|
|
|
2162
2182
|
const label = inlineField.label ? inlineField.label : name;
|
|
2163
2183
|
const type = inlineField.type ? inlineField.type : null;
|
|
2164
2184
|
const required = inlineField.required ? inlineField.required : false;
|
|
2185
|
+
const securityClassification = inlineField.securityClassification ? inlineField.securityClassification : null;
|
|
2186
|
+
const complianceCategory = inlineField.complianceCategory ? inlineField.complianceCategory : null;
|
|
2165
2187
|
return {
|
|
2166
2188
|
type_name: "customfield",
|
|
2167
2189
|
description,
|
|
@@ -2170,6 +2192,8 @@ function convertInlineFieldsToCustomFieldMetadata(inlineField, parentName) {
|
|
|
2170
2192
|
parentName,
|
|
2171
2193
|
type,
|
|
2172
2194
|
required,
|
|
2195
|
+
securityClassification,
|
|
2196
|
+
complianceCategory,
|
|
2173
2197
|
pickListValues: getPickListValues(inlineField)
|
|
2174
2198
|
};
|
|
2175
2199
|
}
|
|
@@ -2241,7 +2265,9 @@ function toCustomFieldMetadata(parserResult) {
|
|
|
2241
2265
|
const customField = (parserResult == null ? void 0 : parserResult.CustomField) != null && typeof parserResult.CustomField === "object" ? parserResult.CustomField : {};
|
|
2242
2266
|
const defaultValues = {
|
|
2243
2267
|
description: null,
|
|
2244
|
-
required: false
|
|
2268
|
+
required: false,
|
|
2269
|
+
securityClassification: null,
|
|
2270
|
+
complianceCategory: null
|
|
2245
2271
|
};
|
|
2246
2272
|
return __spreadProps$c(__spreadValues$c(__spreadValues$c({}, defaultValues), customField), {
|
|
2247
2273
|
type_name: "customfield",
|
|
@@ -2590,7 +2616,8 @@ function generateDocs(unparsedBundles, config) {
|
|
|
2590
2616
|
);
|
|
2591
2617
|
}
|
|
2592
2618
|
return _function.pipe(
|
|
2593
|
-
|
|
2619
|
+
TE__namespace.right(replaceMacros(unparsedBundles, config.macros)),
|
|
2620
|
+
TE__namespace.flatMap((unparsedBundles2) => generateForApex(filterApexSourceFiles(unparsedBundles2), config)),
|
|
2594
2621
|
TE__namespace.chain((parsedApexFiles) => {
|
|
2595
2622
|
return _function.pipe(
|
|
2596
2623
|
reflectCustomFieldsAndObjectsAndMetadataRecords(
|
|
@@ -2624,6 +2651,25 @@ function generateDocs(unparsedBundles, config) {
|
|
|
2624
2651
|
TE__namespace.map(postHookCompile$1)
|
|
2625
2652
|
);
|
|
2626
2653
|
}
|
|
2654
|
+
function replaceMacros(unparsedBundles, macros) {
|
|
2655
|
+
if (!macros) {
|
|
2656
|
+
return unparsedBundles;
|
|
2657
|
+
}
|
|
2658
|
+
return unparsedBundles.map((bundle) => {
|
|
2659
|
+
return __spreadProps$8(__spreadValues$8({}, bundle), {
|
|
2660
|
+
content: Object.entries(macros).reduce((acc, [macroName, macroFunction]) => {
|
|
2661
|
+
return acc.replace(
|
|
2662
|
+
new RegExp(`{{${macroName}}}`, "g"),
|
|
2663
|
+
macroFunction({
|
|
2664
|
+
type: bundle.type,
|
|
2665
|
+
name: bundle.name,
|
|
2666
|
+
filePath: bundle.filePath
|
|
2667
|
+
})
|
|
2668
|
+
);
|
|
2669
|
+
}, bundle.content)
|
|
2670
|
+
});
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2627
2673
|
function generateForApex(apexBundles, config) {
|
|
2628
2674
|
const filterOutOfScope = apply(filterScope, config.scope);
|
|
2629
2675
|
const removeExcluded = apply(removeExcludedTags, config.excludeTags);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"ts-jest": "^29.2.0",
|
|
81
81
|
"typescript": "^5.7.3",
|
|
82
82
|
"typescript-eslint": "^7.16.0",
|
|
83
|
-
"wireit": "^0.14.
|
|
83
|
+
"wireit": "^0.14.12"
|
|
84
84
|
},
|
|
85
85
|
"husky": {
|
|
86
86
|
"hooks": {
|