You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can find these files after the first run in the `apis` folder generated by the parser. You can prevent caching by setting it to false:
52
+
53
+
```json
54
+
"cacheApis": true,
55
+
```
56
+
57
+
### 2. Preprocessing
58
+
59
+
The preprocessing will modify the loaded api.json objects (no files are modified) using the [jsonpath package](https://www.npmjs.com/package/jsonpath). Thus, it uses json path to get the desired parameters specified by `jsonpath`. In the subscript filter javascript can be used (for example regex).
60
+
61
+
After that it will apply the function given in `script`. The scriptfunction always gets a val variable, which has to be manipulated and **returned**. The logger will output the caught object in debug level or set a breakpoint in the debugwrapper in the parser.ts, if you are running it with a debugger.
62
+
63
+
In addition a comment can be provided to describe what is happening in the log output.
64
+
65
+
This example will set all methods except extend and getMetadata for all modules starting with `sap/m/` to not static:
66
+
67
+
```json
68
+
"preProcessing": {
69
+
"correctStaticSapM": {
70
+
"comment": "Replaces incorrect static values in sap/m",
The parsing process goes through the loaded api docs, takes all exported symbols and combines them to valid typings. Via config you have multiple ways to adjust the process.
81
+
82
+
#### 3.1 Types and parameter name replacements / fixes
83
+
84
+
To fix some bugs in parameter names (for example usage of html tags or other not-allowed figures for variable and parameter names) the `cleanParamNames` section can be used:
85
+
86
+
```json
87
+
"cleanParamNames": {
88
+
"<code>vData</code>": "vData",
89
+
"<your-page-object-name>": "[key: string]"
90
+
},
91
+
```
92
+
93
+
The property name is the parameter to replace and gets replaced by the value (which has to be a string). Example:
94
+
95
+
```typescript
96
+
classa {
97
+
public testMethod(<code>vData</code>:string):void;
98
+
}
99
+
```
100
+
101
+
The method above would not be compilable for the parser. Using the replacement, the `<code>vData</code>` will be replaced with the proper `"vData"` name:
102
+
103
+
```typescript
104
+
classa {
105
+
public testMethod(vData:string):void;
106
+
}
107
+
```
108
+
109
+
This will be applied to all function/method parameters in all classes, namespaces, etc.
110
+
111
+
#### 3.2 Type Map
112
+
113
+
The type map is the same as the `cleanParameterNames`. It will replace wrong types, in all classes, namespaces, enums, etc. The key will be the type to replace, the value will be the replacement
114
+
115
+
```json
116
+
"typeMap": {
117
+
"*": "any",
118
+
"any[]": "any[]",
119
+
"array": "any[]",
120
+
```
121
+
122
+
Example:
123
+
124
+
```typescript
125
+
class a {
126
+
public testMethod(data: *): void;
127
+
}
128
+
```
129
+
130
+
will be replaced by
131
+
132
+
```typescript
133
+
classa {
134
+
public testMethod(data:any):void;
135
+
}
136
+
```
137
+
138
+
#### 3.3 Parsing enums
139
+
140
+
Enums will be parsed using the template `enums.d.ts.hb`. The template uses [Handlebars](https://handlebarsjs.com/) syntax and the raw symbol:
141
+
142
+
```typescript
143
+
interfaceISymbol {
144
+
// enum
145
+
kind:string;
146
+
// sap.m.BackgroundDesign
147
+
name:string;
148
+
// BackgroundDesign
149
+
basename:string;
150
+
// sap/m/library.js
151
+
resource:string;
152
+
// sap/m/library or sap.m.library if not modular
153
+
module:string;
154
+
// BackgroundDesign
155
+
export:string;
156
+
// true
157
+
static:boolean;
158
+
// public, private, recstricted or protected
159
+
visibility:string;
160
+
// Description text
161
+
description:string;
162
+
// The properties the enum uses
163
+
properties:IProperty[];
164
+
}
165
+
166
+
interfaceIProperty {
167
+
// Solid
168
+
name:string;
169
+
// public, private, restricted or protected
170
+
visibility:string;
171
+
// true or false
172
+
static:boolean;
173
+
// any type, basetype or other sap.ui.... type
174
+
type:string;
175
+
// any description
176
+
description:string;
177
+
}
178
+
```
179
+
180
+
The files will all be put out in the out folder and enums subfolder. All enums will be declared ambient.
181
+
182
+
#### 3.4 Parsing namespaces
183
+
184
+
Uses `ParsedNamespace` class and `namespace.d.ts.hb` template. All namespaces are ambient (thus, always available).
185
+
186
+
#### 3.5 Parsing interfaces
187
+
188
+
Uses `ParsedClass` class and `interface.d.ts.hb` template. All interfaces are ambient (thus, always available).
189
+
190
+
#### 3.6 Parsing classes
191
+
192
+
Uses `ParsedClass` class and either `classAmbient.d.ts.hb` template, if the class is ambient (`module` of Symbol in the api json is separated with dots `.` instead of slashes `/`), otherwise it uses `classModule.d.ts.hb`.
193
+
194
+
##### a) Establishing Inheritance
195
+
196
+
After getting all classes (that means the ParsedClass objects are instanciated), the parser will start with base classes that have no base class and work its way up until the inheritance hierarchy is established.
197
+
198
+
##### b) Creating Overloads
199
+
200
+
After the class inheritance is done, the parser will start to get all overloaded methods and try to adjust them so they can be overloaded. Furthermore leading optional parameters are resolved as overloads. Tailing optional method parameters are left with `?`.
201
+
202
+
### 4. Postprocessing
203
+
204
+
Postprocessing will be going through all output files and replace whole text sections either using strings or regular expressions. The key will be the path to the file starting from the output folder. The value is an array with all replacements that should be done in the file.
0 commit comments