Skip to content

Commit

Permalink
docs: update ApexDocs, method documentation (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschach authored Oct 4, 2023
1 parent 55549bd commit 6a29eb9
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 1,092 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,27 +243,27 @@ There are two methods that will show additional information.

`TriggerHandler.showDebug()` will show trigger entry and exit in debug logs. Use sparingly, as it will decrease org performance.

To use one or both of these, add them to the trigger:
To use one or both of these, either add them to the *trigger* (note that you can specify for ALL handlers or for a specific handler)
```apex
TriggerHandler.showLimits();
AccountTriggerHandler.showDebug();
new AccountSampleTriggerHandler().run();
TriggerHandler.showLimits(false);
AccountTriggerHandler.showDebug(false);
```
or just put them in your Apex code before and after DML statements.
or put them in your Apex *trigger handler* code before and after DML statements.

```apex
showLimits();
showDebug();
LeadTriggerHandler.showLimits();
TriggerHandler.showDebug();
update leadsList;
showLimits(false);
showDebug(false);
LeadTriggerHandler.showLimits(false);
TriggerHandler.showDebug(false);
```

In version 1.2, the ability to chain methods was added. Now, you can specify showing debug messages and limits in a single line in your trigger:
In version 1.2, the ability to chain methods *in triggers* was added. Now, you can specify showing debug messages and limits in a single line in your trigger:

```apex
trigger OpportunityTrigger on Opportunity (before update, after update) {
Expand Down
463 changes: 1 addition & 462 deletions doc-assets/files/changelog.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions doc-assets/homePage.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,23 @@ <h3>Debug Statements</h3>
<p>There are two methods that will show additional information.</p>
<p><code>TriggerHandler.showLimits()</code> will debug Apex query and DML limits when the trigger handler has completed.</p>
<p><code>TriggerHandler.showDebug()</code> will show trigger entry and exit in debug logs. Use sparingly, as it will decrease org performance.</p>
<p>To use one or both of these, add them to the trigger:</p>
<p>To use one or both of these, either add them to the <em>trigger</em> (note that you can specify for ALL handlers or for a specific handler)</p>
<pre><code class="language-apex">TriggerHandler.showLimits();
AccountTriggerHandler.showDebug();
new AccountSampleTriggerHandler().run();
TriggerHandler.showLimits(false);
AccountTriggerHandler.showDebug(false);
</code></pre>
<p>or just put them in your Apex code before and after DML statements.</p>
<pre><code class="language-apex">showLimits();
showDebug();
<p>or put them in your Apex <em>trigger handler</em> code before and after DML statements.</p>
<pre><code class="language-apex">LeadTriggerHandler.showLimits();
TriggerHandler.showDebug();

update leadsList;

showLimits(false);
showDebug(false);
LeadTriggerHandler.showLimits(false);
TriggerHandler.showDebug(false);
</code></pre>
<p>In version 1.2, the ability to chain methods was added. Now, you can specify showing debug messages and limits in a single line in your trigger:</p>
<p>In version 1.2, the ability to chain methods <em>in triggers</em> was added. Now, you can specify showing debug messages and limits in a single line in your trigger:</p>
<pre><code class="language-apex">trigger OpportunityTrigger on Opportunity (before update, after update) {
new OpportunityTriggerHandler().debug().limits().run(); // debug() is the same as debug(true)
}
Expand Down
155 changes: 83 additions & 72 deletions docs/TriggerHandler.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/assets/search-idx.js

Large diffs are not rendered by default.

523 changes: 1 addition & 522 deletions docs/changelog.html

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,25 @@ <h3>Debug Statements</h3>
<p>There are two methods that will show additional information.</p>
<p><code>TriggerHandler.showLimits()</code> will debug Apex query and DML limits when the trigger handler has completed.</p>
<p><code>TriggerHandler.showDebug()</code> will show trigger entry and exit in debug logs. Use sparingly, as it will decrease org performance.</p>
<p>To use one or both of these, add them to the trigger:</p>
<p>To use one or both of these, either add them to the <em>trigger</em> (note that you can specify for ALL handlers or for a specific handler)</p>
<pre><code class="language-apex">TriggerHandler.showLimits();
AccountTriggerHandler.showDebug();
new AccountSampleTriggerHandler().run();
TriggerHandler.showLimits(false);
AccountTriggerHandler.showDebug(false);
</code></pre>
<p>or just put them in your Apex code before and after DML statements.</p>
<pre><code class="language-apex">showLimits();
showDebug();
<p>or put them in your Apex <em>trigger handler</em> code before and after DML statements.</p>
<pre><code class="language-apex">LeadTriggerHandler.showLimits();
TriggerHandler.showDebug();

update leadsList;

showLimits(false);
showDebug(false);
LeadTriggerHandler.showLimits(false);
TriggerHandler.showDebug(false);
</code></pre>
<p>In version 1.2, the ability to chain methods was added. Now, you can specify showing debug messages and limits in a single line in your trigger:</p>
<p>
In version 1.2, the ability to chain methods <em>in triggers</em> was added. Now, you can specify showing debug messages and limits in a single line in your trigger:
</p>
<pre><code class="language-apex">trigger OpportunityTrigger on Opportunity (before update, after update) {
new OpportunityTriggerHandler().debug().limits().run(); // debug() is the same as debug(true)
}
Expand Down
25 changes: 15 additions & 10 deletions force-app/main/default/classes/TriggerHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,16 @@ public virtual class TriggerHandler {

/**
* @description Limit the number of times this handler can be run before it fails silently
* <br>Returning `TriggerHandler` enables method chaining
* <br>Returning `TriggerHandler` enables method chaining when used in a trigger
* <br>Use this in the trigger or handler
* @author {@link [David Schach](https://github.com/dschach)}
* @param max Naximum number of times
* @return `TriggerHandler` enables method chaining
* @example
* this.setMaxLoopCount(5);
* this.setMaxLoopCount(5); // in handler
* AccountTriggerHandler.setMaxLoopCount(5); // in handler
* or
* new TriggerHandler().setMaxLoopCount(5).run();
* new TriggerHandler().setMaxLoopCount(5).run(); // in trigger
*/
public TriggerHandler setMaxLoopCount(Integer max) {
String handlerName = getHandlerName();
Expand Down Expand Up @@ -419,7 +421,7 @@ public virtual class TriggerHandler {
// handle limits

/**
* @description Instance method to show limits for just this trigger handler, allowing method chaining.
* @description Instance method to show limits for just this trigger handler, allowing method chaining in the trigger.
* @since 2023
* @see TriggerHandler.showLimits[0]
* @example
Expand All @@ -433,7 +435,7 @@ public virtual class TriggerHandler {
}

/**
* @description Instance method to show/hide limits for just this trigger handler, allowing method chaining.
* @description Instance method to show/hide limits for just this trigger handler, allowing method chaining in the trigger.
* @since 2023
* @see TriggerHandler.showLimits[1]
* @example
Expand All @@ -448,7 +450,8 @@ public virtual class TriggerHandler {
}

/**
* @description Called before the trigger to force the class to debug query limits when it runs
* @description Called before the trigger to force the class to debug query limits when it runs.
* <br>Use this in the trigger or handler
* @see TriggerHandler.showLimits[1]
* @example
* TriggerHandler.showLimits();
Expand All @@ -463,6 +466,7 @@ public virtual class TriggerHandler {
/**
* @description Called before the trigger to enable the class to debug (or not) query limits when it runs.
* <br>Set to true to show limits.
* <br>Use this in the trigger or handler
*
* @param enabled true to enable; false to disable
* @see TriggerHandler.showLimits[0]
Expand All @@ -480,7 +484,7 @@ public virtual class TriggerHandler {
// handle debugs

/**
* @description Instance method to show debug logs for just this trigger handler, allowing method chaining.
* @description Instance method to show debug logs for just this trigger handler, allowing method chaining in the trigger.
* @since 2023
* @see TriggerHandler.showDebug[0]
* @example
Expand All @@ -494,7 +498,7 @@ public virtual class TriggerHandler {
}

/**
* @description Instance method to show debug logs for just this trigger handler, allowing method chaining.
* @description Instance method to show debug logs for just this trigger handler, allowing method chaining in the trigger.
* @since 2023
* @param enabled true to enable; false to disable
* @return `TriggerHandler` returning this class enables method chaining
Expand All @@ -509,14 +513,15 @@ public virtual class TriggerHandler {

/**
* @description Called in the trigger to force the class to debug trigger entry and exit with context.
* <br>Use this in the trigger or handler
* @author {@link [David Schach](https://github.com/dschach)}
* @since 2021
* @see TriggerHandler.showDebug[1]
* @example
* TriggerHandler.showDebug();
* new AccountSampleTriggerHandler.run();
* new AccountSampleTriggerHandler.run(); // in trigger
* -or-
* AccountSampleTriggerHandler.showDebug();
* AccountSampleTriggerHandler.showDebug(); // in handler
*/
public static void showDebug() {
showDebug(true);
Expand Down
4 changes: 2 additions & 2 deletions scripts/updateHighlight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ npx marked -i README.md --gfm >> "doc-assets/homePage.html"
sed -i '' 's|DEPLOY.md|deploy.html|g' doc-assets/homePage.html

# Changelog to web page
printf '<link href="assets/styling.css" rel="stylesheet" />' > "doc-assets/changelog.html"
echo >> "doc-assets/changelog.html"
printf '<link href="assets/styling.css" rel="stylesheet" />' > "doc-assets/files/changelog.html"
echo >> "doc-assets/files/changelog.html"
npx marked -i CHANGELOG.md --gfm >> "doc-assets/files/changelog.html"
sed -i '' 's|CHANGELOG.md|changelog.html|g' doc-assets/homePage.html

Expand Down

0 comments on commit 6a29eb9

Please sign in to comment.