@cparra/apexdocs 3.10.0 → 3.11.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 +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -1
- package/dist/{logger-D2kLvcfb.js → logger-C1Ezw_pW.js} +21 -1
- package/package.json +1 -1
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 (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
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;
|
|
@@ -152,6 +160,7 @@ type Skip = {
|
|
|
152
160
|
* The configurable hooks that can be used to modify the output of the Markdown generator.
|
|
153
161
|
*/
|
|
154
162
|
type MarkdownConfigurableHooks = {
|
|
163
|
+
macros: Record<string, MacroFunction>;
|
|
155
164
|
transformReferenceGuide: TransformReferenceGuide;
|
|
156
165
|
transformDocs: TransformDocs;
|
|
157
166
|
transformDocPage: TransformDocPage;
|
|
@@ -232,4 +241,4 @@ type ConfigurableChangelogConfig = Omit<Partial<UserDefinedChangelogConfig>, 'ta
|
|
|
232
241
|
*/
|
|
233
242
|
declare function defineChangelogConfig(config: ConfigurableChangelogConfig): Partial<UserDefinedChangelogConfig>;
|
|
234
243
|
|
|
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 };
|
|
244
|
+
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
|
@@ -2590,7 +2590,8 @@ function generateDocs(unparsedBundles, config) {
|
|
|
2590
2590
|
);
|
|
2591
2591
|
}
|
|
2592
2592
|
return _function.pipe(
|
|
2593
|
-
|
|
2593
|
+
TE__namespace.right(replaceMacros(unparsedBundles, config.macros)),
|
|
2594
|
+
TE__namespace.flatMap((unparsedBundles2) => generateForApex(filterApexSourceFiles(unparsedBundles2), config)),
|
|
2594
2595
|
TE__namespace.chain((parsedApexFiles) => {
|
|
2595
2596
|
return _function.pipe(
|
|
2596
2597
|
reflectCustomFieldsAndObjectsAndMetadataRecords(
|
|
@@ -2624,6 +2625,25 @@ function generateDocs(unparsedBundles, config) {
|
|
|
2624
2625
|
TE__namespace.map(postHookCompile$1)
|
|
2625
2626
|
);
|
|
2626
2627
|
}
|
|
2628
|
+
function replaceMacros(unparsedBundles, macros) {
|
|
2629
|
+
if (!macros) {
|
|
2630
|
+
return unparsedBundles;
|
|
2631
|
+
}
|
|
2632
|
+
return unparsedBundles.map((bundle) => {
|
|
2633
|
+
return __spreadProps$8(__spreadValues$8({}, bundle), {
|
|
2634
|
+
content: Object.entries(macros).reduce((acc, [macroName, macroFunction]) => {
|
|
2635
|
+
return acc.replace(
|
|
2636
|
+
new RegExp(`{{${macroName}}}`, "g"),
|
|
2637
|
+
macroFunction({
|
|
2638
|
+
type: bundle.type,
|
|
2639
|
+
name: bundle.name,
|
|
2640
|
+
filePath: bundle.filePath
|
|
2641
|
+
})
|
|
2642
|
+
);
|
|
2643
|
+
}, bundle.content)
|
|
2644
|
+
});
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2627
2647
|
function generateForApex(apexBundles, config) {
|
|
2628
2648
|
const filterOutOfScope = apply(filterScope, config.scope);
|
|
2629
2649
|
const removeExcluded = apply(removeExcludedTags, config.excludeTags);
|