Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
| `--includeMetadata ` | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | `false` | No |
| `--linkingStrategy` | N/A | The strategy to use when linking to other classes. Possible values are `relative`, `no-link`, and `none` | `relative` | No |
| `--customObjectsGroupName` | N/A | The name under which custom objects will be grouped in the Reference Guide | `Custom Objects` | No |
| `--triggersGroupName` | N/A | The name under which triggers will be grouped in the Reference Guide | `Triggers` | No |

##### Linking Strategy

Expand Down
2 changes: 1 addition & 1 deletion examples/docsify/apexdocs.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineMarkdownConfig } from '../../src';

export default defineMarkdownConfig({
sourceDir: 'classes',
sourceDir: 'src',
targetDir: 'docs',
scope: ['public', 'global'],
linkingStrategy: 'none',
Expand Down
26 changes: 4 additions & 22 deletions examples/docsify/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
# Apex Reference Guide
# Reference Guide

## Miscellaneous
## Triggers

### [ASampleClass](miscellaneous/ASampleClass.md)
### [PaymentDeviceTrigger](triggers/PaymentDeviceTrigger.md)

This is a class description.

### [CodeControl](miscellaneous/CodeControl.md)

### [SomeDto](miscellaneous/SomeDto.md)

Some description

## Sample Classes

### [SampleClass](sample-classes/SampleClass.md)

This is a class description.

## Sample Interfaces

### [SampleInterface](sample-interfaces/SampleInterface.md)

This is an interface description.
This trigger is used to handle the logic for the Payment Device object.
9 changes: 9 additions & 0 deletions examples/docsify/docs/triggers/PaymentDeviceTrigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# PaymentDeviceTrigger Trigger

## Trigger On Payment_Device__c

This trigger is used to handle the logic for the Payment Device object.

**Events**
* Before Insert
* Before Update
4 changes: 4 additions & 0 deletions examples/docsify/src/triggers/PaymentDeviceTrigger.trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This trigger is used to handle the logic for the Payment Device object.
*/
trigger PaymentDeviceTrigger on Payment_Device__c (before insert, before update) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<status>Active</status>
</ApexTrigger>
50 changes: 25 additions & 25 deletions examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions examples/vitepress/docs/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"hash": "38118198",
"configHash": "7f7b0dad",
"hash": "c8200423",
"configHash": "8e537a0d",
"lockfileHash": "09651dfc",
"browserHash": "1bd3b4f7",
"browserHash": "b18c62f2",
"optimized": {
"vue": {
"src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "12c2c40e",
"fileHash": "f55612ac",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "7b21a64c",
"fileHash": "78b7bc58",
"needsInterop": false
},
"vitepress > @vueuse/core": {
"src": "../../../../node_modules/@vueuse/core/index.mjs",
"file": "vitepress___@vueuse_core.js",
"fileHash": "5d565a7a",
"fileHash": "f7f18ce5",
"needsInterop": false
},
"@theme/index": {
"src": "../../../../node_modules/vitepress/dist/client/theme-default/index.js",
"file": "@theme_index.js",
"fileHash": "e4373905",
"fileHash": "19a25279",
"needsInterop": false
}
},
Expand Down
4 changes: 4 additions & 0 deletions examples/vitepress/docs/.vitepress/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"text": "ParentInterface",
"link": "miscellaneous/ParentInterface.md"
},
{
"text": "PaymentDeviceTrigger",
"link": "triggers/PaymentDeviceTrigger.md"
},
{
"text": "ReferencedEnum",
"link": "miscellaneous/ReferencedEnum.md"
Expand Down
6 changes: 6 additions & 0 deletions examples/vitepress/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Eu excepteur irure occaecat adipisicing anim non consequat deserunt ipsum id ame

Represents a speaker at an event.

## New Triggers

These triggers are new.

- PaymentDeviceTrigger on Payment_Device__c

## New or Removed Fields to Custom Objects or Standard Objects

These custom fields have been added or removed.
Expand Down
8 changes: 7 additions & 1 deletion examples/vitepress/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@ This description has several lines
### [SampleClass](samplegroup/SampleClass)

aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
**deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
**deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.

## Triggers

### [PaymentDeviceTrigger](triggers/PaymentDeviceTrigger)

This trigger is used to handle the logic for the Payment Device object.
16 changes: 16 additions & 0 deletions examples/vitepress/docs/triggers/PaymentDeviceTrigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: PaymentDeviceTrigger
---

# PaymentDeviceTrigger Trigger

## Trigger On Payment_Device__c

This trigger is used to handle the logic for the Payment Device object.

## Namespace
apexdocs

**Run**
* Before Insert
* Before Update
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This trigger is used to handle the logic for the Payment Device object.
*/
trigger PaymentDeviceTrigger on Payment_Device__c (before insert, before update) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<status>Active</status>
</ApexTrigger>
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cparra/apexdocs",
"version": "3.9.0",
"version": "3.10.0",
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
"keywords": [
"apex",
Expand Down Expand Up @@ -93,7 +93,7 @@
]
},
"dependencies": {
"@cparra/apex-reflection": "2.16.1",
"@cparra/apex-reflection": "2.19.0",
"@salesforce/source-deploy-retrieve": "^12.8.1",
"@types/js-yaml": "^4.0.9",
"@types/yargs": "^17.0.32",
Expand Down
43 changes: 41 additions & 2 deletions src/application/source-code-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ import {
UnparsedCustomFieldBundle,
UnparsedCustomMetadataBundle,
UnparsedCustomObjectBundle,
UnparsedTriggerBundle,
} from '../core/shared/types';
import { minimatch } from 'minimatch';
import { flow, pipe } from 'fp-ts/function';
import { apply } from '#utils/fp';

export type ComponentTypes = 'ApexClass' | 'CustomObject' | 'CustomField' | 'CustomMetadata';
export const allComponentTypes: ComponentTypes[] = ['ApexClass', 'CustomObject', 'CustomField', 'CustomMetadata'];
export type ComponentTypes = 'ApexClass' | 'CustomObject' | 'CustomField' | 'CustomMetadata' | 'ApexTrigger';
export const allComponentTypes: ComponentTypes[] = [
'ApexClass',
'CustomObject',
'CustomField',
'CustomMetadata',
'ApexTrigger',
];

/**
* Simplified representation of a source component, with only
Expand All @@ -36,6 +43,12 @@ type ApexClassApexSourceComponent = {
contentPath: string;
};

type TriggerSourceComponent = {
type: 'ApexTrigger';
name: string;
contentPath: string;
};

type CustomObjectSourceComponent = {
type: 'CustomObject';
name: string;
Expand Down Expand Up @@ -91,6 +104,28 @@ function toUnparsedApexBundle(
});
}

function getTriggerSourceComponents(sourceComponents: SourceComponentAdapter[]): TriggerSourceComponent[] {
return sourceComponents
.filter((component) => component.type.name === 'ApexTrigger')
.map((component) => ({
type: 'ApexTrigger' as const,
name: component.name,
contentPath: component.content!,
}));
}

function toUnparsedTriggerBundle(
fileSystem: FileSystem,
triggerSourceComponents: TriggerSourceComponent[],
): UnparsedTriggerBundle[] {
return triggerSourceComponents.map((component) => ({
type: 'trigger',
name: component.name,
filePath: component.contentPath,
content: fileSystem.readFile(component.contentPath),
}));
}

function getCustomObjectSourceComponents(sourceComponents: SourceComponentAdapter[]): CustomObjectSourceComponent[] {
return sourceComponents
.filter((component) => component.type.name === 'CustomObject')
Expand Down Expand Up @@ -191,6 +226,7 @@ export function processFiles(fileSystem: FileSystem) {
| UnparsedCustomObjectBundle
| UnparsedCustomFieldBundle
| UnparsedCustomMetadataBundle
| UnparsedTriggerBundle
)[]
> = {
ApexClass: flow(apply(getApexSourceComponents, options.includeMetadata), (apexSourceComponents) =>
Expand All @@ -205,6 +241,9 @@ export function processFiles(fileSystem: FileSystem) {
CustomMetadata: flow(getCustomMetadataSourceComponents, (customMetadataSourceComponents) =>
toUnparsedCustomMetadataBundle(fileSystem, customMetadataSourceComponents),
),
ApexTrigger: flow(getTriggerSourceComponents, (triggerSourceComponents) =>
toUnparsedTriggerBundle(fileSystem, triggerSourceComponents),
),
};

const convertersToUse = componentTypesToRetrieve.map((componentType) => converters[componentType]);
Expand Down
5 changes: 5 additions & 0 deletions src/cli/commands/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export const markdownOptions: Record<keyof CliConfigurableMarkdownConfig, Option
default: markdownDefaults.customObjectsGroupName,
describe: 'The name under which custom objects will be grouped in the Reference Guide',
},
triggersGroupName: {
type: 'string',
default: markdownDefaults.triggersGroupName,
describe: 'The name under which triggers will be grouped in the Reference Guide',
},
namespace: {
type: 'string',
describe: 'The package namespace, if any. If provided, it will be added to the generated files.',
Expand Down
Loading