@cparra/apexdocs 3.0.0-alpha.2 → 3.0.0-alpha.3
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 +23 -12
- package/examples/vitepress/docs/index.md +10 -10
- 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 +4 -4
- package/package.json +1 -1
- package/src/cli/commands/markdown.ts +2 -1
- package/src/core/markdown/adapters/renderable-bundle.ts +31 -11
package/dist/cli/generate.js
CHANGED
|
@@ -573,13 +573,13 @@ function parsedFilesToRenderableBundle(config, parsedFiles, references) {
|
|
|
573
573
|
const referenceFinder = apply(linkGenerator, references, config.documentationRootDir);
|
|
574
574
|
function toReferenceGuide(parsedFiles2) {
|
|
575
575
|
return parsedFiles2.reduce(
|
|
576
|
-
addToReferenceGuide(referenceFinder, config, references),
|
|
576
|
+
addToReferenceGuide(apply(referenceFinder, "__base__"), config, references),
|
|
577
577
|
{}
|
|
578
578
|
);
|
|
579
579
|
}
|
|
580
580
|
function toRenderables(parsedFiles2) {
|
|
581
581
|
return parsedFiles2.reduce((acc, parsedFile) => {
|
|
582
|
-
const renderable = typeToRenderable(parsedFile, referenceFinder, config);
|
|
582
|
+
const renderable = typeToRenderable(parsedFile, apply(referenceFinder, parsedFile.source.name), config);
|
|
583
583
|
acc.push(renderable);
|
|
584
584
|
return acc;
|
|
585
585
|
}, []);
|
|
@@ -604,16 +604,27 @@ function addToReferenceGuide(findLinkFromHome, config, references) {
|
|
|
604
604
|
return acc;
|
|
605
605
|
};
|
|
606
606
|
}
|
|
607
|
-
const linkGenerator = (references, documentationRootDir, referenceName) => {
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
{
|
|
607
|
+
const linkGenerator = (references, documentationRootDir, from, referenceName) => {
|
|
608
|
+
const referenceTo = references[referenceName];
|
|
609
|
+
if (referenceTo && from === "__base__") {
|
|
610
|
+
return {
|
|
612
611
|
__type: "link",
|
|
613
|
-
title:
|
|
614
|
-
url: path__namespace.join(
|
|
615
|
-
}
|
|
616
|
-
|
|
612
|
+
title: referenceTo.displayName,
|
|
613
|
+
url: path__namespace.join(documentationRootDir, referenceTo.referencePath)
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
const referenceFrom = references[from];
|
|
617
|
+
if (!referenceFrom || !referenceTo) {
|
|
618
|
+
return referenceName;
|
|
619
|
+
}
|
|
620
|
+
const fromPath = path__namespace.parse(path__namespace.join("/", documentationRootDir, referenceFrom.referencePath)).dir;
|
|
621
|
+
const toPath = path__namespace.join("/", documentationRootDir, referenceTo.referencePath);
|
|
622
|
+
const relativePath = path__namespace.relative(fromPath, toPath);
|
|
623
|
+
return {
|
|
624
|
+
__type: "link",
|
|
625
|
+
title: referenceTo.displayName,
|
|
626
|
+
url: relativePath
|
|
627
|
+
};
|
|
617
628
|
};
|
|
618
629
|
function getTypeGroup$1(type, config) {
|
|
619
630
|
var _a, _b;
|
|
@@ -2888,7 +2899,7 @@ const markdownOptions = {
|
|
|
2888
2899
|
},
|
|
2889
2900
|
documentationRootDir: {
|
|
2890
2901
|
type: "string",
|
|
2891
|
-
describe: "The root directory of the documentation. This is used to
|
|
2902
|
+
describe: "The root directory of the documentation. This is used to create the correct relative paths when generating links between documents.",
|
|
2892
2903
|
default: defaults.defaults.documentationRootDir
|
|
2893
2904
|
}
|
|
2894
2905
|
};
|
|
@@ -19,38 +19,38 @@ hero:
|
|
|
19
19
|
|
|
20
20
|
## Miscellaneous
|
|
21
21
|
|
|
22
|
-
### [BaseClass](
|
|
22
|
+
### [BaseClass](miscellaneous/BaseClass.md)
|
|
23
23
|
|
|
24
|
-
### [MultiInheritanceClass](
|
|
24
|
+
### [MultiInheritanceClass](miscellaneous/MultiInheritanceClass.md)
|
|
25
25
|
|
|
26
|
-
### [ParentInterface](
|
|
26
|
+
### [ParentInterface](miscellaneous/ParentInterface.md)
|
|
27
27
|
|
|
28
|
-
### [ReferencedEnum](
|
|
28
|
+
### [ReferencedEnum](miscellaneous/ReferencedEnum.md)
|
|
29
29
|
|
|
30
|
-
### [SampleException](
|
|
30
|
+
### [SampleException](miscellaneous/SampleException.md)
|
|
31
31
|
|
|
32
32
|
This is a sample exception.
|
|
33
33
|
|
|
34
|
-
### [SampleInterface](
|
|
34
|
+
### [SampleInterface](miscellaneous/SampleInterface.md)
|
|
35
35
|
|
|
36
36
|
This is a sample interface
|
|
37
37
|
|
|
38
|
-
### [Url](
|
|
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
|
-
### [SampleEnum](
|
|
45
|
+
### [SampleEnum](sample-enums/SampleEnum.md)
|
|
46
46
|
|
|
47
|
-
This is a sample enum. This references [ReferencedEnum](
|
|
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
|
-
### [SampleClass](
|
|
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
|
-
[SampleClass](
|
|
12
|
+
[SampleClass](../samplegroup/SampleClass.md) < [BaseClass](BaseClass.md)
|
|
13
13
|
|
|
14
14
|
## Fields
|
|
15
15
|
### `sampleEnumFromBase`
|
|
@@ -22,7 +22,7 @@ public sampleEnumFromBase
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
#### Type
|
|
25
|
-
[SampleEnum](
|
|
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 [SampleClass](
|
|
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** [SampleEnum](
|
|
22
|
+
**See** [SampleEnum](../sample-enums/SampleEnum.md)
|
|
23
23
|
|
|
24
|
-
**See** [ReferencedEnum](
|
|
24
|
+
**See** [ReferencedEnum](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
|
-
[ParentInterface](
|
|
34
|
+
[ParentInterface](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
|
-
[SampleException](
|
|
69
|
+
[SampleException](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 | [SampleEnum](
|
|
97
|
+
| theEnum | [SampleEnum](../sample-enums/SampleEnum.md) | This is an enum parameter |
|
|
98
98
|
|
|
99
99
|
#### Return Type
|
|
100
|
-
**[SampleEnum](
|
|
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 | [Url](
|
|
123
|
+
| context | [Url](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
|
-
**[Url](
|
|
194
|
+
**[Url](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
|
-
**[Url](
|
|
302
|
+
**[Url](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
|
|
|
@@ -6,13 +6,13 @@ title: SampleEnum
|
|
|
6
6
|
|
|
7
7
|
`NAMESPACEACCESSIBLE`
|
|
8
8
|
|
|
9
|
-
This is a sample enum. This references [ReferencedEnum](
|
|
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 [ReferencedEnum](
|
|
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** [ReferencedEnum](
|
|
30
|
+
**See** [ReferencedEnum](../miscellaneous/ReferencedEnum.md)
|
|
31
31
|
|
|
32
32
|
## Namespace
|
|
33
33
|
apexdocs
|
|
@@ -19,12 +19,12 @@ sample.doSomething();
|
|
|
19
19
|
|
|
20
20
|
**Inheritance**
|
|
21
21
|
|
|
22
|
-
[BaseClass](
|
|
22
|
+
[BaseClass](../miscellaneous/BaseClass.md)
|
|
23
23
|
|
|
24
24
|
**Implements**
|
|
25
25
|
|
|
26
|
-
[SampleInterface](
|
|
27
|
-
[ParentInterface](
|
|
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
|
-
[SampleEnum](
|
|
54
|
+
[SampleEnum](../sample-enums/SampleEnum.md)
|
|
55
55
|
|
|
56
56
|
## Properties
|
|
57
57
|
### Group Name
|
package/package.json
CHANGED
|
@@ -46,7 +46,8 @@ export const markdownOptions: { [key: string]: Options } = {
|
|
|
46
46
|
},
|
|
47
47
|
documentationRootDir: {
|
|
48
48
|
type: 'string',
|
|
49
|
-
describe:
|
|
49
|
+
describe:
|
|
50
|
+
'The root directory of the documentation. This is used to create the correct relative paths when generating links between documents.',
|
|
50
51
|
default: defaults.documentationRootDir,
|
|
51
52
|
},
|
|
52
53
|
};
|
|
@@ -16,14 +16,14 @@ export function parsedFilesToRenderableBundle(
|
|
|
16
16
|
|
|
17
17
|
function toReferenceGuide(parsedFiles: ParsedFile[]): Record<string, ReferenceGuideReference[]> {
|
|
18
18
|
return parsedFiles.reduce<Record<string, ReferenceGuideReference[]>>(
|
|
19
|
-
addToReferenceGuide(referenceFinder, config, references),
|
|
19
|
+
addToReferenceGuide(apply(referenceFinder, '__base__'), config, references),
|
|
20
20
|
{},
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function toRenderables(parsedFiles: ParsedFile[]): Renderable[] {
|
|
25
25
|
return parsedFiles.reduce<Renderable[]>((acc, parsedFile) => {
|
|
26
|
-
const renderable = typeToRenderable(parsedFile, referenceFinder, config);
|
|
26
|
+
const renderable = typeToRenderable(parsedFile, apply(referenceFinder, parsedFile.source.name), config);
|
|
27
27
|
acc.push(renderable);
|
|
28
28
|
return acc;
|
|
29
29
|
}, []);
|
|
@@ -58,18 +58,38 @@ function addToReferenceGuide(
|
|
|
58
58
|
const linkGenerator = (
|
|
59
59
|
references: Record<string, DocPageReference>,
|
|
60
60
|
documentationRootDir: string,
|
|
61
|
+
from: string, // The name of the file for which the reference is being generated
|
|
61
62
|
referenceName: string,
|
|
62
63
|
): StringOrLink => {
|
|
63
|
-
const
|
|
64
|
+
const referenceTo: DocPageReference | undefined = references[referenceName];
|
|
65
|
+
// When linking from the base path (e.g. the reference guide/index page), the reference path is the same as the output
|
|
66
|
+
// path.
|
|
67
|
+
if (referenceTo && from === '__base__') {
|
|
68
|
+
return {
|
|
69
|
+
__type: 'link',
|
|
70
|
+
title: referenceTo.displayName,
|
|
71
|
+
url: path.join(documentationRootDir, referenceTo.referencePath),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const referenceFrom: DocPageReference | undefined = references[from];
|
|
76
|
+
|
|
77
|
+
if (!referenceFrom || !referenceTo) {
|
|
78
|
+
return referenceName;
|
|
79
|
+
}
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
// Gets the directory of the file that is being linked from.
|
|
82
|
+
// This is used to calculate the relative path to the file
|
|
83
|
+
// being linked to.
|
|
84
|
+
const fromPath = path.parse(path.join('/', documentationRootDir, referenceFrom.referencePath)).dir;
|
|
85
|
+
const toPath = path.join('/', documentationRootDir, referenceTo.referencePath);
|
|
86
|
+
const relativePath = path.relative(fromPath, toPath);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
__type: 'link',
|
|
90
|
+
title: referenceTo.displayName,
|
|
91
|
+
url: relativePath,
|
|
92
|
+
};
|
|
73
93
|
};
|
|
74
94
|
|
|
75
95
|
function getTypeGroup(type: Type, config: MarkdownGeneratorConfig): string {
|