@cparra/apexdocs 3.0.0-rc.0 → 3.0.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 +50 -571
- package/dist/cli/generate.js +73 -3094
- package/dist/defaults-BcE8DTat.js +13 -0
- package/dist/defaults-D07y_bq4.js +40 -0
- package/dist/defaults-gPzwP66p.js +14 -0
- package/dist/index.d.ts +35 -3
- package/dist/index.js +90 -2
- package/dist/logger-BEbUIfqN.js +3282 -0
- package/dist/logger-BGuf1PnL.js +3281 -0
- package/dist/logger-CWBRF2za.js +3284 -0
- package/dist/logger-CdBmDEN1.js +3283 -0
- package/dist/logger-Ce4QqPFR.js +3278 -0
- package/dist/logger-CyEVYaAC.js +3284 -0
- package/dist/logger-D7a83ycP.js +3277 -0
- package/dist/logger-DGaHeBKk.js +3279 -0
- package/dist/logger-Dqhl_lO_.js +3278 -0
- package/dist/logger-aySSWi0G.js +3280 -0
- package/dist/logger-qLCcAtiy.js +3284 -0
- package/examples/README.md +5 -0
- package/examples/docsify/README.md +17 -0
- package/examples/docsify/apexdocs.config.ts +13 -0
- package/examples/docsify/classes/ASampleClass.cls +57 -0
- package/examples/docsify/classes/CodeControl.cls +19 -0
- package/examples/docsify/classes/SampleClass.cls +95 -0
- package/examples/docsify/classes/SampleInterface.cls +17 -0
- package/examples/docsify/classes/SomeDto.cls +122 -0
- package/examples/docsify/docs/.nojekyll +0 -0
- package/examples/docsify/docs/README.md +25 -0
- package/examples/docsify/docs/_config.yml +1 -0
- package/examples/docsify/docs/index.html +22 -0
- package/examples/docsify/docs/miscellaneous/ASampleClass.md +88 -0
- package/examples/docsify/docs/miscellaneous/CodeControl.md +107 -0
- package/examples/docsify/docs/miscellaneous/SomeDto.md +244 -0
- package/examples/docsify/docs/sample-classes/SampleClass.md +171 -0
- package/examples/docsify/docs/sample-interfaces/SampleInterface.md +36 -0
- package/examples/docsify/package-lock.json +2459 -0
- package/examples/docsify/package.json +14 -0
- package/examples/imported/.forceignore +12 -0
- package/examples/imported/README.md +6 -0
- package/examples/imported/config/project-scratch-def.json +5 -0
- package/examples/imported/docs/index.md +109 -0
- package/examples/imported/docs/miscellaneous/BaseClass.md +13 -0
- package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +69 -0
- package/examples/imported/docs/miscellaneous/ParentInterface.md +12 -0
- package/examples/imported/docs/miscellaneous/ReferencedEnum.md +5 -0
- package/examples/imported/docs/miscellaneous/SampleException.md +21 -0
- package/examples/imported/docs/miscellaneous/SampleInterface.md +113 -0
- package/examples/imported/docs/miscellaneous/Url.md +308 -0
- package/examples/imported/docs/sample-enums/SampleEnum.md +33 -0
- package/examples/imported/docs/samplegroup/SampleClass.md +167 -0
- package/examples/imported/force-app/classes/BaseClass.cls +3 -0
- package/examples/imported/force-app/classes/MultiInheritanceClass.cls +1 -0
- package/examples/imported/force-app/classes/ParentInterface.cls +3 -0
- package/examples/imported/force-app/classes/ReferencedEnum.cls +3 -0
- package/examples/imported/force-app/classes/SampleClass.cls +72 -0
- package/examples/imported/force-app/classes/SampleInterface.cls +50 -0
- package/examples/imported/force-app/classes/Url.cls +196 -0
- package/examples/imported/package-lock.json +665 -0
- package/examples/imported/package.json +6 -0
- package/examples/imported/scripts/process-docs.mjs +16 -0
- package/examples/imported/sfdx-project.json +12 -0
- package/examples/markdown/README.md +7 -0
- package/examples/markdown-jsconfig/README.md +9 -0
- package/examples/markdown-jsconfig/apexdocs.config.mjs +1 -0
- package/examples/markdown-jsconfig/docs/index.md +1 -1
- package/examples/open-api/README.md +5 -0
- package/examples/open-api/docs/openapi.json +2 -570
- package/examples/vitepress/README.md +25 -0
- package/examples/vitepress/apexdocs.config.ts +2 -0
- package/examples/vitepress/force-app/main/default/classes/{SampleClass.cls → feature-a/SampleClass.cls} +1 -0
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +30 -0
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +17 -0
- package/package.json +2 -2
- package/src/application/Apexdocs.ts +16 -19
- package/src/application/__tests__/apex-file-reader.spec.ts +108 -67
- package/src/application/apex-file-reader.ts +1 -0
- package/src/application/generators/openapi.ts +17 -13
- package/src/cli/args.ts +12 -3
- package/src/cli/commands/markdown.ts +14 -9
- package/src/cli/commands/openapi.ts +5 -5
- package/src/cli/generate.ts +20 -4
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +14 -257
- package/src/core/markdown/__test__/generating-docs.spec.ts +271 -4
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +4 -264
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +4 -232
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +17 -1
- package/src/core/markdown/__test__/test-helpers.ts +3 -1
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +3 -1
- package/src/core/markdown/adapters/renderable-to-page-data.ts +6 -4
- package/src/core/markdown/generate-docs.ts +13 -15
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +2 -18
- package/src/core/markdown/reflection/__test__/helpers.ts +18 -0
- package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +200 -0
- package/src/core/markdown/reflection/remove-excluded-tags.ts +168 -0
- package/src/core/markdown/reflection/{sort-members.ts → sort-types-and-members.ts} +7 -5
- package/src/core/markdown/templates/reference-guide.ts +2 -2
- package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +6 -3
- package/src/core/openapi/open-api-docs-processor.ts +3 -3
- package/src/core/openapi/parser.ts +5 -2
- package/src/core/shared/types.d.ts +4 -2
- package/src/defaults.ts +15 -3
- package/src/index.ts +65 -4
- package/src/util/error-logger.ts +36 -36
- package/src/util/logger.ts +18 -11
- /package/examples/{vitepress/force-app/main/default → imported/force-app}/classes/SampleEnum.cls +0 -0
- /package/examples/{vitepress/force-app/main/default → imported/force-app}/classes/SampleException.cls +0 -0
- /package/examples/vitepress/force-app/main/default/classes/{SampleInterface.cls → feature-a/SampleInterface.cls} +0 -0
|
@@ -7,266 +7,6 @@ describe('Generates enum documentation', () => {
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
describe('documentation content', () => {
|
|
10
|
-
it('generates a heading with the enum name', async () => {
|
|
11
|
-
const input = `
|
|
12
|
-
public enum MyEnum {
|
|
13
|
-
VALUE1,
|
|
14
|
-
VALUE2
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
const output = `# MyEnum Enum`;
|
|
19
|
-
|
|
20
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
21
|
-
expect(result).documentationBundleHasLength(1);
|
|
22
|
-
assertEither(result, (data) => expect(data).firstDocContains(output));
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('displays type level annotations', async () => {
|
|
26
|
-
const input = `
|
|
27
|
-
@NamespaceAccessible
|
|
28
|
-
public enum MyEnum {
|
|
29
|
-
VALUE1,
|
|
30
|
-
VALUE2
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
35
|
-
expect(result).documentationBundleHasLength(1);
|
|
36
|
-
assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('displays the description', async () => {
|
|
40
|
-
const input = `
|
|
41
|
-
/**
|
|
42
|
-
* This is a description
|
|
43
|
-
*/
|
|
44
|
-
public enum MyEnum {
|
|
45
|
-
VALUE1,
|
|
46
|
-
VALUE2
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
51
|
-
expect(result).documentationBundleHasLength(1);
|
|
52
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('display custom documentation tags', async () => {
|
|
56
|
-
const input = `
|
|
57
|
-
/**
|
|
58
|
-
* @custom-tag My Value
|
|
59
|
-
*/
|
|
60
|
-
public enum MyEnum {
|
|
61
|
-
VALUE1,
|
|
62
|
-
VALUE2
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
67
|
-
expect(result).documentationBundleHasLength(1);
|
|
68
|
-
assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
|
|
69
|
-
assertEither(result, (data) => expect(data).firstDocContains('My Value'));
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('displays the group', async () => {
|
|
73
|
-
const input = `
|
|
74
|
-
/**
|
|
75
|
-
* @group MyGroup
|
|
76
|
-
*/
|
|
77
|
-
public enum MyEnum {
|
|
78
|
-
VALUE1,
|
|
79
|
-
VALUE2
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
84
|
-
expect(result).documentationBundleHasLength(1);
|
|
85
|
-
assertEither(result, (data) => expect(data).firstDocContains('Group'));
|
|
86
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('displays the author', async () => {
|
|
90
|
-
const input = `
|
|
91
|
-
/**
|
|
92
|
-
* @author John Doe
|
|
93
|
-
*/
|
|
94
|
-
public enum MyEnum {
|
|
95
|
-
VALUE1,
|
|
96
|
-
VALUE2
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
101
|
-
expect(result).documentationBundleHasLength(1);
|
|
102
|
-
assertEither(result, (data) => expect(data).firstDocContains('Author'));
|
|
103
|
-
assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('displays the date', async () => {
|
|
107
|
-
const input = `
|
|
108
|
-
/**
|
|
109
|
-
* @date 2021-01-01
|
|
110
|
-
*/
|
|
111
|
-
public enum MyEnum {
|
|
112
|
-
VALUE1,
|
|
113
|
-
VALUE2
|
|
114
|
-
}
|
|
115
|
-
`;
|
|
116
|
-
|
|
117
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
118
|
-
expect(result).documentationBundleHasLength(1);
|
|
119
|
-
assertEither(result, (data) => expect(data).firstDocContains('Date'));
|
|
120
|
-
assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('displays descriptions', async () => {
|
|
124
|
-
const input = `
|
|
125
|
-
/**
|
|
126
|
-
* @description This is a description
|
|
127
|
-
*/
|
|
128
|
-
public enum MyEnum {}
|
|
129
|
-
`;
|
|
130
|
-
|
|
131
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
132
|
-
expect(result).documentationBundleHasLength(1);
|
|
133
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('displays descriptions with links', async () => {
|
|
137
|
-
const input1 = `
|
|
138
|
-
/**
|
|
139
|
-
* @description This is a description with a {@link EnumRef} reference
|
|
140
|
-
*/
|
|
141
|
-
public enum MyEnum {}
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
const input2 = 'public enum EnumRef {}';
|
|
145
|
-
|
|
146
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
147
|
-
expect(result).documentationBundleHasLength(2);
|
|
148
|
-
assertEither(result, (data) => expect(data).firstDocContains('Description'));
|
|
149
|
-
assertEither(result, (data) =>
|
|
150
|
-
expect(data).firstDocContains('This is a description with a [EnumRef](EnumRef.md) reference'),
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('displays descriptions with emails', async () => {
|
|
155
|
-
const input = `
|
|
156
|
-
/**
|
|
157
|
-
* @description This is a description with an {@email test@testerson.com} email
|
|
158
|
-
*/
|
|
159
|
-
public enum MyEnum {}
|
|
160
|
-
`;
|
|
161
|
-
|
|
162
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
163
|
-
expect(result).documentationBundleHasLength(1);
|
|
164
|
-
assertEither(result, (data) =>
|
|
165
|
-
expect(data).firstDocContains(
|
|
166
|
-
'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
|
|
167
|
-
),
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('displays sees with accurately resolved links', async () => {
|
|
172
|
-
const input1 = `
|
|
173
|
-
/**
|
|
174
|
-
* @see EnumRef
|
|
175
|
-
*/
|
|
176
|
-
public enum MyEnum {}
|
|
177
|
-
`;
|
|
178
|
-
|
|
179
|
-
const input2 = 'public enum EnumRef {}';
|
|
180
|
-
|
|
181
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
182
|
-
expect(result).documentationBundleHasLength(2);
|
|
183
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
184
|
-
assertEither(result, (data) => expect(data).firstDocContains('[EnumRef](EnumRef.md)'));
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('displays sees without links when the reference is not found', async () => {
|
|
188
|
-
const input = `
|
|
189
|
-
/**
|
|
190
|
-
* @see EnumRef
|
|
191
|
-
*/
|
|
192
|
-
public enum MyEnum {}
|
|
193
|
-
`;
|
|
194
|
-
|
|
195
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
196
|
-
expect(result).documentationBundleHasLength(1);
|
|
197
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
198
|
-
assertEither(result, (data) => expect(data).firstDocContains('EnumRef'));
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('displays the namespace if present in the config', async () => {
|
|
202
|
-
const input = `
|
|
203
|
-
public enum MyEnum {}
|
|
204
|
-
`;
|
|
205
|
-
|
|
206
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' })();
|
|
207
|
-
expect(result).documentationBundleHasLength(1);
|
|
208
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
|
|
209
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('does not display the namespace if not present in the config', async () => {
|
|
213
|
-
const input = `
|
|
214
|
-
public enum MyEnum {}
|
|
215
|
-
`;
|
|
216
|
-
|
|
217
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
218
|
-
expect(result).documentationBundleHasLength(1);
|
|
219
|
-
assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('displays a mermaid diagram', async () => {
|
|
223
|
-
const input = `
|
|
224
|
-
/**
|
|
225
|
-
* @mermaid
|
|
226
|
-
* \`\`\`mermaid
|
|
227
|
-
* graph TD
|
|
228
|
-
* A[Square Rect] -- Link text --> B((Circle))
|
|
229
|
-
* A --> C(Round Rect)
|
|
230
|
-
* B --> D{Rhombus}
|
|
231
|
-
* C --> D
|
|
232
|
-
* \`\`\`
|
|
233
|
-
*/
|
|
234
|
-
public enum MyEnum {
|
|
235
|
-
VALUE1,
|
|
236
|
-
VALUE2
|
|
237
|
-
}
|
|
238
|
-
`;
|
|
239
|
-
|
|
240
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
241
|
-
expect(result).documentationBundleHasLength(1);
|
|
242
|
-
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
243
|
-
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('displays an example code block', async () => {
|
|
247
|
-
const input = `
|
|
248
|
-
/**
|
|
249
|
-
* @example
|
|
250
|
-
* \`\`\`apex
|
|
251
|
-
* public class MyClass {
|
|
252
|
-
* public void myMethod() {
|
|
253
|
-
* System.debug('Hello, World!');
|
|
254
|
-
* }
|
|
255
|
-
* }
|
|
256
|
-
* \`\`\`
|
|
257
|
-
*/
|
|
258
|
-
public enum MyEnum {
|
|
259
|
-
VALUE1,
|
|
260
|
-
VALUE2
|
|
261
|
-
}
|
|
262
|
-
`;
|
|
263
|
-
|
|
264
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
265
|
-
expect(result).documentationBundleHasLength(1);
|
|
266
|
-
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
267
|
-
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
268
|
-
});
|
|
269
|
-
|
|
270
10
|
it('displays values', async () => {
|
|
271
11
|
const input = `
|
|
272
12
|
public enum MyEnum {
|
|
@@ -282,7 +22,7 @@ describe('Generates enum documentation', () => {
|
|
|
282
22
|
assertEither(result, (data) => expect(data).firstDocContains('VALUE2'));
|
|
283
23
|
});
|
|
284
24
|
|
|
285
|
-
it('displays values sorted when
|
|
25
|
+
it('displays values sorted when sortAlphabetically is true', async () => {
|
|
286
26
|
const input = `
|
|
287
27
|
public enum MyEnum {
|
|
288
28
|
VALUE2,
|
|
@@ -290,7 +30,7 @@ describe('Generates enum documentation', () => {
|
|
|
290
30
|
}
|
|
291
31
|
`;
|
|
292
32
|
|
|
293
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
33
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
294
34
|
expect(result).documentationBundleHasLength(1);
|
|
295
35
|
assertEither(result, (data) => expect(data).firstDocContains('## Values'));
|
|
296
36
|
assertEither(result, (data) => {
|
|
@@ -300,7 +40,7 @@ describe('Generates enum documentation', () => {
|
|
|
300
40
|
});
|
|
301
41
|
});
|
|
302
42
|
|
|
303
|
-
it('does not sort values when
|
|
43
|
+
it('does not sort values when sortAlphabetically is false', async () => {
|
|
304
44
|
const input = `
|
|
305
45
|
public enum MyEnum {
|
|
306
46
|
VALUE2,
|
|
@@ -308,7 +48,7 @@ describe('Generates enum documentation', () => {
|
|
|
308
48
|
}
|
|
309
49
|
`;
|
|
310
50
|
|
|
311
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
51
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
312
52
|
expect(result).documentationBundleHasLength(1);
|
|
313
53
|
assertEither(result, (data) => expect(data).firstDocContains('## Values'));
|
|
314
54
|
assertEither(result, (data) => {
|
|
@@ -7,234 +7,6 @@ describe('Generates interface documentation', () => {
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
describe('documentation content', () => {
|
|
10
|
-
describe('type level information', () => {
|
|
11
|
-
it('generates a heading with the interface name', async () => {
|
|
12
|
-
const input = `
|
|
13
|
-
public interface MyInterface {}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const output = `# MyInterface Interface`;
|
|
17
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
18
|
-
expect(result).documentationBundleHasLength(1);
|
|
19
|
-
assertEither(result, (data) => expect(data).firstDocContains(output));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('displays type level annotations', async () => {
|
|
23
|
-
const input = `
|
|
24
|
-
@NamespaceAccessible
|
|
25
|
-
public interface MyInterface {
|
|
26
|
-
@Deprecated
|
|
27
|
-
void myMethod();
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
32
|
-
expect(result).documentationBundleHasLength(1);
|
|
33
|
-
assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
|
|
34
|
-
assertEither(result, (data) => expect(data).firstDocContains('DEPRECATED'));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('displays the description', async () => {
|
|
38
|
-
const input = `
|
|
39
|
-
/**
|
|
40
|
-
* This is a description
|
|
41
|
-
*/
|
|
42
|
-
public interface MyInterface {}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
46
|
-
expect(result).documentationBundleHasLength(1);
|
|
47
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('display custom documentation tags', async () => {
|
|
51
|
-
const input = `
|
|
52
|
-
/**
|
|
53
|
-
* @custom-tag My Value
|
|
54
|
-
*/
|
|
55
|
-
public interface MyInterface {}
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
59
|
-
expect(result).documentationBundleHasLength(1);
|
|
60
|
-
assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
|
|
61
|
-
assertEither(result, (data) => expect(data).firstDocContains('My Value'));
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('displays the group', async () => {
|
|
65
|
-
const input = `
|
|
66
|
-
/**
|
|
67
|
-
* @group MyGroup
|
|
68
|
-
*/
|
|
69
|
-
public interface MyInterface {}`;
|
|
70
|
-
|
|
71
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
72
|
-
expect(result).documentationBundleHasLength(1);
|
|
73
|
-
assertEither(result, (data) => expect(data).firstDocContains('Group'));
|
|
74
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('displays the author', async () => {
|
|
78
|
-
const input = `
|
|
79
|
-
/**
|
|
80
|
-
* @author John Doe
|
|
81
|
-
*/
|
|
82
|
-
public interface MyInterface {}`;
|
|
83
|
-
|
|
84
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
85
|
-
expect(result).documentationBundleHasLength(1);
|
|
86
|
-
assertEither(result, (data) => expect(data).firstDocContains('Author'));
|
|
87
|
-
assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('displays the date', async () => {
|
|
91
|
-
const input = `
|
|
92
|
-
/**
|
|
93
|
-
* @date 2021-01-01
|
|
94
|
-
*/
|
|
95
|
-
public interface MyInterface {}`;
|
|
96
|
-
|
|
97
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
98
|
-
expect(result).documentationBundleHasLength(1);
|
|
99
|
-
assertEither(result, (data) => expect(data).firstDocContains('Date'));
|
|
100
|
-
assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('displays descriptions', async () => {
|
|
104
|
-
const input = `
|
|
105
|
-
/**
|
|
106
|
-
* @description This is a description
|
|
107
|
-
*/
|
|
108
|
-
public interface MyInterface {}`;
|
|
109
|
-
|
|
110
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
111
|
-
expect(result).documentationBundleHasLength(1);
|
|
112
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('displays descriptions with links', async () => {
|
|
116
|
-
const input1 = `
|
|
117
|
-
/**
|
|
118
|
-
* @description This is a description with a {@link InterfaceRef} reference
|
|
119
|
-
*/
|
|
120
|
-
public enum MyInterface {}
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
const input2 = 'public interface InterfaceRef {}';
|
|
124
|
-
|
|
125
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
126
|
-
expect(result).documentationBundleHasLength(2);
|
|
127
|
-
assertEither(result, (data) =>
|
|
128
|
-
expect(data).firstDocContains('This is a description with a [InterfaceRef](InterfaceRef.md) reference'),
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('displays descriptions with emails', async () => {
|
|
133
|
-
const input = `
|
|
134
|
-
/**
|
|
135
|
-
* @description This is a description with an {@email test@testerson.com} email
|
|
136
|
-
*/
|
|
137
|
-
public interface MyInterface {}
|
|
138
|
-
`;
|
|
139
|
-
|
|
140
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
141
|
-
expect(result).documentationBundleHasLength(1);
|
|
142
|
-
assertEither(result, (data) =>
|
|
143
|
-
expect(data).firstDocContains(
|
|
144
|
-
'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
|
|
145
|
-
),
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('displays sees with accurately resolved links', async () => {
|
|
150
|
-
const input1 = `
|
|
151
|
-
/**
|
|
152
|
-
* @see InterfaceRef
|
|
153
|
-
*/
|
|
154
|
-
public interface MyInterface {}
|
|
155
|
-
`;
|
|
156
|
-
|
|
157
|
-
const input2 = 'public interface InterfaceRef {}';
|
|
158
|
-
|
|
159
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
160
|
-
expect(result).documentationBundleHasLength(2);
|
|
161
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
162
|
-
assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](InterfaceRef.md)'));
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('displays sees without links when the reference is not found', async () => {
|
|
166
|
-
const input = `
|
|
167
|
-
/**
|
|
168
|
-
* @see InterfaceRef
|
|
169
|
-
*/
|
|
170
|
-
public interface MyInterface {}
|
|
171
|
-
`;
|
|
172
|
-
|
|
173
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
174
|
-
expect(result).documentationBundleHasLength(1);
|
|
175
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
176
|
-
assertEither(result, (data) => expect(data).firstDocContains('InterfaceRef'));
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('displays the namespace if present in the config', async () => {
|
|
180
|
-
const input = 'public interface MyInterface {}';
|
|
181
|
-
|
|
182
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' })();
|
|
183
|
-
expect(result).documentationBundleHasLength(1);
|
|
184
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
|
|
185
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('does not display the namespace if not present in the config', async () => {
|
|
189
|
-
const input = 'public interface MyInterface {}';
|
|
190
|
-
|
|
191
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
192
|
-
expect(result).documentationBundleHasLength(1);
|
|
193
|
-
assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('displays a mermaid diagram', async () => {
|
|
197
|
-
const input = `
|
|
198
|
-
/**
|
|
199
|
-
* @mermaid
|
|
200
|
-
* \`\`\`mermaid
|
|
201
|
-
* graph TD
|
|
202
|
-
* A[Square Rect] -- Link text --> B((Circle))
|
|
203
|
-
* A --> C(Round Rect)
|
|
204
|
-
* B --> D{Rhombus}
|
|
205
|
-
* C --> D
|
|
206
|
-
* \`\`\`
|
|
207
|
-
*/
|
|
208
|
-
public interface MyInterface {}
|
|
209
|
-
`;
|
|
210
|
-
|
|
211
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
212
|
-
expect(result).documentationBundleHasLength(1);
|
|
213
|
-
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
214
|
-
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('displays an example code block', async () => {
|
|
218
|
-
const input = `
|
|
219
|
-
/**
|
|
220
|
-
* @example
|
|
221
|
-
* \`\`\`apex
|
|
222
|
-
* public class MyClass {
|
|
223
|
-
* public void myMethod() {
|
|
224
|
-
* System.debug('Hello, World!');
|
|
225
|
-
* }
|
|
226
|
-
* }
|
|
227
|
-
* \`\`\`
|
|
228
|
-
*/
|
|
229
|
-
public interface MyInterface {}`;
|
|
230
|
-
|
|
231
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
232
|
-
expect(result).documentationBundleHasLength(1);
|
|
233
|
-
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
234
|
-
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
|
|
238
10
|
describe('method information', () => {
|
|
239
11
|
it('displays the Method heading', async () => {
|
|
240
12
|
const input = `
|
|
@@ -248,7 +20,7 @@ describe('Generates interface documentation', () => {
|
|
|
248
20
|
assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
|
|
249
21
|
});
|
|
250
22
|
|
|
251
|
-
it('displays methods sorted if
|
|
23
|
+
it('displays methods sorted if sortAlphabetically is true', async () => {
|
|
252
24
|
const input = `
|
|
253
25
|
public interface MyInterface {
|
|
254
26
|
void myMethod();
|
|
@@ -256,14 +28,14 @@ describe('Generates interface documentation', () => {
|
|
|
256
28
|
}
|
|
257
29
|
`;
|
|
258
30
|
|
|
259
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
31
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
260
32
|
expect(result).documentationBundleHasLength(1);
|
|
261
33
|
assertEither(result, (data) => {
|
|
262
34
|
expect(data.docs[0].content.indexOf('anotherMethod')).toBeLessThan(data.docs[0].content.indexOf('myMethod'));
|
|
263
35
|
});
|
|
264
36
|
});
|
|
265
37
|
|
|
266
|
-
it('does not display methods sorted if
|
|
38
|
+
it('does not display methods sorted if sortAlphabetically is false', async () => {
|
|
267
39
|
const input = `
|
|
268
40
|
public interface MyInterface {
|
|
269
41
|
void myMethod();
|
|
@@ -271,7 +43,7 @@ describe('Generates interface documentation', () => {
|
|
|
271
43
|
}
|
|
272
44
|
`;
|
|
273
45
|
|
|
274
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
46
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
275
47
|
expect(result).documentationBundleHasLength(1);
|
|
276
48
|
assertEither(result, (data) => {
|
|
277
49
|
expect(data.docs[0].content.indexOf('myMethod')).toBeLessThan(data.docs[0].content.indexOf('anotherMethod'));
|
|
@@ -4,11 +4,27 @@ import * as E from 'fp-ts/Either';
|
|
|
4
4
|
import { apexBundleFromRawString, generateDocs } from './test-helpers';
|
|
5
5
|
import { ReferenceGuidePageData } from '../../shared/types';
|
|
6
6
|
|
|
7
|
-
describe('
|
|
7
|
+
describe('When generating the Reference Guide', () => {
|
|
8
8
|
beforeAll(() => {
|
|
9
9
|
extendExpect();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
it('contains the correct default title by default', async () => {
|
|
13
|
+
const result = await generateDocs([])();
|
|
14
|
+
|
|
15
|
+
assertEither(result, (data) =>
|
|
16
|
+
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('# Apex Reference Guide'),
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('allows for the reference guide title to be configured', async () => {
|
|
21
|
+
const result = await generateDocs([], { referenceGuideTitle: 'Custom Title' })();
|
|
22
|
+
|
|
23
|
+
assertEither(result, (data) =>
|
|
24
|
+
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('# Custom Title'),
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
12
28
|
it('returns a reference guide with links to all other files', async () => {
|
|
13
29
|
const input1 = `
|
|
14
30
|
public enum MyEnum {
|
|
@@ -15,9 +15,11 @@ export function generateDocs(apexBundles: UnparsedSourceFile[], config?: Partial
|
|
|
15
15
|
targetDir: 'target',
|
|
16
16
|
scope: ['global', 'public'],
|
|
17
17
|
defaultGroupName: 'Miscellaneous',
|
|
18
|
-
|
|
18
|
+
sortAlphabetically: false,
|
|
19
19
|
referenceGuideTemplate: referenceGuideTemplate,
|
|
20
20
|
linkingStrategy: 'relative',
|
|
21
|
+
excludeTags: [],
|
|
22
|
+
referenceGuideTitle: 'Apex Reference Guide',
|
|
21
23
|
...config,
|
|
22
24
|
});
|
|
23
25
|
}
|
|
@@ -14,8 +14,10 @@ const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
|
|
|
14
14
|
namespace: '',
|
|
15
15
|
defaultGroupName: 'Miscellaneous',
|
|
16
16
|
referenceGuideTemplate: '',
|
|
17
|
-
|
|
17
|
+
sortAlphabetically: false,
|
|
18
18
|
linkingStrategy: 'relative',
|
|
19
|
+
referenceGuideTitle: 'Apex Reference Guide',
|
|
20
|
+
excludeTags: [],
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
describe('Conversion from InterfaceMirror to InterfaceSource understandable by the templating engine', () => {
|
|
@@ -5,15 +5,16 @@ import { CompilationRequest, Template } from '../templates/template';
|
|
|
5
5
|
import { enumMarkdownTemplate } from '../templates/enum-template';
|
|
6
6
|
import { interfaceMarkdownTemplate } from '../templates/interface-template';
|
|
7
7
|
import { classMarkdownTemplate } from '../templates/class-template';
|
|
8
|
-
import {
|
|
8
|
+
import { markdownDefaults } from '../../../defaults';
|
|
9
9
|
|
|
10
10
|
export const convertToDocumentationBundle = (
|
|
11
|
+
referenceGuideTitle: string,
|
|
11
12
|
referenceGuideTemplate: string,
|
|
12
13
|
{ referencesByGroup, renderables }: RenderableBundle,
|
|
13
14
|
): DocumentationBundle => ({
|
|
14
15
|
referenceGuide: {
|
|
15
16
|
frontmatter: null,
|
|
16
|
-
content: referencesToReferenceGuideContent(referencesByGroup, referenceGuideTemplate),
|
|
17
|
+
content: referencesToReferenceGuideContent(referenceGuideTitle, referencesByGroup, referenceGuideTemplate),
|
|
17
18
|
outputDocPath: 'index.md',
|
|
18
19
|
},
|
|
19
20
|
docs: renderables.map((renderable: Renderable) =>
|
|
@@ -22,6 +23,7 @@ export const convertToDocumentationBundle = (
|
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
function referencesToReferenceGuideContent(
|
|
26
|
+
referenceGuideTitle: string,
|
|
25
27
|
references: { [key: string]: ReferenceGuideReference[] },
|
|
26
28
|
template: string,
|
|
27
29
|
): string {
|
|
@@ -39,7 +41,7 @@ function referencesToReferenceGuideContent(
|
|
|
39
41
|
return pipe(references, alphabetizeReferences, (references) =>
|
|
40
42
|
compile({
|
|
41
43
|
template: template,
|
|
42
|
-
source: references,
|
|
44
|
+
source: { referenceGuideTitle: referenceGuideTitle, references },
|
|
43
45
|
}),
|
|
44
46
|
);
|
|
45
47
|
}
|
|
@@ -59,7 +61,7 @@ function renderableToPageData(referenceGuideReference: ReferenceGuideReference[]
|
|
|
59
61
|
outputDocPath: reference!.reference.outputDocPath,
|
|
60
62
|
frontmatter: null,
|
|
61
63
|
content: docContents,
|
|
62
|
-
group: renderable.doc.group ??
|
|
64
|
+
group: renderable.doc.group ?? markdownDefaults.defaultGroupName,
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
|