@cparra/apexdocs 3.0.0-beta.1 → 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/LICENSE +1 -1
- package/README.md +246 -650
- package/dist/cli/generate.js +74 -3095
- 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 +49 -19
- 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/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/docs/miscellaneous/Url.md +10 -8
- package/examples/markdown/force-app/classes/Url.cls +3 -1
- package/examples/markdown-jsconfig/.forceignore +12 -0
- package/examples/markdown-jsconfig/README.md +9 -0
- package/examples/markdown-jsconfig/apexdocs.config.mjs +22 -0
- package/examples/markdown-jsconfig/config/project-scratch-def.json +5 -0
- package/examples/markdown-jsconfig/docs/index.md +12 -0
- package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +315 -0
- package/examples/markdown-jsconfig/force-app/classes/Url.cls +196 -0
- package/examples/markdown-jsconfig/package-lock.json +665 -0
- package/examples/markdown-jsconfig/package.json +15 -0
- package/examples/markdown-jsconfig/sfdx-project.json +12 -0
- 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 +9 -2
- package/examples/vitepress/docs/index.md +11 -11
- package/examples/vitepress/docs/miscellaneous/BaseClass.md +1 -1
- package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +2 -2
- package/examples/vitepress/docs/miscellaneous/SampleException.md +1 -1
- package/examples/vitepress/docs/miscellaneous/SampleInterface.md +6 -6
- package/examples/vitepress/docs/miscellaneous/Url.md +3 -3
- package/examples/vitepress/docs/sample-enums/SampleEnum.md +3 -3
- package/examples/vitepress/docs/samplegroup/SampleClass.md +5 -5
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +73 -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 +3 -3
- 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 +15 -12
- 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 +15 -386
- package/src/core/markdown/__test__/generating-docs.spec.ts +378 -0
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +4 -328
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +4 -296
- 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 +290 -0
- 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 +18 -18
- package/src/defaults.ts +15 -3
- package/src/index.ts +88 -14
- 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/SampleClass.cls +0 -0
- /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
|
@@ -6,331 +6,7 @@ describe('Generates enum documentation', () => {
|
|
|
6
6
|
extendExpect();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
describe('documentation output', () => {
|
|
10
|
-
it('returns the name of the enum', async () => {
|
|
11
|
-
const input = `
|
|
12
|
-
public enum MyEnum {
|
|
13
|
-
VALUE1,
|
|
14
|
-
VALUE2
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
19
|
-
expect(result).documentationBundleHasLength(1);
|
|
20
|
-
assertEither(result, (data) => expect(data.docs[0].outputDocPath).toContain('MyEnum'));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('returns the type as enum', async () => {
|
|
24
|
-
const input = `
|
|
25
|
-
public enum MyEnum {
|
|
26
|
-
VALUE1,
|
|
27
|
-
VALUE2
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
32
|
-
expect(result).documentationBundleHasLength(1);
|
|
33
|
-
assertEither(result, (data) => expect(data.docs[0].source.type).toBe('enum'));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('does not return enums out of scope', async () => {
|
|
37
|
-
const input1 = `
|
|
38
|
-
global enum MyEnum {
|
|
39
|
-
VALUE1,
|
|
40
|
-
VALUE2
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
const input2 = `
|
|
45
|
-
public enum MyEnum {
|
|
46
|
-
VALUE1,
|
|
47
|
-
VALUE2
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
|
|
52
|
-
scope: ['global'],
|
|
53
|
-
})();
|
|
54
|
-
expect(result).documentationBundleHasLength(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('does not return enums that have an @ignore in the docs', async () => {
|
|
58
|
-
const input = `
|
|
59
|
-
/**
|
|
60
|
-
* @ignore
|
|
61
|
-
*/
|
|
62
|
-
public enum MyEnum {
|
|
63
|
-
VALUE1,
|
|
64
|
-
VALUE2
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
69
|
-
expect(result).documentationBundleHasLength(0);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
9
|
describe('documentation content', () => {
|
|
74
|
-
it('generates a heading with the enum name', async () => {
|
|
75
|
-
const input = `
|
|
76
|
-
public enum MyEnum {
|
|
77
|
-
VALUE1,
|
|
78
|
-
VALUE2
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
const output = `# MyEnum Enum`;
|
|
83
|
-
|
|
84
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
85
|
-
expect(result).documentationBundleHasLength(1);
|
|
86
|
-
assertEither(result, (data) => expect(data).firstDocContains(output));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('displays type level annotations', async () => {
|
|
90
|
-
const input = `
|
|
91
|
-
@NamespaceAccessible
|
|
92
|
-
public enum MyEnum {
|
|
93
|
-
VALUE1,
|
|
94
|
-
VALUE2
|
|
95
|
-
}
|
|
96
|
-
`;
|
|
97
|
-
|
|
98
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
99
|
-
expect(result).documentationBundleHasLength(1);
|
|
100
|
-
assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('displays the description', async () => {
|
|
104
|
-
const input = `
|
|
105
|
-
/**
|
|
106
|
-
* This is a description
|
|
107
|
-
*/
|
|
108
|
-
public enum MyEnum {
|
|
109
|
-
VALUE1,
|
|
110
|
-
VALUE2
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
113
|
-
|
|
114
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
115
|
-
expect(result).documentationBundleHasLength(1);
|
|
116
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('display custom documentation tags', async () => {
|
|
120
|
-
const input = `
|
|
121
|
-
/**
|
|
122
|
-
* @custom-tag My Value
|
|
123
|
-
*/
|
|
124
|
-
public enum MyEnum {
|
|
125
|
-
VALUE1,
|
|
126
|
-
VALUE2
|
|
127
|
-
}
|
|
128
|
-
`;
|
|
129
|
-
|
|
130
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
131
|
-
expect(result).documentationBundleHasLength(1);
|
|
132
|
-
assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
|
|
133
|
-
assertEither(result, (data) => expect(data).firstDocContains('My Value'));
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('displays the group', async () => {
|
|
137
|
-
const input = `
|
|
138
|
-
/**
|
|
139
|
-
* @group MyGroup
|
|
140
|
-
*/
|
|
141
|
-
public enum MyEnum {
|
|
142
|
-
VALUE1,
|
|
143
|
-
VALUE2
|
|
144
|
-
}
|
|
145
|
-
`;
|
|
146
|
-
|
|
147
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
148
|
-
expect(result).documentationBundleHasLength(1);
|
|
149
|
-
assertEither(result, (data) => expect(data).firstDocContains('Group'));
|
|
150
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('displays the author', async () => {
|
|
154
|
-
const input = `
|
|
155
|
-
/**
|
|
156
|
-
* @author John Doe
|
|
157
|
-
*/
|
|
158
|
-
public enum MyEnum {
|
|
159
|
-
VALUE1,
|
|
160
|
-
VALUE2
|
|
161
|
-
}
|
|
162
|
-
`;
|
|
163
|
-
|
|
164
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
165
|
-
expect(result).documentationBundleHasLength(1);
|
|
166
|
-
assertEither(result, (data) => expect(data).firstDocContains('Author'));
|
|
167
|
-
assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('displays the date', async () => {
|
|
171
|
-
const input = `
|
|
172
|
-
/**
|
|
173
|
-
* @date 2021-01-01
|
|
174
|
-
*/
|
|
175
|
-
public enum MyEnum {
|
|
176
|
-
VALUE1,
|
|
177
|
-
VALUE2
|
|
178
|
-
}
|
|
179
|
-
`;
|
|
180
|
-
|
|
181
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
182
|
-
expect(result).documentationBundleHasLength(1);
|
|
183
|
-
assertEither(result, (data) => expect(data).firstDocContains('Date'));
|
|
184
|
-
assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('displays descriptions', async () => {
|
|
188
|
-
const input = `
|
|
189
|
-
/**
|
|
190
|
-
* @description This is a description
|
|
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('This is a description'));
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('displays descriptions with links', async () => {
|
|
201
|
-
const input1 = `
|
|
202
|
-
/**
|
|
203
|
-
* @description This is a description with a {@link EnumRef} reference
|
|
204
|
-
*/
|
|
205
|
-
public enum MyEnum {}
|
|
206
|
-
`;
|
|
207
|
-
|
|
208
|
-
const input2 = 'public enum EnumRef {}';
|
|
209
|
-
|
|
210
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
211
|
-
expect(result).documentationBundleHasLength(2);
|
|
212
|
-
assertEither(result, (data) => expect(data).firstDocContains('Description'));
|
|
213
|
-
assertEither(result, (data) =>
|
|
214
|
-
expect(data).firstDocContains('This is a description with a [EnumRef](EnumRef.md) reference'),
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('displays descriptions with emails', async () => {
|
|
219
|
-
const input = `
|
|
220
|
-
/**
|
|
221
|
-
* @description This is a description with an {@email test@testerson.com} email
|
|
222
|
-
*/
|
|
223
|
-
public enum MyEnum {}
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
227
|
-
expect(result).documentationBundleHasLength(1);
|
|
228
|
-
assertEither(result, (data) =>
|
|
229
|
-
expect(data).firstDocContains(
|
|
230
|
-
'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
|
|
231
|
-
),
|
|
232
|
-
);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('displays sees with accurately resolved links', async () => {
|
|
236
|
-
const input1 = `
|
|
237
|
-
/**
|
|
238
|
-
* @see EnumRef
|
|
239
|
-
*/
|
|
240
|
-
public enum MyEnum {}
|
|
241
|
-
`;
|
|
242
|
-
|
|
243
|
-
const input2 = 'public enum EnumRef {}';
|
|
244
|
-
|
|
245
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
246
|
-
expect(result).documentationBundleHasLength(2);
|
|
247
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
248
|
-
assertEither(result, (data) => expect(data).firstDocContains('[EnumRef](EnumRef.md)'));
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it('displays sees without links when the reference is not found', async () => {
|
|
252
|
-
const input = `
|
|
253
|
-
/**
|
|
254
|
-
* @see EnumRef
|
|
255
|
-
*/
|
|
256
|
-
public enum MyEnum {}
|
|
257
|
-
`;
|
|
258
|
-
|
|
259
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
260
|
-
expect(result).documentationBundleHasLength(1);
|
|
261
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
262
|
-
assertEither(result, (data) => expect(data).firstDocContains('EnumRef'));
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it('displays the namespace if present in the config', async () => {
|
|
266
|
-
const input = `
|
|
267
|
-
public enum MyEnum {}
|
|
268
|
-
`;
|
|
269
|
-
|
|
270
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' })();
|
|
271
|
-
expect(result).documentationBundleHasLength(1);
|
|
272
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
|
|
273
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it('does not display the namespace if not present in the config', async () => {
|
|
277
|
-
const input = `
|
|
278
|
-
public enum MyEnum {}
|
|
279
|
-
`;
|
|
280
|
-
|
|
281
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
282
|
-
expect(result).documentationBundleHasLength(1);
|
|
283
|
-
assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('displays a mermaid diagram', async () => {
|
|
287
|
-
const input = `
|
|
288
|
-
/**
|
|
289
|
-
* @mermaid
|
|
290
|
-
* \`\`\`mermaid
|
|
291
|
-
* graph TD
|
|
292
|
-
* A[Square Rect] -- Link text --> B((Circle))
|
|
293
|
-
* A --> C(Round Rect)
|
|
294
|
-
* B --> D{Rhombus}
|
|
295
|
-
* C --> D
|
|
296
|
-
* \`\`\`
|
|
297
|
-
*/
|
|
298
|
-
public enum MyEnum {
|
|
299
|
-
VALUE1,
|
|
300
|
-
VALUE2
|
|
301
|
-
}
|
|
302
|
-
`;
|
|
303
|
-
|
|
304
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
305
|
-
expect(result).documentationBundleHasLength(1);
|
|
306
|
-
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
307
|
-
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('displays an example code block', async () => {
|
|
311
|
-
const input = `
|
|
312
|
-
/**
|
|
313
|
-
* @example
|
|
314
|
-
* \`\`\`apex
|
|
315
|
-
* public class MyClass {
|
|
316
|
-
* public void myMethod() {
|
|
317
|
-
* System.debug('Hello, World!');
|
|
318
|
-
* }
|
|
319
|
-
* }
|
|
320
|
-
* \`\`\`
|
|
321
|
-
*/
|
|
322
|
-
public enum MyEnum {
|
|
323
|
-
VALUE1,
|
|
324
|
-
VALUE2
|
|
325
|
-
}
|
|
326
|
-
`;
|
|
327
|
-
|
|
328
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
329
|
-
expect(result).documentationBundleHasLength(1);
|
|
330
|
-
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
331
|
-
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
332
|
-
});
|
|
333
|
-
|
|
334
10
|
it('displays values', async () => {
|
|
335
11
|
const input = `
|
|
336
12
|
public enum MyEnum {
|
|
@@ -346,7 +22,7 @@ describe('Generates enum documentation', () => {
|
|
|
346
22
|
assertEither(result, (data) => expect(data).firstDocContains('VALUE2'));
|
|
347
23
|
});
|
|
348
24
|
|
|
349
|
-
it('displays values sorted when
|
|
25
|
+
it('displays values sorted when sortAlphabetically is true', async () => {
|
|
350
26
|
const input = `
|
|
351
27
|
public enum MyEnum {
|
|
352
28
|
VALUE2,
|
|
@@ -354,7 +30,7 @@ describe('Generates enum documentation', () => {
|
|
|
354
30
|
}
|
|
355
31
|
`;
|
|
356
32
|
|
|
357
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
33
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
358
34
|
expect(result).documentationBundleHasLength(1);
|
|
359
35
|
assertEither(result, (data) => expect(data).firstDocContains('## Values'));
|
|
360
36
|
assertEither(result, (data) => {
|
|
@@ -364,7 +40,7 @@ describe('Generates enum documentation', () => {
|
|
|
364
40
|
});
|
|
365
41
|
});
|
|
366
42
|
|
|
367
|
-
it('does not sort values when
|
|
43
|
+
it('does not sort values when sortAlphabetically is false', async () => {
|
|
368
44
|
const input = `
|
|
369
45
|
public enum MyEnum {
|
|
370
46
|
VALUE2,
|
|
@@ -372,7 +48,7 @@ describe('Generates enum documentation', () => {
|
|
|
372
48
|
}
|
|
373
49
|
`;
|
|
374
50
|
|
|
375
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
51
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
376
52
|
expect(result).documentationBundleHasLength(1);
|
|
377
53
|
assertEither(result, (data) => expect(data).firstDocContains('## Values'));
|
|
378
54
|
assertEither(result, (data) => {
|
|
@@ -6,299 +6,7 @@ describe('Generates interface documentation', () => {
|
|
|
6
6
|
extendExpect();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
describe('documentation output', () => {
|
|
10
|
-
it('returns the name of the interface', async () => {
|
|
11
|
-
const input = `
|
|
12
|
-
public interface MyInterface {
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
17
|
-
expect(result).documentationBundleHasLength(1);
|
|
18
|
-
assertEither(result, (data) => expect(data.docs[0].source.name).toBe('MyInterface'));
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('returns the type as interface', async () => {
|
|
22
|
-
const input = `
|
|
23
|
-
public interface MyInterface {
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
28
|
-
expect(result).documentationBundleHasLength(1);
|
|
29
|
-
assertEither(result, (data) => expect(data.docs[0].source.type).toBe('interface'));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('does not return interfaces out of scope', async () => {
|
|
33
|
-
const input1 = `
|
|
34
|
-
global interface MyInterface {}
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
const input2 = `
|
|
38
|
-
public interface AnotherInterface {}
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
|
|
42
|
-
scope: ['global'],
|
|
43
|
-
})();
|
|
44
|
-
expect(result).documentationBundleHasLength(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('does not return interfaces that have an @ignore in the docs', async () => {
|
|
48
|
-
const input = `
|
|
49
|
-
/**
|
|
50
|
-
* @ignore
|
|
51
|
-
*/
|
|
52
|
-
public interface MyInterface {}`;
|
|
53
|
-
|
|
54
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
55
|
-
expect(result).documentationBundleHasLength(0);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('does not return interface methods that have @ignore in the docs', async () => {
|
|
59
|
-
const input = `
|
|
60
|
-
public interface MyInterface {
|
|
61
|
-
/**
|
|
62
|
-
* @ignore
|
|
63
|
-
*/
|
|
64
|
-
void myMethod();
|
|
65
|
-
}`;
|
|
66
|
-
|
|
67
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
68
|
-
expect(result).documentationBundleHasLength(1);
|
|
69
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('myMethod'));
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
9
|
describe('documentation content', () => {
|
|
74
|
-
describe('type level information', () => {
|
|
75
|
-
it('generates a heading with the interface name', async () => {
|
|
76
|
-
const input = `
|
|
77
|
-
public interface MyInterface {}
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
const output = `# MyInterface Interface`;
|
|
81
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
82
|
-
expect(result).documentationBundleHasLength(1);
|
|
83
|
-
assertEither(result, (data) => expect(data).firstDocContains(output));
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('displays type level annotations', async () => {
|
|
87
|
-
const input = `
|
|
88
|
-
@NamespaceAccessible
|
|
89
|
-
public interface MyInterface {
|
|
90
|
-
@Deprecated
|
|
91
|
-
void myMethod();
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
|
|
95
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
96
|
-
expect(result).documentationBundleHasLength(1);
|
|
97
|
-
assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
|
|
98
|
-
assertEither(result, (data) => expect(data).firstDocContains('DEPRECATED'));
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('displays the description', async () => {
|
|
102
|
-
const input = `
|
|
103
|
-
/**
|
|
104
|
-
* This is a description
|
|
105
|
-
*/
|
|
106
|
-
public interface MyInterface {}
|
|
107
|
-
`;
|
|
108
|
-
|
|
109
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
110
|
-
expect(result).documentationBundleHasLength(1);
|
|
111
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('display custom documentation tags', async () => {
|
|
115
|
-
const input = `
|
|
116
|
-
/**
|
|
117
|
-
* @custom-tag My Value
|
|
118
|
-
*/
|
|
119
|
-
public interface MyInterface {}
|
|
120
|
-
`;
|
|
121
|
-
|
|
122
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
123
|
-
expect(result).documentationBundleHasLength(1);
|
|
124
|
-
assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
|
|
125
|
-
assertEither(result, (data) => expect(data).firstDocContains('My Value'));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('displays the group', async () => {
|
|
129
|
-
const input = `
|
|
130
|
-
/**
|
|
131
|
-
* @group MyGroup
|
|
132
|
-
*/
|
|
133
|
-
public interface MyInterface {}`;
|
|
134
|
-
|
|
135
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
136
|
-
expect(result).documentationBundleHasLength(1);
|
|
137
|
-
assertEither(result, (data) => expect(data).firstDocContains('Group'));
|
|
138
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('displays the author', async () => {
|
|
142
|
-
const input = `
|
|
143
|
-
/**
|
|
144
|
-
* @author John Doe
|
|
145
|
-
*/
|
|
146
|
-
public interface MyInterface {}`;
|
|
147
|
-
|
|
148
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
149
|
-
expect(result).documentationBundleHasLength(1);
|
|
150
|
-
assertEither(result, (data) => expect(data).firstDocContains('Author'));
|
|
151
|
-
assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('displays the date', async () => {
|
|
155
|
-
const input = `
|
|
156
|
-
/**
|
|
157
|
-
* @date 2021-01-01
|
|
158
|
-
*/
|
|
159
|
-
public interface MyInterface {}`;
|
|
160
|
-
|
|
161
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
162
|
-
expect(result).documentationBundleHasLength(1);
|
|
163
|
-
assertEither(result, (data) => expect(data).firstDocContains('Date'));
|
|
164
|
-
assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('displays descriptions', async () => {
|
|
168
|
-
const input = `
|
|
169
|
-
/**
|
|
170
|
-
* @description This is a description
|
|
171
|
-
*/
|
|
172
|
-
public interface MyInterface {}`;
|
|
173
|
-
|
|
174
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
175
|
-
expect(result).documentationBundleHasLength(1);
|
|
176
|
-
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('displays descriptions with links', async () => {
|
|
180
|
-
const input1 = `
|
|
181
|
-
/**
|
|
182
|
-
* @description This is a description with a {@link InterfaceRef} reference
|
|
183
|
-
*/
|
|
184
|
-
public enum MyInterface {}
|
|
185
|
-
`;
|
|
186
|
-
|
|
187
|
-
const input2 = 'public interface InterfaceRef {}';
|
|
188
|
-
|
|
189
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
190
|
-
expect(result).documentationBundleHasLength(2);
|
|
191
|
-
assertEither(result, (data) =>
|
|
192
|
-
expect(data).firstDocContains('This is a description with a [InterfaceRef](InterfaceRef.md) reference'),
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('displays descriptions with emails', async () => {
|
|
197
|
-
const input = `
|
|
198
|
-
/**
|
|
199
|
-
* @description This is a description with an {@email test@testerson.com} email
|
|
200
|
-
*/
|
|
201
|
-
public interface MyInterface {}
|
|
202
|
-
`;
|
|
203
|
-
|
|
204
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
205
|
-
expect(result).documentationBundleHasLength(1);
|
|
206
|
-
assertEither(result, (data) =>
|
|
207
|
-
expect(data).firstDocContains(
|
|
208
|
-
'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
|
|
209
|
-
),
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('displays sees with accurately resolved links', async () => {
|
|
214
|
-
const input1 = `
|
|
215
|
-
/**
|
|
216
|
-
* @see InterfaceRef
|
|
217
|
-
*/
|
|
218
|
-
public interface MyInterface {}
|
|
219
|
-
`;
|
|
220
|
-
|
|
221
|
-
const input2 = 'public interface InterfaceRef {}';
|
|
222
|
-
|
|
223
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
224
|
-
expect(result).documentationBundleHasLength(2);
|
|
225
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
226
|
-
assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](InterfaceRef.md)'));
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('displays sees without links when the reference is not found', async () => {
|
|
230
|
-
const input = `
|
|
231
|
-
/**
|
|
232
|
-
* @see InterfaceRef
|
|
233
|
-
*/
|
|
234
|
-
public interface MyInterface {}
|
|
235
|
-
`;
|
|
236
|
-
|
|
237
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
238
|
-
expect(result).documentationBundleHasLength(1);
|
|
239
|
-
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
240
|
-
assertEither(result, (data) => expect(data).firstDocContains('InterfaceRef'));
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('displays the namespace if present in the config', async () => {
|
|
244
|
-
const input = 'public interface MyInterface {}';
|
|
245
|
-
|
|
246
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { namespace: 'MyNamespace' })();
|
|
247
|
-
expect(result).documentationBundleHasLength(1);
|
|
248
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
|
|
249
|
-
assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('does not display the namespace if not present in the config', async () => {
|
|
253
|
-
const input = 'public interface MyInterface {}';
|
|
254
|
-
|
|
255
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
256
|
-
expect(result).documentationBundleHasLength(1);
|
|
257
|
-
assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('displays a mermaid diagram', async () => {
|
|
261
|
-
const input = `
|
|
262
|
-
/**
|
|
263
|
-
* @mermaid
|
|
264
|
-
* \`\`\`mermaid
|
|
265
|
-
* graph TD
|
|
266
|
-
* A[Square Rect] -- Link text --> B((Circle))
|
|
267
|
-
* A --> C(Round Rect)
|
|
268
|
-
* B --> D{Rhombus}
|
|
269
|
-
* C --> D
|
|
270
|
-
* \`\`\`
|
|
271
|
-
*/
|
|
272
|
-
public interface MyInterface {}
|
|
273
|
-
`;
|
|
274
|
-
|
|
275
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
276
|
-
expect(result).documentationBundleHasLength(1);
|
|
277
|
-
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
278
|
-
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('displays an example code block', async () => {
|
|
282
|
-
const input = `
|
|
283
|
-
/**
|
|
284
|
-
* @example
|
|
285
|
-
* \`\`\`apex
|
|
286
|
-
* public class MyClass {
|
|
287
|
-
* public void myMethod() {
|
|
288
|
-
* System.debug('Hello, World!');
|
|
289
|
-
* }
|
|
290
|
-
* }
|
|
291
|
-
* \`\`\`
|
|
292
|
-
*/
|
|
293
|
-
public interface MyInterface {}`;
|
|
294
|
-
|
|
295
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
296
|
-
expect(result).documentationBundleHasLength(1);
|
|
297
|
-
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
298
|
-
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
10
|
describe('method information', () => {
|
|
303
11
|
it('displays the Method heading', async () => {
|
|
304
12
|
const input = `
|
|
@@ -312,7 +20,7 @@ describe('Generates interface documentation', () => {
|
|
|
312
20
|
assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
|
|
313
21
|
});
|
|
314
22
|
|
|
315
|
-
it('displays methods sorted if
|
|
23
|
+
it('displays methods sorted if sortAlphabetically is true', async () => {
|
|
316
24
|
const input = `
|
|
317
25
|
public interface MyInterface {
|
|
318
26
|
void myMethod();
|
|
@@ -320,14 +28,14 @@ describe('Generates interface documentation', () => {
|
|
|
320
28
|
}
|
|
321
29
|
`;
|
|
322
30
|
|
|
323
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
31
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
324
32
|
expect(result).documentationBundleHasLength(1);
|
|
325
33
|
assertEither(result, (data) => {
|
|
326
34
|
expect(data.docs[0].content.indexOf('anotherMethod')).toBeLessThan(data.docs[0].content.indexOf('myMethod'));
|
|
327
35
|
});
|
|
328
36
|
});
|
|
329
37
|
|
|
330
|
-
it('does not display methods sorted if
|
|
38
|
+
it('does not display methods sorted if sortAlphabetically is false', async () => {
|
|
331
39
|
const input = `
|
|
332
40
|
public interface MyInterface {
|
|
333
41
|
void myMethod();
|
|
@@ -335,7 +43,7 @@ describe('Generates interface documentation', () => {
|
|
|
335
43
|
}
|
|
336
44
|
`;
|
|
337
45
|
|
|
338
|
-
const result = await generateDocs([apexBundleFromRawString(input)], {
|
|
46
|
+
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
339
47
|
expect(result).documentationBundleHasLength(1);
|
|
340
48
|
assertEither(result, (data) => {
|
|
341
49
|
expect(data.docs[0].content.indexOf('myMethod')).toBeLessThan(data.docs[0].content.indexOf('anotherMethod'));
|