@cparra/apexdocs 2.25.0-alpha.8 → 2.25.0-alpha.9
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/dist/cli/generate.js +153 -165
- package/dist/index.d.ts +51 -13
- package/examples/plain-markdown/docs/index.md +25 -33
- package/examples/plain-markdown/docs/{Miscellaneous/ns.BaseClass.md → miscellaneous/BaseClass.md} +1 -1
- package/examples/plain-markdown/docs/{Miscellaneous/ns.MultiInheritanceClass.md → miscellaneous/MultiInheritanceClass.md} +5 -6
- package/examples/plain-markdown/docs/{Miscellaneous/ns.SampleException.md → miscellaneous/SampleException.md} +3 -4
- package/examples/plain-markdown/docs/{Miscellaneous/ns.SampleInterface.md → miscellaneous/SampleInterface.md} +22 -29
- package/examples/plain-markdown/docs/{Miscellaneous/ns.Url.md → miscellaneous/Url.md} +32 -43
- package/examples/plain-markdown/docs/sample-enums/SampleEnum.md +36 -0
- package/examples/plain-markdown/docs/{SampleGroup/ns.SampleClass.md → samplegroup/SampleClass.md} +8 -11
- package/examples/vitepress/apexdocs.config.ts +1 -3
- package/examples/vitepress/docs/.vitepress/sidebar.json +18 -18
- package/examples/vitepress/docs/index.md +10 -10
- package/examples/vitepress/docs/{Miscellaneous/apexdocs.BaseClass.md → miscellaneous/BaseClass.md} +1 -1
- package/examples/vitepress/docs/{Miscellaneous/apexdocs.MultiInheritanceClass.md → miscellaneous/MultiInheritanceClass.md} +2 -2
- package/examples/vitepress/docs/{Miscellaneous/apexdocs.SampleException.md → miscellaneous/SampleException.md} +1 -1
- package/examples/vitepress/docs/{Miscellaneous/apexdocs.SampleInterface.md → miscellaneous/SampleInterface.md} +6 -6
- package/examples/vitepress/docs/{Miscellaneous/apexdocs.Url.md → miscellaneous/Url.md} +3 -3
- package/examples/vitepress/docs/{Sample-Enums/apexdocs.SampleEnum.md → sample-enums/SampleEnum.md} +3 -3
- package/examples/vitepress/docs/{SampleGroup/apexdocs.SampleClass.md → samplegroup/SampleClass.md} +4 -4
- package/package.json +1 -1
- package/src/application/apex-file-reader.ts +3 -3
- package/src/application/file-writer.ts +5 -9
- package/src/application/generators/markdown.ts +9 -4
- package/src/application/generators/openapi.ts +4 -4
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +5 -3
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +3 -3
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +5 -3
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +3 -7
- package/src/core/markdown/__test__/test-helpers.ts +3 -3
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +40 -5
- package/src/core/markdown/adapters/apex-types.ts +3 -2
- package/src/core/markdown/adapters/reference-guide.ts +35 -0
- package/src/core/markdown/adapters/renderable-bundle.ts +43 -119
- package/src/core/markdown/adapters/renderable-to-page-data.ts +12 -15
- package/src/core/markdown/adapters/types.d.ts +4 -6
- package/src/core/markdown/generate-docs.ts +99 -42
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +1 -1
- package/src/core/markdown/reflection/reflect-source.ts +8 -4
- package/src/core/openapi/manifest-factory.ts +2 -2
- package/src/core/openapi/openapi-type-file.ts +1 -3
- package/src/core/openapi/parser.ts +4 -4
- package/src/core/shared/types.d.ts +52 -14
- package/src/index.ts +2 -1
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +0 -38
- /package/examples/plain-markdown/docs/{Miscellaneous/ns.ParentInterface.md → miscellaneous/ParentInterface.md} +0 -0
- /package/examples/plain-markdown/docs/{Miscellaneous/ns.ReferencedEnum.md → miscellaneous/ReferencedEnum.md} +0 -0
- /package/examples/vitepress/docs/{Miscellaneous/apexdocs.ParentInterface.md → miscellaneous/ParentInterface.md} +0 -0
- /package/examples/vitepress/docs/{Miscellaneous/apexdocs.ReferencedEnum.md → miscellaneous/ReferencedEnum.md} +0 -0
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"items": [
|
|
11
11
|
{
|
|
12
12
|
"text": "BaseClass",
|
|
13
|
-
"link": "
|
|
13
|
+
"link": "miscellaneous/BaseClass.md"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"text": "MultiInheritanceClass",
|
|
17
|
-
"link": "
|
|
17
|
+
"link": "miscellaneous/MultiInheritanceClass.md"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"text": "SampleClass",
|
|
21
|
-
"link": "
|
|
21
|
+
"link": "samplegroup/SampleClass.md"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"text": "SampleException",
|
|
25
|
-
"link": "
|
|
25
|
+
"link": "miscellaneous/SampleException.md"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"text": "Url",
|
|
29
|
-
"link": "
|
|
29
|
+
"link": "miscellaneous/Url.md"
|
|
30
30
|
}
|
|
31
31
|
]
|
|
32
32
|
},
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"items": [
|
|
36
36
|
{
|
|
37
37
|
"text": "ParentInterface",
|
|
38
|
-
"link": "
|
|
38
|
+
"link": "miscellaneous/ParentInterface.md"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"text": "SampleInterface",
|
|
42
|
-
"link": "
|
|
42
|
+
"link": "miscellaneous/SampleInterface.md"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
45
45
|
},
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"items": [
|
|
49
49
|
{
|
|
50
50
|
"text": "ReferencedEnum",
|
|
51
|
-
"link": "
|
|
51
|
+
"link": "miscellaneous/ReferencedEnum.md"
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"text": "SampleEnum",
|
|
55
|
-
"link": "
|
|
55
|
+
"link": "sample-enums/SampleEnum.md"
|
|
56
56
|
}
|
|
57
57
|
]
|
|
58
58
|
}
|
|
@@ -66,31 +66,31 @@
|
|
|
66
66
|
"items": [
|
|
67
67
|
{
|
|
68
68
|
"text": "BaseClass",
|
|
69
|
-
"link": "
|
|
69
|
+
"link": "miscellaneous/BaseClass.md"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"text": "MultiInheritanceClass",
|
|
73
|
-
"link": "
|
|
73
|
+
"link": "miscellaneous/MultiInheritanceClass.md"
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"text": "ParentInterface",
|
|
77
|
-
"link": "
|
|
77
|
+
"link": "miscellaneous/ParentInterface.md"
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"text": "ReferencedEnum",
|
|
81
|
-
"link": "
|
|
81
|
+
"link": "miscellaneous/ReferencedEnum.md"
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"text": "SampleException",
|
|
85
|
-
"link": "
|
|
85
|
+
"link": "miscellaneous/SampleException.md"
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
"text": "SampleInterface",
|
|
89
|
-
"link": "
|
|
89
|
+
"link": "miscellaneous/SampleInterface.md"
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
"text": "Url",
|
|
93
|
-
"link": "
|
|
93
|
+
"link": "miscellaneous/Url.md"
|
|
94
94
|
}
|
|
95
95
|
]
|
|
96
96
|
},
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"items": [
|
|
100
100
|
{
|
|
101
101
|
"text": "SampleClass",
|
|
102
|
-
"link": "
|
|
102
|
+
"link": "samplegroup/SampleClass.md"
|
|
103
103
|
}
|
|
104
104
|
]
|
|
105
105
|
},
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"items": [
|
|
109
109
|
{
|
|
110
110
|
"text": "SampleEnum",
|
|
111
|
-
"link": "
|
|
111
|
+
"link": "sample-enums/SampleEnum.md"
|
|
112
112
|
}
|
|
113
113
|
]
|
|
114
114
|
}
|
|
@@ -19,38 +19,38 @@ hero:
|
|
|
19
19
|
|
|
20
20
|
## Miscellaneous
|
|
21
21
|
|
|
22
|
-
### [
|
|
22
|
+
### [BaseClass](/miscellaneous/BaseClass.md)
|
|
23
23
|
|
|
24
|
-
### [
|
|
24
|
+
### [MultiInheritanceClass](/miscellaneous/MultiInheritanceClass.md)
|
|
25
25
|
|
|
26
|
-
### [
|
|
26
|
+
### [ParentInterface](/miscellaneous/ParentInterface.md)
|
|
27
27
|
|
|
28
|
-
### [
|
|
28
|
+
### [ReferencedEnum](/miscellaneous/ReferencedEnum.md)
|
|
29
29
|
|
|
30
|
-
### [
|
|
30
|
+
### [SampleException](/miscellaneous/SampleException.md)
|
|
31
31
|
|
|
32
32
|
This is a sample exception.
|
|
33
33
|
|
|
34
|
-
### [
|
|
34
|
+
### [SampleInterface](/miscellaneous/SampleInterface.md)
|
|
35
35
|
|
|
36
36
|
This is a sample interface
|
|
37
37
|
|
|
38
|
-
### [
|
|
38
|
+
### [Url](/miscellaneous/Url.md)
|
|
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
|
-
### [
|
|
45
|
+
### [SampleEnum](/sample-enums/SampleEnum.md)
|
|
46
46
|
|
|
47
|
-
This is a sample enum. This references [
|
|
47
|
+
This is a sample enum. This references [ReferencedEnum](/miscellaneous/ReferencedEnum.md) .
|
|
48
48
|
|
|
49
49
|
This description has several lines
|
|
50
50
|
|
|
51
51
|
## SampleGroup
|
|
52
52
|
|
|
53
|
-
### [
|
|
53
|
+
### [SampleClass](/samplegroup/SampleClass.md)
|
|
54
54
|
|
|
55
55
|
aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
|
|
56
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
|
-
[
|
|
12
|
+
[SampleClass](/samplegroup/SampleClass.md) < [BaseClass](/miscellaneous/BaseClass.md)
|
|
13
13
|
|
|
14
14
|
## Fields
|
|
15
15
|
### `sampleEnumFromBase`
|
|
@@ -22,7 +22,7 @@ public sampleEnumFromBase
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
#### Type
|
|
25
|
-
[
|
|
25
|
+
[SampleEnum](/sample-enums/SampleEnum.md)
|
|
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 [
|
|
12
|
+
You can also take a look at [SampleClass](/samplegroup/SampleClass.md) 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** [
|
|
22
|
+
**See** [SampleEnum](/sample-enums/SampleEnum.md)
|
|
23
23
|
|
|
24
|
-
**See** [
|
|
24
|
+
**See** [ReferencedEnum](/miscellaneous/ReferencedEnum.md)
|
|
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
|
-
[
|
|
34
|
+
[ParentInterface](/miscellaneous/ParentInterface.md)
|
|
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
|
-
[
|
|
69
|
+
[SampleException](/miscellaneous/SampleException.md): 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 | [
|
|
97
|
+
| theEnum | [SampleEnum](/sample-enums/SampleEnum.md) | This is an enum parameter |
|
|
98
98
|
|
|
99
99
|
#### Return Type
|
|
100
|
-
**[
|
|
100
|
+
**[SampleEnum](/sample-enums/SampleEnum.md)**
|
|
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 | [
|
|
123
|
+
| context | [Url](/miscellaneous/Url.md) | 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
|
-
**[
|
|
194
|
+
**[Url](/miscellaneous/Url.md)**
|
|
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
|
-
**[
|
|
302
|
+
**[Url](/miscellaneous/Url.md)**
|
|
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
|
|
package/examples/vitepress/docs/{Sample-Enums/apexdocs.SampleEnum.md → sample-enums/SampleEnum.md}
RENAMED
|
@@ -6,13 +6,13 @@ title: SampleEnum
|
|
|
6
6
|
|
|
7
7
|
`NAMESPACEACCESSIBLE`
|
|
8
8
|
|
|
9
|
-
This is a sample enum. This references [
|
|
9
|
+
This is a sample enum. This references [ReferencedEnum](/miscellaneous/ReferencedEnum.md) .
|
|
10
10
|
|
|
11
11
|
This description has several lines
|
|
12
12
|
|
|
13
13
|
**Some Custom**
|
|
14
14
|
|
|
15
|
-
Test. I can also have a [
|
|
15
|
+
Test. I can also have a [ReferencedEnum](/miscellaneous/ReferencedEnum.md) 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** [
|
|
30
|
+
**See** [ReferencedEnum](/miscellaneous/ReferencedEnum.md)
|
|
31
31
|
|
|
32
32
|
## Namespace
|
|
33
33
|
apexdocs
|
package/examples/vitepress/docs/{SampleGroup/apexdocs.SampleClass.md → samplegroup/SampleClass.md}
RENAMED
|
@@ -19,12 +19,12 @@ sample.doSomething();
|
|
|
19
19
|
|
|
20
20
|
**Inheritance**
|
|
21
21
|
|
|
22
|
-
[
|
|
22
|
+
[BaseClass](/miscellaneous/BaseClass.md)
|
|
23
23
|
|
|
24
24
|
**Implements**
|
|
25
25
|
|
|
26
|
-
[
|
|
27
|
-
[
|
|
26
|
+
[SampleInterface](/miscellaneous/SampleInterface.md),
|
|
27
|
+
[ParentInterface](/miscellaneous/ParentInterface.md)
|
|
28
28
|
|
|
29
29
|
## Fields
|
|
30
30
|
### Group Name
|
|
@@ -51,7 +51,7 @@ public sampleEnumFromBase
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
##### Type
|
|
54
|
-
[
|
|
54
|
+
[SampleEnum](/sample-enums/SampleEnum.md)
|
|
55
55
|
|
|
56
56
|
## Properties
|
|
57
57
|
### Group Name
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileSystem } from './file-system';
|
|
2
|
-
import {
|
|
2
|
+
import { UnparsedSourceFile } from '../core/shared/types';
|
|
3
3
|
|
|
4
4
|
const APEX_FILE_EXTENSION = '.cls';
|
|
5
5
|
|
|
@@ -10,8 +10,8 @@ export class ApexFileReader {
|
|
|
10
10
|
/**
|
|
11
11
|
* Reads from .cls files and returns their raw body.
|
|
12
12
|
*/
|
|
13
|
-
static processFiles(fileSystem: FileSystem, rootPath: string, includeMetadata: boolean):
|
|
14
|
-
let bundles:
|
|
13
|
+
static processFiles(fileSystem: FileSystem, rootPath: string, includeMetadata: boolean): UnparsedSourceFile[] {
|
|
14
|
+
let bundles: UnparsedSourceFile[] = [];
|
|
15
15
|
|
|
16
16
|
const directoryContents = fileSystem.readDirectory(rootPath);
|
|
17
17
|
directoryContents.forEach((filePath) => {
|
|
@@ -5,21 +5,17 @@ import { PageData } from '../core/shared/types';
|
|
|
5
5
|
export class FileWriter {
|
|
6
6
|
static write(files: PageData[], outputDir: string, onWriteCallback: (file: PageData) => void) {
|
|
7
7
|
files.forEach((file) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const filePath = path.join(resolvedFile.directory, `${resolvedFile.fileName}.${resolvedFile.fileExtension}`);
|
|
14
|
-
fs.writeFileSync(filePath, resolvedFile.content, 'utf8');
|
|
15
|
-
onWriteCallback(resolvedFile);
|
|
8
|
+
const { filePath, content } = this.getTargetLocation(file, outputDir);
|
|
9
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
10
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
11
|
+
onWriteCallback(file);
|
|
16
12
|
});
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
private static getTargetLocation(file: PageData, outputDir: string): PageData {
|
|
20
16
|
return {
|
|
21
17
|
...file,
|
|
22
|
-
|
|
18
|
+
filePath: path.join(outputDir, file.filePath),
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
}
|
|
@@ -2,13 +2,18 @@ import { generateDocs } from '../../core/markdown/generate-docs';
|
|
|
2
2
|
import { FileWriter } from '../file-writer';
|
|
3
3
|
import { Logger } from '#utils/logger';
|
|
4
4
|
import { pipe } from 'fp-ts/function';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
PageData,
|
|
7
|
+
PostHookDocumentationBundle,
|
|
8
|
+
UnparsedSourceFile,
|
|
9
|
+
UserDefinedMarkdownConfig,
|
|
10
|
+
} from '../../core/shared/types';
|
|
6
11
|
import { ReflectionError } from '../../core/markdown/reflection/error-handling';
|
|
7
12
|
import { referenceGuideTemplate } from '../../core/markdown/templates/reference-guide';
|
|
8
13
|
import * as TE from 'fp-ts/TaskEither';
|
|
9
14
|
import { isSkip } from '../../core/shared/utils';
|
|
10
15
|
|
|
11
|
-
export default function generate(bundles:
|
|
16
|
+
export default function generate(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
12
17
|
return pipe(
|
|
13
18
|
generateDocumentationBundle(bundles, config),
|
|
14
19
|
TE.map((files) => writeFilesToSystem(files, config.targetDir)),
|
|
@@ -29,7 +34,7 @@ export default function generate(bundles: SourceFile[], config: UserDefinedMarkd
|
|
|
29
34
|
)();
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
function generateDocumentationBundle(bundles:
|
|
37
|
+
function generateDocumentationBundle(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
33
38
|
return generateDocs(bundles, {
|
|
34
39
|
...config,
|
|
35
40
|
referenceGuideTemplate: referenceGuideTemplate,
|
|
@@ -43,7 +48,7 @@ function writeFilesToSystem(files: PostHookDocumentationBundle, outputDir: strin
|
|
|
43
48
|
.filter((file) => !isSkip(file)) as PageData[],
|
|
44
49
|
outputDir,
|
|
45
50
|
(file: PageData) => {
|
|
46
|
-
Logger.logSingle(`${file.
|
|
51
|
+
Logger.logSingle(`${file.filePath} processed.`, false, 'green', false);
|
|
47
52
|
},
|
|
48
53
|
);
|
|
49
54
|
}
|
|
@@ -7,10 +7,10 @@ import { Logger } from '#utils/logger';
|
|
|
7
7
|
import ErrorLogger from '#utils/error-logger';
|
|
8
8
|
import { reflect, ReflectionResult } from '@cparra/apex-reflection';
|
|
9
9
|
import Manifest from '../../core/manifest';
|
|
10
|
-
import { PageData,
|
|
10
|
+
import { PageData, UnparsedSourceFile, UserDefinedOpenApiConfig } from '../../core/shared/types';
|
|
11
11
|
import { OpenApiDocsProcessor } from '../../core/openapi/open-api-docs-processor';
|
|
12
12
|
|
|
13
|
-
export default function openApi(fileBodies:
|
|
13
|
+
export default function openApi(fileBodies: UnparsedSourceFile[], config: UserDefinedOpenApiConfig) {
|
|
14
14
|
const manifest = createManifest(new RawBodyParser(fileBodies), reflectionWithLogger);
|
|
15
15
|
TypesRepository.getInstance().populateAll(manifest.types);
|
|
16
16
|
const filteredTypes = filterByScopes(manifest);
|
|
@@ -19,14 +19,14 @@ export default function openApi(fileBodies: SourceFile[], config: UserDefinedOpe
|
|
|
19
19
|
const generatedFiles = processor.fileBuilder().files();
|
|
20
20
|
|
|
21
21
|
FileWriter.write(generatedFiles, config.targetDir, (file: PageData) => {
|
|
22
|
-
Logger.logSingle(`${file.
|
|
22
|
+
Logger.logSingle(`${file.filePath} processed.`, false, 'green', false);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// Error logging
|
|
26
26
|
ErrorLogger.logErrors(filteredTypes);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function reflectionWithLogger(apexBundle:
|
|
29
|
+
function reflectionWithLogger(apexBundle: UnparsedSourceFile): ReflectionResult {
|
|
30
30
|
const result = reflect(apexBundle.content);
|
|
31
31
|
if (result.error) {
|
|
32
32
|
Logger.error(`${apexBundle.filePath} - Parsing error ${result.error?.message}`);
|
|
@@ -12,7 +12,7 @@ describe('Generates interface documentation', () => {
|
|
|
12
12
|
|
|
13
13
|
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
14
14
|
expect(result).documentationBundleHasLength(1);
|
|
15
|
-
assertEither(result, (data) => expect(data.docs[0].
|
|
15
|
+
assertEither(result, (data) => expect(data.docs[0].filePath).toContain('MyClass'));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('returns the type as class', async () => {
|
|
@@ -268,7 +268,9 @@ describe('Generates interface documentation', () => {
|
|
|
268
268
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
269
269
|
expect(result).documentationBundleHasLength(2);
|
|
270
270
|
assertEither(result, (data) =>
|
|
271
|
-
expect(data).firstDocContains(
|
|
271
|
+
expect(data).firstDocContains(
|
|
272
|
+
'This is a description with a [ClassRef](/miscellaneous/ClassRef.md) reference',
|
|
273
|
+
),
|
|
272
274
|
);
|
|
273
275
|
});
|
|
274
276
|
|
|
@@ -302,7 +304,7 @@ describe('Generates interface documentation', () => {
|
|
|
302
304
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
303
305
|
expect(result).documentationBundleHasLength(2);
|
|
304
306
|
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
305
|
-
assertEither(result, (data) => expect(data).firstDocContains('[ClassRef](
|
|
307
|
+
assertEither(result, (data) => expect(data).firstDocContains('[ClassRef](/miscellaneous/ClassRef.md)'));
|
|
306
308
|
});
|
|
307
309
|
|
|
308
310
|
it('displays sees without links when the reference is not found', async () => {
|
|
@@ -17,7 +17,7 @@ describe('Generates enum documentation', () => {
|
|
|
17
17
|
|
|
18
18
|
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
19
19
|
expect(result).documentationBundleHasLength(1);
|
|
20
|
-
assertEither(result, (data) => expect(data.docs[0].
|
|
20
|
+
assertEither(result, (data) => expect(data.docs[0].filePath).toContain('MyEnum'));
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('returns the type as enum', async () => {
|
|
@@ -211,7 +211,7 @@ describe('Generates enum documentation', () => {
|
|
|
211
211
|
expect(result).documentationBundleHasLength(2);
|
|
212
212
|
assertEither(result, (data) => expect(data).firstDocContains('Description'));
|
|
213
213
|
assertEither(result, (data) =>
|
|
214
|
-
expect(data).firstDocContains('This is a description with a [EnumRef](
|
|
214
|
+
expect(data).firstDocContains('This is a description with a [EnumRef](/miscellaneous/EnumRef.md) reference'),
|
|
215
215
|
);
|
|
216
216
|
});
|
|
217
217
|
|
|
@@ -245,7 +245,7 @@ describe('Generates enum documentation', () => {
|
|
|
245
245
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
246
246
|
expect(result).documentationBundleHasLength(2);
|
|
247
247
|
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
248
|
-
assertEither(result, (data) => expect(data).firstDocContains('[EnumRef](
|
|
248
|
+
assertEither(result, (data) => expect(data).firstDocContains('[EnumRef](/miscellaneous/EnumRef.md)'));
|
|
249
249
|
});
|
|
250
250
|
|
|
251
251
|
it('displays sees without links when the reference is not found', async () => {
|
|
@@ -189,7 +189,9 @@ describe('Generates interface documentation', () => {
|
|
|
189
189
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
190
190
|
expect(result).documentationBundleHasLength(2);
|
|
191
191
|
assertEither(result, (data) =>
|
|
192
|
-
expect(data).firstDocContains(
|
|
192
|
+
expect(data).firstDocContains(
|
|
193
|
+
'This is a description with a [InterfaceRef](/miscellaneous/InterfaceRef.md) reference',
|
|
194
|
+
),
|
|
193
195
|
);
|
|
194
196
|
});
|
|
195
197
|
|
|
@@ -223,7 +225,7 @@ describe('Generates interface documentation', () => {
|
|
|
223
225
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
224
226
|
expect(result).documentationBundleHasLength(2);
|
|
225
227
|
assertEither(result, (data) => expect(data).firstDocContains('See'));
|
|
226
|
-
assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](
|
|
228
|
+
assertEither(result, (data) => expect(data).firstDocContains('[InterfaceRef](/miscellaneous/InterfaceRef.md)'));
|
|
227
229
|
});
|
|
228
230
|
|
|
229
231
|
it('displays sees without links when the reference is not found', async () => {
|
|
@@ -451,7 +453,7 @@ describe('Generates interface documentation', () => {
|
|
|
451
453
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
452
454
|
expect(result).documentationBundleHasLength(2);
|
|
453
455
|
assertEither(result, (data) =>
|
|
454
|
-
expect(data.docs.find((doc) => doc.
|
|
456
|
+
expect(data.docs.find((doc) => doc.filePath.includes('AnotherInterface'))?.content).toContain('Inherited'),
|
|
455
457
|
);
|
|
456
458
|
});
|
|
457
459
|
});
|
|
@@ -25,12 +25,10 @@ describe('Generates a Reference Guide', () => {
|
|
|
25
25
|
expect(result).documentationBundleHasLength(2);
|
|
26
26
|
|
|
27
27
|
assertEither(result, (data) =>
|
|
28
|
-
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyEnum](
|
|
28
|
+
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyEnum](/miscellaneous/MyEnum.md)'),
|
|
29
29
|
);
|
|
30
30
|
assertEither(result, (data) =>
|
|
31
|
-
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain(
|
|
32
|
-
'[MyClass](./Miscellaneous/MyClass.md)',
|
|
33
|
-
),
|
|
31
|
+
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('[MyClass](/miscellaneous/MyClass.md)'),
|
|
34
32
|
);
|
|
35
33
|
});
|
|
36
34
|
|
|
@@ -176,9 +174,7 @@ describe('Generates a Reference Guide', () => {
|
|
|
176
174
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
177
175
|
expect(result).documentationBundleHasLength(2);
|
|
178
176
|
assertEither(result, (data) =>
|
|
179
|
-
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain(
|
|
180
|
-
'with a [MyClass](./Group2/MyClass.md)',
|
|
181
|
-
),
|
|
177
|
+
expect((data.referenceGuide as ReferenceGuidePageData).content).toContain('with a [MyClass](/group2/MyClass.md)'),
|
|
182
178
|
);
|
|
183
179
|
});
|
|
184
180
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnparsedSourceFile } from '../../shared/types';
|
|
2
2
|
import { generateDocs as gen, MarkdownGeneratorConfig } from '../generate-docs';
|
|
3
3
|
import { referenceGuideTemplate } from '../templates/reference-guide';
|
|
4
4
|
|
|
5
|
-
export function apexBundleFromRawString(raw: string, rawMetadata?: string):
|
|
5
|
+
export function apexBundleFromRawString(raw: string, rawMetadata?: string): UnparsedSourceFile {
|
|
6
6
|
return {
|
|
7
7
|
filePath: 'test.cls',
|
|
8
8
|
content: raw,
|
|
@@ -10,7 +10,7 @@ export function apexBundleFromRawString(raw: string, rawMetadata?: string): Sour
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function generateDocs(apexBundles:
|
|
13
|
+
export function generateDocs(apexBundles: UnparsedSourceFile[], config?: Partial<MarkdownGeneratorConfig>) {
|
|
14
14
|
return gen(apexBundles, {
|
|
15
15
|
targetDir: 'target',
|
|
16
16
|
scope: ['global', 'public'],
|