@cparra/apexdocs 2.25.0-alpha.0 → 2.25.0-alpha.2
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/__mocks__/chalk.js +12 -0
- package/__mocks__/log-update.js +6 -0
- package/eslint.config.mjs +10 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +16 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +73 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +15 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +8 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +7 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +115 -0
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +36 -0
- package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +173 -0
- package/examples/plain-markdown/docs/index.md +33 -0
- package/examples/plain-markdown/force-app/classes/MultiInheritanceClass.cls +1 -0
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +37 -0
- package/examples/plain-markdown/package.json +2 -6
- package/jest.config.js +4 -0
- package/jest.d.ts +7 -0
- package/lib/__spec__/core/expect-extensions.d.ts +3 -0
- package/lib/__spec__/core/expect-extensions.js +54 -0
- package/lib/__spec__/core/expect-extensions.js.map +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.js +427 -0
- package/lib/__spec__/core/generating-class-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js +303 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js +361 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js +161 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js.map +1 -0
- package/lib/adapters/apex-types.d.ts +5 -5
- package/lib/adapters/apex-types.js +97 -22
- package/lib/adapters/apex-types.js.map +1 -1
- package/lib/adapters/documentables.d.ts +4 -3
- package/lib/adapters/documentables.js +23 -8
- package/lib/adapters/documentables.js.map +1 -1
- package/lib/adapters/fields-and-properties.d.ts +4 -3
- package/lib/adapters/fields-and-properties.js +26 -5
- package/lib/adapters/fields-and-properties.js.map +1 -1
- package/lib/adapters/methods-and-constructors.d.ts +4 -3
- package/lib/adapters/methods-and-constructors.js +54 -12
- package/lib/adapters/methods-and-constructors.js.map +1 -1
- package/lib/adapters/references.d.ts +1 -1
- package/lib/adapters/references.js +3 -3
- package/lib/adapters/references.js.map +1 -1
- package/lib/adapters/type-utils.d.ts +1 -1
- package/lib/adapters/type-utils.js +1 -2
- package/lib/adapters/type-utils.js.map +1 -1
- package/lib/application/Apexdocs.js +21 -15
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/application/flows/generate-markdown-files.d.ts +3 -0
- package/lib/application/flows/generate-markdown-files.js +57 -0
- package/lib/application/flows/generate-markdown-files.js.map +1 -0
- package/lib/cli/generate.js +7 -7
- package/lib/cli/generate.js.map +1 -1
- package/lib/core/__test__/inheritance-chain.test.d.ts +1 -0
- package/lib/core/__test__/inheritance-chain.test.js +42 -0
- package/lib/core/__test__/inheritance-chain.test.js.map +1 -0
- package/lib/core/generate-docs.d.ts +24 -0
- package/lib/core/generate-docs.js +267 -0
- package/lib/core/generate-docs.js.map +1 -0
- package/lib/core/inheritance-chain.d.ts +2 -0
- package/lib/core/inheritance-chain.js +35 -0
- package/lib/core/inheritance-chain.js.map +1 -0
- package/lib/core/template.d.ts +10 -0
- package/lib/core/template.js +92 -0
- package/lib/core/template.js.map +1 -0
- package/lib/core/templates/reference-guide.d.ts +1 -0
- package/lib/core/templates/reference-guide.js +18 -0
- package/lib/core/templates/reference-guide.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +14 -3
- package/lib/index.js.map +1 -1
- package/lib/model/inheritance.d.ts +4 -1
- package/lib/model/manifest.js +8 -2
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.d.ts +2 -2
- package/lib/model/markdown-file.js +5 -4
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +3 -4
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.js +1 -2
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js +2 -3
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.js +1 -2
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/open-api.js.map +1 -1
- package/lib/model/outputFile.d.ts +1 -1
- package/lib/model/outputFile.js +2 -9
- package/lib/model/outputFile.js.map +1 -1
- package/lib/model/types-repository.js.map +1 -1
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.js +1 -2
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/metadata-processor.js.map +1 -1
- package/lib/service/parser.js +1 -1
- package/lib/service/parser.js.map +1 -1
- package/lib/service/state.js.map +1 -1
- package/lib/service/walkers/class-walker.js.map +1 -1
- package/lib/service/walkers/interface-walker.js.map +1 -1
- package/lib/service/walkers/walker-factory.js.map +1 -1
- package/lib/service/walkers/walker.js.map +1 -1
- package/lib/settings.d.ts +0 -6
- package/lib/settings.js +0 -11
- package/lib/settings.js.map +1 -1
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +4 -0
- package/lib/test-helpers/ClassMirrorBuilder.js +11 -1
- package/lib/test-helpers/ClassMirrorBuilder.js.map +1 -1
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/class-template.js +53 -12
- package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +13 -16
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +11 -8
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/enum-template.js +7 -6
- package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +9 -6
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js +10 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js +4 -4
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +18 -20
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +0 -4
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +6 -86
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js +31 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js.map +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +3 -2
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -1
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.js +1 -1
- package/lib/util/logger.js.map +1 -1
- package/lib/util/string-utils.js +2 -2
- package/lib/util/string-utils.js.map +1 -1
- package/package.json +17 -17
- package/src/__spec__/core/expect-extensions.ts +32 -0
- package/src/__spec__/core/generating-class-docs.spec.ts +511 -0
- package/src/__spec__/core/generating-enum-docs.spec.ts +355 -0
- package/src/__spec__/core/generating-interface-docs.spec.ts +431 -0
- package/src/__spec__/core/generating-reference-guide.spec.ts +163 -0
- package/src/adapters/__tests__/interface-adapter.spec.ts +15 -11
- package/src/adapters/__tests__/references.spec.ts +1 -1
- package/src/adapters/apex-types.ts +205 -41
- package/src/adapters/documentables.ts +44 -9
- package/src/adapters/fields-and-properties.ts +31 -7
- package/src/adapters/methods-and-constructors.ts +65 -22
- package/src/adapters/references.ts +1 -1
- package/src/adapters/type-utils.ts +1 -1
- package/src/application/Apexdocs.ts +21 -15
- package/src/application/flows/generate-markdown-files.ts +47 -0
- package/src/cli/generate.ts +96 -96
- package/src/core/__test__/inheritance-chain.test.ts +54 -0
- package/src/core/generate-docs.ts +396 -0
- package/src/core/inheritance-chain.ts +23 -0
- package/src/core/renderable/types.d.ts +131 -0
- package/src/core/template.ts +108 -0
- package/src/core/templates/reference-guide.ts +14 -0
- package/src/index.ts +3 -1
- package/src/model/inheritance.ts +2 -1
- package/src/model/manifest.ts +12 -2
- package/src/model/markdown-file.ts +5 -4
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +1 -1
- package/src/model/markdown-generation-util/method-declaration-util.ts +1 -1
- package/src/model/outputFile.ts +2 -11
- package/src/service/parser.ts +1 -1
- package/src/settings.ts +0 -15
- package/src/test-helpers/ClassMirrorBuilder.ts +14 -1
- package/src/transpiler/markdown/class-file-generatorHelper.ts +1 -1
- package/src/transpiler/markdown/plain-markdown/class-template.ts +53 -12
- package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +13 -16
- package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +11 -8
- package/src/transpiler/markdown/plain-markdown/enum-template.ts +7 -6
- package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +9 -6
- package/src/transpiler/markdown/plain-markdown/grouped-members-partial-template.ts +6 -0
- package/src/transpiler/markdown/plain-markdown/interface-template.ts +4 -4
- package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +18 -20
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +8 -100
- package/src/transpiler/markdown/plain-markdown/type-doc-partial.ts +27 -0
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +3 -2
- package/src/util/logger.ts +1 -1
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -12
- package/examples/plain-markdown/README.md +0 -301
- package/lib/templating/compile.d.ts +0 -7
- package/lib/templating/compile.js +0 -98
- package/lib/templating/compile.js.map +0 -1
- package/lib/templating/helpers.d.ts +0 -2
- package/lib/templating/helpers.js +0 -18
- package/lib/templating/helpers.js.map +0 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.d.ts +0 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js +0 -31
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js.map +0 -1
- package/src/templating/__tests__/compile.spec.ts +0 -741
- package/src/templating/compile.ts +0 -187
- package/src/templating/helpers.ts +0 -14
- package/src/templating/types.d.ts +0 -104
- package/src/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.ts +0 -27
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { generateDocs } from '../../core/generate-docs';
|
|
2
|
+
import { assertEither, extendExpect } from './expect-extensions';
|
|
3
|
+
|
|
4
|
+
describe('Generates enum documentation', () => {
|
|
5
|
+
beforeAll(() => {
|
|
6
|
+
extendExpect();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('documentation output', () => {
|
|
10
|
+
it('always returns markdown as the format', () => {
|
|
11
|
+
const input = `
|
|
12
|
+
public enum MyEnum {
|
|
13
|
+
VALUE1,
|
|
14
|
+
VALUE2
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const result = generateDocs([input]);
|
|
19
|
+
assertEither(result, (data) => expect(data.format).toBe('markdown'));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns the name of the enum', () => {
|
|
23
|
+
const input = `
|
|
24
|
+
public enum MyEnum {
|
|
25
|
+
VALUE1,
|
|
26
|
+
VALUE2
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const result = generateDocs([input]);
|
|
31
|
+
expect(result).documentationBundleHasLength(1);
|
|
32
|
+
assertEither(result, (data) => expect(data.docs[0].typeName).toBe('MyEnum'));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('returns the type as enum', () => {
|
|
36
|
+
const input = `
|
|
37
|
+
public enum MyEnum {
|
|
38
|
+
VALUE1,
|
|
39
|
+
VALUE2
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
const result = generateDocs([input]);
|
|
44
|
+
expect(result).documentationBundleHasLength(1);
|
|
45
|
+
assertEither(result, (data) => expect(data.docs[0].type).toBe('enum'));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('does not return enums out of scope', () => {
|
|
49
|
+
const input1 = `
|
|
50
|
+
global enum MyEnum {
|
|
51
|
+
VALUE1,
|
|
52
|
+
VALUE2
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const input2 = `
|
|
57
|
+
public enum MyEnum {
|
|
58
|
+
VALUE1,
|
|
59
|
+
VALUE2
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const result = generateDocs([input1, input2], { scope: ['global'] });
|
|
64
|
+
expect(result).documentationBundleHasLength(1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('does not return enums that have an @ignore in the docs', () => {
|
|
68
|
+
const input = `
|
|
69
|
+
/**
|
|
70
|
+
* @ignore
|
|
71
|
+
*/
|
|
72
|
+
public enum MyEnum {
|
|
73
|
+
VALUE1,
|
|
74
|
+
VALUE2
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
const result = generateDocs([input]);
|
|
79
|
+
expect(result).documentationBundleHasLength(0);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('documentation content', () => {
|
|
84
|
+
it('generates a heading with the enum name', () => {
|
|
85
|
+
const input = `
|
|
86
|
+
public enum MyEnum {
|
|
87
|
+
VALUE1,
|
|
88
|
+
VALUE2
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const output = `# MyEnum Enum`;
|
|
93
|
+
|
|
94
|
+
const result = generateDocs([input]);
|
|
95
|
+
expect(result).documentationBundleHasLength(1);
|
|
96
|
+
assertEither(result, (data) => expect(data).firstDocContains(output));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('displays type level annotations', () => {
|
|
100
|
+
const input = `
|
|
101
|
+
@NamespaceAccessible
|
|
102
|
+
public enum MyEnum {
|
|
103
|
+
VALUE1,
|
|
104
|
+
VALUE2
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
const result = generateDocs([input]);
|
|
109
|
+
expect(result).documentationBundleHasLength(1);
|
|
110
|
+
assertEither(result, (data) => expect(data).firstDocContains('NAMESPACEACCESSIBLE'));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('displays the description', () => {
|
|
114
|
+
const input = `
|
|
115
|
+
/**
|
|
116
|
+
* This is a description
|
|
117
|
+
*/
|
|
118
|
+
public enum MyEnum {
|
|
119
|
+
VALUE1,
|
|
120
|
+
VALUE2
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const result = generateDocs([input]);
|
|
125
|
+
expect(result).documentationBundleHasLength(1);
|
|
126
|
+
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('display custom documentation tags', () => {
|
|
130
|
+
const input = `
|
|
131
|
+
/**
|
|
132
|
+
* @custom-tag My Value
|
|
133
|
+
*/
|
|
134
|
+
public enum MyEnum {
|
|
135
|
+
VALUE1,
|
|
136
|
+
VALUE2
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const result = generateDocs([input]);
|
|
141
|
+
expect(result).documentationBundleHasLength(1);
|
|
142
|
+
assertEither(result, (data) => expect(data).firstDocContains('Custom Tag'));
|
|
143
|
+
assertEither(result, (data) => expect(data).firstDocContains('My Value'));
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('displays the group', () => {
|
|
147
|
+
const input = `
|
|
148
|
+
/**
|
|
149
|
+
* @group MyGroup
|
|
150
|
+
*/
|
|
151
|
+
public enum MyEnum {
|
|
152
|
+
VALUE1,
|
|
153
|
+
VALUE2
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
const result = generateDocs([input]);
|
|
158
|
+
expect(result).documentationBundleHasLength(1);
|
|
159
|
+
assertEither(result, (data) => expect(data).firstDocContains('Group'));
|
|
160
|
+
assertEither(result, (data) => expect(data).firstDocContains('MyGroup'));
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('displays the author', () => {
|
|
164
|
+
const input = `
|
|
165
|
+
/**
|
|
166
|
+
* @author John Doe
|
|
167
|
+
*/
|
|
168
|
+
public enum MyEnum {
|
|
169
|
+
VALUE1,
|
|
170
|
+
VALUE2
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
const result = generateDocs([input]);
|
|
175
|
+
expect(result).documentationBundleHasLength(1);
|
|
176
|
+
assertEither(result, (data) => expect(data).firstDocContains('Author'));
|
|
177
|
+
assertEither(result, (data) => expect(data).firstDocContains('John Doe'));
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('displays the date', () => {
|
|
181
|
+
const input = `
|
|
182
|
+
/**
|
|
183
|
+
* @date 2021-01-01
|
|
184
|
+
*/
|
|
185
|
+
public enum MyEnum {
|
|
186
|
+
VALUE1,
|
|
187
|
+
VALUE2
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
const result = generateDocs([input]);
|
|
192
|
+
expect(result).documentationBundleHasLength(1);
|
|
193
|
+
assertEither(result, (data) => expect(data).firstDocContains('Date'));
|
|
194
|
+
assertEither(result, (data) => expect(data).firstDocContains('2021-01-01'));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('displays descriptions', () => {
|
|
198
|
+
const input = `
|
|
199
|
+
/**
|
|
200
|
+
* @description This is a description
|
|
201
|
+
*/
|
|
202
|
+
public enum MyEnum {}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
const result = generateDocs([input]);
|
|
206
|
+
expect(result).documentationBundleHasLength(1);
|
|
207
|
+
assertEither(result, (data) => expect(data).firstDocContains('This is a description'));
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('displays descriptions with links', () => {
|
|
211
|
+
const input1 = `
|
|
212
|
+
/**
|
|
213
|
+
* @description This is a description with a {@link EnumRef} reference
|
|
214
|
+
*/
|
|
215
|
+
public enum MyEnum {}
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
const input2 = 'public enum EnumRef {}';
|
|
219
|
+
|
|
220
|
+
const result = generateDocs([input1, input2]);
|
|
221
|
+
expect(result).documentationBundleHasLength(2);
|
|
222
|
+
assertEither(result, (data) => expect(data).firstDocContains('Description'));
|
|
223
|
+
assertEither(result, (data) =>
|
|
224
|
+
expect(data).firstDocContains('This is a description with a [EnumRef](./EnumRef.md) reference'),
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('displays descriptions with emails', () => {
|
|
229
|
+
const input = `
|
|
230
|
+
/**
|
|
231
|
+
* @description This is a description with an {@email test@testerson.com} email
|
|
232
|
+
*/
|
|
233
|
+
public enum MyEnum {}
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
const result = generateDocs([input]);
|
|
237
|
+
expect(result).documentationBundleHasLength(1);
|
|
238
|
+
assertEither(result, (data) =>
|
|
239
|
+
expect(data).firstDocContains(
|
|
240
|
+
'This is a description with an [test@testerson.com](mailto:test@testerson.com) email',
|
|
241
|
+
),
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('displays sees with accurately resolved links', () => {
|
|
246
|
+
const input1 = `
|
|
247
|
+
/**
|
|
248
|
+
* @see EnumRef
|
|
249
|
+
*/
|
|
250
|
+
public enum MyEnum {}
|
|
251
|
+
`;
|
|
252
|
+
|
|
253
|
+
const input2 = 'public enum EnumRef {}';
|
|
254
|
+
|
|
255
|
+
const result = generateDocs([input1, input2]);
|
|
256
|
+
expect(result).documentationBundleHasLength(2);
|
|
257
|
+
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
258
|
+
assertEither(result, (data) => expect(data).firstDocContains('[EnumRef](./EnumRef.md)'));
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('displays sees without links when the reference is not found', () => {
|
|
262
|
+
const input = `
|
|
263
|
+
/**
|
|
264
|
+
* @see EnumRef
|
|
265
|
+
*/
|
|
266
|
+
public enum MyEnum {}
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
const result = generateDocs([input]);
|
|
270
|
+
expect(result).documentationBundleHasLength(1);
|
|
271
|
+
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
272
|
+
assertEither(result, (data) => expect(data).firstDocContains('EnumRef'));
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('displays the namespace if present in the config', () => {
|
|
276
|
+
const input = `
|
|
277
|
+
public enum MyEnum {}
|
|
278
|
+
`;
|
|
279
|
+
|
|
280
|
+
const result = generateDocs([input], { namespace: 'MyNamespace' });
|
|
281
|
+
expect(result).documentationBundleHasLength(1);
|
|
282
|
+
assertEither(result, (data) => expect(data).firstDocContains('## Namespace'));
|
|
283
|
+
assertEither(result, (data) => expect(data).firstDocContains('MyNamespace'));
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('does not display the namespace if not present in the config', () => {
|
|
287
|
+
const input = `
|
|
288
|
+
public enum MyEnum {}
|
|
289
|
+
`;
|
|
290
|
+
|
|
291
|
+
const result = generateDocs([input]);
|
|
292
|
+
expect(result).documentationBundleHasLength(1);
|
|
293
|
+
assertEither(result, (data) => expect(data).firstDocContainsNot('## Namespace'));
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('displays a mermaid diagram', () => {
|
|
297
|
+
const input = `
|
|
298
|
+
/**
|
|
299
|
+
* @mermaid
|
|
300
|
+
* graph TD
|
|
301
|
+
* A[Square Rect] -- Link text --> B((Circle))
|
|
302
|
+
* A --> C(Round Rect)
|
|
303
|
+
* B --> D{Rhombus}
|
|
304
|
+
* C --> D
|
|
305
|
+
*/
|
|
306
|
+
public enum MyEnum {
|
|
307
|
+
VALUE1,
|
|
308
|
+
VALUE2
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
|
|
312
|
+
const result = generateDocs([input]);
|
|
313
|
+
expect(result).documentationBundleHasLength(1);
|
|
314
|
+
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
315
|
+
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('displays an example code block', () => {
|
|
319
|
+
const input = `
|
|
320
|
+
/**
|
|
321
|
+
* @example
|
|
322
|
+
* public class MyClass {
|
|
323
|
+
* public void myMethod() {
|
|
324
|
+
* System.debug('Hello, World!');
|
|
325
|
+
* }
|
|
326
|
+
* }
|
|
327
|
+
*/
|
|
328
|
+
public enum MyEnum {
|
|
329
|
+
VALUE1,
|
|
330
|
+
VALUE2
|
|
331
|
+
}
|
|
332
|
+
`;
|
|
333
|
+
|
|
334
|
+
const result = generateDocs([input]);
|
|
335
|
+
expect(result).documentationBundleHasLength(1);
|
|
336
|
+
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
337
|
+
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('displays values', () => {
|
|
341
|
+
const input = `
|
|
342
|
+
public enum MyEnum {
|
|
343
|
+
VALUE1,
|
|
344
|
+
VALUE2
|
|
345
|
+
}
|
|
346
|
+
`;
|
|
347
|
+
|
|
348
|
+
const result = generateDocs([input]);
|
|
349
|
+
expect(result).documentationBundleHasLength(1);
|
|
350
|
+
assertEither(result, (data) => expect(data).firstDocContains('## Values'));
|
|
351
|
+
assertEither(result, (data) => expect(data).firstDocContains('VALUE1'));
|
|
352
|
+
assertEither(result, (data) => expect(data).firstDocContains('VALUE2'));
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
});
|