@cparra/apexdocs 2.6.0-alpha.0 → 2.6.0-beta.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 +32 -13
- package/docs/Main/SampleClass.md +14 -8
- package/docs/README.md +16 -3
- package/docs/core-utils/ClassWithDescriptionBlock.md +36 -0
- package/examples/force-app/main/default/classes/ClassWithDescriptionBlock.cls +31 -0
- package/examples/force-app/main/default/classes/SampleClass.cls +9 -0
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.js +11 -2
- package/lib/cli/generate.js.map +1 -1
- package/lib/model/file.js +4 -2
- package/lib/model/file.js.map +1 -1
- package/lib/model/markdown-file.js +2 -2
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.js +4 -2
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
- package/lib/model/markdown-home-file.js +6 -2
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/service/metadata-processor.js +4 -2
- package/lib/service/metadata-processor.js.map +1 -1
- package/lib/settings.d.ts +4 -1
- package/lib/settings.js +6 -4
- package/lib/settings.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +2 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +2 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +0 -2
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +2 -1
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/processor-type-transpiler.d.ts +2 -0
- package/lib/transpiler/processor-type-transpiler.js.map +1 -1
- package/lib/util/truncate.d.ts +1 -0
- package/lib/util/truncate.js +8 -0
- package/lib/util/truncate.js.map +1 -0
- package/package.json +3 -4
- package/src/application/Apexdocs.ts +1 -1
- package/src/cli/generate.ts +12 -2
- package/src/model/file.ts +4 -2
- package/src/model/markdown-file.ts +3 -2
- package/src/model/markdown-generation-util/type-declaration-util.ts +4 -2
- package/src/model/markdown-home-file.ts +9 -1
- package/src/service/metadata-processor.ts +4 -1
- package/src/settings.ts +10 -5
- package/src/transpiler/markdown/class-file-generatorHelper.ts +1 -2
- package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +2 -1
- package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +2 -1
- package/src/transpiler/markdown/markdown-transpiler-base.ts +0 -4
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +2 -1
- package/src/transpiler/processor-type-transpiler.ts +4 -0
- package/src/util/truncate.ts +3 -0
- package/docs/ts/GroupedClass.d.ts +0 -3
- package/docs/ts/SampleClass.d.ts +0 -11
- package/docs/ts/SampleInterface.d.ts +0 -0
- package/lib/model/ts-definition-file.d.ts +0 -26
- package/lib/model/ts-definition-file.js +0 -137
- package/lib/model/ts-definition-file.js.map +0 -1
- package/lib/transpiler/ts-types/TsTypesTranspiler.d.ts +0 -9
- package/lib/transpiler/ts-types/TsTypesTranspiler.js +0 -23
- package/lib/transpiler/ts-types/TsTypesTranspiler.js.map +0 -1
- package/src/model/ts-definition-file.ts +0 -165
- package/src/transpiler/ts-types/TsTypesTranspiler.ts +0 -24
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { File } from './file';
|
|
2
|
-
import { WalkerListener } from '../service/walkers/walker';
|
|
3
|
-
import {
|
|
4
|
-
ClassMirror,
|
|
5
|
-
ConstructorMirror,
|
|
6
|
-
EnumMirror,
|
|
7
|
-
FieldMirror,
|
|
8
|
-
InterfaceMirror,
|
|
9
|
-
MethodMirror,
|
|
10
|
-
PropertyMirror,
|
|
11
|
-
Type,
|
|
12
|
-
} from '@cparra/apex-reflection';
|
|
13
|
-
import { WalkerFactory } from '../service/walkers/walker-factory';
|
|
14
|
-
|
|
15
|
-
export default class TsDefinitionFile extends File implements WalkerListener {
|
|
16
|
-
fileExtension(): string {
|
|
17
|
-
return '.d.ts';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
constructor(typeMirror: Type) {
|
|
21
|
-
super(typeMirror.name, '');
|
|
22
|
-
const walker = WalkerFactory.get(typeMirror);
|
|
23
|
-
walker.walk(this);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
27
|
-
onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void {}
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
30
|
-
onFieldsDeclaration(fields: FieldMirror[]): void {}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
33
|
-
onInnerClassesDeclaration(classes: ClassMirror[]): void {}
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
36
|
-
onInnerEnumsDeclaration(enums: EnumMirror[]): void {}
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
39
|
-
onInnerInterfacesDeclaration(interfaces: InterfaceMirror[]): void {}
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
42
|
-
onMethodsDeclaration(methods: MethodMirror[]): void {}
|
|
43
|
-
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
45
|
-
onPropertiesDeclaration(properties: PropertyMirror[]): void {}
|
|
46
|
-
|
|
47
|
-
onTypeDeclaration(typeMirror: Type): void {
|
|
48
|
-
this.initializeBlock();
|
|
49
|
-
this.declareType(typeMirror.name, typeMirror.docComment?.description ?? '');
|
|
50
|
-
this.addPropertiesAndFields(typeMirror);
|
|
51
|
-
// TODO: Auraenabled method support
|
|
52
|
-
// TODO: Remember that methods with getX and setX lose the get and set
|
|
53
|
-
// TODO: Classes that dont have any auraenabled things should be skipped
|
|
54
|
-
this.finalizeBlock();
|
|
55
|
-
this.addInnerClasses(typeMirror);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private addPropertiesAndFields(typeMirror: Type) {
|
|
59
|
-
const classModel = typeMirror as ClassMirror;
|
|
60
|
-
if (classModel.properties.length === 0 && classModel.fields.length === 0) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const propertiesAndFields = [...classModel.properties, ...classModel.fields].filter(
|
|
65
|
-
(e) => e.annotations.findIndex((a) => a.name === 'auraenabled') !== -1,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
propertiesAndFields
|
|
69
|
-
.sort((propA, propB) => {
|
|
70
|
-
if (propA.name < propB.name) return -1;
|
|
71
|
-
if (propA.name > propB.name) return 1;
|
|
72
|
-
return 0;
|
|
73
|
-
})
|
|
74
|
-
.forEach((propertyModel) => {
|
|
75
|
-
this.declareProperty(propertyModel.type, propertyModel.name, propertyModel.docComment?.description ?? '');
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private addInnerClasses(typeMirror: Type) {
|
|
80
|
-
const classModel = typeMirror as ClassMirror;
|
|
81
|
-
if (classModel.classes.length > 0) {
|
|
82
|
-
classModel.classes
|
|
83
|
-
.sort((classA, classB) => {
|
|
84
|
-
if (classA.name < classB.name) return -1;
|
|
85
|
-
if (classA.name > classB.name) return 1;
|
|
86
|
-
return 0;
|
|
87
|
-
})
|
|
88
|
-
.forEach((innerClass) => {
|
|
89
|
-
this.onTypeDeclaration(innerClass);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
addBlankLine() {
|
|
95
|
-
this._contents += '\n';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
initializeBlock() {
|
|
99
|
-
this._contents += '/**';
|
|
100
|
-
this.addBlankLine();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
finalizeBlock() {
|
|
104
|
-
this._contents += ' */';
|
|
105
|
-
this.addBlankLine();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
declareType(className: string, docDescription: string) {
|
|
109
|
-
this._contents += ` * @typedef {Object} ${className} ${docDescription}`;
|
|
110
|
-
this.addBlankLine();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
declareProperty(propertyType: string, propertyName: string, docDescription: string) {
|
|
114
|
-
let sanitizedType;
|
|
115
|
-
// First we check if we are dealing with a list
|
|
116
|
-
if (this.isListProperty(propertyType)) {
|
|
117
|
-
// If we are then we first extract the type from the list
|
|
118
|
-
sanitizedType = this.extractTypeFromList(propertyType);
|
|
119
|
-
// then sanitize it
|
|
120
|
-
sanitizedType = this.sanitizeApexPropertyToJavascript(sanitizedType);
|
|
121
|
-
// and then we add brackets ([])
|
|
122
|
-
sanitizedType = sanitizedType + '[]';
|
|
123
|
-
} else {
|
|
124
|
-
sanitizedType = this.sanitizeApexPropertyToJavascript(propertyType);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this._contents += ` * @property {${sanitizedType}} ${propertyName} ${docDescription}`;
|
|
128
|
-
this.addBlankLine();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
sanitizeApexPropertyToJavascript(propertyType: string) {
|
|
132
|
-
const lowerPropertyType = propertyType.toLowerCase();
|
|
133
|
-
if (lowerPropertyType === 'decimal' || lowerPropertyType === 'integer' || lowerPropertyType === 'double') {
|
|
134
|
-
return 'number';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (lowerPropertyType === 'boolean' || lowerPropertyType === 'string') {
|
|
138
|
-
// If it is a built-in type then we return the lower-cased version.
|
|
139
|
-
return lowerPropertyType;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Otherwise, we respect casing
|
|
143
|
-
return propertyType;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
isListProperty(propertyType: string) {
|
|
147
|
-
const lowerPropertyType = propertyType.toLowerCase();
|
|
148
|
-
if (lowerPropertyType.includes('<') && lowerPropertyType.includes('list')) {
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
extractTypeFromList(propertyType: string) {
|
|
154
|
-
const propertyWithoutList = this.replaceAll(propertyType, 'list', '');
|
|
155
|
-
return propertyWithoutList.replace('list', '').replace('<', '').replace('>', '');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Case insensitive replace
|
|
159
|
-
replaceAll(sourceString: string, strReplace: string, strWith: string) {
|
|
160
|
-
// See http://stackoverflow.com/a/3561711/556609
|
|
161
|
-
const esc = strReplace.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
162
|
-
const reg = new RegExp(esc, 'ig');
|
|
163
|
-
return sourceString.replace(reg, strWith);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import ProcessorTypeTranspiler from '../processor-type-transpiler';
|
|
2
|
-
import { Type } from '@cparra/apex-reflection';
|
|
3
|
-
import { FileContainer } from '../file-container';
|
|
4
|
-
import TsDefinitionFile from '../../model/ts-definition-file';
|
|
5
|
-
|
|
6
|
-
export class TsTypesTranspiler extends ProcessorTypeTranspiler {
|
|
7
|
-
protected readonly _fileContainer: FileContainer;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this._fileContainer = new FileContainer();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
fileBuilder(): FileContainer {
|
|
15
|
-
return this._fileContainer;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
onProcess(type: Type): void {
|
|
19
|
-
if (type.type_name !== 'class') {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this._fileContainer.pushFile(new TsDefinitionFile(type));
|
|
23
|
-
}
|
|
24
|
-
}
|