Skip to content

Commit c8dd673

Browse files
committed
Enhance documentation examples with specific class titles for clarity
Signed-off-by: Piotr PG Gajek <[email protected]>
1 parent 4aee5dd commit c8dd673

File tree

5 files changed

+49
-26
lines changed

5 files changed

+49
-26
lines changed

website/docs/advanced-usage/fls.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ none (by default) | `USER_MODE` | enforced
1818

1919
`USER_MODE` is a enabled by default. It means that **the object permissions, field-level security**, as well as sharing rules, **are enforced**.
2020

21-
```apex
21+
```apex title="SOQL_Account.cls"
2222
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
2323
public static SOQL_Account query() {
2424
return new SOQL_Account();
@@ -34,7 +34,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
3434
The object permissions, field-level security, and sharing rules are enforced.
3535
Access to the `Account` object and fields (`Account.Name` and `Account.AccountNumber`) will be checked.
3636

37-
```apex
37+
```apex title="ExampleController.cls"
3838
public without sharing class ExampleController {
3939
public static List<Account> getAccountsByRecordType(String recordType) {
4040
return SOQL_Account.query().toList();
@@ -48,7 +48,7 @@ public without sharing class ExampleController {
4848

4949
Developer can disable `USER_MODE` and enable `SYSTEM_MODE` using `.systemMode()` method.
5050

51-
```apex
51+
```apex title="SOQL_Account.cls"
5252
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
5353
public static SOQL_Account query() {
5454
return new SOQL_Account();
@@ -64,7 +64,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
6464

6565
The object permissions and field-level permissions are ignored.
6666

67-
```apex
67+
```apex title="ExampleController.cls"
6868
public without sharing class ExampleController {
6969
public static List<Account> getAccountsByRecordType(String recordType) {
7070
return SOQL_Account.query().toList();
@@ -78,7 +78,7 @@ public without sharing class ExampleController {
7878
You may encounter situations where you need object and field-level security but want to ignore sharing rules (`without sharing`).
7979
To achieve this, use `.systemMode()`, `.withoutSharing()` and `.stripInaccessible()`.
8080

81-
```apex
81+
```apex title="SOQL_Account.cls"
8282
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
8383
public static SOQL_Account query() {
8484
return new SOQL_Account();
@@ -96,7 +96,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
9696

9797
The object permissions and field-level permissions are enforced, but sharing rules are ignored.
9898

99-
```apex
99+
```apex title="ExampleController.cls"
100100
public without sharing class ExampleController {
101101
public static List<Account> getAccountsByRecordType(String recordType) {
102102
return SOQL_Account.query().toList();

website/docs/advanced-usage/mocking.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_position: 30
77
Mocking provides a way to substitute records from a Database with some prepared data. Data can be prepared in form of SObject records and lists in Apex code or Static Resource `.csv` file.
88
Mocked queries won't make any SOQL's and simply return data set in method definition, mock __will ignore all filters and relations__, what is returned depends __solely on data provided to the method__. Mocking is working __only during test execution__. To mock SOQL query, use `.mockId(id)` method to make it identifiable. If you mark more than one query with the same ID, all marked queries will return the same data.
99

10-
```apex
10+
```apex title="ExampleController.cls"
1111
public with sharing class ExampleController {
1212
1313
public static List<Account> getPartnerAccounts(String accountName) {
@@ -111,7 +111,7 @@ This behavior is consistent with Salesforce’s native limits, ensuring that you
111111

112112
## List of records
113113

114-
```apex
114+
```apex title="ExampleControllerTest.cls"
115115
@IsTest
116116
private class ExampleControllerTest {
117117
@@ -134,7 +134,7 @@ private class ExampleControllerTest {
134134

135135
## Single record
136136

137-
```apex
137+
```apex title="ExampleControllerTest.cls"
138138
@IsTest
139139
private class ExampleControllerTest {
140140
@@ -152,7 +152,7 @@ private class ExampleControllerTest {
152152

153153
## Static resource
154154

155-
```apex
155+
```apex title="ExampleControllerTest.cls"
156156
@IsTest
157157
private class ExampleControllerTest {
158158
@@ -170,7 +170,7 @@ private class ExampleControllerTest {
170170

171171
## Count Result
172172

173-
```
173+
```apex title="ExampleControllerTest.cls"
174174
@IsTest
175175
private class ExampleControllerTest {
176176
@@ -195,7 +195,7 @@ _Using JSON String_
195195

196196
By passing simple String, it is possible to write non-writable fields, like `Name` on Contact object.
197197

198-
```
198+
```apex
199199
@IsTest
200200
static void getAccountsWithContacts() {
201201
List<Account> mocks = (List<Account>) JSON.deserialize(
@@ -221,7 +221,7 @@ _Using Serialization/Deserialization_
221221

222222
Using this approach it is possible to bind data with additional logic, like using Test Data Factory.
223223

224-
```
224+
```apex
225225
@IsTest
226226
static void getAccountsWithContacts() {
227227
List<Account> mocks = (List<Account>) JSON.deserialize(
@@ -256,7 +256,7 @@ static void getAccountsWithContacts() {
256256

257257
## Parent relationship
258258

259-
```
259+
```apex
260260
@IsTest
261261
private class ExampleControllerTest {
262262
@IsTest
@@ -281,7 +281,7 @@ There is no way to create a `new AggregateResult()` instance in Apex. You can fi
281281

282282
To mock `AggregateResult`, we introduced `SOQL.AggregateResultProxy`, which provides the same methods as the standard `AggregateResult` class.
283283

284-
```apex
284+
```apex title="ExampleController.cls"
285285
public with sharing class ExampleController {
286286
public void getLeadAggregateResults() {
287287
List<SOQL.AggregateResultProxy> result = SOQL.of(Lead.SObjectType)
@@ -292,8 +292,9 @@ public with sharing class ExampleController {
292292
.toAggregatedProxy(); // <== use toAggregatedProxy()
293293
}
294294
}
295+
```
295296

296-
297+
```apex title="ExampleControllerTest.cls"
297298
@IsTest
298299
public class ExampleControllerTest {
299300
@IsTest
@@ -324,7 +325,7 @@ Pass an empty list: `.thenReturn(new List<Type>())`;
324325

325326
This behavior will be the same as it is during runtime.
326327

327-
```apex
328+
```apex title="ExampleControllerTest.cls"
328329
@IsTest
329330
public class ExampleControllerTest {
330331
private static final String TEST_ACCOUNT_NAME = 'MyAccount 1';

website/docs/advanced-usage/sharing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ none (by default) | `USER_MODE` | `with sharing`
1919

2020
`USER_MODE` is a enabled by default. It means that the object permissions, field-level security and **sharing rules are enforced**.
2121

22-
```apex
22+
```apex title="SOQL_Account.cls"
2323
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
2424
public static SOQL_Account query() {
2525
return new SOQL_Account();
@@ -34,7 +34,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
3434

3535
The object permissions, field-level security, and sharing rules are enforced. Class sharing mode is ignored (`without sharing`).
3636

37-
```apex
37+
```apex title="ExampleController.cls"
3838
public without sharing class ExampleController {
3939
public static List<Account> getAccountsByRecordType(String recordType) {
4040
return SOQL_Account.query().toList();
@@ -51,7 +51,7 @@ Developers can control the sharing mode (`inherited sharing`, `with sharing`, an
5151

5252
**NOTE!** To make it work, always set `inherited sharing` in your selector class.
5353

54-
```apex
54+
```apex title="SOQL_Account.cls"
5555
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
5656
public static SOQL_Account query() {
5757
return new SOQL_Account();
@@ -67,7 +67,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
6767

6868
The object permissions and field-level permissions are ignored. Sharing rules are controlled by the sharing mode (`without sharing`).
6969

70-
```apex
70+
```apex title="ExampleController.cls"
7171
public without sharing class ExampleController {
7272
public static List<Account> getAccountsByRecordType(String recordType) {
7373
return SOQL_Account.query().toList();
@@ -79,7 +79,7 @@ public without sharing class ExampleController {
7979

8080
You can force the sharing mode for all of your queries.
8181

82-
```apex
82+
```apex title="SOQL_Account.cls"
8383
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
8484
public static SOQL_Account query() {
8585
return new SOQL_Account();
@@ -96,7 +96,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
9696

9797
The object permissions and field-level permissions are ignored. Sharing rules are controlled by the sharing mode specified in the `query()` method (`.withSharing()`).
9898

99-
```apex
99+
```apex title="ExampleController.cls"
100100
public with sharing class ExampleController {
101101
public static List<Account> getAccountsByRecordType(String recordType) {
102102
return SOQL_Account.query().toList();
@@ -109,7 +109,7 @@ public with sharing class ExampleController {
109109

110110
You can force the sharing mode for all of your queries.
111111

112-
```apex
112+
```apex title="SOQL_Account.cls"
113113
public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selector {
114114
public static SOQL_Account query() {
115115
return new SOQL_Account();
@@ -126,7 +126,7 @@ public inherited sharing class SOQL_Account extends SOQL implements SOQL.Selecto
126126

127127
The object permissions and field-level permissions are ignored. Sharing rules are controlled by the sharing mode specified in the `query()` method (`.withoutSharing()`).
128128

129-
```apex
129+
```apex title="ExampleController.cls"
130130
public with sharing class ExampleController {
131131
public static List<Account> getAccountsByRecordType(String recordType) {
132132
return SOQL_Account.query().toList();

website/docs/advanced-usage/soql-caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ This clear distinction gives architects full control over which records should b
7575

7676
Additionally, Cached Selectors look slightly different and include cache-specific methods:
7777

78-
```apex
78+
```apex title="SOQL_ProfileCache.cls"
7979
public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector {
8080
public static SOQL_ProfileCache query() {
8181
return new SOQL_ProfileCache();

website/src/css/custom.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,25 @@ body {
5353
-webkit-font-smoothing: antialiased;
5454
-moz-osx-font-smoothing: grayscale;
5555
}
56+
57+
.prism-code {
58+
counter-reset: line-number;
59+
border: 1px solid #eaeaea;
60+
border-radius: 5px;
61+
padding: 1em;
62+
background-color: #f9f9f9;
63+
}
64+
.prism-code > code > span {
65+
display: block;
66+
counter-increment: line-number;
67+
position: relative;
68+
padding-left: 3.5em;
69+
}
70+
.prism-code > code > span::before {
71+
content: counter(line-number);
72+
position: absolute;
73+
left: 0;
74+
width: 2.5em;
75+
text-align: right;
76+
color: #999;
77+
}

0 commit comments

Comments
 (0)