@cparra/apexdocs 3.0.0-beta.1 → 3.0.0-rc.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 +442 -325
- package/dist/cli/generate.js +1 -1
- package/dist/index.d.ts +15 -17
- 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/apexdocs.config.mjs +21 -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/vitepress/apexdocs.config.ts +7 -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/SampleClass.cls +1 -1
- package/package.json +2 -2
- package/src/cli/commands/markdown.ts +1 -3
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +1 -129
- package/src/core/markdown/__test__/generating-docs.spec.ts +111 -0
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -64
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -64
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +306 -0
- package/src/core/shared/types.d.ts +14 -16
- package/src/index.ts +23 -10
|
@@ -29,10 +29,15 @@ export default defineMarkdownConfig({
|
|
|
29
29
|
sourceDir: 'force-app',
|
|
30
30
|
scope: ['global', 'public', 'protected', 'private', 'namespaceaccessible'],
|
|
31
31
|
namespace: 'apexdocs',
|
|
32
|
-
|
|
32
|
+
transformReference: (reference) => {
|
|
33
|
+
return {
|
|
34
|
+
// remove the trailing .md
|
|
35
|
+
referencePath: reference.referencePath.replace(/\.md$/, ''),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
transformReferenceGuide: async () => {
|
|
33
39
|
const frontMatter = await loadFileAsync('./docs/index-frontmatter.md');
|
|
34
40
|
return {
|
|
35
|
-
...referenceGuide,
|
|
36
41
|
frontmatter: frontMatter,
|
|
37
42
|
};
|
|
38
43
|
},
|
|
@@ -19,38 +19,38 @@ hero:
|
|
|
19
19
|
|
|
20
20
|
## Miscellaneous
|
|
21
21
|
|
|
22
|
-
### [BaseClass](miscellaneous/BaseClass
|
|
22
|
+
### [BaseClass](miscellaneous/BaseClass)
|
|
23
23
|
|
|
24
|
-
### [MultiInheritanceClass](miscellaneous/MultiInheritanceClass
|
|
24
|
+
### [MultiInheritanceClass](miscellaneous/MultiInheritanceClass)
|
|
25
25
|
|
|
26
|
-
### [ParentInterface](miscellaneous/ParentInterface
|
|
26
|
+
### [ParentInterface](miscellaneous/ParentInterface)
|
|
27
27
|
|
|
28
|
-
### [ReferencedEnum](miscellaneous/ReferencedEnum
|
|
28
|
+
### [ReferencedEnum](miscellaneous/ReferencedEnum)
|
|
29
29
|
|
|
30
|
-
### [SampleException](miscellaneous/SampleException
|
|
30
|
+
### [SampleException](miscellaneous/SampleException)
|
|
31
31
|
|
|
32
32
|
This is a sample exception.
|
|
33
33
|
|
|
34
|
-
### [SampleInterface](miscellaneous/SampleInterface
|
|
34
|
+
### [SampleInterface](miscellaneous/SampleInterface)
|
|
35
35
|
|
|
36
36
|
This is a sample interface
|
|
37
37
|
|
|
38
|
-
### [Url](miscellaneous/Url
|
|
38
|
+
### [Url](miscellaneous/Url)
|
|
39
39
|
|
|
40
40
|
Represents a uniform resource locator (URL) and provides access to parts of the URL.
|
|
41
41
|
Enables access to the base URL used to access your Salesforce org.
|
|
42
42
|
|
|
43
43
|
## Sample Enums
|
|
44
44
|
|
|
45
|
-
### [SampleEnum](sample-enums/SampleEnum
|
|
45
|
+
### [SampleEnum](sample-enums/SampleEnum)
|
|
46
46
|
|
|
47
|
-
This is a sample enum. This references [ReferencedEnum](miscellaneous/ReferencedEnum
|
|
47
|
+
This is a sample enum. This references [ReferencedEnum](miscellaneous/ReferencedEnum) .
|
|
48
48
|
|
|
49
49
|
This description has several lines
|
|
50
50
|
|
|
51
51
|
## SampleGroup
|
|
52
52
|
|
|
53
|
-
### [SampleClass](samplegroup/SampleClass
|
|
53
|
+
### [SampleClass](samplegroup/SampleClass)
|
|
54
54
|
|
|
55
55
|
aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
|
|
56
|
-
deserunt ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
56
|
+
**deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
@@ -9,7 +9,7 @@ apexdocs
|
|
|
9
9
|
|
|
10
10
|
**Inheritance**
|
|
11
11
|
|
|
12
|
-
[SampleClass](../samplegroup/SampleClass
|
|
12
|
+
[SampleClass](../samplegroup/SampleClass) < [BaseClass](BaseClass)
|
|
13
13
|
|
|
14
14
|
## Fields
|
|
15
15
|
### `sampleEnumFromBase`
|
|
@@ -22,7 +22,7 @@ public sampleEnumFromBase
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
#### Type
|
|
25
|
-
[SampleEnum](../sample-enums/SampleEnum
|
|
25
|
+
[SampleEnum](../sample-enums/SampleEnum)
|
|
26
26
|
|
|
27
27
|
## Properties
|
|
28
28
|
### Group Name
|
|
@@ -9,7 +9,7 @@ This is a sample exception.
|
|
|
9
9
|
**Usage**
|
|
10
10
|
|
|
11
11
|
You can use the exception the following way.
|
|
12
|
-
You can also take a look at [SampleClass](../samplegroup/SampleClass
|
|
12
|
+
You can also take a look at [SampleClass](../samplegroup/SampleClass) to see how it is used.
|
|
13
13
|
This is a dangerous HTML tag: <script>alert('Hello');</script>
|
|
14
14
|
|
|
15
15
|
```apex
|
|
@@ -19,9 +19,9 @@ C -->|extends| D[GreatGrandParentInterface]
|
|
|
19
19
|
|
|
20
20
|
**Date** 2020-01-01
|
|
21
21
|
|
|
22
|
-
**See** [SampleEnum](../sample-enums/SampleEnum
|
|
22
|
+
**See** [SampleEnum](../sample-enums/SampleEnum)
|
|
23
23
|
|
|
24
|
-
**See** [ReferencedEnum](ReferencedEnum
|
|
24
|
+
**See** [ReferencedEnum](ReferencedEnum)
|
|
25
25
|
|
|
26
26
|
## Namespace
|
|
27
27
|
apexdocs
|
|
@@ -31,7 +31,7 @@ SampleInterface sampleInterface = new SampleInterface();
|
|
|
31
31
|
sampleInterface.sampleMethod();
|
|
32
32
|
|
|
33
33
|
**Extends**
|
|
34
|
-
[ParentInterface](ParentInterface
|
|
34
|
+
[ParentInterface](ParentInterface)
|
|
35
35
|
|
|
36
36
|
## Methods
|
|
37
37
|
### `sampleMethod()`
|
|
@@ -66,7 +66,7 @@ public String sampleMethod()
|
|
|
66
66
|
Some return value
|
|
67
67
|
|
|
68
68
|
#### Throws
|
|
69
|
-
[SampleException](SampleException
|
|
69
|
+
[SampleException](SampleException): This is a sample exception
|
|
70
70
|
|
|
71
71
|
AnotherSampleException: This is another sample exception
|
|
72
72
|
|
|
@@ -94,10 +94,10 @@ public SampleEnum sampleMethodWithParams(String param1, Integer param2, SampleEn
|
|
|
94
94
|
|------|------|-------------|
|
|
95
95
|
| param1 | String | This is the first parameter |
|
|
96
96
|
| param2 | Integer | This is the second parameter |
|
|
97
|
-
| theEnum | [SampleEnum](../sample-enums/SampleEnum
|
|
97
|
+
| theEnum | [SampleEnum](../sample-enums/SampleEnum) | This is an enum parameter |
|
|
98
98
|
|
|
99
99
|
#### Return Type
|
|
100
|
-
**[SampleEnum](../sample-enums/SampleEnum
|
|
100
|
+
**[SampleEnum](../sample-enums/SampleEnum)**
|
|
101
101
|
|
|
102
102
|
Some return value
|
|
103
103
|
|
|
@@ -120,7 +120,7 @@ global Url(Url context, String spec)
|
|
|
120
120
|
#### Parameters
|
|
121
121
|
| Name | Type | Description |
|
|
122
122
|
|------|------|-------------|
|
|
123
|
-
| context | [Url](Url
|
|
123
|
+
| context | [Url](Url) | The context in which to parse the specification. |
|
|
124
124
|
| spec | String | The string to parse as a URL. |
|
|
125
125
|
|
|
126
126
|
---
|
|
@@ -191,7 +191,7 @@ global static Url getCurrentRequestUrl()
|
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
#### Return Type
|
|
194
|
-
**[Url](Url
|
|
194
|
+
**[Url](Url)**
|
|
195
195
|
|
|
196
196
|
The URL of the entire request.
|
|
197
197
|
|
|
@@ -299,7 +299,7 @@ global static Url getOrgDomainUrl()
|
|
|
299
299
|
```
|
|
300
300
|
|
|
301
301
|
#### Return Type
|
|
302
|
-
**[Url](Url
|
|
302
|
+
**[Url](Url)**
|
|
303
303
|
|
|
304
304
|
getOrgDomainUrl() always returns the login URL for your org, regardless of context. Use that URL when making API calls to your org.
|
|
305
305
|
|
|
@@ -6,13 +6,13 @@ title: SampleEnum
|
|
|
6
6
|
|
|
7
7
|
`NAMESPACEACCESSIBLE`
|
|
8
8
|
|
|
9
|
-
This is a sample enum. This references [ReferencedEnum](../miscellaneous/ReferencedEnum
|
|
9
|
+
This is a sample enum. This references [ReferencedEnum](../miscellaneous/ReferencedEnum) .
|
|
10
10
|
|
|
11
11
|
This description has several lines
|
|
12
12
|
|
|
13
13
|
**Some Custom**
|
|
14
14
|
|
|
15
|
-
Test. I can also have a [ReferencedEnum](../miscellaneous/ReferencedEnum
|
|
15
|
+
Test. I can also have a [ReferencedEnum](../miscellaneous/ReferencedEnum) here.
|
|
16
16
|
And it can be multiline.
|
|
17
17
|
|
|
18
18
|
**Mermaid**
|
|
@@ -27,7 +27,7 @@ B -->|referenced by| A
|
|
|
27
27
|
|
|
28
28
|
**Date** 2022-01-01
|
|
29
29
|
|
|
30
|
-
**See** [ReferencedEnum](../miscellaneous/ReferencedEnum
|
|
30
|
+
**See** [ReferencedEnum](../miscellaneous/ReferencedEnum)
|
|
31
31
|
|
|
32
32
|
## Namespace
|
|
33
33
|
apexdocs
|
|
@@ -6,7 +6,7 @@ title: SampleClass
|
|
|
6
6
|
`virtual`
|
|
7
7
|
|
|
8
8
|
aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
|
|
9
|
-
deserunt ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
9
|
+
**deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
10
10
|
|
|
11
11
|
**Group** SampleGroup
|
|
12
12
|
|
|
@@ -19,12 +19,12 @@ sample.doSomething();
|
|
|
19
19
|
|
|
20
20
|
**Inheritance**
|
|
21
21
|
|
|
22
|
-
[BaseClass](../miscellaneous/BaseClass
|
|
22
|
+
[BaseClass](../miscellaneous/BaseClass)
|
|
23
23
|
|
|
24
24
|
**Implements**
|
|
25
25
|
|
|
26
|
-
[SampleInterface](../miscellaneous/SampleInterface
|
|
27
|
-
[ParentInterface](../miscellaneous/ParentInterface
|
|
26
|
+
[SampleInterface](../miscellaneous/SampleInterface),
|
|
27
|
+
[ParentInterface](../miscellaneous/ParentInterface)
|
|
28
28
|
|
|
29
29
|
## Fields
|
|
30
30
|
### Group Name
|
|
@@ -51,7 +51,7 @@ public sampleEnumFromBase
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
##### Type
|
|
54
|
-
[SampleEnum](../sample-enums/SampleEnum
|
|
54
|
+
[SampleEnum](../sample-enums/SampleEnum)
|
|
55
55
|
|
|
56
56
|
## Properties
|
|
57
57
|
### Group Name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
|
|
3
|
-
* deserunt ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
3
|
+
* **deserunt** ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
|
|
4
4
|
* @group SampleGroup
|
|
5
5
|
* @example
|
|
6
6
|
* SampleClass sample = new SampleClass();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "npm run build && jest",
|
|
20
|
+
"test:cov": "npm run build && jest --coverage",
|
|
20
21
|
"build": "rimraf ./lib && npm run lint && tsc --noEmit && pkgroll",
|
|
21
22
|
"lint": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
|
|
22
23
|
"prepare": "npm run build",
|
|
@@ -68,7 +69,6 @@
|
|
|
68
69
|
"fp-ts": "^2.16.8",
|
|
69
70
|
"handlebars": "^4.7.8",
|
|
70
71
|
"js-yaml": "^4.1.0",
|
|
71
|
-
"type-fest": "^4.23.0",
|
|
72
72
|
"yargs": "^17.7.2"
|
|
73
73
|
},
|
|
74
74
|
"imports": {
|
|
@@ -30,9 +30,7 @@ export const markdownOptions: { [key: string]: Options } = {
|
|
|
30
30
|
},
|
|
31
31
|
namespace: {
|
|
32
32
|
type: 'string',
|
|
33
|
-
describe:
|
|
34
|
-
'The package namespace, if any. If this value is provided the namespace will be added as a prefix to all of the parsed files. ' +
|
|
35
|
-
"If generating an OpenApi definition, it will be added to the file's Server Url.",
|
|
33
|
+
describe: 'The package namespace, if any. If provided, it will be added to the generated files.',
|
|
36
34
|
},
|
|
37
35
|
sortMembersAlphabetically: {
|
|
38
36
|
type: 'boolean',
|
|
@@ -1,139 +1,11 @@
|
|
|
1
1
|
import { assertEither, extendExpect } from './expect-extensions';
|
|
2
2
|
import { apexBundleFromRawString, generateDocs } from './test-helpers';
|
|
3
3
|
|
|
4
|
-
describe('
|
|
4
|
+
describe('When generating documentation for a class', () => {
|
|
5
5
|
beforeAll(() => {
|
|
6
6
|
extendExpect();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
describe('documentation output', () => {
|
|
10
|
-
it('returns the name of the class', async () => {
|
|
11
|
-
const input = 'public class MyClass {}';
|
|
12
|
-
|
|
13
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
14
|
-
expect(result).documentationBundleHasLength(1);
|
|
15
|
-
assertEither(result, (data) => expect(data.docs[0].outputDocPath).toContain('MyClass'));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('returns the type as class', async () => {
|
|
19
|
-
const input = 'public class MyClass {}';
|
|
20
|
-
|
|
21
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
22
|
-
expect(result).documentationBundleHasLength(1);
|
|
23
|
-
assertEither(result, (data) => expect(data.docs[0].source.type).toBe('class'));
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('does not return classes out of scope', async () => {
|
|
27
|
-
const input1 = `
|
|
28
|
-
global class MyClass {}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
const input2 = `
|
|
32
|
-
public class AnotherClass {}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
|
|
36
|
-
scope: ['global'],
|
|
37
|
-
})();
|
|
38
|
-
expect(result).documentationBundleHasLength(1);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('does not return classes that have an @ignore in the docs', async () => {
|
|
42
|
-
const input = `
|
|
43
|
-
/**
|
|
44
|
-
* @ignore
|
|
45
|
-
*/
|
|
46
|
-
public class MyClass {}`;
|
|
47
|
-
|
|
48
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
49
|
-
expect(result).documentationBundleHasLength(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('does not return class methods that have @ignore in the docs', async () => {
|
|
53
|
-
const input = `
|
|
54
|
-
public class MyClass {
|
|
55
|
-
/**
|
|
56
|
-
* @ignore
|
|
57
|
-
*/
|
|
58
|
-
public void myMethod() {}
|
|
59
|
-
}`;
|
|
60
|
-
|
|
61
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
62
|
-
expect(result).documentationBundleHasLength(1);
|
|
63
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('myMethod'));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('does not return class properties that have @ignore in the docs', async () => {
|
|
67
|
-
const input = `
|
|
68
|
-
public class MyClass {
|
|
69
|
-
/**
|
|
70
|
-
* @ignore
|
|
71
|
-
*/
|
|
72
|
-
public String myProperty { get; set; }
|
|
73
|
-
}`;
|
|
74
|
-
|
|
75
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
76
|
-
expect(result).documentationBundleHasLength(1);
|
|
77
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('myProperty'));
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('does not return class fields that have @ignore in the docs', async () => {
|
|
81
|
-
const input = `
|
|
82
|
-
public class MyClass {
|
|
83
|
-
/**
|
|
84
|
-
* @ignore
|
|
85
|
-
*/
|
|
86
|
-
public String myField;
|
|
87
|
-
}`;
|
|
88
|
-
|
|
89
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
90
|
-
expect(result).documentationBundleHasLength(1);
|
|
91
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('myField'));
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('does not return class inner classes that have @ignore in the docs', async () => {
|
|
95
|
-
const input = `
|
|
96
|
-
public class MyClass {
|
|
97
|
-
/**
|
|
98
|
-
* @ignore
|
|
99
|
-
*/
|
|
100
|
-
public class InnerClass {}
|
|
101
|
-
}`;
|
|
102
|
-
|
|
103
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
104
|
-
expect(result).documentationBundleHasLength(1);
|
|
105
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('InnerClass'));
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('does not return class inner interfaces that have @ignore in the docs', async () => {
|
|
109
|
-
const input = `
|
|
110
|
-
public class MyClass {
|
|
111
|
-
/**
|
|
112
|
-
* @ignore
|
|
113
|
-
*/
|
|
114
|
-
public interface InnerInterface {}
|
|
115
|
-
}`;
|
|
116
|
-
|
|
117
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
118
|
-
expect(result).documentationBundleHasLength(1);
|
|
119
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('InnerInterface'));
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('does not return class inner enums that have @ignore in the docs', async () => {
|
|
123
|
-
const input = `
|
|
124
|
-
public class MyClass {
|
|
125
|
-
/**
|
|
126
|
-
* @ignore
|
|
127
|
-
*/
|
|
128
|
-
public enum InnerEnum {}
|
|
129
|
-
}`;
|
|
130
|
-
|
|
131
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
132
|
-
expect(result).documentationBundleHasLength(1);
|
|
133
|
-
assertEither(result, (data) => expect(data.docs[0].content).not.toContain('InnerEnum'));
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
9
|
describe('documentation content', () => {
|
|
138
10
|
describe('type level information', () => {
|
|
139
11
|
it('generates a heading with the class name', async () => {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { DocPageData, PostHookDocumentationBundle } from '../../shared/types';
|
|
2
|
+
import { assertEither, extendExpect } from './expect-extensions';
|
|
3
|
+
import { apexBundleFromRawString, generateDocs } from './test-helpers';
|
|
4
|
+
|
|
5
|
+
function aSingleDoc(result: PostHookDocumentationBundle): DocPageData {
|
|
6
|
+
expect(result.docs).toHaveLength(1);
|
|
7
|
+
return result.docs[0];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe('When generating documentation', () => {
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
extendExpect();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('the resulting files', () => {
|
|
16
|
+
it('are named after the type', async () => {
|
|
17
|
+
const properties: [string, string][] = [
|
|
18
|
+
['public class MyClass {}', 'MyClass.md'],
|
|
19
|
+
['public interface MyInterface {}', 'MyInterface.md'],
|
|
20
|
+
['public enum MyEnum {}', 'MyEnum.md'],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
for (const [input, expected] of properties) {
|
|
24
|
+
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
25
|
+
assertEither(result, (data) => expect(aSingleDoc(data).outputDocPath).toContain(expected));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('are placed in the miscellaneous folder if no group is provided', async () => {
|
|
30
|
+
const properties: [string, string][] = [
|
|
31
|
+
['public class MyClass {}', 'miscellaneous'],
|
|
32
|
+
['public interface MyInterface {}', 'miscellaneous'],
|
|
33
|
+
['public enum MyEnum {}', 'miscellaneous'],
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
for (const [input, expected] of properties) {
|
|
37
|
+
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
38
|
+
assertEither(result, (data) => expect(aSingleDoc(data).outputDocPath).toContain(expected));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('are placed in the slugified group folder if a group is provided', async () => {
|
|
43
|
+
const properties: [string, string][] = [
|
|
44
|
+
[
|
|
45
|
+
`/**
|
|
46
|
+
* @group MyGroup
|
|
47
|
+
*/
|
|
48
|
+
public class MyClass {}`,
|
|
49
|
+
'mygroup',
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
`/**
|
|
53
|
+
* @group MyGroup
|
|
54
|
+
*/
|
|
55
|
+
public interface MyInterface {}`,
|
|
56
|
+
'mygroup',
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
`/**
|
|
60
|
+
* @group MyGroup
|
|
61
|
+
*/
|
|
62
|
+
public enum MyEnum {}`,
|
|
63
|
+
'mygroup',
|
|
64
|
+
],
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
for (const [input, expected] of properties) {
|
|
68
|
+
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
69
|
+
assertEither(result, (data) => expect(aSingleDoc(data).outputDocPath).toContain(expected));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('the generated bundles', () => {
|
|
75
|
+
it('return the type', async () => {
|
|
76
|
+
const properties: [string, string][] = [
|
|
77
|
+
['public class MyClass {}', 'class'],
|
|
78
|
+
['public interface MyInterface {}', 'interface'],
|
|
79
|
+
['public enum MyEnum {}', 'enum'],
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
for (const [input, expected] of properties) {
|
|
83
|
+
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
84
|
+
assertEither(result, (data) => expect(aSingleDoc(data).source.type).toBe(expected));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('the generated bundle', () => {
|
|
90
|
+
it('does not return files out of scope', async () => {
|
|
91
|
+
const input1 = 'global class MyClass {}';
|
|
92
|
+
const input2 = 'public class AnotherClass {}';
|
|
93
|
+
|
|
94
|
+
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)], {
|
|
95
|
+
scope: ['global'],
|
|
96
|
+
})();
|
|
97
|
+
expect(result).documentationBundleHasLength(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('does not return files that have an @ignore in the docs', async () => {
|
|
101
|
+
const input = `
|
|
102
|
+
/**
|
|
103
|
+
* @ignore
|
|
104
|
+
*/
|
|
105
|
+
public class MyClass {}`;
|
|
106
|
+
|
|
107
|
+
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
108
|
+
expect(result).documentationBundleHasLength(0);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -6,70 +6,6 @@ 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
10
|
it('generates a heading with the enum name', async () => {
|
|
75
11
|
const input = `
|