@cparra/apexdocs 2.0.2 → 2.1.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/README.md +37 -9
- package/ROADMAP.md +2 -0
- package/docs/Sample-Classes/SampleClass.md +27 -15
- package/examples/force-app/main/default/classes/SampleClass.cls +16 -4
- package/lib/model/markdown-file.d.ts +1 -0
- package/lib/model/markdown-file.js +4 -0
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.js +33 -12
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js +2 -5
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +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-type-file.d.ts +9 -3
- package/lib/model/markdown-type-file.js +65 -10
- package/lib/model/markdown-type-file.js.map +1 -1
- package/package.json +2 -2
- package/src/model/markdown-file.ts +5 -0
- package/src/model/markdown-generation-util/field-declaration-util.ts +33 -11
- package/src/model/markdown-generation-util/method-declaration-util.ts +1 -5
- package/src/model/markdown-generation-util/type-declaration-util.ts +1 -3
- package/src/model/markdown-type-file.ts +75 -9
package/README.md
CHANGED
|
@@ -109,15 +109,15 @@ apexdocs-generate
|
|
|
109
109
|
|
|
110
110
|
The CLI supports the following parameters:
|
|
111
111
|
|
|
112
|
-
| Parameter | Alias | Description
|
|
113
|
-
| ----------------- | -----
|
|
114
|
-
| --sourceDir | -s | The directory location which contains your apex .cls classes.
|
|
115
|
-
| --targetDir | -t | The directory location where documentation will be generated to.
|
|
116
|
-
| --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided.
|
|
117
|
-
| --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private
|
|
118
|
-
| --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports jekyll and docsify.
|
|
119
|
-
| --configPath | -c | The path to the JSON configuration file that defines the structure of the documents to docGenerator.
|
|
120
|
-
| --group | -o | Define whether the generated files should be grouped by the @group tag on the top level classes.
|
|
112
|
+
| Parameter | Alias | Description | Default | Required |
|
|
113
|
+
| ----------------- | ----- |--------------------------------------------------------------------------------------------------------------------------| ----------------------------------- | -------- |
|
|
114
|
+
| --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
|
|
115
|
+
| --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
|
|
116
|
+
| --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
|
|
117
|
+
| --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private | `global namespaceaccessible public` | No |
|
|
118
|
+
| --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports jekyll and docsify. | `jekyll` | No |
|
|
119
|
+
| --configPath | -c | (Only versions 1.X) The path to the JSON configuration file that defines the structure of the documents to docGenerator. | N/A | No |
|
|
120
|
+
| --group | -o | (Only versions 1.X) Define whether the generated files should be grouped by the @group tag on the top level classes. | `true` | No |
|
|
121
121
|
|
|
122
122
|
#### Configuration File
|
|
123
123
|
|
|
@@ -314,6 +314,34 @@ The following tags are supported on the method level:
|
|
|
314
314
|
public static Object call(String action) {
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
+
### Grouping Declarations Within A Class
|
|
318
|
+
|
|
319
|
+
A class might have members that should be grouped together. For example, you can have a class for constants with
|
|
320
|
+
groups of constants that should be grouped together because they share a common behavior (e.g. different groups
|
|
321
|
+
of constants representing the possible values for different picklists.)
|
|
322
|
+
|
|
323
|
+
You can group things together within a class by using the following syntax:
|
|
324
|
+
```apex
|
|
325
|
+
// @start-group Group Name or Description
|
|
326
|
+
public static final String CONSTANT_FOO = 'Foo';
|
|
327
|
+
public static final String CONSTANT_BAR = 'Bar';
|
|
328
|
+
// @end-group
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Groups of members are displayed together under their own subsection after its name or description.
|
|
332
|
+
|
|
333
|
+
Some notes about grouping:
|
|
334
|
+
* This is only supported on classes, NOT enums and interfaces
|
|
335
|
+
* Supports
|
|
336
|
+
* Properties
|
|
337
|
+
* Fields (variables and constants)
|
|
338
|
+
* Constructors
|
|
339
|
+
* Methods
|
|
340
|
+
* BUT only members of the same type are grouped together. For example,
|
|
341
|
+
if you have a group that contains properties and methods the properties will be grouped together under Properties -> Group Name, and the methods will be grouped together under Methods -> Group Name
|
|
342
|
+
* Does not support inner types (inner classes, interfaces, and enums)
|
|
343
|
+
* It is necessary to use `// @end-group` whenever a group has been started, otherwise a parsing error will be raised for that file.
|
|
344
|
+
|
|
317
345
|
### Inline linking
|
|
318
346
|
|
|
319
347
|
Apexdocs allows you to reference other classes from anywhere in your docs, and automatically creates a link to that
|
package/ROADMAP.md
CHANGED
|
@@ -17,63 +17,71 @@ This is a class description. This class relates to [SampleInterface](/Sample-Int
|
|
|
17
17
|
**See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
|
|
18
18
|
|
|
19
19
|
## Constructors
|
|
20
|
-
###
|
|
20
|
+
### My Super Group
|
|
21
|
+
##### `SampleClass()`
|
|
21
22
|
|
|
22
23
|
`NAMESPACEACCESSIBLE`
|
|
23
24
|
|
|
24
25
|
Constructs a SampleClass without any arguments. This relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md)
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
###### Throws
|
|
27
28
|
|Exception|Description|
|
|
28
29
|
|---|---|
|
|
29
30
|
|`ExcName`|some exception|
|
|
30
31
|
|
|
32
|
+
|
|
31
33
|
**CustomAnnotation** A Custom method annotation
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
**See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
###### Example
|
|
37
39
|
```apex
|
|
38
40
|
// Example
|
|
39
41
|
SampleClass sampleInstance = new SampleClass();
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
---
|
|
45
|
+
### Other
|
|
46
|
+
##### `SampleClass(String argument1, String argument2)`
|
|
43
47
|
|
|
44
48
|
Constructs a SampleClass with an argument.
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
###### Parameters
|
|
47
51
|
|Param|Description|
|
|
48
52
|
|---|---|
|
|
49
|
-
|`
|
|
53
|
+
|`argument1`|Argument1 definition|
|
|
54
|
+
|`argument2`|Argument2 definition|
|
|
55
|
+
|
|
50
56
|
---
|
|
51
57
|
## Fields
|
|
58
|
+
### Common Constants
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### `someVariable` → `String`
|
|
60
|
+
* `ANOTHER_CONSTANT` → `String`
|
|
61
|
+
* `A_CONSTANT` → `String` [`NAMESPACEACCESSIBLE` ] - This is a constant.
|
|
62
|
+
---
|
|
63
|
+
### Other variables
|
|
58
64
|
|
|
65
|
+
* `someVariable` → `String`
|
|
59
66
|
---
|
|
60
67
|
## Properties
|
|
61
68
|
|
|
62
69
|
### `AnotherProp` → `Decimal`
|
|
63
70
|
|
|
64
|
-
`AURAENABLED`
|
|
71
|
+
`AURAENABLED`
|
|
65
72
|
|
|
66
73
|
This is a Decimal property.
|
|
67
74
|
|
|
68
75
|
### `MyProp` → `String`
|
|
69
76
|
|
|
70
|
-
`AURAENABLED`
|
|
77
|
+
`AURAENABLED`
|
|
78
|
+
`DEPRECATED`
|
|
71
79
|
|
|
72
80
|
This is a String property.
|
|
73
81
|
|
|
74
82
|
---
|
|
75
83
|
## Methods
|
|
76
|
-
### `static sampleMethod(String
|
|
84
|
+
### `static sampleMethod(String argument1, String argument2)`
|
|
77
85
|
|
|
78
86
|
`NAMESPACEACCESSIBLE`
|
|
79
87
|
|
|
@@ -82,7 +90,9 @@ Executes commands based on the passed in argument.
|
|
|
82
90
|
#### Parameters
|
|
83
91
|
|Param|Description|
|
|
84
92
|
|---|---|
|
|
85
|
-
|`
|
|
93
|
+
|`argument1`|Argument1 to debug|
|
|
94
|
+
|`argument2`|Argument2 to debug|
|
|
95
|
+
|
|
86
96
|
#### Return
|
|
87
97
|
|
|
88
98
|
**Type**
|
|
@@ -122,6 +132,7 @@ Inner class belonging to SampleClass.
|
|
|
122
132
|
|
|
123
133
|
##### `InnerProp` → `String`
|
|
124
134
|
|
|
135
|
+
|
|
125
136
|
Description of the inner property.
|
|
126
137
|
|
|
127
138
|
---
|
|
@@ -140,6 +151,7 @@ Inner class belonging to SampleClass.
|
|
|
140
151
|
|
|
141
152
|
##### `InnerProp` → `String`
|
|
142
153
|
|
|
154
|
+
|
|
143
155
|
Description of the inner property.
|
|
144
156
|
|
|
145
157
|
---
|
|
@@ -19,12 +19,20 @@ public with sharing class SampleClass {
|
|
|
19
19
|
C
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// @start-group Common Constants
|
|
22
23
|
/**
|
|
23
24
|
* @description This is a constant.
|
|
24
25
|
*/
|
|
26
|
+
@NamespaceAccessible
|
|
25
27
|
public static final String A_CONSTANT = 'My Constant Value';
|
|
28
|
+
public static final String ANOTHER_CONSTANT = 'My Constant Value';
|
|
29
|
+
// @end-group
|
|
30
|
+
|
|
31
|
+
// @start-group Other variables
|
|
26
32
|
public String someVariable = 'test';
|
|
33
|
+
// @end-group
|
|
27
34
|
|
|
35
|
+
// @start-group My Super Group
|
|
28
36
|
/**
|
|
29
37
|
* @description Constructs a SampleClass without any arguments. This relates to {@link SampleInterface}
|
|
30
38
|
* @throws ExcName some exception
|
|
@@ -38,12 +46,14 @@ public with sharing class SampleClass {
|
|
|
38
46
|
public SampleClass() {
|
|
39
47
|
System.debug('Constructor');
|
|
40
48
|
}
|
|
49
|
+
// @end-group
|
|
41
50
|
|
|
42
51
|
/**
|
|
43
52
|
* @description Constructs a SampleClass with an argument.
|
|
44
|
-
* @param
|
|
53
|
+
* @param argument1 Argument1 definition
|
|
54
|
+
* @param argument2 Argument2 definition
|
|
45
55
|
*/
|
|
46
|
-
public SampleClass(String
|
|
56
|
+
public SampleClass(String argument1, String argument2) {
|
|
47
57
|
System.debug('Constructor');
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -52,11 +62,12 @@ public with sharing class SampleClass {
|
|
|
52
62
|
* @example
|
|
53
63
|
* String result = SampleClass.testMethod();
|
|
54
64
|
* System.debug(result);
|
|
55
|
-
* @param
|
|
65
|
+
* @param argument1 Argument1 to debug
|
|
66
|
+
* @param argument2 Argument2 to debug
|
|
56
67
|
* @return Empty string
|
|
57
68
|
*/
|
|
58
69
|
@NamespaceAccessible
|
|
59
|
-
public static String sampleMethod(String
|
|
70
|
+
public static String sampleMethod(String argument1, String argument2) {
|
|
60
71
|
System.debug('Execute');
|
|
61
72
|
return '';
|
|
62
73
|
}
|
|
@@ -73,6 +84,7 @@ public with sharing class SampleClass {
|
|
|
73
84
|
* @description This is a String property.
|
|
74
85
|
*/
|
|
75
86
|
@AuraEnabled
|
|
87
|
+
@Deprecated
|
|
76
88
|
public String MyProp { get; set; }
|
|
77
89
|
|
|
78
90
|
/**
|
|
@@ -7,5 +7,6 @@ export declare class MarkdownFile extends File {
|
|
|
7
7
|
addHorizontalRule(): void;
|
|
8
8
|
initializeTable(...headers: string[]): void;
|
|
9
9
|
addTableRow(...columns: string[]): void;
|
|
10
|
+
addListItem(text: string): void;
|
|
10
11
|
protected static replaceInlineLinks(text: string): string;
|
|
11
12
|
}
|
|
@@ -48,6 +48,10 @@ class MarkdownFile extends file_1.File {
|
|
|
48
48
|
columns.forEach((column) => {
|
|
49
49
|
this._contents += column + '|';
|
|
50
50
|
});
|
|
51
|
+
this.addBlankLine();
|
|
52
|
+
}
|
|
53
|
+
addListItem(text) {
|
|
54
|
+
this._contents += `* ${text}`;
|
|
51
55
|
}
|
|
52
56
|
static replaceInlineLinks(text) {
|
|
53
57
|
// Parsing text to extract possible linking classes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-file.js","sourceRoot":"","sources":["../../src/model/markdown-file.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,kGAAyF;AAEzF,MAAa,YAAa,SAAQ,WAAI;IACpC,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,KAAK,GAAG,CAAC;QAC9B,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,KAAK,IAAI,GAAG,CAAC;SACd;QAED,KAAK,IAAI,GAAG,CAAC;QACb,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;QACxB,MAAM,cAAc,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC;QACjC,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,YAAY;QACV,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,eAAe,CAAC,GAAG,OAAiB;QAClC,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;QACtB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,IAAI,CAAC,SAAS,IAAI,MAAM,GAAG,GAAG,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,EAAE,CAAC;QAC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,CAAC,CAAC;YAC3E,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,oCAAwB,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACvG,CAAC,EAAE;QAEH,+CAA+C;QAC/C,MAAM,eAAe,GAAG,eAAe,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,CAAC;QACV,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,GAAG;YACD,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9B,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF,QAAQ,KAAK,EAAE;QAEhB,KAAK,MAAM,YAAY,IAAI,OAAO,EAAE;YAClC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,oCAAwB,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACvG;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArFD,oCAqFC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MarkdownFile } from '../markdown-file';
|
|
2
2
|
import { FieldMirror, PropertyMirror } from '@cparra/apex-reflection';
|
|
3
|
-
export declare function declareField(
|
|
3
|
+
export declare function declareField(markdownFile: MarkdownFile, fields: FieldMirror[] | PropertyMirror[], startingHeadingLevel: number, grouped?: boolean): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.declareField = void 0;
|
|
4
|
-
function declareField(
|
|
5
|
-
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
4
|
+
function declareField(markdownFile, fields, startingHeadingLevel, grouped = false) {
|
|
6
5
|
markdownFile.addBlankLine();
|
|
7
6
|
fields
|
|
8
7
|
.sort((propA, propB) => {
|
|
@@ -13,22 +12,44 @@ function declareField(title, markdownFile, fields, startingHeadingLevel) {
|
|
|
13
12
|
return 0;
|
|
14
13
|
})
|
|
15
14
|
.forEach((propertyModel) => {
|
|
16
|
-
addFieldSection(markdownFile, propertyModel, startingHeadingLevel);
|
|
15
|
+
addFieldSection(markdownFile, propertyModel, startingHeadingLevel, grouped);
|
|
17
16
|
});
|
|
18
17
|
markdownFile.addHorizontalRule();
|
|
19
18
|
}
|
|
20
19
|
exports.declareField = declareField;
|
|
21
|
-
function addFieldSection(markdownFile,
|
|
22
|
-
var _a;
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function addFieldSection(markdownFile, mirrorModel, startingHeadingLevel, grouped) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
if (!grouped) {
|
|
23
|
+
markdownFile.addTitle(`\`${mirrorModel.name}\` → \`${mirrorModel.type}\``, startingHeadingLevel + 2);
|
|
25
24
|
markdownFile.addBlankLine();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
mirrorModel.annotations.forEach((annotation) => {
|
|
26
|
+
markdownFile.addText(`\`${annotation.type.toUpperCase()}\` `);
|
|
27
|
+
});
|
|
28
|
+
if ((_a = mirrorModel.docComment) === null || _a === void 0 ? void 0 : _a.description) {
|
|
29
|
+
markdownFile.addBlankLine();
|
|
30
|
+
markdownFile.addText(mirrorModel.docComment.description);
|
|
31
|
+
}
|
|
32
|
+
markdownFile.addBlankLine();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
let annotations = '';
|
|
36
|
+
const hasAnnotations = !!mirrorModel.annotations.length;
|
|
37
|
+
if (hasAnnotations) {
|
|
38
|
+
annotations += ' [';
|
|
39
|
+
}
|
|
40
|
+
mirrorModel.annotations.forEach((annotation) => {
|
|
41
|
+
annotations += `\`${annotation.type.toUpperCase()}\` `;
|
|
42
|
+
});
|
|
43
|
+
if (hasAnnotations) {
|
|
44
|
+
annotations += ']';
|
|
45
|
+
}
|
|
46
|
+
// If grouped we want to display these as a list
|
|
47
|
+
let description = '';
|
|
48
|
+
if ((_b = mirrorModel.docComment) === null || _b === void 0 ? void 0 : _b.description) {
|
|
49
|
+
description = ` - ${(_c = mirrorModel.docComment) === null || _c === void 0 ? void 0 : _c.description}`;
|
|
50
|
+
}
|
|
51
|
+
markdownFile.addListItem(`\`${mirrorModel.name}\` → \`${mirrorModel.type}\`${annotations} ${description}`);
|
|
29
52
|
markdownFile.addBlankLine();
|
|
30
|
-
markdownFile.addText(propertyModel.docComment.description);
|
|
31
53
|
}
|
|
32
|
-
markdownFile.addBlankLine();
|
|
33
54
|
}
|
|
34
55
|
//# sourceMappingURL=field-declaration-util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/field-declaration-util.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAC1B,
|
|
1
|
+
{"version":3,"file":"field-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/field-declaration-util.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAC1B,YAA0B,EAC1B,MAAwC,EACxC,oBAA4B,EAC5B,OAAO,GAAG,KAAK;IAEf,YAAY,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM;SACH,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,IAAI,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAAE,OAAO,CAAC,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAAE,OAAO,CAAC,CAAC;QACtC,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;QACzB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;I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W,EAAE;YACvC,WAAW,GAAG,MAAM,MAAA,WAAW,CAAC,UAAU,0CAAE,WAAW,EAAE,CAAC;SAC3D;QACD,YAAY,CAAC,WAAW,CAAC,KAAK,WAAW,CAAC,IAAI,UAAU,WAAW,CAAC,IAAI,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC,CAAC;QAC3G,YAAY,CAAC,YAAY,EAAE,CAAC;KAC7B;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ConstructorMirror, MethodMirror } from '@cparra/apex-reflection';
|
|
2
2
|
import { MarkdownFile } from '../markdown-file';
|
|
3
|
-
export declare function declareMethod(
|
|
3
|
+
export declare function declareMethod(markdownFile: MarkdownFile, methods: ConstructorMirror[] | MethodMirror[], startingHeadingLevel: number, className?: string): void;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.declareMethod = void 0;
|
|
4
4
|
const doc_comment_annotation_util_1 = require("./doc-comment-annotation-util");
|
|
5
|
-
function declareMethod(
|
|
6
|
-
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
5
|
+
function declareMethod(markdownFile, methods, startingHeadingLevel, className = '') {
|
|
7
6
|
methods.forEach((currentMethod) => {
|
|
8
7
|
var _a, _b;
|
|
9
8
|
const signatureName = isMethod(currentMethod) ? currentMethod.name : className;
|
|
@@ -37,9 +36,7 @@ function buildSignature(name, parameterAware) {
|
|
|
37
36
|
if (isMethod(parameterAware) && parameterAware.memberModifiers.length) {
|
|
38
37
|
signature = parameterAware.memberModifiers.join(' ') + ' ' + signature;
|
|
39
38
|
}
|
|
40
|
-
const signatureParameters = parameterAware.parameters.map((param) => {
|
|
41
|
-
signature += `${param.type} ${param.name}`;
|
|
42
|
-
});
|
|
39
|
+
const signatureParameters = parameterAware.parameters.map((param) => `${param.type} ${param.name}`);
|
|
43
40
|
signature += signatureParameters.join(', ');
|
|
44
41
|
return (signature += ')');
|
|
45
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/method-declaration-util.ts"],"names":[],"mappings":";;;AAGA,+EAA+E;AAE/E,SAAgB,aAAa,CAC3B,
|
|
1
|
+
{"version":3,"file":"method-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/method-declaration-util.ts"],"names":[],"mappings":";;;AAGA,+EAA+E;AAE/E,SAAgB,aAAa,CAC3B,YAA0B,EAC1B,OAA6C,EAC7C,oBAA4B,EAC5B,SAAS,GAAG,EAAE;IAEd,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;;QAChC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAE,aAA8B,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACjG,YAAY,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC;QACvG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAC/C,YAAY,CAAC,YAAY,EAAE,CAAC;YAC5B,YAAY,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QAEH,UAAI,aAAa,CAAC,UAAU,0CAAE,WAAW,EAAE;YACzC,YAAY,CAAC,YAAY,EAAE,CAAC;YAC5B,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAC3D,YAAY,CAAC,YAAY,EAAE,CAAC;SAC7B;QAED,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE;YACnC,aAAa,CAAC,YAAY,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;SAClE;QAED,IAAI,QAAQ,CAAC,a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AAC,eAAe,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAEzD,MAAA,eAAe,CAAC,UAAU,0CAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACnE,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;QAC/C,MAAM,oBAAoB,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE5D,YAAY,CAAC,WAAW,CAAC,KAAK,aAAa,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACzE,CAAC,EAAE;IAEH,YAAY,CAAC,YAAY,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,YAA0B,EAAE,eAAgC,EAAE,oBAA4B;;IAC5G,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC;IAC3D,YAAY,CAAC,cAAc,EAAE,CAAC;IAC9B,MAAA,eAAe,CAAC,UAAU,0CAAE,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACvE,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE;IACH,YAAY,CAAC,YAAY,EAAE,CAAC;IAC5B,YAAY,CAAC,YAAY,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,MAAyD;IACzE,OAAQ,MAAuB,CAAC,IAAI,KAAK,SAAS,CAAC;AACrD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MarkdownFile } from '../markdown-file';
|
|
2
2
|
import { Type } from '@cparra/apex-reflection';
|
|
3
|
-
export declare function declareType(markdownFile: MarkdownFile, typeMirror: Type
|
|
3
|
+
export declare function declareType(markdownFile: MarkdownFile, typeMirror: Type): void;
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.declareType = void 0;
|
|
4
4
|
const doc_comment_annotation_util_1 = require("./doc-comment-annotation-util");
|
|
5
|
-
function declareType(markdownFile, typeMirror
|
|
5
|
+
function declareType(markdownFile, typeMirror) {
|
|
6
6
|
var _a;
|
|
7
|
-
markdownFile.addTitle(typeMirror.name, startingHeadingLevel);
|
|
8
7
|
typeMirror.annotations.forEach((currentAnnotation) => {
|
|
9
8
|
markdownFile.addBlankLine();
|
|
10
9
|
markdownFile.addText(`\`${currentAnnotation.type.toUpperCase()}\``);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/type-declaration-util.ts"],"names":[],"mappings":";;;AACA,+EAA+E;AAG/E,SAAgB,WAAW,CAAC,YAA0B,EAAE,UAAgB
|
|
1
|
+
{"version":3,"file":"type-declaration-util.js","sourceRoot":"","sources":["../../../src/model/markdown-generation-util/type-declaration-util.ts"],"names":[],"mappings":";;;AACA,+EAA+E;AAG/E,SAAgB,WAAW,CAAC,YAA0B,EAAE,UAAgB;;IACtE,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,iBAA6B,EAAE,EAAE;QAC/D,YAAY,CAAC,YAAY,EAAE,CAAC;QAC5B,YAAY,CAAC,OAAO,CAAC,KAAK,iBAAiB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,UAAI,UAAU,CAAC,UAAU,0CAAE,WAAW,EAAE;QACtC,YAAY,CAAC,YAAY,EAAE,CAAC;QAC5B,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACxD,YAAY,CAAC,YAAY,EAAE,CAAC;KAC7B;IAED,4DAA8B,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC3D,CAAC;AAbD,kCAaC"}
|
|
@@ -3,10 +3,10 @@ import { WalkerListener } from '../service/walkers/walker';
|
|
|
3
3
|
import { MarkdownFile } from './markdown-file';
|
|
4
4
|
export declare class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
5
5
|
type: Type;
|
|
6
|
-
|
|
7
|
-
constructor(type: Type,
|
|
6
|
+
headingLevel: number;
|
|
7
|
+
constructor(type: Type, headingLevel?: number, headerContent?: string);
|
|
8
8
|
addText(text: string, encodeHtml?: boolean): void;
|
|
9
|
-
onTypeDeclaration(typeMirror: Type
|
|
9
|
+
onTypeDeclaration(typeMirror: Type): void;
|
|
10
10
|
onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void;
|
|
11
11
|
onFieldsDeclaration(fields: FieldMirror[]): void;
|
|
12
12
|
onPropertiesDeclaration(properties: PropertyMirror[]): void;
|
|
@@ -15,4 +15,10 @@ export declare class MarkdownTypeFile extends MarkdownFile implements WalkerList
|
|
|
15
15
|
onInnerClassesDeclaration(classes: ClassMirror[]): void;
|
|
16
16
|
onInnerInterfacesDeclaration(interfaces: InterfaceMirror[]): void;
|
|
17
17
|
private addInnerTypes;
|
|
18
|
+
private hasGroupings;
|
|
19
|
+
private declareMethodWithGroupings;
|
|
20
|
+
private declareFieldOrProperty;
|
|
21
|
+
private startGroup;
|
|
22
|
+
private endGroup;
|
|
23
|
+
private group;
|
|
18
24
|
}
|
|
@@ -6,10 +6,10 @@ const markdown_file_1 = require("./markdown-file");
|
|
|
6
6
|
const markdown_generation_util_1 = require("./markdown-generation-util");
|
|
7
7
|
const class_file_generatorHelper_1 = require("../transpiler/markdown/class-file-generatorHelper");
|
|
8
8
|
class MarkdownTypeFile extends markdown_file_1.MarkdownFile {
|
|
9
|
-
constructor(type,
|
|
9
|
+
constructor(type, headingLevel = 1, headerContent) {
|
|
10
10
|
super(`${type.name}`, class_file_generatorHelper_1.default.getSanitizedGroup(type));
|
|
11
11
|
this.type = type;
|
|
12
|
-
this.
|
|
12
|
+
this.headingLevel = headingLevel;
|
|
13
13
|
if (headerContent) {
|
|
14
14
|
this.addText(headerContent);
|
|
15
15
|
}
|
|
@@ -20,20 +20,25 @@ class MarkdownTypeFile extends markdown_file_1.MarkdownFile {
|
|
|
20
20
|
text = markdown_file_1.MarkdownFile.replaceInlineLinks(text);
|
|
21
21
|
super.addText(text, encodeHtml);
|
|
22
22
|
}
|
|
23
|
-
onTypeDeclaration(typeMirror
|
|
24
|
-
|
|
23
|
+
onTypeDeclaration(typeMirror) {
|
|
24
|
+
this.addTitle(typeMirror.name, this.headingLevel);
|
|
25
|
+
markdown_generation_util_1.declareType(this, typeMirror);
|
|
25
26
|
}
|
|
26
27
|
onConstructorDeclaration(className, constructors) {
|
|
27
|
-
|
|
28
|
+
this.addTitle('Constructors', this.headingLevel + 1);
|
|
29
|
+
this.declareMethodWithGroupings(constructors, className);
|
|
28
30
|
}
|
|
29
31
|
onFieldsDeclaration(fields) {
|
|
30
|
-
|
|
32
|
+
this.addTitle('Fields', this.headingLevel + 1);
|
|
33
|
+
this.declareFieldOrProperty(fields);
|
|
31
34
|
}
|
|
32
35
|
onPropertiesDeclaration(properties) {
|
|
33
|
-
|
|
36
|
+
this.addTitle('Properties', this.headingLevel + 1);
|
|
37
|
+
this.declareFieldOrProperty(properties);
|
|
34
38
|
}
|
|
35
39
|
onMethodsDeclaration(methods) {
|
|
36
|
-
|
|
40
|
+
this.addTitle('Methods', this.headingLevel + 1);
|
|
41
|
+
this.declareMethodWithGroupings(methods);
|
|
37
42
|
}
|
|
38
43
|
onInnerEnumsDeclaration(enums) {
|
|
39
44
|
this.addInnerTypes('Enums', enums);
|
|
@@ -45,7 +50,7 @@ class MarkdownTypeFile extends markdown_file_1.MarkdownFile {
|
|
|
45
50
|
this.addInnerTypes('Interfaces', interfaces, false);
|
|
46
51
|
}
|
|
47
52
|
addInnerTypes(title, types, addSeparator = true) {
|
|
48
|
-
this.addTitle(title, this.
|
|
53
|
+
this.addTitle(title, this.headingLevel + 1);
|
|
49
54
|
types
|
|
50
55
|
.sort((typeA, typeB) => {
|
|
51
56
|
if (typeA.name < typeB.name)
|
|
@@ -55,13 +60,63 @@ class MarkdownTypeFile extends markdown_file_1.MarkdownFile {
|
|
|
55
60
|
return 0;
|
|
56
61
|
})
|
|
57
62
|
.forEach((currentType) => {
|
|
58
|
-
const innerFile = new MarkdownTypeFile(currentType, this.
|
|
63
|
+
const innerFile = new MarkdownTypeFile(currentType, this.headingLevel + 2);
|
|
59
64
|
this.addText(innerFile._contents);
|
|
60
65
|
});
|
|
61
66
|
if (addSeparator) {
|
|
62
67
|
this.addHorizontalRule();
|
|
63
68
|
}
|
|
64
69
|
}
|
|
70
|
+
hasGroupings(groupAware) {
|
|
71
|
+
return !!groupAware.find((current) => !!current.group);
|
|
72
|
+
}
|
|
73
|
+
declareMethodWithGroupings(methods, className = '') {
|
|
74
|
+
const hasGroupings = this.hasGroupings(methods);
|
|
75
|
+
if (!hasGroupings) {
|
|
76
|
+
markdown_generation_util_1.declareMethod(this, methods, this.headingLevel, className);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const groupedConstructors = this.group(methods);
|
|
80
|
+
for (const key in groupedConstructors) {
|
|
81
|
+
this.startGroup(key);
|
|
82
|
+
const constructorsForGroup = groupedConstructors[key];
|
|
83
|
+
markdown_generation_util_1.declareMethod(this, constructorsForGroup, this.headingLevel, className);
|
|
84
|
+
this.endGroup();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
declareFieldOrProperty(fieldsOrProperties) {
|
|
89
|
+
const hasGroupings = this.hasGroupings(fieldsOrProperties);
|
|
90
|
+
if (!hasGroupings) {
|
|
91
|
+
markdown_generation_util_1.declareField(this, fieldsOrProperties, this.headingLevel, false);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const groupedFields = this.group(fieldsOrProperties);
|
|
95
|
+
for (const key in groupedFields) {
|
|
96
|
+
this.startGroup(key);
|
|
97
|
+
const fieldsForGroup = groupedFields[key];
|
|
98
|
+
markdown_generation_util_1.declareField(this, fieldsForGroup, this.headingLevel, true);
|
|
99
|
+
this.endGroup();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
startGroup(groupName) {
|
|
104
|
+
this.headingLevel = this.headingLevel + 2;
|
|
105
|
+
this.addTitle(groupName, this.headingLevel);
|
|
106
|
+
}
|
|
107
|
+
endGroup() {
|
|
108
|
+
this.headingLevel = this.headingLevel - 2;
|
|
109
|
+
}
|
|
110
|
+
group(list) {
|
|
111
|
+
return list.reduce((groups, item) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const groupName = (_a = item.group) !== null && _a !== void 0 ? _a : 'Other';
|
|
114
|
+
const group = groups[groupName] || [];
|
|
115
|
+
group.push(item);
|
|
116
|
+
groups[groupName] = group;
|
|
117
|
+
return groups;
|
|
118
|
+
}, {});
|
|
119
|
+
}
|
|
65
120
|
}
|
|
66
121
|
exports.MarkdownTypeFile = MarkdownTypeFile;
|
|
67
122
|
//# sourceMappingURL=markdown-type-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-type-file.js","sourceRoot":"","sources":["../../src/model/markdown-type-file.ts"],"names":[],"mappings":";;;AAUA,sEAAkE;AAElE,mDAA+C;AAC/C,yEAAsF;AACtF,kGAAyF;
|
|
1
|
+
{"version":3,"file":"markdown-type-file.js","sourceRoot":"","sources":["../../src/model/markdown-type-file.ts"],"names":[],"mappings":";;;AAUA,sEAAkE;AAElE,mDAA+C;AAC/C,yEAAsF;AACtF,kGAAyF;AAUzF,MAAa,gBAAiB,SAAQ,4BAAY;IAChD,YAAmB,IAAU,EAAS,eAAuB,CAAC,EAAE,aAAsB;QACpF,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,oCAAwB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QADvD,SAAI,GAAJ,IAAI,CAAM;QAAS,iBAAY,GAAZ,YAAY,CAAY;QAE5D,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CA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,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAEO,QAAQ;QACd,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IAC5C,CAAC;IAEO,KAAK,CAAC,IAAkB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,MAAgB,EAAE,IAAI,EAAE,EAAE;;YAC5C,MAAM,SAAS,SAAW,IAAI,CAAC,KAAK,mCAAI,OAAO,CAAC;YAChD,MAAM,KAAK,GAAiB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;YAC1B,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AAzHD,4CAyHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@cparra/apex-reflection": "^1.
|
|
66
|
+
"@cparra/apex-reflection": "^1.1.2",
|
|
67
67
|
"chalk": "^4.1.2",
|
|
68
68
|
"html-entities": "^2.3.2",
|
|
69
69
|
"yargs": "^16.0.3"
|
|
@@ -53,6 +53,11 @@ export class MarkdownFile extends File {
|
|
|
53
53
|
columns.forEach((column) => {
|
|
54
54
|
this._contents += column + '|';
|
|
55
55
|
});
|
|
56
|
+
this.addBlankLine();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
addListItem(text: string) {
|
|
60
|
+
this._contents += `* ${text}`;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
protected static replaceInlineLinks(text: string) {
|
|
@@ -2,12 +2,11 @@ import { MarkdownFile } from '../markdown-file';
|
|
|
2
2
|
import { FieldMirror, PropertyMirror } from '@cparra/apex-reflection';
|
|
3
3
|
|
|
4
4
|
export function declareField(
|
|
5
|
-
title: string,
|
|
6
5
|
markdownFile: MarkdownFile,
|
|
7
6
|
fields: FieldMirror[] | PropertyMirror[],
|
|
8
7
|
startingHeadingLevel: number,
|
|
8
|
+
grouped = false,
|
|
9
9
|
) {
|
|
10
|
-
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
11
10
|
markdownFile.addBlankLine();
|
|
12
11
|
fields
|
|
13
12
|
.sort((propA, propB) => {
|
|
@@ -16,7 +15,7 @@ export function declareField(
|
|
|
16
15
|
return 0;
|
|
17
16
|
})
|
|
18
17
|
.forEach((propertyModel) => {
|
|
19
|
-
addFieldSection(markdownFile, propertyModel, startingHeadingLevel);
|
|
18
|
+
addFieldSection(markdownFile, propertyModel, startingHeadingLevel, grouped);
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
markdownFile.addHorizontalRule();
|
|
@@ -24,19 +23,42 @@ export function declareField(
|
|
|
24
23
|
|
|
25
24
|
function addFieldSection(
|
|
26
25
|
markdownFile: MarkdownFile,
|
|
27
|
-
|
|
26
|
+
mirrorModel: FieldMirror | PropertyMirror,
|
|
28
27
|
startingHeadingLevel: number,
|
|
28
|
+
grouped: boolean,
|
|
29
29
|
) {
|
|
30
|
-
|
|
30
|
+
if (!grouped) {
|
|
31
|
+
markdownFile.addTitle(`\`${mirrorModel.name}\` → \`${mirrorModel.type}\``, startingHeadingLevel + 2);
|
|
32
|
+
markdownFile.addBlankLine();
|
|
33
|
+
|
|
34
|
+
mirrorModel.annotations.forEach((annotation) => {
|
|
35
|
+
markdownFile.addText(`\`${annotation.type.toUpperCase()}\` `);
|
|
36
|
+
});
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
if (mirrorModel.docComment?.description) {
|
|
39
|
+
markdownFile.addBlankLine();
|
|
40
|
+
markdownFile.addText(mirrorModel.docComment.description);
|
|
41
|
+
}
|
|
33
42
|
markdownFile.addBlankLine();
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
} else {
|
|
44
|
+
let annotations = '';
|
|
45
|
+
const hasAnnotations = !!mirrorModel.annotations.length;
|
|
46
|
+
if (hasAnnotations) {
|
|
47
|
+
annotations += ' [';
|
|
48
|
+
}
|
|
49
|
+
mirrorModel.annotations.forEach((annotation) => {
|
|
50
|
+
annotations += `\`${annotation.type.toUpperCase()}\` `;
|
|
51
|
+
});
|
|
52
|
+
if (hasAnnotations) {
|
|
53
|
+
annotations += ']';
|
|
54
|
+
}
|
|
36
55
|
|
|
37
|
-
|
|
56
|
+
// If grouped we want to display these as a list
|
|
57
|
+
let description = '';
|
|
58
|
+
if (mirrorModel.docComment?.description) {
|
|
59
|
+
description = ` - ${mirrorModel.docComment?.description}`;
|
|
60
|
+
}
|
|
61
|
+
markdownFile.addListItem(`\`${mirrorModel.name}\` → \`${mirrorModel.type}\`${annotations} ${description}`);
|
|
38
62
|
markdownFile.addBlankLine();
|
|
39
|
-
markdownFile.addText(propertyModel.docComment.description);
|
|
40
63
|
}
|
|
41
|
-
markdownFile.addBlankLine();
|
|
42
64
|
}
|
|
@@ -4,13 +4,11 @@ import { ParameterMirror } from '@cparra/apex-reflection/index';
|
|
|
4
4
|
import { addCustomDocCommentAnnotations } from './doc-comment-annotation-util';
|
|
5
5
|
|
|
6
6
|
export function declareMethod(
|
|
7
|
-
title: string,
|
|
8
7
|
markdownFile: MarkdownFile,
|
|
9
8
|
methods: ConstructorMirror[] | MethodMirror[],
|
|
10
9
|
startingHeadingLevel: number,
|
|
11
10
|
className = '',
|
|
12
11
|
): void {
|
|
13
|
-
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
14
12
|
methods.forEach((currentMethod) => {
|
|
15
13
|
const signatureName = isMethod(currentMethod) ? (currentMethod as MethodMirror).name : className;
|
|
16
14
|
markdownFile.addTitle(`\`${buildSignature(signatureName, currentMethod)}\``, startingHeadingLevel + 2);
|
|
@@ -58,9 +56,7 @@ function buildSignature(name: string, parameterAware: ParameterAware): string {
|
|
|
58
56
|
if (isMethod(parameterAware) && (parameterAware as MethodMirror).memberModifiers.length) {
|
|
59
57
|
signature = (parameterAware as MethodMirror).memberModifiers.join(' ') + ' ' + signature;
|
|
60
58
|
}
|
|
61
|
-
const signatureParameters = parameterAware.parameters.map((param) => {
|
|
62
|
-
signature += `${param.type} ${param.name}`;
|
|
63
|
-
});
|
|
59
|
+
const signatureParameters = parameterAware.parameters.map((param) => `${param.type} ${param.name}`);
|
|
64
60
|
signature += signatureParameters.join(', ');
|
|
65
61
|
return (signature += ')');
|
|
66
62
|
}
|
|
@@ -2,9 +2,7 @@ import { MarkdownFile } from '../markdown-file';
|
|
|
2
2
|
import { addCustomDocCommentAnnotations } from './doc-comment-annotation-util';
|
|
3
3
|
import { Annotation, Type } from '@cparra/apex-reflection';
|
|
4
4
|
|
|
5
|
-
export function declareType(markdownFile: MarkdownFile, typeMirror: Type
|
|
6
|
-
markdownFile.addTitle(typeMirror.name, startingHeadingLevel);
|
|
7
|
-
|
|
5
|
+
export function declareType(markdownFile: MarkdownFile, typeMirror: Type): void {
|
|
8
6
|
typeMirror.annotations.forEach((currentAnnotation: Annotation) => {
|
|
9
7
|
markdownFile.addBlankLine();
|
|
10
8
|
markdownFile.addText(`\`${currentAnnotation.type.toUpperCase()}\``);
|
|
@@ -14,8 +14,16 @@ import { MarkdownFile } from './markdown-file';
|
|
|
14
14
|
import { declareType, declareMethod, declareField } from './markdown-generation-util';
|
|
15
15
|
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
16
16
|
|
|
17
|
+
interface GroupAware {
|
|
18
|
+
group?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface GroupMap {
|
|
22
|
+
[key: string]: GroupAware[];
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
18
|
-
constructor(public type: Type, public
|
|
26
|
+
constructor(public type: Type, public headingLevel: number = 1, headerContent?: string) {
|
|
19
27
|
super(`${type.name}`, ClassFileGeneratorHelper.getSanitizedGroup(type));
|
|
20
28
|
if (headerContent) {
|
|
21
29
|
this.addText(headerContent);
|
|
@@ -29,24 +37,29 @@ export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
|
29
37
|
super.addText(text, encodeHtml);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
public onTypeDeclaration(typeMirror: Type
|
|
33
|
-
|
|
40
|
+
public onTypeDeclaration(typeMirror: Type): void {
|
|
41
|
+
this.addTitle(typeMirror.name, this.headingLevel);
|
|
42
|
+
declareType(this, typeMirror);
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
public onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void {
|
|
37
|
-
|
|
46
|
+
this.addTitle('Constructors', this.headingLevel + 1);
|
|
47
|
+
this.declareMethodWithGroupings(constructors, className);
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
public onFieldsDeclaration(fields: FieldMirror[]): void {
|
|
41
|
-
|
|
51
|
+
this.addTitle('Fields', this.headingLevel + 1);
|
|
52
|
+
this.declareFieldOrProperty(fields);
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
public onPropertiesDeclaration(properties: PropertyMirror[]): void {
|
|
45
|
-
|
|
56
|
+
this.addTitle('Properties', this.headingLevel + 1);
|
|
57
|
+
this.declareFieldOrProperty(properties);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
public onMethodsDeclaration(methods: MethodMirror[]): void {
|
|
49
|
-
|
|
61
|
+
this.addTitle('Methods', this.headingLevel + 1);
|
|
62
|
+
this.declareMethodWithGroupings(methods);
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
public onInnerEnumsDeclaration(enums: EnumMirror[]): void {
|
|
@@ -62,7 +75,7 @@ export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
private addInnerTypes(title: string, types: Type[], addSeparator = true) {
|
|
65
|
-
this.addTitle(title, this.
|
|
78
|
+
this.addTitle(title, this.headingLevel + 1);
|
|
66
79
|
types
|
|
67
80
|
.sort((typeA, typeB) => {
|
|
68
81
|
if (typeA.name < typeB.name) return -1;
|
|
@@ -70,11 +83,64 @@ export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
|
70
83
|
return 0;
|
|
71
84
|
})
|
|
72
85
|
.forEach((currentType) => {
|
|
73
|
-
const innerFile = new MarkdownTypeFile(currentType, this.
|
|
86
|
+
const innerFile = new MarkdownTypeFile(currentType, this.headingLevel + 2);
|
|
74
87
|
this.addText(innerFile._contents);
|
|
75
88
|
});
|
|
76
89
|
if (addSeparator) {
|
|
77
90
|
this.addHorizontalRule();
|
|
78
91
|
}
|
|
79
92
|
}
|
|
93
|
+
|
|
94
|
+
private hasGroupings(groupAware: GroupAware[]): boolean {
|
|
95
|
+
return !!groupAware.find((current) => !!current.group);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private declareMethodWithGroupings(methods: ConstructorMirror[] | MethodMirror[], className = ''): void {
|
|
99
|
+
const hasGroupings = this.hasGroupings(methods);
|
|
100
|
+
if (!hasGroupings) {
|
|
101
|
+
declareMethod(this, methods, this.headingLevel, className);
|
|
102
|
+
} else {
|
|
103
|
+
const groupedConstructors = this.group(methods);
|
|
104
|
+
for (const key in groupedConstructors) {
|
|
105
|
+
this.startGroup(key);
|
|
106
|
+
const constructorsForGroup = groupedConstructors[key] as ConstructorMirror[];
|
|
107
|
+
declareMethod(this, constructorsForGroup, this.headingLevel, className);
|
|
108
|
+
this.endGroup();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private declareFieldOrProperty(fieldsOrProperties: FieldMirror[] | PropertyMirror[]): void {
|
|
114
|
+
const hasGroupings = this.hasGroupings(fieldsOrProperties);
|
|
115
|
+
if (!hasGroupings) {
|
|
116
|
+
declareField(this, fieldsOrProperties, this.headingLevel, false);
|
|
117
|
+
} else {
|
|
118
|
+
const groupedFields = this.group(fieldsOrProperties);
|
|
119
|
+
for (const key in groupedFields) {
|
|
120
|
+
this.startGroup(key);
|
|
121
|
+
const fieldsForGroup = groupedFields[key] as FieldMirror[];
|
|
122
|
+
declareField(this, fieldsForGroup, this.headingLevel, true);
|
|
123
|
+
this.endGroup();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private startGroup(groupName: string) {
|
|
129
|
+
this.headingLevel = this.headingLevel + 2;
|
|
130
|
+
this.addTitle(groupName, this.headingLevel);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private endGroup() {
|
|
134
|
+
this.headingLevel = this.headingLevel - 2;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private group(list: GroupAware[]) {
|
|
138
|
+
return list.reduce((groups: GroupMap, item) => {
|
|
139
|
+
const groupName: string = item.group ?? 'Other';
|
|
140
|
+
const group: GroupAware[] = groups[groupName] || [];
|
|
141
|
+
group.push(item);
|
|
142
|
+
groups[groupName] = group;
|
|
143
|
+
return groups;
|
|
144
|
+
}, {});
|
|
145
|
+
}
|
|
80
146
|
}
|