@ui5/webcomponents-tools 1.24.0-rc.4 → 2.0.0-rc.0
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/CHANGELOG.md +271 -0
- package/components-package/nps.js +4 -11
- package/components-package/wdio.js +404 -405
- package/icons-collection/nps.js +2 -2
- package/lib/create-new-component/index.js +4 -11
- package/lib/generate-json-imports/i18n.js +3 -35
- package/lib/generate-json-imports/themes.js +2 -29
- package/lib/i18n/defaults.js +1 -1
- package/package.json +2 -3
- package/components-package/wdio.sync.js +0 -368
- package/lib/create-new-component/jsFileContentTemplate.js +0 -73
- package/lib/generate-custom-elements-manifest/index.js +0 -271
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/configTypescript.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2468
- package/lib/jsdoc/preprocess.js +0 -146
- package/lib/jsdoc/template/publish.js +0 -4120
@@ -1,4120 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* JSDoc3 template for UI5 documentation generation.
|
3
|
-
*
|
4
|
-
* (c) Copyright 2009-2018 SAP SE or an SAP affiliate company.
|
5
|
-
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
6
|
-
*/
|
7
|
-
|
8
|
-
/*global env: true */
|
9
|
-
/*eslint strict: [2, "global"]*/
|
10
|
-
|
11
|
-
"use strict";
|
12
|
-
|
13
|
-
/* imports */
|
14
|
-
var template = require('jsdoc/template'),
|
15
|
-
helper = require('jsdoc/util/templateHelper'),
|
16
|
-
fs = require('jsdoc/fs'),
|
17
|
-
doclet = require('jsdoc/doclet'),
|
18
|
-
path = require('jsdoc/path');
|
19
|
-
|
20
|
-
/* globals, constants */
|
21
|
-
var MY_TEMPLATE_NAME = "ui5",
|
22
|
-
ANONYMOUS_LONGNAME = doclet.ANONYMOUS_LONGNAME,
|
23
|
-
A_SECURITY_TAGS = [
|
24
|
-
{
|
25
|
-
name : "SecSource",
|
26
|
-
caption : "Taint Source",
|
27
|
-
description : "APIs that might introduce tainted data into an application, e.g. due to user input or network access",
|
28
|
-
params : ["out","flags"]
|
29
|
-
},
|
30
|
-
{
|
31
|
-
name : "SecEntryPoint",
|
32
|
-
caption : "Taint Entry Point",
|
33
|
-
description: "APIs that are called implicitly by a framework or server and trigger execution of application logic",
|
34
|
-
params : ["in","flags"]
|
35
|
-
},
|
36
|
-
{
|
37
|
-
name : "SecSink",
|
38
|
-
caption : "Taint Sink",
|
39
|
-
description : "APIs that pose a security risk when they receive tainted data",
|
40
|
-
params : ["in","flags"]
|
41
|
-
},
|
42
|
-
{
|
43
|
-
name : "SecPassthrough",
|
44
|
-
caption : "Taint Passthrough",
|
45
|
-
description : "APIs that might propagate tainted data when they receive it as input",
|
46
|
-
params : ["in","out","flags"]
|
47
|
-
},
|
48
|
-
{
|
49
|
-
name : "SecValidate",
|
50
|
-
caption : "Validation",
|
51
|
-
description : "APIs that (partially) cleanse tainted data so that it no longer poses a security risk in the further data flow of an application",
|
52
|
-
params : ["in","out","flags"]
|
53
|
-
}
|
54
|
-
];
|
55
|
-
|
56
|
-
var rSecurityTags = new RegExp(A_SECURITY_TAGS.map(function($) {return $.name.toLowerCase(); }).join('|'), "i");
|
57
|
-
//debug(A_SECURITY_TAGS.map(function($) {return $.name; }).join('|'));
|
58
|
-
|
59
|
-
var templateConf = (env.conf.templates || {})[MY_TEMPLATE_NAME] || {},
|
60
|
-
pluginConf = templateConf,
|
61
|
-
conf = {},
|
62
|
-
view;
|
63
|
-
|
64
|
-
var __db;
|
65
|
-
var __longnames;
|
66
|
-
var __missingLongnames = {};
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Maps the symbol 'longname's to the unique filename that contains the documentation of that symbol.
|
70
|
-
* This map is maintained to deal with names that only differ in case (e.g. the namespace sap.ui.model.type and the class sap.ui.model.Type).
|
71
|
-
*/
|
72
|
-
var __uniqueFilenames = {};
|
73
|
-
|
74
|
-
function info() {
|
75
|
-
if ( env.opts.verbose || env.opts.debug ) {
|
76
|
-
console.log.apply(console, arguments);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
function warning(msg) {
|
81
|
-
var args = Array.prototype.slice.apply(arguments);
|
82
|
-
args[0] = "**** warning: " + args[0];
|
83
|
-
// console.log.apply(console, args); // TODO: fix warnings. For the moment disable them
|
84
|
-
}
|
85
|
-
|
86
|
-
function error(msg) {
|
87
|
-
var args = Array.prototype.slice.apply(arguments);
|
88
|
-
args[0] = "**** error: " + args[0];
|
89
|
-
// console.log.apply(console, args); // TODO: fix warnings. For the moment disable them
|
90
|
-
}
|
91
|
-
|
92
|
-
function debug() {
|
93
|
-
if ( env.opts.debug ) {
|
94
|
-
console.log.apply(console, arguments);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
function merge(target) {
|
99
|
-
for (var i = 1; i < arguments.length; i++) {
|
100
|
-
var source = arguments[i];
|
101
|
-
Object.keys(source).forEach(function(p) {
|
102
|
-
var v = source[p];
|
103
|
-
target[p] = ( v.constructor === Object ) ? merge(target[p] || {}, v) : v;
|
104
|
-
});
|
105
|
-
}
|
106
|
-
return target;
|
107
|
-
}
|
108
|
-
|
109
|
-
function lookup(longname /*, variant*/) {
|
110
|
-
var key = longname; // variant ? longname + "|" + variant : longname;
|
111
|
-
if ( !Object.prototype.hasOwnProperty.call(__longnames, key) ) {
|
112
|
-
__missingLongnames[key] = (__missingLongnames[key] || 0) + 1;
|
113
|
-
var oResult = __db({longname: longname /*, variant: variant ? variant : {isUndefined: true}*/});
|
114
|
-
__longnames[key] = oResult.first();
|
115
|
-
}
|
116
|
-
return __longnames[key];
|
117
|
-
}
|
118
|
-
|
119
|
-
var externalSymbols = {};
|
120
|
-
|
121
|
-
function loadExternalSymbols(apiJsonFolder) {
|
122
|
-
|
123
|
-
var files;
|
124
|
-
|
125
|
-
try {
|
126
|
-
files = fs.readdirSync(templateConf.apiJsonFolder);
|
127
|
-
} catch (e) {
|
128
|
-
error("failed to list symbol files in folder '" + apiJsonFolder + "': " + (e.message || e));
|
129
|
-
return;
|
130
|
-
}
|
131
|
-
|
132
|
-
if ( files && files.length ) {
|
133
|
-
files.forEach(function(localFileName) {
|
134
|
-
try {
|
135
|
-
var file = path.join(templateConf.apiJsonFolder, localFileName);
|
136
|
-
var sJSON = fs.readFileSync(file, 'UTF-8');
|
137
|
-
var data = JSON.parse(sJSON);
|
138
|
-
if ( !Array.isArray(data.symbols) ) {
|
139
|
-
throw new TypeError("api.json does not contain a 'symbols' array");
|
140
|
-
}
|
141
|
-
data.symbols.forEach(function(symbol) {
|
142
|
-
debug(" adding external symbol " + symbol.name);
|
143
|
-
externalSymbols[symbol.name] = symbol;
|
144
|
-
});
|
145
|
-
} catch (e) {
|
146
|
-
error("failed to load symbols from " + file + ": " + (e.message || e));
|
147
|
-
}
|
148
|
-
});
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
function isModuleExport($) {
|
153
|
-
return $.longname.startsWith("module:") && $.longname.search(/[.#~]/) < 0;
|
154
|
-
}
|
155
|
-
|
156
|
-
function isaClass($) {
|
157
|
-
return /^(namespace|interface|class|typedef)$/.test($.kind) || ($.kind === 'member' && $.isEnum ) /* isNonEmptyNamespace($) */;
|
158
|
-
}
|
159
|
-
|
160
|
-
function supportsInheritance($) {
|
161
|
-
return /^(interface|class|typedef)$/.test($.kind);
|
162
|
-
}
|
163
|
-
|
164
|
-
/*
|
165
|
-
* Returns true for any symbol that should appear in the API reference index of the SDK.
|
166
|
-
*
|
167
|
-
* In a perfect world, such symbols would be
|
168
|
-
* - default exports of AMD modules (named 'module:some/module)
|
169
|
-
* - classes, interfaces, enums, typedefs and namespaces, all with global names whose parents are all namespaces
|
170
|
-
* In the less perfect documentation build, the criterion 'whose parents are all namespaces' is ignored
|
171
|
-
*/
|
172
|
-
function isFirstClassSymbol($) {
|
173
|
-
return /^(namespace|interface|class|typedef)$/.test($.kind) || ($.kind === 'member' && $.isEnum || isModuleExport($) ) /* isNonEmptyNamespace($) */;
|
174
|
-
}
|
175
|
-
|
176
|
-
|
177
|
-
var REGEXP_ARRAY_TYPE = /^Array\.<(.*)>$/;
|
178
|
-
|
179
|
-
// ---- Version class -----------------------------------------------------------------------------------------------------------------------------------------------------------
|
180
|
-
|
181
|
-
var Version = (function() {
|
182
|
-
|
183
|
-
var rVersion = /^[0-9]+(?:\.([0-9]+)(?:\.([0-9]+))?)?(.*)$/;
|
184
|
-
|
185
|
-
/**
|
186
|
-
* Returns a Version instance created from the given parameters.
|
187
|
-
*
|
188
|
-
* This function can either be called as a constructor (using <code>new</code>) or as a normal function.
|
189
|
-
* It always returns an immutable Version instance.
|
190
|
-
*
|
191
|
-
* The parts of the version number (major, minor, patch, suffix) can be provided in several ways:
|
192
|
-
* <ul>
|
193
|
-
* <li>Version("1.2.3-SNAPSHOT") - as a dot-separated string. Any non-numerical char or a dot followed by a non-numerical char starts the suffix portion.
|
194
|
-
* Any missing major, minor or patch versions will be set to 0.</li>
|
195
|
-
* <li>Version(1,2,3,"-SNAPSHOT") - as individual parameters. Major, minor and patch must be integer numbers or empty, suffix must be a string not starting with digits.</li>
|
196
|
-
* <li>Version([1,2,3,"-SNAPSHOT"]) - as an array with the individual parts. The same type restrictions apply as before.</li>
|
197
|
-
* <li>Version(otherVersion) - as a Version instance (cast operation). Returns the given instance instead of creating a new one.</li>
|
198
|
-
* </ul>
|
199
|
-
*
|
200
|
-
* To keep the code size small, this implementation mainly validates the single string variant.
|
201
|
-
* All other variants are only validated to some degree. It is the responsibility of the caller to
|
202
|
-
* provide proper parts.
|
203
|
-
*
|
204
|
-
* @param {int|string|any[]|jQuery.sap.Version} vMajor the major part of the version (int) or any of the single parameter variants explained above.
|
205
|
-
* @param {int} iMinor the minor part of the version number
|
206
|
-
* @param {int} iPatch the patch part of the version number
|
207
|
-
* @param {string} sSuffix the suffix part of the version number
|
208
|
-
* @return {jQuery.sap.Version} the version object as determined from the parameters
|
209
|
-
*
|
210
|
-
* @class Represents a version consisting of major, minor, patch version and suffix, e.g. '1.2.7-SNAPSHOT'.
|
211
|
-
*
|
212
|
-
* @author SAP SE
|
213
|
-
* @version ${version}
|
214
|
-
* @constructor
|
215
|
-
* @public
|
216
|
-
* @since 1.15.0
|
217
|
-
* @name jQuery.sap.Version
|
218
|
-
*/
|
219
|
-
function Version(versionStr) {
|
220
|
-
|
221
|
-
var match = rVersion.exec(versionStr) || [];
|
222
|
-
|
223
|
-
function norm(v) {
|
224
|
-
v = parseInt(v,10);
|
225
|
-
return isNaN(v) ? 0 : v;
|
226
|
-
}
|
227
|
-
|
228
|
-
Object.defineProperty(this, "major", {
|
229
|
-
enumerable: true,
|
230
|
-
value: norm(match[0])
|
231
|
-
});
|
232
|
-
Object.defineProperty(this, "minor", {
|
233
|
-
enumerable: true,
|
234
|
-
value: norm(match[1])
|
235
|
-
});
|
236
|
-
Object.defineProperty(this, "patch", {
|
237
|
-
enumerable: true,
|
238
|
-
value: norm(match[2])
|
239
|
-
});
|
240
|
-
Object.defineProperty(this, "suffix", {
|
241
|
-
enumerable: true,
|
242
|
-
value: String(match[3] || "")
|
243
|
-
});
|
244
|
-
|
245
|
-
}
|
246
|
-
|
247
|
-
Version.prototype.toMajorMinor = function() {
|
248
|
-
return new Version(this.major + "." + this.minor);
|
249
|
-
};
|
250
|
-
|
251
|
-
Version.prototype.toString = function() {
|
252
|
-
return this.major + "." + this.minor + "." + this.patch + this.suffix;
|
253
|
-
};
|
254
|
-
|
255
|
-
Version.prototype.compareTo = function(other) {
|
256
|
-
return this.major - other.major ||
|
257
|
-
this.minor - other.minor ||
|
258
|
-
this.patch - other.patch ||
|
259
|
-
((this.suffix < other.suffix) ? -1 : (this.suffix === other.suffix) ? 0 : 1);
|
260
|
-
};
|
261
|
-
|
262
|
-
return Version;
|
263
|
-
|
264
|
-
}());
|
265
|
-
|
266
|
-
// ---- Link class --------------------------------------------------------------------------------------------------------------------------------------------------------------
|
267
|
-
|
268
|
-
//TODO move to separate module
|
269
|
-
|
270
|
-
var Link = (function() {
|
271
|
-
|
272
|
-
var Link = function() {
|
273
|
-
};
|
274
|
-
|
275
|
-
Link.prototype.toSymbol = function(longname) {
|
276
|
-
if ( longname != null ) {
|
277
|
-
longname = String(longname);
|
278
|
-
if ( /#constructor$/.test(longname) ) {
|
279
|
-
if ( !this.innerName ) {
|
280
|
-
this.innerName = 'constructor';
|
281
|
-
}
|
282
|
-
longname = longname.slice(0, -"#constructor".length);
|
283
|
-
}
|
284
|
-
this.longname = longname;
|
285
|
-
}
|
286
|
-
return this;
|
287
|
-
};
|
288
|
-
|
289
|
-
Link.prototype.withText = function(text) {
|
290
|
-
this.text = text;
|
291
|
-
return this;
|
292
|
-
};
|
293
|
-
|
294
|
-
Link.prototype.withTooltip = function(text) {
|
295
|
-
this.tooltip = text;
|
296
|
-
return this;
|
297
|
-
};
|
298
|
-
|
299
|
-
Link.prototype.toFile = function(file) {
|
300
|
-
if ( file != null ) this.file = file;
|
301
|
-
return this;
|
302
|
-
};
|
303
|
-
|
304
|
-
function _makeLink(href, target, tooltip, text) {
|
305
|
-
return '<a' +
|
306
|
-
(tooltip ? ' title="' + tooltip + '"' : '') +
|
307
|
-
' href="' + href + '"' +
|
308
|
-
(target ? ' target="' + target + '"' : '') +
|
309
|
-
'>' + text + '</a>';
|
310
|
-
}
|
311
|
-
|
312
|
-
Link.prototype.toString = function() {
|
313
|
-
var longname = this.longname,
|
314
|
-
linkString;
|
315
|
-
|
316
|
-
if (longname) {
|
317
|
-
|
318
|
-
if ( /^(?:(?:ftp|https?):\/\/|\.\.?\/)/.test(longname) ) {
|
319
|
-
// handle real hyperlinks (TODO should be handled with a different "to" method
|
320
|
-
linkString = _makeLink(longname, this.targetName, this.tooltip, this.text || longname);
|
321
|
-
} else if ( /^topic:/.test(longname) ) {
|
322
|
-
// handle documentation links
|
323
|
-
longname = conf.topicUrlPattern.replace("{{topic}}", longname.slice("topic:".length));
|
324
|
-
linkString = _makeLink(longname, this.targetName, this.tooltip, this.text || longname);
|
325
|
-
} else {
|
326
|
-
linkString = this._makeSymbolLink(longname);
|
327
|
-
}
|
328
|
-
|
329
|
-
} else if (this.file) {
|
330
|
-
linkString = _makeLink(Link.base + this.file, this.targetName, null, this.text || this.file);
|
331
|
-
}
|
332
|
-
|
333
|
-
return linkString;
|
334
|
-
};
|
335
|
-
|
336
|
-
var missingTypes = {};
|
337
|
-
Link.getMissingTypes = function() {
|
338
|
-
return Object.keys(missingTypes);
|
339
|
-
};
|
340
|
-
|
341
|
-
Link.prototype._makeSymbolLink = function(longname) {
|
342
|
-
|
343
|
-
// normalize .prototype. and #
|
344
|
-
longname = longname.replace(/\.prototype\./g, '#');
|
345
|
-
|
346
|
-
// if it is an internal reference, then don't validate against symbols, just create a link
|
347
|
-
if ( longname.charAt(0) == "#" ) {
|
348
|
-
|
349
|
-
return _makeLink(longname + (this.innerName ? "#" + this.innerName : ""), this.targetName, this.tooltip, this.text || longname.slice(1));
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
var linkTo = lookup(longname);
|
354
|
-
// if there is no symbol by that name just return the name unaltered
|
355
|
-
if ( !linkTo ) {
|
356
|
-
|
357
|
-
missingTypes[longname] = true;
|
358
|
-
|
359
|
-
return this.text || longname;
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
// it's a full symbol reference (potentially to another file)
|
364
|
-
var mainSymbol, anchor;
|
365
|
-
if ( (linkTo.kind === 'member' && !linkTo.isEnum) || linkTo.kind === 'constant' || linkTo.kind === 'function' || linkTo.kind === 'event' ) { // it's a method or property
|
366
|
-
|
367
|
-
mainSymbol = linkTo.memberof;
|
368
|
-
anchor = ( linkTo.kind === 'event' ? "event:" : "") + Link.symbolNameToLinkName(linkTo);
|
369
|
-
|
370
|
-
} else {
|
371
|
-
|
372
|
-
mainSymbol = linkTo.longname;
|
373
|
-
anchor = this.innerName;
|
374
|
-
|
375
|
-
}
|
376
|
-
|
377
|
-
return _makeLink(Link.baseSymbols + __uniqueFilenames[mainSymbol] + conf.ext + (anchor ? "#" + anchor : ""), this.targetName, this.tooltip, this.text || longname);
|
378
|
-
}
|
379
|
-
|
380
|
-
Link.symbolNameToLinkName = function(symbol) {
|
381
|
-
var linker = "";
|
382
|
-
if ( symbol.scope === 'static' ) {
|
383
|
-
linker = ".";
|
384
|
-
} else if (symbol.isInner) {
|
385
|
-
linker = "-"; // TODO-migrate?
|
386
|
-
}
|
387
|
-
return linker + symbol.name;
|
388
|
-
};
|
389
|
-
|
390
|
-
return Link;
|
391
|
-
|
392
|
-
}());
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
// ---- publish() - main entry point for JSDoc templates -------------------------------------------------------------------------------------------------------
|
397
|
-
|
398
|
-
/** Called automatically by JsDoc Toolkit. */
|
399
|
-
function publish(symbolSet) {
|
400
|
-
|
401
|
-
info("entering sapui5 template");
|
402
|
-
|
403
|
-
// create output dir
|
404
|
-
fs.mkPath(env.opts.destination);
|
405
|
-
|
406
|
-
// if ( symbolSet().count() < 20000 ) {
|
407
|
-
// info("writing raw symbols to " + path.join(env.opts.destination, "symbols-unpruned-ui5.json"));
|
408
|
-
// fs.writeFileSync(path.join(env.opts.destination, "symbols-unpruned-ui5.json"), JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
|
409
|
-
// }
|
410
|
-
|
411
|
-
info("before prune: " + symbolSet().count() + " symbols.");
|
412
|
-
symbolSet = helper.prune(symbolSet);
|
413
|
-
info("after prune: " + symbolSet().count() + " symbols.");
|
414
|
-
|
415
|
-
__db = symbolSet;
|
416
|
-
__longnames = {};
|
417
|
-
__db().each(function($) {
|
418
|
-
__longnames[$.longname] = $;
|
419
|
-
});
|
420
|
-
|
421
|
-
if ( templateConf.apiJsonFolder ) {
|
422
|
-
info("loading external apis from folder '" + templateConf.apiJsonFolder + "'");
|
423
|
-
loadExternalSymbols(templateConf.apiJsonFolder);
|
424
|
-
}
|
425
|
-
|
426
|
-
var templatePath = path.join(env.opts.template, 'tmpl/');
|
427
|
-
info("using templates from '" + templatePath + "'");
|
428
|
-
view = new template.Template(templatePath);
|
429
|
-
|
430
|
-
function filter(key,value) {
|
431
|
-
if ( key === 'meta' ) {
|
432
|
-
//return;
|
433
|
-
}
|
434
|
-
if ( key === '__ui5' && value ) {
|
435
|
-
var v = {
|
436
|
-
resource: value.resource,
|
437
|
-
module: value.module,
|
438
|
-
stakeholders: value.stakeholders
|
439
|
-
};
|
440
|
-
if ( value.derived ) {
|
441
|
-
v.derived = value.derived.map(function($) { return $.longname });
|
442
|
-
}
|
443
|
-
if ( value.base ) {
|
444
|
-
v.base = value.base.longname;
|
445
|
-
}
|
446
|
-
if ( value.implementations ) {
|
447
|
-
v.base = value.implementations.map(function($) { return $.longname });
|
448
|
-
}
|
449
|
-
if ( value.parent ) {
|
450
|
-
v.parent = value.parent.longname;
|
451
|
-
}
|
452
|
-
if ( value.children ) {
|
453
|
-
v.children = value.children.map(function($) { return $.longname });
|
454
|
-
}
|
455
|
-
return v;
|
456
|
-
}
|
457
|
-
return value;
|
458
|
-
}
|
459
|
-
|
460
|
-
// now resolve relationships
|
461
|
-
var aRootNamespaces = createNamespaceTree();
|
462
|
-
var hierarchyRoots = createInheritanceTree();
|
463
|
-
collectMembers();
|
464
|
-
mergeEventDocumentation();
|
465
|
-
|
466
|
-
if ( symbolSet().count() < 20000 ) {
|
467
|
-
info("writing raw symbols to " + path.join(env.opts.destination, "symbols-pruned-ui5.json"));
|
468
|
-
// skip this for now
|
469
|
-
// fs.writeFileSync(path.join(env.opts.destination, "symbols-pruned-ui5.json"), JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
|
470
|
-
}
|
471
|
-
|
472
|
-
// used to allow Link to check the details of things being linked to
|
473
|
-
Link.symbolSet = symbolSet;
|
474
|
-
|
475
|
-
// get an array version of the symbol set, useful for filtering
|
476
|
-
var symbols = symbolSet().get();
|
477
|
-
|
478
|
-
// -----
|
479
|
-
|
480
|
-
|
481
|
-
var PUBLISHING_VARIANTS = {
|
482
|
-
|
483
|
-
"apijson" : {
|
484
|
-
defaults : {
|
485
|
-
apiJsonFile: path.join(env.opts.destination, "api.json")
|
486
|
-
},
|
487
|
-
processor : function(conf) {
|
488
|
-
createAPIJSON(symbols, conf.apiJsonFile);
|
489
|
-
}
|
490
|
-
}
|
491
|
-
};
|
492
|
-
|
493
|
-
var now = new Date();
|
494
|
-
|
495
|
-
info("start publishing");
|
496
|
-
for (var i = 0; i < templateConf.variants.length; i++) {
|
497
|
-
|
498
|
-
var vVariant = templateConf.variants[i];
|
499
|
-
if ( typeof vVariant === "string" ) {
|
500
|
-
vVariant = { variant : vVariant };
|
501
|
-
}
|
502
|
-
|
503
|
-
info("");
|
504
|
-
|
505
|
-
if ( PUBLISHING_VARIANTS[vVariant.variant] ) {
|
506
|
-
|
507
|
-
// Merge different sources of configuration (listed in increasing priority order - last one wins)
|
508
|
-
// and expose the result in the global 'conf' variable
|
509
|
-
// - global defaults
|
510
|
-
// - defaults for current variant
|
511
|
-
// - user configuration for sapui5 template
|
512
|
-
// - user configuration for current variant
|
513
|
-
//
|
514
|
-
// Note: trailing slash expected for dirs
|
515
|
-
conf = merge({
|
516
|
-
ext: ".html",
|
517
|
-
filter: function($) { return true; },
|
518
|
-
templatesDir: "/templates/sapui5/",
|
519
|
-
symbolsDir: "symbols/",
|
520
|
-
modulesDir: "modules/",
|
521
|
-
topicUrlPattern: "../../guide/{{topic}}.html",
|
522
|
-
srcDir: "symbols/src/",
|
523
|
-
creationDate : now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDay() + " " + now.getHours() + ":" + now.getMinutes(),
|
524
|
-
outdir: env.opts.destination
|
525
|
-
}, PUBLISHING_VARIANTS[vVariant.variant].defaults, templateConf, vVariant);
|
526
|
-
|
527
|
-
info("publishing as variant '" + vVariant.variant + "'");
|
528
|
-
debug("final configuration:");
|
529
|
-
debug(conf);
|
530
|
-
|
531
|
-
PUBLISHING_VARIANTS[vVariant.variant].processor(conf);
|
532
|
-
|
533
|
-
info("done with variant " + vVariant.variant);
|
534
|
-
|
535
|
-
} else {
|
536
|
-
|
537
|
-
info("cannot publish unknown variant '" + vVariant.variant + "' (ignored)");
|
538
|
-
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
|
-
var builtinSymbols = templateConf.builtinSymbols;
|
543
|
-
if ( builtinSymbols ) {
|
544
|
-
Link.getMissingTypes().filter(function($) {
|
545
|
-
return builtinSymbols.indexOf($) < 0;
|
546
|
-
}).sort().forEach(function($) {
|
547
|
-
// TODO instead of filtering topic: and fiori: links out here, they should be correctly linked in the template
|
548
|
-
if ( !/\{@link (?:topic:|fiori:)/.test($) ) {
|
549
|
-
error(" unresolved reference: " + $);
|
550
|
-
}
|
551
|
-
});
|
552
|
-
}
|
553
|
-
info("publishing done.");
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
//---- namespace tree --------------------------------------------------------------------------------
|
558
|
-
|
559
|
-
/**
|
560
|
-
* Completes the tree of namespaces. Namespaces for which content is available
|
561
|
-
* but which have not been documented are created as dummy without documentation.
|
562
|
-
*/
|
563
|
-
function createNamespaceTree() {
|
564
|
-
|
565
|
-
info("create namespace tree (" + __db().count() + " symbols)");
|
566
|
-
|
567
|
-
var aRootNamespaces = [];
|
568
|
-
var aTypes = __db(function() { return isFirstClassSymbol(this); }).get();
|
569
|
-
|
570
|
-
for (var i = 0; i < aTypes.length; i++) { // loop with a for-loop as it can handle concurrent modifications
|
571
|
-
|
572
|
-
var symbol = aTypes[i];
|
573
|
-
if ( symbol.memberof ) {
|
574
|
-
|
575
|
-
var parent = lookup(symbol.memberof);
|
576
|
-
if ( !parent ) {
|
577
|
-
warning("create missing namespace '" + symbol.memberof + "' (referenced by " + symbol.longname + ")");
|
578
|
-
parent = makeNamespace(symbol.memberof);
|
579
|
-
__longnames[symbol.memberof] = parent;
|
580
|
-
__db.insert(parent);
|
581
|
-
aTypes.push(parent); // concurrent modification: parent will be processed later in this loop
|
582
|
-
}
|
583
|
-
symbol.__ui5.parent = parent;
|
584
|
-
parent.__ui5.children = parent.__ui5.children || [];
|
585
|
-
parent.__ui5.children.push(symbol);
|
586
|
-
|
587
|
-
} else if ( symbol.longname !== ANONYMOUS_LONGNAME ) {
|
588
|
-
|
589
|
-
aRootNamespaces.push(symbol);
|
590
|
-
|
591
|
-
}
|
592
|
-
}
|
593
|
-
|
594
|
-
return aRootNamespaces;
|
595
|
-
}
|
596
|
-
|
597
|
-
function makeNamespace(memberof) {
|
598
|
-
|
599
|
-
info("adding synthetic namespace symbol " + memberof);
|
600
|
-
|
601
|
-
var comment = [
|
602
|
-
"@name " + memberof,
|
603
|
-
"@namespace",
|
604
|
-
"@synthetic",
|
605
|
-
"@public"
|
606
|
-
];
|
607
|
-
|
608
|
-
var symbol = new doclet.Doclet("/**\n * " + comment.join("\n * ") + "\n */", {});
|
609
|
-
symbol.__ui5 = {};
|
610
|
-
|
611
|
-
return symbol;
|
612
|
-
}
|
613
|
-
|
614
|
-
//---- inheritance hierarchy ----------------------------------------------------------------------------
|
615
|
-
|
616
|
-
/**
|
617
|
-
* Calculates the inheritance hierarchy for all class/interface/namespace symbols.
|
618
|
-
* Each node in the tree has the content
|
619
|
-
*
|
620
|
-
* Node : {
|
621
|
-
* longname : {string} // name of the node (usually equals symbol.longname)
|
622
|
-
* symbol : {Symbol} // backlink to the original symbol
|
623
|
-
* base : {Node} // parent node or undefined for root nodes
|
624
|
-
* derived : {Node[]} // subclasses/-types
|
625
|
-
* }
|
626
|
-
*
|
627
|
-
*/
|
628
|
-
function createInheritanceTree() {
|
629
|
-
|
630
|
-
function makeDoclet(longname, lines) {
|
631
|
-
lines.push("@name " + longname);
|
632
|
-
var newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
|
633
|
-
newDoclet.__ui5 = {};
|
634
|
-
__longnames[longname] = newDoclet;
|
635
|
-
__db.insert(newDoclet);
|
636
|
-
return newDoclet;
|
637
|
-
}
|
638
|
-
|
639
|
-
info("create inheritance tree (" + __db().count() + " symbols)");
|
640
|
-
|
641
|
-
var oTypes = __db(function() { return supportsInheritance(this); });
|
642
|
-
var aRootTypes = [];
|
643
|
-
|
644
|
-
var oObject = lookup("Object");
|
645
|
-
if ( !oObject ) {
|
646
|
-
oObject = makeDoclet("Object", [
|
647
|
-
"@class",
|
648
|
-
"@synthetic",
|
649
|
-
"@public"
|
650
|
-
]);
|
651
|
-
aRootTypes.push(oObject);
|
652
|
-
}
|
653
|
-
|
654
|
-
function getOrCreateClass(sClass, sExtendingClass) {
|
655
|
-
var oClass = lookup(sClass);
|
656
|
-
if ( !oClass ) {
|
657
|
-
warning("create missing class " + sClass + " (extended by " + sExtendingClass + ")");
|
658
|
-
var sBaseClass = 'Object';
|
659
|
-
if ( externalSymbols[sClass] ) {
|
660
|
-
sBaseClass = externalSymbols[sClass].extends || sBaseClass;
|
661
|
-
}
|
662
|
-
var oBaseClass = getOrCreateClass(sBaseClass, sClass);
|
663
|
-
oClass = makeDoclet(sClass, [
|
664
|
-
"@extends " + sBaseClass,
|
665
|
-
"@class",
|
666
|
-
"@synthetic",
|
667
|
-
"@public"
|
668
|
-
]);
|
669
|
-
oClass.__ui5.base = oBaseClass;
|
670
|
-
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
|
671
|
-
oBaseClass.__ui5.derived.push(oClass);
|
672
|
-
}
|
673
|
-
return oClass;
|
674
|
-
}
|
675
|
-
|
676
|
-
// link them according to the inheritance infos
|
677
|
-
oTypes.each(function(oClass) {
|
678
|
-
|
679
|
-
if ( oClass.longname === 'Object') {
|
680
|
-
return;
|
681
|
-
}
|
682
|
-
|
683
|
-
var sBaseClass = "Object";
|
684
|
-
if ( oClass.augments && oClass.augments.length > 0 ) {
|
685
|
-
if ( oClass.augments.length > 1 ) {
|
686
|
-
warning("multiple inheritance detected in " + oClass.longname);
|
687
|
-
}
|
688
|
-
sBaseClass = oClass.augments[0];
|
689
|
-
} else {
|
690
|
-
aRootTypes.push(oClass);
|
691
|
-
}
|
692
|
-
|
693
|
-
var oBaseClass = getOrCreateClass(sBaseClass, oClass.longname);
|
694
|
-
oClass.__ui5.base = oBaseClass;
|
695
|
-
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
|
696
|
-
oBaseClass.__ui5.derived.push(oClass);
|
697
|
-
|
698
|
-
if ( oClass.implements ) {
|
699
|
-
for (var j = 0; j < oClass.implements.length; j++) {
|
700
|
-
var oInterface = lookup(oClass.implements[j]);
|
701
|
-
if ( !oInterface ) {
|
702
|
-
warning("create missing interface " + oClass.implements[j]);
|
703
|
-
oInterface = makeDoclet(oClass.implements[j], [
|
704
|
-
"@extends Object",
|
705
|
-
"@interface",
|
706
|
-
"@synthetic",
|
707
|
-
"@public"
|
708
|
-
]);
|
709
|
-
oInterface.__ui5.base = oObject;
|
710
|
-
oObject.__ui5.derived = oObject.__ui5.derived || [];
|
711
|
-
oObject.__ui5.derived.push(oInterface);
|
712
|
-
}
|
713
|
-
oInterface.__ui5.implementations = oInterface.__ui5.implementations || [];
|
714
|
-
oInterface.__ui5.implementations.push(oClass);
|
715
|
-
}
|
716
|
-
}
|
717
|
-
});
|
718
|
-
|
719
|
-
function setStereotype(oSymbol, sStereotype) {
|
720
|
-
if ( !oSymbol ) {
|
721
|
-
return;
|
722
|
-
}
|
723
|
-
oSymbol.__ui5.stereotype = sStereotype;
|
724
|
-
var derived = oSymbol.__ui5.derived;
|
725
|
-
if ( derived ) {
|
726
|
-
for (var i = 0; i < derived.length; i++ ) {
|
727
|
-
if ( !derived[i].__ui5.stereotype ) {
|
728
|
-
setStereotype(derived[i], sStereotype);
|
729
|
-
}
|
730
|
-
}
|
731
|
-
}
|
732
|
-
}
|
733
|
-
|
734
|
-
setStereotype(lookup("sap.ui.core.Component"), "component");
|
735
|
-
setStereotype(lookup("sap.ui.core.Control"), "control");
|
736
|
-
setStereotype(lookup("sap.ui.core.Element"), "element");
|
737
|
-
setStereotype(lookup("sap.ui.base.Object"), "object");
|
738
|
-
|
739
|
-
// check for cyclic inheritance (not supported)
|
740
|
-
// Note: the check needs to run bottom up, not top down as a typical cyclic dependency never will end at the root node
|
741
|
-
oTypes.each(function(oStartClass) {
|
742
|
-
var visited = {};
|
743
|
-
function visit(oClass) {
|
744
|
-
if ( visited[oClass.longname] ) {
|
745
|
-
throw new Error("cyclic inheritance detected: " + JSON.stringify(Object.keys(visited)));
|
746
|
-
}
|
747
|
-
if ( oClass.__ui5.base ) {
|
748
|
-
visited[oClass.longname] = true;
|
749
|
-
visit(oClass.__ui5.base);
|
750
|
-
delete visited[oClass.longname];
|
751
|
-
}
|
752
|
-
}
|
753
|
-
visit(oStartClass);
|
754
|
-
});
|
755
|
-
|
756
|
-
// collect root nodes (and ignore pure packages)
|
757
|
-
return aRootTypes;
|
758
|
-
/*
|
759
|
-
return __db(function() {
|
760
|
-
return R_KINDS.test(this.kind) && this.__ui5 && this.__ui5.base == null;
|
761
|
-
}).get();
|
762
|
-
*/
|
763
|
-
}
|
764
|
-
|
765
|
-
function collectMembers() {
|
766
|
-
__db().each(function($) {
|
767
|
-
if ( $.memberof ) {
|
768
|
-
var parent = lookup($.memberof);
|
769
|
-
if ( parent /* && supportsInheritance(parent) */ ) {
|
770
|
-
parent.__ui5.members = parent.__ui5.members || [];
|
771
|
-
parent.__ui5.members.push($);
|
772
|
-
}
|
773
|
-
}
|
774
|
-
});
|
775
|
-
}
|
776
|
-
|
777
|
-
function mergeEventDocumentation() {
|
778
|
-
|
779
|
-
console.log("merging JSDoc event documentation into UI5 metadata");
|
780
|
-
|
781
|
-
var oTypes = __db(function() { return isaClass(this); });
|
782
|
-
|
783
|
-
oTypes.each(function(symbol) {
|
784
|
-
|
785
|
-
var metadata = symbol.__ui5.metadata;
|
786
|
-
var members = symbol.__ui5.members;
|
787
|
-
|
788
|
-
if ( !metadata || !metadata.events || Object.keys(metadata.events).length <= 0 || !members ) {
|
789
|
-
return;
|
790
|
-
}
|
791
|
-
|
792
|
-
// console.log('mergeing events for ' + symbol.longname);
|
793
|
-
members.forEach(function($) {
|
794
|
-
if ( $.kind === 'event' && !$.inherited
|
795
|
-
&& ($.access === 'public' || $.access === 'protected' || $.access == null)
|
796
|
-
&& metadata.events[$.name]
|
797
|
-
&& Array.isArray($.params)
|
798
|
-
&& !$.synthetic ) {
|
799
|
-
|
800
|
-
var event = metadata.events[$.name];
|
801
|
-
var modified = false;
|
802
|
-
//console.log("<<<<<<<");
|
803
|
-
//console.log(event);
|
804
|
-
//console.log("=======");
|
805
|
-
//console.log($);
|
806
|
-
|
807
|
-
$.params.forEach(function(param) {
|
808
|
-
var m = /^\w+\.getParameters\.(.*)$/.exec(param.name);
|
809
|
-
if ( m ) {
|
810
|
-
var pname = m[1];
|
811
|
-
var ui5param = event.parameters[pname] || ( event.parameters[pname] = {});
|
812
|
-
if ( ui5param.type == null ) {
|
813
|
-
ui5param.type = listTypes(param.type);
|
814
|
-
modified = true;
|
815
|
-
}
|
816
|
-
if ( ui5param.doc == null ) {
|
817
|
-
ui5param.doc = param.description;
|
818
|
-
modified = true;
|
819
|
-
}
|
820
|
-
}
|
821
|
-
});
|
822
|
-
|
823
|
-
if ( modified ) {
|
824
|
-
console.log(" merged documentation for managed event " + symbol.longname + "#" + $.name);
|
825
|
-
}
|
826
|
-
|
827
|
-
//console.log("=======");
|
828
|
-
//console.log(JSON.stringify(event, null, '\t'));
|
829
|
-
//console.log(">>>>>>>");
|
830
|
-
}
|
831
|
-
});
|
832
|
-
|
833
|
-
});
|
834
|
-
|
835
|
-
}
|
836
|
-
|
837
|
-
// ---- publishing -----------------------------------------------------------------------
|
838
|
-
|
839
|
-
function publishClasses(symbols, aRootNamespaces, hierarchyRoots) {
|
840
|
-
|
841
|
-
// create output dir
|
842
|
-
fs.mkPath(path.join(conf.outdir, conf.symbolsDir));
|
843
|
-
|
844
|
-
// get a list of all the first class symbols in the symbolset
|
845
|
-
var firstClassSymbols = symbols(function() {
|
846
|
-
return supportsInheritance(this) && conf.filter(this);
|
847
|
-
}).order("longname");
|
848
|
-
|
849
|
-
// create unique file names
|
850
|
-
__uniqueFilenames = {};
|
851
|
-
var filenames = {};
|
852
|
-
firstClassSymbols.get().sort(sortByAlias).forEach(function(symbol) {
|
853
|
-
var filename = escape(symbol.longname.replace(/^module:/, "")).replace(/\//g, "%25");
|
854
|
-
if ( filenames.hasOwnProperty(filename.toUpperCase()) && (filenames[filename.toUpperCase()].longname !== symbol.longname) ) {
|
855
|
-
// find an unused filename by appending "-n" where n is an integer > 0
|
856
|
-
for (var j = 1; filenames.hasOwnProperty(filename.toUpperCase() + "-" + j); j++);
|
857
|
-
warning("duplicate symbol names " + filenames[filename.toUpperCase()].longname + " and " + symbol.longname + ", renaming the latter to " + filename + "-" + j);
|
858
|
-
filename = filename + "-" + j;
|
859
|
-
}
|
860
|
-
filenames[filename.toUpperCase()] = symbol;
|
861
|
-
__uniqueFilenames[symbol.longname] = filename;
|
862
|
-
});
|
863
|
-
filenames = null;
|
864
|
-
|
865
|
-
// create a class index, displayed in the left-hand column of every class page
|
866
|
-
var classTemplate;
|
867
|
-
if ( !conf.contentOnly ) {
|
868
|
-
info("create embedded class index");
|
869
|
-
Link.base = "../";
|
870
|
-
Link.baseSymbols = "";
|
871
|
-
classTemplate = 'classWithIndex.html.tmpl';
|
872
|
-
publish.header = processTemplate("_header.tmpl", firstClassSymbols);
|
873
|
-
publish.footer = processTemplate("_footer.tmpl", firstClassSymbols);
|
874
|
-
publish.classesIndex = processTemplate("_navIndex.tmpl", firstClassSymbols); // kept in memory
|
875
|
-
} else {
|
876
|
-
var newStyle = !!pluginConf.newStyle;
|
877
|
-
classTemplate = newStyle ? "class-new.html.tmpl" : "class.html.tmpl";
|
878
|
-
publish.header = '';
|
879
|
-
publish.footer = '';
|
880
|
-
publish.classesIndex = '';
|
881
|
-
|
882
|
-
// instead create an index as XML
|
883
|
-
Link.base = "";
|
884
|
-
Link.baseSymbols = conf.symbolsDir;
|
885
|
-
processTemplateAndSave("index.xml.tmpl", aRootNamespaces, "index.xml");
|
886
|
-
}
|
887
|
-
|
888
|
-
// create each of the class pages
|
889
|
-
info("create class/namespace pages");
|
890
|
-
Link.base = "../";
|
891
|
-
Link.baseSymbols = "";
|
892
|
-
firstClassSymbols.each(function(symbol) {
|
893
|
-
var sOutName = path.join(conf.symbolsDir, __uniqueFilenames[symbol.longname]) + conf.ext;
|
894
|
-
processTemplateAndSave(classTemplate, symbol, sOutName);
|
895
|
-
});
|
896
|
-
|
897
|
-
if ( conf.modulePages ) {
|
898
|
-
info("create module pages");
|
899
|
-
Link.base = "../";
|
900
|
-
Link.baseSymbols = "../" + conf.symbolsDir;
|
901
|
-
fs.mkPath(path.join(conf.outdir, conf.modulesDir));
|
902
|
-
groupByModule(firstClassSymbols.get()).forEach(function(module) {
|
903
|
-
var sOutName = path.join(conf.modulesDir, module.name.replace(/\//g, '_')) + conf.ext;
|
904
|
-
processTemplateAndSave("module.html.tmpl", module, sOutName);
|
905
|
-
});
|
906
|
-
}
|
907
|
-
|
908
|
-
// regenerate the index with a different link base, used in the overview pages
|
909
|
-
info("create global class/namespace index");
|
910
|
-
Link.base = "";
|
911
|
-
Link.baseSymbols = conf.symbolsDir;
|
912
|
-
publish.header = processTemplate("_header.tmpl", firstClassSymbols);
|
913
|
-
publish.footer = processTemplate("_footer.tmpl", firstClassSymbols);
|
914
|
-
publish.classesIndex = processTemplate("_navIndex.tmpl", firstClassSymbols);
|
915
|
-
|
916
|
-
// create the all classes index
|
917
|
-
processTemplateAndSave("index.html.tmpl", firstClassSymbols, "index" + conf.ext);
|
918
|
-
|
919
|
-
// create the class hierarchy page
|
920
|
-
if ( conf.hierarchyIndex ) {
|
921
|
-
info("create class hierarchy index");
|
922
|
-
Link.base = "";
|
923
|
-
Link.baseSymbols = conf.symbolsDir;
|
924
|
-
processTemplateAndSave("hierarchy.html.tmpl", hierarchyRoots.filter(conf.filter), "hierarchy" + conf.ext);
|
925
|
-
}
|
926
|
-
|
927
|
-
if ( conf.sinceIndex ) {
|
928
|
-
info("create API by version index");
|
929
|
-
Link.base = "";
|
930
|
-
Link.baseSymbols = conf.symbolsDir;
|
931
|
-
var sinceSymbols = symbols(function() {
|
932
|
-
var r = !!this.since && !this.inherited && conf.filter(this);
|
933
|
-
if ( r && this.memberof ) {
|
934
|
-
var parent = lookup(this.memberof);
|
935
|
-
// filter out symbol when parent is filtered out
|
936
|
-
if ( !parent || !conf.filter(parent) ) {
|
937
|
-
debug("since index: filtering out " + this.longname + ", member of " + this.memberof);
|
938
|
-
r = false;
|
939
|
-
}
|
940
|
-
if ( parent && parent.since === this.since ) {
|
941
|
-
// r = false;
|
942
|
-
}
|
943
|
-
}
|
944
|
-
return r;
|
945
|
-
}).order("longname");
|
946
|
-
processTemplateAndSave("since.html.tmpl", sinceSymbols, "since" + conf.ext);
|
947
|
-
}
|
948
|
-
|
949
|
-
if ( conf.deprecationIndex ) {
|
950
|
-
info("create deprecated API index");
|
951
|
-
Link.base = "";
|
952
|
-
Link.baseSymbols = conf.symbolsDir;
|
953
|
-
var deprecatedSymbols = symbols(function() {
|
954
|
-
return !!this.deprecated && !this.inherited && conf.filter(this);
|
955
|
-
}).order("longname");
|
956
|
-
processTemplateAndSave("deprecation.html.tmpl", deprecatedSymbols, "deprecation" + conf.ext);
|
957
|
-
}
|
958
|
-
|
959
|
-
if ( conf.experimentalIndex ) {
|
960
|
-
info("create experimental API index");
|
961
|
-
Link.base = "";
|
962
|
-
Link.baseSymbols = conf.symbolsDir;
|
963
|
-
var experimentalSymbols = symbols(function() {
|
964
|
-
return !!this.experimental && !this.inherited && conf.filter(this);
|
965
|
-
}).order("longname");
|
966
|
-
processTemplateAndSave("experimental.html.tmpl", experimentalSymbols, "experimental" + conf.ext);
|
967
|
-
}
|
968
|
-
|
969
|
-
if ( conf.securityIndex ) {
|
970
|
-
info("create Security Relevant API index");
|
971
|
-
|
972
|
-
var securityRelevantSymbols = {};
|
973
|
-
A_SECURITY_TAGS.forEach(function(oTagDef) {
|
974
|
-
securityRelevantSymbols[oTagDef.name.toLowerCase()] = { tag : oTagDef, symbols: [] };
|
975
|
-
});
|
976
|
-
symbols().each(function($) {
|
977
|
-
var tags = $.tags;
|
978
|
-
if ( !$.inherited && conf.filter($) && tags ) {
|
979
|
-
for (var i = 0; i < tags.length; i++) {
|
980
|
-
if ( rSecurityTags.test(tags[i].title) ) {
|
981
|
-
securityRelevantSymbols[tags[i].title.toLowerCase()].symbols.push({ symbol: $, tag : tags[i]});
|
982
|
-
}
|
983
|
-
}
|
984
|
-
}
|
985
|
-
});
|
986
|
-
|
987
|
-
Link.base = "";
|
988
|
-
Link.baseSymbols = conf.symbolsDir;
|
989
|
-
processTemplateAndSave("security.html.tmpl", securityRelevantSymbols, "security" + conf.ext);
|
990
|
-
}
|
991
|
-
|
992
|
-
firstClassSymbols = null;
|
993
|
-
|
994
|
-
// copy needed mimes
|
995
|
-
info("copy mimes");
|
996
|
-
// copy the template's static files to outdir
|
997
|
-
var templatePath = env.opts.template;
|
998
|
-
var fromDir = path.join(templatePath, 'static');
|
999
|
-
var staticFiles = fs.ls(fromDir, 3);
|
1000
|
-
staticFiles.forEach(function(fileName) {
|
1001
|
-
var toDir = fs.toDir( fileName.replace(fromDir, conf.outdir) );
|
1002
|
-
fs.mkPath(toDir);
|
1003
|
-
fs.copyFileSync(fileName, toDir);
|
1004
|
-
});
|
1005
|
-
|
1006
|
-
__uniqueFilenames = null;
|
1007
|
-
|
1008
|
-
info("publishing done.");
|
1009
|
-
}
|
1010
|
-
|
1011
|
-
// ---- helper functions for the templates ----
|
1012
|
-
|
1013
|
-
var rSinceVersion = /^([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z\.]+)?)(?:\s|$)/i;
|
1014
|
-
|
1015
|
-
function extractVersion(value) {
|
1016
|
-
|
1017
|
-
if ( !value ) {
|
1018
|
-
return;
|
1019
|
-
}
|
1020
|
-
|
1021
|
-
if ( value === true ) {
|
1022
|
-
value = '';
|
1023
|
-
} else {
|
1024
|
-
value = String(value);
|
1025
|
-
}
|
1026
|
-
|
1027
|
-
var m = rSinceVersion.exec(value);
|
1028
|
-
return m ? m[1] : undefined;
|
1029
|
-
}
|
1030
|
-
|
1031
|
-
var rSince = /^(?:as\s+of|since)(?:\s+version)?\s*([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?([-.][0-9A-Z]+)?)(?:\.$|\.\s+|[,:]\s*|\s-\s*|\s|$)/i;
|
1032
|
-
|
1033
|
-
function extractSince(value) {
|
1034
|
-
|
1035
|
-
if ( !value ) {
|
1036
|
-
return;
|
1037
|
-
}
|
1038
|
-
|
1039
|
-
if ( value === true ) {
|
1040
|
-
value = '';
|
1041
|
-
} else {
|
1042
|
-
value = String(value);
|
1043
|
-
}
|
1044
|
-
|
1045
|
-
var m = rSince.exec(value);
|
1046
|
-
if ( m ) {
|
1047
|
-
return {
|
1048
|
-
since : m[1],
|
1049
|
-
pos : m[0].length,
|
1050
|
-
value : value.slice(m[0].length).trim()
|
1051
|
-
}
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
return {
|
1055
|
-
pos : 0,
|
1056
|
-
value: value.trim()
|
1057
|
-
};
|
1058
|
-
|
1059
|
-
}
|
1060
|
-
|
1061
|
-
function sortByAlias(a, b) {
|
1062
|
-
var partsA = a.longname.split(/[.#]/);
|
1063
|
-
var partsB = b.longname.split(/[.#]/);
|
1064
|
-
var i = 0;
|
1065
|
-
while ( i < partsA.length && i < partsB.length ) {
|
1066
|
-
if ( partsA[i].toLowerCase() < partsB[i].toLowerCase() )
|
1067
|
-
return -1;
|
1068
|
-
if ( partsA[i].toLowerCase() > partsB[i].toLowerCase() )
|
1069
|
-
return 1;
|
1070
|
-
i++;
|
1071
|
-
}
|
1072
|
-
if ( partsA.length < partsB.length )
|
1073
|
-
return -1;
|
1074
|
-
if ( partsA.length > partsB.length )
|
1075
|
-
return 1;
|
1076
|
-
// as a last resort, try to compare the aliases case sensitive in case we have aliases that only
|
1077
|
-
// differ in case like with "sap.ui.model.type" and "sap.ui.model.Type"
|
1078
|
-
if ( a.longname < b.longname ) {
|
1079
|
-
return -1;
|
1080
|
-
}
|
1081
|
-
if ( a.longname > b.longname ) {
|
1082
|
-
return 1;
|
1083
|
-
}
|
1084
|
-
return 0;
|
1085
|
-
}
|
1086
|
-
|
1087
|
-
/*
|
1088
|
-
function isNonEmptyNamespace($) {
|
1089
|
-
return $.isNamespace && (
|
1090
|
-
($.properties && $.properties.length > 0) ||
|
1091
|
-
($.methods && $.methods.length > 0) ||
|
1092
|
-
($.augments && $.augments.length > 0) ||
|
1093
|
-
($.children && $.children.length > 0));
|
1094
|
-
};*/
|
1095
|
-
|
1096
|
-
/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
|
1097
|
-
function summarize(desc) {
|
1098
|
-
if ( desc != null ) {
|
1099
|
-
desc = String(desc).replace(/\s+/g, ' ').
|
1100
|
-
replace(/"'/g, '"').
|
1101
|
-
replace(/^(<\/?p>|<br\/?>|\s)+/, '');
|
1102
|
-
|
1103
|
-
var match = /([\w\W]+?\.)[^a-z0-9_$]/i.exec(desc);
|
1104
|
-
return match ? match[1] : desc;
|
1105
|
-
}
|
1106
|
-
}
|
1107
|
-
|
1108
|
-
/** Make a symbol sorter by some attribute. */
|
1109
|
-
function makeSortby(/* fields ...*/) {
|
1110
|
-
var aFields = Array.prototype.slice.apply(arguments),
|
1111
|
-
aNorms = [],
|
1112
|
-
aFuncs = [];
|
1113
|
-
for (var i = 0; i < arguments.length; i++) {
|
1114
|
-
aNorms[i] = 1;
|
1115
|
-
if ( typeof aFields[i] === 'function' ) {
|
1116
|
-
aFuncs[i] = aFields[i];
|
1117
|
-
continue;
|
1118
|
-
}
|
1119
|
-
aFuncs[i] = function($,n) { return $[n]; };
|
1120
|
-
if ( aFields[i].indexOf("!") === 0 ) {
|
1121
|
-
aNorms[i] = -1;
|
1122
|
-
aFields[i] = aFields[i].slice(1);
|
1123
|
-
}
|
1124
|
-
if ( aFields[i] === 'deprecated' ) {
|
1125
|
-
aFuncs[i] = function($,n) { return !!$[n]; };
|
1126
|
-
} else if ( aFields[i] === 'static' ) {
|
1127
|
-
aFields[i] = 'scope';
|
1128
|
-
aFuncs[i] = function($,n) { return $[n] === 'static'; };
|
1129
|
-
} else if ( aFields[i].indexOf("#") === 0 ) {
|
1130
|
-
aFields[i] = aFields[i].slice(1);
|
1131
|
-
aFuncs[i] = function($,n) { return $.comment.getTag(n).length > 0; };
|
1132
|
-
}
|
1133
|
-
}
|
1134
|
-
return function(a, b) {
|
1135
|
-
// info("compare " + a.longname + " : " + b.longname);
|
1136
|
-
var r = 0,i,va,vb;
|
1137
|
-
for (i = 0; r === 0 && i < aFields.length; i++) {
|
1138
|
-
va = aFuncs[i](a,aFields[i]);
|
1139
|
-
vb = aFuncs[i](b,aFields[i]);
|
1140
|
-
if ( va && !vb ) {
|
1141
|
-
r = -aNorms[i];
|
1142
|
-
} else if ( !va && vb ) {
|
1143
|
-
r = aNorms[i];
|
1144
|
-
} else if ( va && vb ) {
|
1145
|
-
va = String(va).toLowerCase();
|
1146
|
-
vb = String(vb).toLowerCase();
|
1147
|
-
if (va < vb) r = -aNorms[i];
|
1148
|
-
if (va > vb) r = aNorms[i];
|
1149
|
-
}
|
1150
|
-
// debug(" " + aFields[i] + ": " + va + " ? " + vb + " = " + r);
|
1151
|
-
}
|
1152
|
-
return r;
|
1153
|
-
}
|
1154
|
-
}
|
1155
|
-
|
1156
|
-
/** Pull in the contents of an external file at the given path. */
|
1157
|
-
|
1158
|
-
function processTemplateAndSave(sTemplateName, oData, sOutputName) {
|
1159
|
-
var sResult = processTemplate(sTemplateName, oData);
|
1160
|
-
if ( conf.normalizeWhitespace && /\.html$/.test(sOutputName) ) {
|
1161
|
-
sResult = normalizeWhitespace(sResult);
|
1162
|
-
}
|
1163
|
-
var sOutpath = path.join(conf.outdir, sOutputName);
|
1164
|
-
try {
|
1165
|
-
fs.mkPath( path.dirname(sOutpath) );
|
1166
|
-
fs.writeFileSync(sOutpath, sResult, 'utf8');
|
1167
|
-
} catch (e) {
|
1168
|
-
error("failed to write generated file '" + sOutpath + "':" + (e.message || String(e)));
|
1169
|
-
}
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
function processTemplate(sTemplateName, data) {
|
1173
|
-
debug("processing template '" + sTemplateName + "' for " + data.longname);
|
1174
|
-
|
1175
|
-
try {
|
1176
|
-
var result = view.render(sTemplateName, {
|
1177
|
-
asPlainSummary: asPlainSummary,
|
1178
|
-
bySimpleName: bySimpleName,
|
1179
|
-
childrenOfKind: childrenOfKind,
|
1180
|
-
conf: conf,
|
1181
|
-
data: data,
|
1182
|
-
getConstructorDescription : getConstructorDescription,
|
1183
|
-
getNSClass: getNSClass,
|
1184
|
-
groupByVersion: groupByVersion,
|
1185
|
-
extractSince: extractSince,
|
1186
|
-
include: processTemplate,
|
1187
|
-
Link: Link,
|
1188
|
-
listTypes: listTypes,
|
1189
|
-
linkTypes: linkTypes,
|
1190
|
-
makeExample: makeExample,
|
1191
|
-
makeLinkList: makeLinkList,
|
1192
|
-
makeLinkToSymbolFile: makeLinkToSymbolFile,
|
1193
|
-
makeSignature: makeSignature,
|
1194
|
-
makeSortby: makeSortby,
|
1195
|
-
publish : publish,
|
1196
|
-
formatText: formatText,
|
1197
|
-
simpleNameOf: simpleNameOf,
|
1198
|
-
sortByAlias: sortByAlias,
|
1199
|
-
summarize: summarize,
|
1200
|
-
Version : Version
|
1201
|
-
});
|
1202
|
-
} catch (e) {
|
1203
|
-
if ( e.source ) {
|
1204
|
-
var filename = path.join(env.opts.destination, sTemplateName + ".js");
|
1205
|
-
console.log("**** failed to process template, source written to " + filename);
|
1206
|
-
fs.mkPath(path.dirname(filename));
|
1207
|
-
fs.writeFileSync(filename, e.source, 'utf8');
|
1208
|
-
}
|
1209
|
-
console.log("error while processing " + sTemplateName);
|
1210
|
-
throw e;
|
1211
|
-
}
|
1212
|
-
debug("processing template done.");
|
1213
|
-
return result;
|
1214
|
-
}
|
1215
|
-
|
1216
|
-
function groupByVersion(symbols, extractVersion) {
|
1217
|
-
|
1218
|
-
var map = {};
|
1219
|
-
|
1220
|
-
symbols.forEach(function(symbol) {
|
1221
|
-
|
1222
|
-
var version = extractVersion(symbol),
|
1223
|
-
key = String(version);
|
1224
|
-
|
1225
|
-
if ( !map[key] ) {
|
1226
|
-
map[key] = { version: version, symbols : [] };
|
1227
|
-
}
|
1228
|
-
map[key].symbols.push(symbol);
|
1229
|
-
|
1230
|
-
});
|
1231
|
-
|
1232
|
-
var groups = Object.keys(map).map(function(key) { return map[key]; });
|
1233
|
-
|
1234
|
-
return groups.sort(function(a,b) {
|
1235
|
-
if ( !a.version && b.version ) {
|
1236
|
-
return -1;
|
1237
|
-
} else if ( a.version && !b.version ) {
|
1238
|
-
return 1;
|
1239
|
-
} else if ( a.version && b.version ) {
|
1240
|
-
return -a.version.compareTo(b.version);
|
1241
|
-
}
|
1242
|
-
return 0;
|
1243
|
-
});
|
1244
|
-
}
|
1245
|
-
|
1246
|
-
function groupByModule(symbols) {
|
1247
|
-
|
1248
|
-
var map = {};
|
1249
|
-
|
1250
|
-
function add(key, symbol) {
|
1251
|
-
if ( !map[key] ) {
|
1252
|
-
map[key] = { name: key, symbols : [] };
|
1253
|
-
}
|
1254
|
-
if ( map[key].symbols.indexOf(symbol) < 0 ) {
|
1255
|
-
map[key].symbols.push(symbol);
|
1256
|
-
}
|
1257
|
-
}
|
1258
|
-
|
1259
|
-
symbols.forEach(function(symbol) {
|
1260
|
-
|
1261
|
-
var key = symbol.__ui5.module;
|
1262
|
-
|
1263
|
-
if ( key ) {
|
1264
|
-
add(key, symbol);
|
1265
|
-
if ( symbol.__ui5.members ) {
|
1266
|
-
symbol.__ui5.members.forEach(function($) {
|
1267
|
-
if ( !$.inherited && $.__ui5.module && $.__ui5.module !== key && conf.filter($) ) {
|
1268
|
-
add($.__ui5.module, $);
|
1269
|
-
}
|
1270
|
-
});
|
1271
|
-
}
|
1272
|
-
}
|
1273
|
-
|
1274
|
-
});
|
1275
|
-
|
1276
|
-
var groups = Object.keys(map).map(function(key) { return map[key]; });
|
1277
|
-
|
1278
|
-
return groups;
|
1279
|
-
}
|
1280
|
-
|
1281
|
-
|
1282
|
-
var REGEXP_TAG = /<(\/?(?:[A-Z][A-Z0-9_-]*:)?[A-Z][A-Z0-9_-]*)(?:\s[^>]*)?>/gi;
|
1283
|
-
|
1284
|
-
/**
|
1285
|
-
* Removes unnecessary whitespace from an HTML document:
|
1286
|
-
* - if the text between two adjacent HTML tags consists of whitespace only, the whole text is removed
|
1287
|
-
* - otherwise, any sequence of whitespace in the text is reduced to a single blank
|
1288
|
-
* - inside a <pre> tag, whitespace is preserved
|
1289
|
-
*
|
1290
|
-
* Whitespace inside an element tag is not touched (although it could be normalized as well)
|
1291
|
-
* @param {string} content raw HTML file
|
1292
|
-
* @returns {string} HTML file with normalized whitespace
|
1293
|
-
*/
|
1294
|
-
function normalizeWhitespace(content) {
|
1295
|
-
var compressed = '',
|
1296
|
-
preformatted = 0,
|
1297
|
-
p = 0, m, text;
|
1298
|
-
|
1299
|
-
REGEXP_TAG.lastIndex = 0;
|
1300
|
-
while ( m = REGEXP_TAG.exec(content) ) {
|
1301
|
-
if ( m.index > p ) {
|
1302
|
-
text = content.slice(p, m.index);
|
1303
|
-
if ( preformatted ) {
|
1304
|
-
compressed += text;
|
1305
|
-
// console.log(' "' + text + '" (preformatted)');
|
1306
|
-
} else {
|
1307
|
-
text = text.replace(/\s+/g,' ');
|
1308
|
-
if ( text.trim() ) {
|
1309
|
-
compressed += text;
|
1310
|
-
}
|
1311
|
-
// console.log(' "' + text + '" (trimmed)');
|
1312
|
-
}
|
1313
|
-
}
|
1314
|
-
|
1315
|
-
compressed += m[0];
|
1316
|
-
// console.log(' "' + m[0] + '" (tag)');
|
1317
|
-
p = m.index + m[0].length;
|
1318
|
-
|
1319
|
-
if ( /^pre$/i.test(m[1]) ) {
|
1320
|
-
preformatted++;
|
1321
|
-
} else if ( /^\/pre$/i.test(m[1]) && preformatted ) {
|
1322
|
-
preformatted--;
|
1323
|
-
}
|
1324
|
-
|
1325
|
-
}
|
1326
|
-
|
1327
|
-
if ( content.length > p ) {
|
1328
|
-
text = content.slice(p, content.length);
|
1329
|
-
if ( preformatted ) {
|
1330
|
-
compressed += text;
|
1331
|
-
// console.log(' "' + text + '" (preformatted)');
|
1332
|
-
} else {
|
1333
|
-
text = text.replace(/\s+/g,' ');
|
1334
|
-
if ( text.trim() ) {
|
1335
|
-
compressed += text;
|
1336
|
-
}
|
1337
|
-
// console.log(' "' + text + '" (trimmed)');
|
1338
|
-
}
|
1339
|
-
}
|
1340
|
-
|
1341
|
-
return compressed;
|
1342
|
-
}
|
1343
|
-
|
1344
|
-
function makeLinkToSymbolFile(longname) {
|
1345
|
-
return Link.baseSymbols + __uniqueFilenames[longname] + conf.ext;
|
1346
|
-
}
|
1347
|
-
|
1348
|
-
function simpleNameOf(longname) {
|
1349
|
-
longname = String(longname);
|
1350
|
-
var p = longname.lastIndexOf('.');
|
1351
|
-
return p < 0 ? longname : longname.slice(p + 1);
|
1352
|
-
}
|
1353
|
-
|
1354
|
-
function bySimpleName(a,b) {
|
1355
|
-
if ( a === b ) {
|
1356
|
-
return 0;
|
1357
|
-
}
|
1358
|
-
var simpleA = simpleNameOf(a);
|
1359
|
-
var simpleB = simpleNameOf(b);
|
1360
|
-
if ( simpleA === simpleB ) {
|
1361
|
-
return a < b ? -1 : 1;
|
1362
|
-
} else {
|
1363
|
-
return simpleA < simpleB ? -1 : 1;
|
1364
|
-
}
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
/** Build output for displaying function parameters. */
|
1368
|
-
function makeSignature(params) {
|
1369
|
-
var r = ['('], desc;
|
1370
|
-
if ( params ) {
|
1371
|
-
for (var i = 0, p; p = params[i]; i++) {
|
1372
|
-
// ignore @param tags for 'virtual' params that are used to document members of config-like params
|
1373
|
-
// (e.g. like "@param param1.key ...")
|
1374
|
-
if (p.name && p.name.indexOf('.') == -1) {
|
1375
|
-
if (i > 0)
|
1376
|
-
r.push(', ');
|
1377
|
-
|
1378
|
-
r.push('<span');
|
1379
|
-
|
1380
|
-
var types = listTypes(p.type, true);
|
1381
|
-
if ( desc = asPlainSummary(p.description) || types ) {
|
1382
|
-
r.push(' title="');
|
1383
|
-
if (types) {
|
1384
|
-
r.push('(');
|
1385
|
-
r.push(types);
|
1386
|
-
r.push(') ');
|
1387
|
-
}
|
1388
|
-
r.push(desc);
|
1389
|
-
r.push('"');
|
1390
|
-
}
|
1391
|
-
|
1392
|
-
r.push('>');
|
1393
|
-
r.push(p.name);
|
1394
|
-
r.push('</span>');
|
1395
|
-
if ( p.optional )
|
1396
|
-
r.push('<i class="help" title="Optional parameter">?</i>');
|
1397
|
-
}
|
1398
|
-
}
|
1399
|
-
}
|
1400
|
-
r.push(')');
|
1401
|
-
return r.join('');
|
1402
|
-
}
|
1403
|
-
|
1404
|
-
|
1405
|
-
/*
|
1406
|
-
* regexp to recognize important places in the text
|
1407
|
-
*
|
1408
|
-
* Capturing groups of the RegExp:
|
1409
|
-
* group 1: begin of a pre block
|
1410
|
-
* group 2: end of a pre block
|
1411
|
-
* group 3: begin of a header/ul/ol/table, implicitly ends a paragraph
|
1412
|
-
* group 4: end of a header/ul/ol/table, implicitly starts a new paragraph
|
1413
|
-
* group 5: target portion of an inline @link tag
|
1414
|
-
* group 6: (optional) text portion of an inline link tag
|
1415
|
-
* group 7: an empty line which implicitly starts a new paragraph
|
1416
|
-
*
|
1417
|
-
* [------- <pre> block -------] [----------------------- some flow content -----------------------] [---- an inline {@link ...} tag ----] [---------- an empty line ---------] */
|
1418
|
-
var rFormatText = /(<pre(?:\s[^>]*)?>)|(<\/pre>)|(<(?:h[\d+]|ul|ol|table)(?:\s[^>]*)?>)|(<\/(?:h[\d+]|ul|ol|table)>)|\{@link\s+([^}\s]+)(?:\s+([^\}]*))?\}|((?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n))/gi;
|
1419
|
-
|
1420
|
-
function formatText(text) {
|
1421
|
-
|
1422
|
-
if ( !text ) {
|
1423
|
-
return '';
|
1424
|
-
}
|
1425
|
-
|
1426
|
-
var inpre = false,
|
1427
|
-
paragraphs = 0;
|
1428
|
-
|
1429
|
-
text = String(text).replace(rFormatText, function(match, pre, endpre, flow, endflow, linkTarget, linkText, emptyline) {
|
1430
|
-
if ( pre ) {
|
1431
|
-
inpre = true;
|
1432
|
-
return pre.replace(/<pre>/gi, "<pre class=\"prettyprint\">").replace(/<pre\s+lang="([^"]+)"\s*>/gi, "<pre class=\"prettyprint lang-$1\">");
|
1433
|
-
} else if ( endpre ) {
|
1434
|
-
inpre = false;
|
1435
|
-
} else if ( flow ) {
|
1436
|
-
if ( !inpre ) {
|
1437
|
-
paragraphs++;
|
1438
|
-
return '</p>' + match;
|
1439
|
-
}
|
1440
|
-
} else if ( endflow ) {
|
1441
|
-
if ( !inpre ) {
|
1442
|
-
paragraphs++;
|
1443
|
-
return match + '<p>';
|
1444
|
-
}
|
1445
|
-
} else if ( emptyline ) {
|
1446
|
-
if ( !inpre ) {
|
1447
|
-
paragraphs++;
|
1448
|
-
return '</p><p>';
|
1449
|
-
}
|
1450
|
-
} else if ( linkTarget ) {
|
1451
|
-
if ( !inpre ) {
|
1452
|
-
// convert to a hyperlink
|
1453
|
-
var link = new Link().toSymbol(linkTarget);
|
1454
|
-
// if link tag contained a replacement text, use it
|
1455
|
-
if ( linkText && linkText.trim()) {
|
1456
|
-
link = link.withText(linkText.trim());
|
1457
|
-
}
|
1458
|
-
return link.toString();
|
1459
|
-
}
|
1460
|
-
}
|
1461
|
-
return match;
|
1462
|
-
});
|
1463
|
-
|
1464
|
-
if ( paragraphs > 0 ) {
|
1465
|
-
text = '<p>' + text + '</p>';
|
1466
|
-
}
|
1467
|
-
|
1468
|
-
// remove empty paragraphs
|
1469
|
-
text = text.replace(/<p>\s*<\/p>/g, '');
|
1470
|
-
|
1471
|
-
return text;
|
1472
|
-
}
|
1473
|
-
|
1474
|
-
|
1475
|
-
//console.log("#### samples");
|
1476
|
-
//console.log(formatText(summarize("This is a first\n\nparagraph with empty \n \n \nlines in it. This is the remainder.")));
|
1477
|
-
|
1478
|
-
function childrenOfKind(data, kind) {
|
1479
|
-
/* old version based on TaffyDB (slow)
|
1480
|
-
var oChildren = symbolSet({kind: kind, memberof: data.longname === GLOBAL_LONGNAME ? {isUndefined: true} : data.longname}).filter(function() { return conf.filter(this); });
|
1481
|
-
return {
|
1482
|
-
own : oChildren.filter({inherited: {isUndefined:true}}).get().sort(makeSortby("!deprecated","static","name")),
|
1483
|
-
borrowed : groupByContributors(data, oChildren.filter({inherited: true}).get().sort(makeSortby("name")))
|
1484
|
-
} */
|
1485
|
-
var oResult = {
|
1486
|
-
own: [],
|
1487
|
-
borrowed: []
|
1488
|
-
};
|
1489
|
-
//console.log("calculating kind " + kind + " from " + data.longname);
|
1490
|
-
//console.log(data);
|
1491
|
-
var fnFilter;
|
1492
|
-
switch (kind) {
|
1493
|
-
case 'property':
|
1494
|
-
fnFilter = function($) {
|
1495
|
-
return $.kind === 'constant' || ($.kind === 'member' && !$.isEnum);
|
1496
|
-
}
|
1497
|
-
break;
|
1498
|
-
case 'event':
|
1499
|
-
fnFilter = function($) {
|
1500
|
-
return $.kind === 'event';
|
1501
|
-
}
|
1502
|
-
break;
|
1503
|
-
case 'method':
|
1504
|
-
fnFilter = function($) {
|
1505
|
-
return $.kind === 'function';
|
1506
|
-
}
|
1507
|
-
break;
|
1508
|
-
default:
|
1509
|
-
// default: none
|
1510
|
-
fnFilter = function($) { return false; };
|
1511
|
-
break;
|
1512
|
-
}
|
1513
|
-
|
1514
|
-
if ( data.__ui5.members ) {
|
1515
|
-
data.__ui5.members.forEach(function($) {
|
1516
|
-
if ( fnFilter($) && conf.filter($) ) {
|
1517
|
-
oResult[$.inherited ? 'borrowed' : 'own'].push($);
|
1518
|
-
}
|
1519
|
-
});
|
1520
|
-
}
|
1521
|
-
oResult.own.sort(makeSortby("!deprecated","static","name"));
|
1522
|
-
oResult.borrowed = groupByContributors(data, oResult.borrowed);
|
1523
|
-
|
1524
|
-
return oResult;
|
1525
|
-
}
|
1526
|
-
|
1527
|
-
/**
|
1528
|
-
* Determines the set of contributors of the given borrowed members.
|
1529
|
-
* The contributors are sorted according to the inheritance hierarchy:
|
1530
|
-
* first the base class of symbol, then the base class of the base class etc.
|
1531
|
-
* Any contributors that can not be found in the hierarchy are appended
|
1532
|
-
* to the set.
|
1533
|
-
*
|
1534
|
-
* @param symbol of which these are the members
|
1535
|
-
* @param borrowedMembers set of borrowed members to determine the contributors for
|
1536
|
-
* @return sorted array of contributors
|
1537
|
-
*/
|
1538
|
-
function groupByContributors(symbol, aBorrowedMembers) {
|
1539
|
-
|
1540
|
-
var MAX_ORDER = 1000, // a sufficiently large number
|
1541
|
-
mContributors = {},
|
1542
|
-
aSortedContributors = [],
|
1543
|
-
i,order;
|
1544
|
-
|
1545
|
-
aBorrowedMembers.forEach(function($) {
|
1546
|
-
$ = lookup($.inherits);
|
1547
|
-
if ($ && mContributors[$.memberof] == null) {
|
1548
|
-
mContributors[$.memberof] = { order : MAX_ORDER, items : [$] };
|
1549
|
-
} else {
|
1550
|
-
mContributors[$.memberof].items.push($);
|
1551
|
-
}
|
1552
|
-
});
|
1553
|
-
|
1554
|
-
// order contributors according to their distance in the inheritance hierarchy
|
1555
|
-
order = 0;
|
1556
|
-
(function handleAugments(oSymbol) {
|
1557
|
-
var i,oTarget,aParentsToVisit;
|
1558
|
-
if ( oSymbol.augments ) {
|
1559
|
-
aParentsToVisit = [];
|
1560
|
-
// first assign an order
|
1561
|
-
for (i = 0; i < oSymbol.augments.length; i++) {
|
1562
|
-
if ( mContributors[oSymbol.augments[i]] != null && mContributors[oSymbol.augments[i]].order === MAX_ORDER ) {
|
1563
|
-
mContributors[oSymbol.augments[i]].order = ++order;
|
1564
|
-
aParentsToVisit.push(oSymbol.augments[i]);
|
1565
|
-
}
|
1566
|
-
}
|
1567
|
-
// only then dive into parents (breadth first search)
|
1568
|
-
for (i = 0; i < aParentsToVisit.length; i++) {
|
1569
|
-
oTarget = lookup(aParentsToVisit);
|
1570
|
-
if ( oTarget ) {
|
1571
|
-
handleAugments(oTarget);
|
1572
|
-
}
|
1573
|
-
}
|
1574
|
-
}
|
1575
|
-
}(symbol));
|
1576
|
-
|
1577
|
-
// convert to an array and sort by order
|
1578
|
-
for (i in mContributors) {
|
1579
|
-
aSortedContributors.push(mContributors[i]);
|
1580
|
-
}
|
1581
|
-
aSortedContributors.sort(function (a,b) { return a.order - b.order; });
|
1582
|
-
|
1583
|
-
return aSortedContributors;
|
1584
|
-
|
1585
|
-
}
|
1586
|
-
|
1587
|
-
function makeLinkList(aSymbols) {
|
1588
|
-
return aSymbols
|
1589
|
-
.sort(makeSortby("name"))
|
1590
|
-
.map(function($) { return new Link().toSymbol($.longname).withText($.name); })
|
1591
|
-
.join(", ");
|
1592
|
-
}
|
1593
|
-
|
1594
|
-
// ---- type parsing ---------------------------------------------------------------------------------------------
|
1595
|
-
|
1596
|
-
function TypeParser(defaultBuilder) {
|
1597
|
-
|
1598
|
-
/* TODO
|
1599
|
-
* - function(this:) // type of this
|
1600
|
-
* - function(new:) // constructor
|
1601
|
-
*/
|
1602
|
-
var rLexer = /\s*(Array\.?<|Object\.?<|Set\.?<|Promise\.?<|function\(|\{|:|\(|\||\}|>|\)|,|\[\]|\*|\?|!|\.\.\.)|\s*((?:module:)?\w+(?:[\/.#~]\w+)*)|./g;
|
1603
|
-
|
1604
|
-
var input,
|
1605
|
-
builder,
|
1606
|
-
token,
|
1607
|
-
tokenStr;
|
1608
|
-
|
1609
|
-
function next(expected) {
|
1610
|
-
if ( expected !== undefined && token !== expected ) {
|
1611
|
-
throw new SyntaxError("TypeParser: expected '" + expected + "', but found '" + tokenStr + "' (pos: " + rLexer.lastIndex + ", input='" + input + "')");
|
1612
|
-
}
|
1613
|
-
var match = rLexer.exec(input);
|
1614
|
-
if ( match ) {
|
1615
|
-
tokenStr = match[1] || match[2];
|
1616
|
-
token = match[1] || (match[2] && 'symbol');
|
1617
|
-
if ( !token ) {
|
1618
|
-
throw new SyntaxError("TypeParser: unexpected '" + tokenStr + "' (pos: " + match.index + ", input='" + input + "')");
|
1619
|
-
}
|
1620
|
-
} else {
|
1621
|
-
tokenStr = token = null;
|
1622
|
-
}
|
1623
|
-
}
|
1624
|
-
|
1625
|
-
function parseType() {
|
1626
|
-
var nullable = false;
|
1627
|
-
var mandatory = false;
|
1628
|
-
if ( token === '?' ) {
|
1629
|
-
next();
|
1630
|
-
nullable = true;
|
1631
|
-
} else if ( token === '!' ) {
|
1632
|
-
next();
|
1633
|
-
mandatory = true;
|
1634
|
-
}
|
1635
|
-
|
1636
|
-
var type;
|
1637
|
-
|
1638
|
-
if ( token === 'Array.<' || token === 'Array<' ) {
|
1639
|
-
next();
|
1640
|
-
var componentType = parseType();
|
1641
|
-
next('>');
|
1642
|
-
type = builder.array(componentType);
|
1643
|
-
} else if ( token === 'Object.<' || token === 'Object<' ) {
|
1644
|
-
next();
|
1645
|
-
var keyType;
|
1646
|
-
var valueType = parseType();
|
1647
|
-
if ( token === ',' ) {
|
1648
|
-
next();
|
1649
|
-
keyType = valueType;
|
1650
|
-
valueType = parseType();
|
1651
|
-
} else {
|
1652
|
-
keyType = builder.synthetic(builder.simpleType('string'));
|
1653
|
-
}
|
1654
|
-
next('>');
|
1655
|
-
type = builder.object(keyType, valueType);
|
1656
|
-
} else if ( token === 'Set.<' || token === 'Set<' ) {
|
1657
|
-
next();
|
1658
|
-
var elementType = parseType();
|
1659
|
-
next('>');
|
1660
|
-
type = builder.set(elementType);
|
1661
|
-
} else if ( token === 'Promise.<' || token === 'Promise<' ) {
|
1662
|
-
next();
|
1663
|
-
var elementType = parseType();
|
1664
|
-
next('>');
|
1665
|
-
type = builder.promise(elementType);
|
1666
|
-
} else if ( token === 'function(' ) {
|
1667
|
-
next();
|
1668
|
-
var thisType, constructorType, paramTypes = [], returnType;
|
1669
|
-
if ( tokenStr === 'this' ) {
|
1670
|
-
next();
|
1671
|
-
next(':');
|
1672
|
-
thisType = parseType();
|
1673
|
-
if ( token === ',' ) {
|
1674
|
-
next();
|
1675
|
-
}
|
1676
|
-
} else if ( tokenStr === 'new' ) {
|
1677
|
-
next();
|
1678
|
-
next(':');
|
1679
|
-
constructorType = parseType();
|
1680
|
-
if ( token === ',' ) {
|
1681
|
-
next();
|
1682
|
-
}
|
1683
|
-
}
|
1684
|
-
while ( token === 'symbol' || token === '...' ) {
|
1685
|
-
var repeatable = token === '...';
|
1686
|
-
if ( repeatable) {
|
1687
|
-
next();
|
1688
|
-
}
|
1689
|
-
var paramType = parseType();
|
1690
|
-
if ( repeatable ) {
|
1691
|
-
paramType = builder.repeatable(paramType);
|
1692
|
-
}
|
1693
|
-
paramTypes.push(paramType);
|
1694
|
-
if ( token === ',' ) {
|
1695
|
-
if ( repeatable ) {
|
1696
|
-
throw new SyntaxError("TypeParser: only the last parameter of a function can be repeatable (pos: " + rLexer.lastIndex + ", input='" + input + "')");
|
1697
|
-
}
|
1698
|
-
next();
|
1699
|
-
}
|
1700
|
-
}
|
1701
|
-
next(')');
|
1702
|
-
if ( token === ':' ) {
|
1703
|
-
next(':');
|
1704
|
-
returnType = parseType();
|
1705
|
-
}
|
1706
|
-
type = builder.function(paramTypes, returnType, thisType, constructorType);
|
1707
|
-
} else if ( token === '{' ) {
|
1708
|
-
var structure = Object.create(null);
|
1709
|
-
var propName,propType;
|
1710
|
-
next();
|
1711
|
-
do {
|
1712
|
-
propName = tokenStr;
|
1713
|
-
if ( !/^\w+$/.test(propName) ) {
|
1714
|
-
throw new SyntaxError("TypeParser: structure field must have a simple name (pos: " + rLexer.lastIndex + ", input='" + input + "', field:'" + propName + "')");
|
1715
|
-
}
|
1716
|
-
next('symbol');
|
1717
|
-
if ( token === ':' ) {
|
1718
|
-
next();
|
1719
|
-
propType = parseType();
|
1720
|
-
} else {
|
1721
|
-
propType = builder.synthetic(builder.simpleType('any'));
|
1722
|
-
}
|
1723
|
-
structure[propName] = propType;
|
1724
|
-
if ( token === '}' ) {
|
1725
|
-
break;
|
1726
|
-
}
|
1727
|
-
next(',');
|
1728
|
-
} while (token);
|
1729
|
-
next('}');
|
1730
|
-
type = builder.structure(structure);
|
1731
|
-
} else if ( token === '(' ) {
|
1732
|
-
next();
|
1733
|
-
type = parseTypes();
|
1734
|
-
next(')');
|
1735
|
-
} else if ( token === '*' ) {
|
1736
|
-
next();
|
1737
|
-
type = builder.simpleType('*');
|
1738
|
-
} else {
|
1739
|
-
type = builder.simpleType(tokenStr);
|
1740
|
-
next('symbol');
|
1741
|
-
while ( token === '[]' ) {
|
1742
|
-
next();
|
1743
|
-
type = builder.array(type);
|
1744
|
-
}
|
1745
|
-
}
|
1746
|
-
if ( nullable ) {
|
1747
|
-
type = builder.nullable(type);
|
1748
|
-
}
|
1749
|
-
if ( mandatory ) {
|
1750
|
-
type = builder.mandatory(type);
|
1751
|
-
}
|
1752
|
-
return type;
|
1753
|
-
}
|
1754
|
-
|
1755
|
-
function parseTypes() {
|
1756
|
-
var types = [];
|
1757
|
-
do {
|
1758
|
-
types.push(parseType());
|
1759
|
-
if ( token !== '|' ) {
|
1760
|
-
break;
|
1761
|
-
}
|
1762
|
-
next();
|
1763
|
-
} while (token);
|
1764
|
-
return types.length === 1 ? types[0] : builder.union(types);
|
1765
|
-
}
|
1766
|
-
|
1767
|
-
this.parse = function(typeStr, tempBuilder) {
|
1768
|
-
builder = tempBuilder || defaultBuilder || TypeParser.ASTBuilder;
|
1769
|
-
input = String(typeStr);
|
1770
|
-
rLexer.lastIndex = 0;
|
1771
|
-
next();
|
1772
|
-
var type = parseTypes();
|
1773
|
-
next(null);
|
1774
|
-
return type;
|
1775
|
-
}
|
1776
|
-
|
1777
|
-
}
|
1778
|
-
|
1779
|
-
TypeParser.ASTBuilder = {
|
1780
|
-
simpleType: function(type) {
|
1781
|
-
return {
|
1782
|
-
type: 'simpleType',
|
1783
|
-
name: type
|
1784
|
-
};
|
1785
|
-
},
|
1786
|
-
array: function(componentType) {
|
1787
|
-
return {
|
1788
|
-
type: 'array',
|
1789
|
-
component: componentType
|
1790
|
-
};
|
1791
|
-
},
|
1792
|
-
object: function(keyType, valueType) {
|
1793
|
-
return {
|
1794
|
-
type: 'object',
|
1795
|
-
key: keyType,
|
1796
|
-
value: valueType
|
1797
|
-
};
|
1798
|
-
},
|
1799
|
-
set: function(elementType) {
|
1800
|
-
return {
|
1801
|
-
type: 'set',
|
1802
|
-
element: elementType
|
1803
|
-
};
|
1804
|
-
},
|
1805
|
-
promise: function(fulfillmentType) {
|
1806
|
-
return {
|
1807
|
-
type: 'promise',
|
1808
|
-
fulfill: fulfillmentType
|
1809
|
-
};
|
1810
|
-
},
|
1811
|
-
function: function(paramTypes, returnType, thisType, constructorType) {
|
1812
|
-
return {
|
1813
|
-
type: 'function',
|
1814
|
-
params: paramTypes,
|
1815
|
-
return: returnType,
|
1816
|
-
this: thisType,
|
1817
|
-
constructor: constructorType
|
1818
|
-
};
|
1819
|
-
},
|
1820
|
-
structure: function(structure) {
|
1821
|
-
return {
|
1822
|
-
type: 'structure',
|
1823
|
-
fields: structure
|
1824
|
-
};
|
1825
|
-
},
|
1826
|
-
union: function(types) {
|
1827
|
-
return {
|
1828
|
-
type: 'union',
|
1829
|
-
types: types
|
1830
|
-
};
|
1831
|
-
},
|
1832
|
-
synthetic: function(type) {
|
1833
|
-
type.synthetic = true;
|
1834
|
-
return type;
|
1835
|
-
},
|
1836
|
-
nullable: function(type) {
|
1837
|
-
type.nullable = true;
|
1838
|
-
return type;
|
1839
|
-
},
|
1840
|
-
mandatory: function(type) {
|
1841
|
-
type.mandatory = true;
|
1842
|
-
return type;
|
1843
|
-
},
|
1844
|
-
repeatable: function(type) {
|
1845
|
-
type.repeatable = true;
|
1846
|
-
return type;
|
1847
|
-
}
|
1848
|
-
};
|
1849
|
-
|
1850
|
-
TypeParser.LinkBuilder = function(style, encoded) {
|
1851
|
-
this.linkStyle = style;
|
1852
|
-
this.lt = encoded ? "<" : "<";
|
1853
|
-
this.gt = encoded ? ">" : ">";
|
1854
|
-
};
|
1855
|
-
TypeParser.LinkBuilder.prototype = {
|
1856
|
-
safe: function(type) {
|
1857
|
-
return type.needsParenthesis ? "(" + type.str + ")" : type.str;
|
1858
|
-
},
|
1859
|
-
simpleType: function(type) {
|
1860
|
-
if ( this.linkStyle === 'text' ) {
|
1861
|
-
return {
|
1862
|
-
str: type
|
1863
|
-
};
|
1864
|
-
}
|
1865
|
-
var link = new Link().toSymbol(type);
|
1866
|
-
if ( this.linkStyle === 'short' ) {
|
1867
|
-
link.withText(simpleNameOf(type)).withTooltip(type);
|
1868
|
-
}
|
1869
|
-
return {
|
1870
|
-
str: link.toString()
|
1871
|
-
};
|
1872
|
-
},
|
1873
|
-
array: function(componentType) {
|
1874
|
-
if ( componentType.needsParenthesis ) {
|
1875
|
-
return {
|
1876
|
-
str: "Array.<" + componentType.str + ">"
|
1877
|
-
};
|
1878
|
-
}
|
1879
|
-
return {
|
1880
|
-
str: componentType.str + "[]"
|
1881
|
-
};
|
1882
|
-
},
|
1883
|
-
object: function(keyType, valueType) {
|
1884
|
-
if ( keyType.synthetic ) {
|
1885
|
-
return {
|
1886
|
-
str: "Object." + this.lt + valueType.str + this.gt
|
1887
|
-
};
|
1888
|
-
}
|
1889
|
-
return {
|
1890
|
-
str: "Object." + this.lt + keyType.str + "," + valueType.str + this.gt
|
1891
|
-
};
|
1892
|
-
},
|
1893
|
-
set: function(elementType) {
|
1894
|
-
return {
|
1895
|
-
str: 'Set.' + this.lt + elementType.str + this.gt
|
1896
|
-
};
|
1897
|
-
},
|
1898
|
-
promise: function(fulfillmentType) {
|
1899
|
-
return {
|
1900
|
-
str: 'Promise.' + this.lt + fulfillmentType.str + this.gt
|
1901
|
-
};
|
1902
|
-
},
|
1903
|
-
function: function(paramTypes, returnType) {
|
1904
|
-
return {
|
1905
|
-
str: "function(" + paramTypes.map(function(type) { return type.str; }).join(',') + ")" + ( returnType ? " : " + this.safe(returnType) : "")
|
1906
|
-
};
|
1907
|
-
},
|
1908
|
-
structure: function(structure) {
|
1909
|
-
var r = [];
|
1910
|
-
for ( var fieldName in structure ) {
|
1911
|
-
if ( structure[fieldName].synthetic ) {
|
1912
|
-
r.push(fieldName);
|
1913
|
-
} else {
|
1914
|
-
r.push(fieldName + ":" + structure[fieldName].str);
|
1915
|
-
}
|
1916
|
-
}
|
1917
|
-
return {
|
1918
|
-
str: "{" + r.join(",") + "}"
|
1919
|
-
};
|
1920
|
-
},
|
1921
|
-
union: function(types) {
|
1922
|
-
return {
|
1923
|
-
needsParenthesis: true,
|
1924
|
-
str: types.map( this.safe.bind(this) ).join('|')
|
1925
|
-
};
|
1926
|
-
},
|
1927
|
-
synthetic: function(type) {
|
1928
|
-
type.synthetic = true;
|
1929
|
-
return type;
|
1930
|
-
},
|
1931
|
-
nullable: function(type) {
|
1932
|
-
type.str = "?" + type.str;
|
1933
|
-
return type;
|
1934
|
-
},
|
1935
|
-
mandatory: function(type) {
|
1936
|
-
type.str = "!" + type.str;
|
1937
|
-
return type;
|
1938
|
-
},
|
1939
|
-
repeatable: function(type) {
|
1940
|
-
type.str = "..." + type.str;
|
1941
|
-
return type;
|
1942
|
-
}
|
1943
|
-
};
|
1944
|
-
|
1945
|
-
var typeParser = new TypeParser();
|
1946
|
-
var _SHORT_BUILDER = new TypeParser.LinkBuilder('short', true);
|
1947
|
-
var _LONG_BUILDER = new TypeParser.LinkBuilder('long', true);
|
1948
|
-
var _TEXT_BUILDER = new TypeParser.LinkBuilder('text', false);
|
1949
|
-
var _TEXT_BUILDER_ENCODED = new TypeParser.LinkBuilder('text', true);
|
1950
|
-
|
1951
|
-
/*
|
1952
|
-
function testTypeParser(type) {
|
1953
|
-
console.log("Type: '" + type + "' gives AST");
|
1954
|
-
try {
|
1955
|
-
console.log(typeParser.parse(type));
|
1956
|
-
} catch (e) {
|
1957
|
-
console.log("**** throws: " + e);
|
1958
|
-
}
|
1959
|
-
}
|
1960
|
-
|
1961
|
-
testTypeParser("Array.<string>");
|
1962
|
-
testTypeParser("Array<string>");
|
1963
|
-
testTypeParser("Object.<string>");
|
1964
|
-
testTypeParser("Object<string>");
|
1965
|
-
testTypeParser("function(...string):Set<string>");
|
1966
|
-
testTypeParser("{a:int,b,c:float,d,e}");
|
1967
|
-
*/
|
1968
|
-
|
1969
|
-
function _processTypeString(type, builder) {
|
1970
|
-
if ( type && Array.isArray(type.names) ) {
|
1971
|
-
type = type.names.join('|');
|
1972
|
-
}
|
1973
|
-
if ( type ) {
|
1974
|
-
try {
|
1975
|
-
return typeParser.parse( type, builder ).str;
|
1976
|
-
} catch (e) {
|
1977
|
-
error("failed to parse type string '" + type + "': " + e);
|
1978
|
-
return type;
|
1979
|
-
}
|
1980
|
-
}
|
1981
|
-
}
|
1982
|
-
|
1983
|
-
function listTypes(type, encoded) {
|
1984
|
-
return _processTypeString(type, encoded ? _TEXT_BUILDER_ENCODED : _TEXT_BUILDER);
|
1985
|
-
}
|
1986
|
-
|
1987
|
-
function linkTypes(type, short) {
|
1988
|
-
return _processTypeString(type, short ? _SHORT_BUILDER : _LONG_BUILDER );
|
1989
|
-
}
|
1990
|
-
|
1991
|
-
function isArrayType(type) {
|
1992
|
-
if ( type && Array.isArray(type.names) ) {
|
1993
|
-
type = type.names.join('|');
|
1994
|
-
}
|
1995
|
-
if ( type ) {
|
1996
|
-
try {
|
1997
|
-
var ast = typeParser.parse( type, TypeParser.ASTBuilder );
|
1998
|
-
return ( ast.type === 'array' || (ast.type === 'union' && ast.types.some( function(subtype) { return subtype.type === 'array'; })) );
|
1999
|
-
} catch (e) {
|
2000
|
-
error("failed to parse type string '" + type + "': " + e);
|
2001
|
-
}
|
2002
|
-
}
|
2003
|
-
return false;
|
2004
|
-
}
|
2005
|
-
|
2006
|
-
/**
|
2007
|
-
* Reduces the given text to a summary and removes all tags links etc. and escapes double quotes.
|
2008
|
-
* The result therefore should be suitable as content for an HTML tag attribute (e.g. title).
|
2009
|
-
* @param sText
|
2010
|
-
* @return summarized, plain attribute
|
2011
|
-
*/
|
2012
|
-
function asPlainSummary(sText) {
|
2013
|
-
return sText ? summarize(sText).replace(/<.*?>/g, '').replace(/\{\@link\s*(.*?)\}/g, '$1').replace(/"/g,""") : '';
|
2014
|
-
}
|
2015
|
-
|
2016
|
-
function getNSClass(item) {
|
2017
|
-
if (item.kind === 'interface') {
|
2018
|
-
return " interface";
|
2019
|
-
} else if (item.kind === 'namespace') {
|
2020
|
-
return " namespace";
|
2021
|
-
} else if (item.kind === 'typedef' ) {
|
2022
|
-
return " typedef";
|
2023
|
-
} else if (item.kind === 'member' && item.isEnum ) {
|
2024
|
-
return " enum";
|
2025
|
-
} else {
|
2026
|
-
return "";
|
2027
|
-
}
|
2028
|
-
}
|
2029
|
-
|
2030
|
-
/*
|
2031
|
-
* regexp to recognize important places in the text
|
2032
|
-
*
|
2033
|
-
* Capturing groups of the RegExp:
|
2034
|
-
* group 1: begin of a pre block
|
2035
|
-
* group 2: end of a pre block
|
2036
|
-
* group 3: an empty line + surrounding whitespace (implicitly starts a new paragraph)
|
2037
|
-
* group 4: an isolated line feed + surrounding whitespace
|
2038
|
-
*
|
2039
|
-
* [------- <pre> block -------] [---- an empty line and surrounding whitespace ----] [---- new line or whitespaces ----] */
|
2040
|
-
var rNormalizeText = /(<pre(?:\s[^>]*)?>)|(<\/pre>)|([ \t]*(?:\r\n|\r|\n)[ \t]*(?:\r\n|\r|\n)[ \t\r\n]*)|([ \t]*(?:\r\n|\r|\n)[ \t]*|[ \t]+)/gi;
|
2041
|
-
|
2042
|
-
function normalizeWS(text) {
|
2043
|
-
if ( text == null ) {
|
2044
|
-
return text;
|
2045
|
-
}
|
2046
|
-
|
2047
|
-
var inpre = false;
|
2048
|
-
return String(text).replace(rNormalizeText, function(match, pre, endpre, emptyline, ws) {
|
2049
|
-
if ( pre ) {
|
2050
|
-
inpre = true;
|
2051
|
-
return pre;
|
2052
|
-
} else if ( endpre ) {
|
2053
|
-
inpre = false;
|
2054
|
-
return endpre;
|
2055
|
-
} else if ( emptyline ) {
|
2056
|
-
return inpre ? emptyline : '\n\n';
|
2057
|
-
} else if ( ws ) {
|
2058
|
-
return inpre ? ws : ' ';
|
2059
|
-
}
|
2060
|
-
return match;
|
2061
|
-
});
|
2062
|
-
|
2063
|
-
}
|
2064
|
-
|
2065
|
-
//---- add on: API JSON -----------------------------------------------------------------
|
2066
|
-
|
2067
|
-
function createAPIJSON(symbols, filename) {
|
2068
|
-
|
2069
|
-
var api = {
|
2070
|
-
"$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0"
|
2071
|
-
}
|
2072
|
-
|
2073
|
-
if ( templateConf.version ) {
|
2074
|
-
api.version = templateConf.version.replace(/-SNAPSHOT$/,"");
|
2075
|
-
}
|
2076
|
-
if ( templateConf.uilib ) {
|
2077
|
-
api.library = templateConf.uilib;
|
2078
|
-
}
|
2079
|
-
|
2080
|
-
api.symbols = [];
|
2081
|
-
// sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken
|
2082
|
-
symbols.slice(0).sort(sortByAlias).forEach(function(symbol) {
|
2083
|
-
if ( isFirstClassSymbol(symbol) && !symbol.synthetic ) { // dump a symbol if it as a class symbol and if it is not a synthetic symbol
|
2084
|
-
api.symbols.push(createAPIJSON4Symbol(symbol, false));
|
2085
|
-
}
|
2086
|
-
});
|
2087
|
-
|
2088
|
-
postProcessAPIJSON(api);
|
2089
|
-
|
2090
|
-
fs.mkPath(path.dirname(filename));
|
2091
|
-
fs.writeFileSync(filename, JSON.stringify(api), 'utf8');
|
2092
|
-
info(" apiJson saved as " + filename);
|
2093
|
-
}
|
2094
|
-
|
2095
|
-
function createAPIJSON4Symbol(symbol, omitDefaults) {
|
2096
|
-
|
2097
|
-
var obj = [];
|
2098
|
-
var curr = obj;
|
2099
|
-
var attribForKind = 'kind';
|
2100
|
-
var stack = [];
|
2101
|
-
|
2102
|
-
function isEmpty(obj) {
|
2103
|
-
if ( !obj ) {
|
2104
|
-
return true;
|
2105
|
-
}
|
2106
|
-
for (var n in obj) {
|
2107
|
-
if ( obj.hasOwnProperty(n) ) {
|
2108
|
-
return false;
|
2109
|
-
}
|
2110
|
-
}
|
2111
|
-
return true;
|
2112
|
-
}
|
2113
|
-
|
2114
|
-
function tag(name, value, omitEmpty) {
|
2115
|
-
|
2116
|
-
if ( omitEmpty && !value ) {
|
2117
|
-
return;
|
2118
|
-
}
|
2119
|
-
if ( arguments.length === 1 ) { // opening tag
|
2120
|
-
stack.push(curr);
|
2121
|
-
stack.push(attribForKind);
|
2122
|
-
var obj = {};
|
2123
|
-
if ( Array.isArray(curr) ) {
|
2124
|
-
if ( attribForKind != null ) {
|
2125
|
-
obj[attribForKind] = name;
|
2126
|
-
}
|
2127
|
-
curr.push(obj);
|
2128
|
-
} else {
|
2129
|
-
curr[name] = obj;
|
2130
|
-
}
|
2131
|
-
curr = obj;
|
2132
|
-
attribForKind = null;
|
2133
|
-
return;
|
2134
|
-
}
|
2135
|
-
if ( value == null ) {
|
2136
|
-
curr[name] = true;
|
2137
|
-
} else {
|
2138
|
-
curr[name] = String(value);
|
2139
|
-
}
|
2140
|
-
}
|
2141
|
-
|
2142
|
-
function attrib(name, value, defaultValue, raw) {
|
2143
|
-
var emptyTag = arguments.length === 1;
|
2144
|
-
if ( omitDefaults && arguments.length >= 3 && value === defaultValue ) {
|
2145
|
-
return;
|
2146
|
-
}
|
2147
|
-
curr[name] = emptyTag ? true : (raw ? value : String(value));
|
2148
|
-
}
|
2149
|
-
|
2150
|
-
function closeTag(name, noIndent) {
|
2151
|
-
attribForKind = stack.pop();
|
2152
|
-
curr = stack.pop();
|
2153
|
-
}
|
2154
|
-
|
2155
|
-
function collection(name, attribForKind) {
|
2156
|
-
stack.push(curr);
|
2157
|
-
stack.push(attribForKind);
|
2158
|
-
// TODO only supported if this.curr was an object check or fully implement
|
2159
|
-
curr = curr[name] = [];
|
2160
|
-
attribForKind = attribForKind || null;
|
2161
|
-
}
|
2162
|
-
|
2163
|
-
function endCollection(name) {
|
2164
|
-
attribForKind = stack.pop();
|
2165
|
-
curr = stack.pop();
|
2166
|
-
}
|
2167
|
-
|
2168
|
-
function tagWithSince(name, value) {
|
2169
|
-
|
2170
|
-
if ( !value ) {
|
2171
|
-
return;
|
2172
|
-
}
|
2173
|
-
|
2174
|
-
var info = extractSince(value);
|
2175
|
-
|
2176
|
-
tag(name);
|
2177
|
-
if ( info.since ) {
|
2178
|
-
attrib("since", info.since);
|
2179
|
-
}
|
2180
|
-
if ( info.value ) {
|
2181
|
-
curr["text"] = normalizeWS(info.value);
|
2182
|
-
}
|
2183
|
-
closeTag(name, true);
|
2184
|
-
|
2185
|
-
}
|
2186
|
-
|
2187
|
-
function examples(symbol) {
|
2188
|
-
var j, example;
|
2189
|
-
|
2190
|
-
if ( symbol.examples && symbol.examples.length ) {
|
2191
|
-
collection("examples");
|
2192
|
-
for ( j = 0; j < symbol.examples.length; j++) {
|
2193
|
-
example = makeExample(symbol.examples[j]);
|
2194
|
-
tag("example");
|
2195
|
-
if ( example.caption ) {
|
2196
|
-
attrib("caption", example.caption);
|
2197
|
-
}
|
2198
|
-
attrib("text", example.example);
|
2199
|
-
closeTag("example");
|
2200
|
-
}
|
2201
|
-
endCollection("examples");
|
2202
|
-
}
|
2203
|
-
}
|
2204
|
-
|
2205
|
-
function referencesList(symbol) {
|
2206
|
-
if ( symbol.see && symbol.see.length ) {
|
2207
|
-
curr["references"] = symbol.see.slice();
|
2208
|
-
}
|
2209
|
-
}
|
2210
|
-
|
2211
|
-
function visibility($) {
|
2212
|
-
if ( $.access === 'protected' ) {
|
2213
|
-
return "protected";
|
2214
|
-
} else if ( $.access === 'restricted' ) {
|
2215
|
-
return "restricted";
|
2216
|
-
} else if ( $.access === 'private' ) {
|
2217
|
-
return "private";
|
2218
|
-
} else {
|
2219
|
-
return "public";
|
2220
|
-
}
|
2221
|
-
}
|
2222
|
-
|
2223
|
-
function exceptions(symbol) {
|
2224
|
-
var array = symbol.exceptions,
|
2225
|
-
j, exception;
|
2226
|
-
|
2227
|
-
if ( Array.isArray(array) ) {
|
2228
|
-
array = array.filter( function (ex) {
|
2229
|
-
return (ex.type && listTypes(ex.type)) || (ex.description && ex.description.trim());
|
2230
|
-
});
|
2231
|
-
}
|
2232
|
-
if ( array == null || array.length === 0 ) {
|
2233
|
-
return;
|
2234
|
-
}
|
2235
|
-
|
2236
|
-
collection("throws");
|
2237
|
-
for (j = 0; j < array.length; j++) {
|
2238
|
-
exception = array[j];
|
2239
|
-
tag("exception");
|
2240
|
-
if ( exception.type !== undefined ) {
|
2241
|
-
attrib("type", listTypes(exception.type));
|
2242
|
-
}
|
2243
|
-
tag("description", normalizeWS(exception.description), true);
|
2244
|
-
closeTag("exception");
|
2245
|
-
}
|
2246
|
-
endCollection("throws");
|
2247
|
-
}
|
2248
|
-
|
2249
|
-
function methodList(tagname, methods) {
|
2250
|
-
methods = methods && Object.keys(methods).map(function(key) { return methods[key]; });
|
2251
|
-
if ( methods != null && methods.length > 0 ) {
|
2252
|
-
curr[tagname] = methods;
|
2253
|
-
}
|
2254
|
-
}
|
2255
|
-
|
2256
|
-
function interfaceList(tagname, interfaces) {
|
2257
|
-
if ( interfaces != null && interfaces.length > 0 ) {
|
2258
|
-
curr[tagname] = interfaces.slice();
|
2259
|
-
}
|
2260
|
-
}
|
2261
|
-
|
2262
|
-
function hasSettings($, visited) {
|
2263
|
-
|
2264
|
-
visited = visited || {};
|
2265
|
-
|
2266
|
-
if ( $.augments && $.augments.length > 0 ) {
|
2267
|
-
var baseSymbol = $.augments[0];
|
2268
|
-
if ( visited.hasOwnProperty(baseSymbol) ) {
|
2269
|
-
error("detected cyclic inheritance when looking at " + $.longname + ": " + JSON.stringify(visited));
|
2270
|
-
return false;
|
2271
|
-
}
|
2272
|
-
visited[baseSymbol] = true;
|
2273
|
-
baseSymbol = lookup(baseSymbol) ;
|
2274
|
-
if ( hasSettings(baseSymbol, visited) ) {
|
2275
|
-
return true;
|
2276
|
-
}
|
2277
|
-
}
|
2278
|
-
|
2279
|
-
var metadata = $.__ui5.metadata;
|
2280
|
-
return metadata &&
|
2281
|
-
(
|
2282
|
-
!isEmpty(metadata.specialSettings)
|
2283
|
-
|| !isEmpty(metadata.properties)
|
2284
|
-
|| !isEmpty(metadata.aggregations)
|
2285
|
-
|| !isEmpty(metadata.associations)
|
2286
|
-
|| !isEmpty(metadata.annotations)
|
2287
|
-
|| !isEmpty(metadata.events)
|
2288
|
-
);
|
2289
|
-
}
|
2290
|
-
|
2291
|
-
function writeMetadata($) {
|
2292
|
-
|
2293
|
-
var metadata = $.__ui5.metadata;
|
2294
|
-
if ( !metadata ) {
|
2295
|
-
return;
|
2296
|
-
}
|
2297
|
-
|
2298
|
-
var n;
|
2299
|
-
|
2300
|
-
if ( metadata.specialSettings && Object.keys(metadata.specialSettings).length > 0 ) {
|
2301
|
-
collection("specialSettings");
|
2302
|
-
for ( n in metadata.specialSettings ) {
|
2303
|
-
var special = metadata.specialSettings[n];
|
2304
|
-
tag("specialSetting");
|
2305
|
-
attrib("name", special.name);
|
2306
|
-
attrib("type", special.type);
|
2307
|
-
attrib("visibility", special.visibility, 'public');
|
2308
|
-
if ( special.since ) {
|
2309
|
-
attrib("since", extractVersion(special.since));
|
2310
|
-
}
|
2311
|
-
tag("description", normalizeWS(special.doc), true);
|
2312
|
-
tagWithSince("experimental", special.experimental);
|
2313
|
-
tagWithSince("deprecated", special.deprecation);
|
2314
|
-
methodList("method", special.methods);
|
2315
|
-
closeTag("specialSetting");
|
2316
|
-
}
|
2317
|
-
endCollection("specialSettings");
|
2318
|
-
}
|
2319
|
-
|
2320
|
-
if ( metadata.properties && Object.keys(metadata.properties).length > 0 ) {
|
2321
|
-
collection("properties");
|
2322
|
-
for ( n in metadata.properties ) {
|
2323
|
-
var prop = metadata.properties[n];
|
2324
|
-
tag("property");
|
2325
|
-
attrib("name", prop.name);
|
2326
|
-
attrib("type", prop.type, 'string');
|
2327
|
-
attrib("defaultValue", prop.defaultValue, null, /* raw = */true);
|
2328
|
-
attrib("group", prop.group, 'Misc');
|
2329
|
-
attrib("readonly", prop.readonly);
|
2330
|
-
attrib("visibility", prop.visibility, 'public');
|
2331
|
-
if ( prop.since ) {
|
2332
|
-
attrib("since", extractVersion(prop.since));
|
2333
|
-
}
|
2334
|
-
if ( prop.bindable ) {
|
2335
|
-
attrib("bindable", prop.bindable, false, /* raw = */true);
|
2336
|
-
}
|
2337
|
-
tag("description", normalizeWS(prop.doc), true);
|
2338
|
-
tagWithSince("experimental", prop.experimental);
|
2339
|
-
tagWithSince("deprecated", prop.deprecation);
|
2340
|
-
methodList("methods", prop.methods);
|
2341
|
-
closeTag("property");
|
2342
|
-
}
|
2343
|
-
endCollection("properties");
|
2344
|
-
}
|
2345
|
-
|
2346
|
-
if ( metadata.defaultProperty ) {
|
2347
|
-
tag("defaultProperty", metadata.defaultProperty);
|
2348
|
-
}
|
2349
|
-
|
2350
|
-
if ( metadata.dnd ) {
|
2351
|
-
curr.dnd = metadata.dnd;
|
2352
|
-
}
|
2353
|
-
|
2354
|
-
if ( metadata.aggregations && Object.keys(metadata.aggregations).length > 0 ) {
|
2355
|
-
collection("aggregations");
|
2356
|
-
for ( n in metadata.aggregations ) {
|
2357
|
-
var aggr = metadata.aggregations[n];
|
2358
|
-
tag("aggregation");
|
2359
|
-
attrib("name", aggr.name);
|
2360
|
-
attrib("singularName", aggr.singularName); // TODO omit default?
|
2361
|
-
attrib("type", aggr.type, 'sap.ui.core.Control');
|
2362
|
-
if ( aggr.altTypes ) {
|
2363
|
-
curr.altTypes = aggr.altTypes.slice();
|
2364
|
-
}
|
2365
|
-
attrib("cardinality", aggr.cardinality, '0..n');
|
2366
|
-
attrib("visibility", aggr.visibility, 'public');
|
2367
|
-
if ( aggr.since ) {
|
2368
|
-
attrib("since", extractVersion(aggr.since));
|
2369
|
-
}
|
2370
|
-
if ( aggr.bindable ) {
|
2371
|
-
attrib("bindable", aggr.bindable, false, /* raw = */true);
|
2372
|
-
}
|
2373
|
-
if ( aggr.dnd ) {
|
2374
|
-
curr.dnd = aggr.dnd;
|
2375
|
-
}
|
2376
|
-
tag("description", normalizeWS(aggr.doc), true);
|
2377
|
-
tagWithSince("experimental", aggr.experimental);
|
2378
|
-
tagWithSince("deprecated", aggr.deprecation);
|
2379
|
-
methodList("methods", aggr.methods);
|
2380
|
-
closeTag("aggregation");
|
2381
|
-
}
|
2382
|
-
endCollection("aggregations");
|
2383
|
-
}
|
2384
|
-
|
2385
|
-
if ( metadata.defaultAggregation ) {
|
2386
|
-
tag("defaultAggregation", metadata.defaultAggregation);
|
2387
|
-
}
|
2388
|
-
|
2389
|
-
if ( metadata.associations && Object.keys(metadata.associations).length > 0 ) {
|
2390
|
-
collection("associations");
|
2391
|
-
for ( n in metadata.associations ) {
|
2392
|
-
var assoc = metadata.associations[n];
|
2393
|
-
tag("association");
|
2394
|
-
attrib("name", assoc.name);
|
2395
|
-
attrib("singularName", assoc.singularName); // TODO omit default?
|
2396
|
-
attrib("type", assoc.type, 'sap.ui.core.Control');
|
2397
|
-
attrib("cardinality", assoc.cardinality, '0..1');
|
2398
|
-
attrib("visibility", assoc.visibility, 'public');
|
2399
|
-
if ( assoc.since ) {
|
2400
|
-
attrib("since", extractVersion(assoc.since));
|
2401
|
-
}
|
2402
|
-
tag("description", normalizeWS(assoc.doc), true);
|
2403
|
-
tagWithSince("experimental", assoc.experimental);
|
2404
|
-
tagWithSince("deprecated", assoc.deprecation);
|
2405
|
-
methodList("methods", assoc.methods);
|
2406
|
-
closeTag("association");
|
2407
|
-
}
|
2408
|
-
endCollection("associations");
|
2409
|
-
}
|
2410
|
-
|
2411
|
-
if ( metadata.events && Object.keys(metadata.events).length > 0 ) {
|
2412
|
-
collection("events");
|
2413
|
-
for ( n in metadata.events ) {
|
2414
|
-
var event = metadata.events[n];
|
2415
|
-
tag("event");
|
2416
|
-
attrib("name", event.name);
|
2417
|
-
attrib("visibility", event.visibility, 'public');
|
2418
|
-
if ( event.since ) {
|
2419
|
-
attrib("since", extractVersion(event.since));
|
2420
|
-
}
|
2421
|
-
tag("description", normalizeWS(event.doc), true);
|
2422
|
-
tagWithSince("experimental", event.experimental);
|
2423
|
-
tagWithSince("deprecated", event.deprecation);
|
2424
|
-
if ( event.parameters && Object.keys(event.parameters).length > 0 ) {
|
2425
|
-
tag("parameters");
|
2426
|
-
for ( var pn in event.parameters ) {
|
2427
|
-
if ( event.parameters.hasOwnProperty(pn) ) {
|
2428
|
-
var param = event.parameters[pn];
|
2429
|
-
tag(pn);
|
2430
|
-
attrib("name", pn);
|
2431
|
-
attrib("type", param.type);
|
2432
|
-
if ( param.since ) {
|
2433
|
-
attrib("since", extractVersion(param.since));
|
2434
|
-
}
|
2435
|
-
tag("description", normalizeWS(param.doc), true);
|
2436
|
-
tagWithSince("experimental", param.experimental);
|
2437
|
-
tagWithSince("deprecated", param.deprecation);
|
2438
|
-
closeTag(pn);
|
2439
|
-
}
|
2440
|
-
}
|
2441
|
-
closeTag("parameters");
|
2442
|
-
}
|
2443
|
-
methodList("methods", event.methods);
|
2444
|
-
closeTag("event");
|
2445
|
-
}
|
2446
|
-
endCollection("events");
|
2447
|
-
}
|
2448
|
-
|
2449
|
-
if ( metadata.annotations && Object.keys(metadata.annotations).length > 0 ) {
|
2450
|
-
collection("annotations");
|
2451
|
-
for ( n in metadata.annotations ) {
|
2452
|
-
var anno = metadata.annotations[n];
|
2453
|
-
tag("annotation");
|
2454
|
-
attrib("name", anno.name);
|
2455
|
-
attrib("namespace", anno.namespace);
|
2456
|
-
if ( anno.target && anno.target.length > 0 ) {
|
2457
|
-
curr.target = anno.target.slice();
|
2458
|
-
}
|
2459
|
-
attrib("annotation", anno.annotation);
|
2460
|
-
attrib("defaultValue", anno.defaultValue);
|
2461
|
-
if ( anno.appliesTo && anno.appliesTo.length > 0 ) {
|
2462
|
-
curr.appliesTo = anno.appliesTo.slice();
|
2463
|
-
}
|
2464
|
-
if ( anno.since ) {
|
2465
|
-
attrib("since", extractVersion(anno.since));
|
2466
|
-
}
|
2467
|
-
tag("description", normalizeWS(anno.doc), true);
|
2468
|
-
tagWithSince("deprecated", anno.deprecation);
|
2469
|
-
closeTag("annotation");
|
2470
|
-
}
|
2471
|
-
endCollection("annotations");
|
2472
|
-
}
|
2473
|
-
|
2474
|
-
if ( metadata.designtime ) { // don't write falsy values
|
2475
|
-
tag("designtime", metadata.designtime);
|
2476
|
-
}
|
2477
|
-
|
2478
|
-
}
|
2479
|
-
|
2480
|
-
function writeParameterProperties(param, params) {
|
2481
|
-
var prefix = param.name + '.',
|
2482
|
-
altPrefix = isArrayType(param.type) ? param.name + '[].' : null,
|
2483
|
-
count = 0,
|
2484
|
-
i;
|
2485
|
-
|
2486
|
-
for ( i = 0; i < params.length; i++ ) {
|
2487
|
-
|
2488
|
-
var name = params[i].name;
|
2489
|
-
if ( altPrefix && name.lastIndexOf(altPrefix, 0) === 0 ) { // startsWith
|
2490
|
-
name = name.slice(altPrefix.length);
|
2491
|
-
} else if ( name.lastIndexOf(prefix, 0) === 0 ) { // startsWith
|
2492
|
-
if ( altPrefix ) {
|
2493
|
-
warning("Nested @param tag in the context of an array type is used without []-suffix", name);
|
2494
|
-
}
|
2495
|
-
name = name.slice(prefix.length);
|
2496
|
-
} else {
|
2497
|
-
continue;
|
2498
|
-
}
|
2499
|
-
|
2500
|
-
if ( name.indexOf('.') >= 0 ) {
|
2501
|
-
continue;
|
2502
|
-
}
|
2503
|
-
|
2504
|
-
if ( count === 0 ) {
|
2505
|
-
tag("parameterProperties");
|
2506
|
-
}
|
2507
|
-
|
2508
|
-
count++;
|
2509
|
-
|
2510
|
-
tag(name);
|
2511
|
-
attrib("name", name);
|
2512
|
-
attrib("type", listTypes(params[i].type));
|
2513
|
-
attrib("optional", !!params[i].optional, false, /* raw = */true);
|
2514
|
-
if ( params[i].defaultvalue !== undefined ) {
|
2515
|
-
attrib("defaultValue", params[i].defaultvalue, undefined, /* raw = */true);
|
2516
|
-
}
|
2517
|
-
if ( params[i].since ) {
|
2518
|
-
attrib("since", extractVersion(params[i].since));
|
2519
|
-
}
|
2520
|
-
|
2521
|
-
writeParameterProperties(params[i], params);
|
2522
|
-
|
2523
|
-
tag("description", normalizeWS(params[i].description), true);
|
2524
|
-
tagWithSince("experimental", params[i].experimental);
|
2525
|
-
tagWithSince("deprecated", params[i].deprecated);
|
2526
|
-
|
2527
|
-
closeTag(name);
|
2528
|
-
}
|
2529
|
-
|
2530
|
-
if ( count > 0 ) {
|
2531
|
-
closeTag("parameterProperties");
|
2532
|
-
}
|
2533
|
-
}
|
2534
|
-
|
2535
|
-
function methodSignature(member) {
|
2536
|
-
var returns = member.returns && member.returns.length && member.returns[0];
|
2537
|
-
var type = member.type || (returns && returns.type);
|
2538
|
-
type = listTypes(type);
|
2539
|
-
//if ( type && type !== 'void' ) {
|
2540
|
-
// attrib("type", type, 'void');
|
2541
|
-
//}
|
2542
|
-
if ( type && type !== 'void' || returns && returns.description ) {
|
2543
|
-
tag("returnValue");
|
2544
|
-
if ( type && type !== 'void' ) {
|
2545
|
-
attrib("type", type);
|
2546
|
-
}
|
2547
|
-
if ( returns && returns.description ) {
|
2548
|
-
attrib("description", normalizeWS(returns.description));
|
2549
|
-
}
|
2550
|
-
closeTag("returnValue");
|
2551
|
-
}
|
2552
|
-
|
2553
|
-
if ( member.params && member.params.length > 0 ) {
|
2554
|
-
collection("parameters");
|
2555
|
-
for ( j = 0; j < member.params.length; j++) {
|
2556
|
-
param = member.params[j];
|
2557
|
-
if ( param.name.indexOf('.') >= 0 ) {
|
2558
|
-
continue;
|
2559
|
-
}
|
2560
|
-
tag("parameter");
|
2561
|
-
attrib("name", param.name);
|
2562
|
-
attrib("type", listTypes(param.type));
|
2563
|
-
attrib("optional", !!param.optional, false, /* raw = */true);
|
2564
|
-
if ( param.defaultvalue !== undefined ) {
|
2565
|
-
attrib("defaultValue", param.defaultvalue, undefined, /* raw = */true);
|
2566
|
-
}
|
2567
|
-
if ( param.since ) {
|
2568
|
-
attrib("since", extractVersion(param.since));
|
2569
|
-
}
|
2570
|
-
writeParameterProperties(param, member.params);
|
2571
|
-
tag("description", normalizeWS(param.description), true);
|
2572
|
-
tagWithSince("experimental", param.experimental);
|
2573
|
-
tagWithSince("deprecated", param.deprecated);
|
2574
|
-
closeTag("parameter");
|
2575
|
-
}
|
2576
|
-
endCollection("parameters");
|
2577
|
-
}
|
2578
|
-
|
2579
|
-
exceptions(member);
|
2580
|
-
|
2581
|
-
}
|
2582
|
-
|
2583
|
-
function writeMethod(member, name) {
|
2584
|
-
tag("method");
|
2585
|
-
attrib("name", name || member.name);
|
2586
|
-
if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) {
|
2587
|
-
attrib("module", member.__ui5.module);
|
2588
|
-
attrib("export", undefined, '', true);
|
2589
|
-
}
|
2590
|
-
attrib("visibility", visibility(member), 'public');
|
2591
|
-
if ( member.scope === 'static' ) {
|
2592
|
-
attrib("static", true, false, /* raw = */true);
|
2593
|
-
}
|
2594
|
-
if ( member.since ) {
|
2595
|
-
attrib("since", extractVersion(member.since));
|
2596
|
-
}
|
2597
|
-
if ( member.tags && member.tags.some(function(tag) { return tag.title === 'ui5-metamodel'; }) ) {
|
2598
|
-
attrib('ui5-metamodel', true, false, /* raw = */true);
|
2599
|
-
}
|
2600
|
-
|
2601
|
-
methodSignature(member);
|
2602
|
-
|
2603
|
-
tag("description", normalizeWS(member.description), true);
|
2604
|
-
tagWithSince("experimental", member.experimental);
|
2605
|
-
tagWithSince("deprecated", member.deprecated);
|
2606
|
-
examples(member);
|
2607
|
-
referencesList(member);
|
2608
|
-
//secTags(member);
|
2609
|
-
if ( member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource ) {
|
2610
|
-
attrib("resource", member.__ui5.resource);
|
2611
|
-
}
|
2612
|
-
closeTag("method");
|
2613
|
-
|
2614
|
-
}
|
2615
|
-
|
2616
|
-
/*
|
2617
|
-
var rSplitSecTag = /^\s*\{([^\}]*)\}/;
|
2618
|
-
|
2619
|
-
function secTags($) {
|
2620
|
-
if ( true ) {
|
2621
|
-
return;
|
2622
|
-
}
|
2623
|
-
var aTags = $.tags;
|
2624
|
-
if ( !aTags ) {
|
2625
|
-
return;
|
2626
|
-
}
|
2627
|
-
for (var iTag = 0; iTag < A_SECURITY_TAGS.length; iTag++ ) {
|
2628
|
-
var oTagDef = A_SECURITY_TAGS[iTag];
|
2629
|
-
for (var j = 0; j < aTags.length; j++ ) {
|
2630
|
-
if ( aTags[j].title.toLowerCase() === oTagDef.name.toLowerCase() ) {
|
2631
|
-
tag(oTagDef.name);
|
2632
|
-
var m = rSplitSecTag.exec(aTags[j].text);
|
2633
|
-
if ( m && m[1].trim() ) {
|
2634
|
-
var aParams = m[1].trim().split(/\s*\|\s* /); <-- remember to remove the space!
|
2635
|
-
for (var iParam = 0; iParam < aParams.length; iParam++ ) {
|
2636
|
-
tag(oTagDef.params[iParam], aParams[iParam]);
|
2637
|
-
}
|
2638
|
-
}
|
2639
|
-
var sDesc = aTags[j].description;
|
2640
|
-
tag("description", sDesc, true);
|
2641
|
-
closeTag(oTagDef.name);
|
2642
|
-
}
|
2643
|
-
}
|
2644
|
-
}
|
2645
|
-
}
|
2646
|
-
*/
|
2647
|
-
|
2648
|
-
var kind = (symbol.kind === 'member' && symbol.isEnum) ? "enum" : symbol.kind; // handle pseudo-kind 'enum'
|
2649
|
-
|
2650
|
-
tag(kind);
|
2651
|
-
|
2652
|
-
attrib("name", symbol.longname);
|
2653
|
-
attrib("basename", symbol.name);
|
2654
|
-
if (symbol.tagname) {
|
2655
|
-
attrib("tagname", symbol.tagname);
|
2656
|
-
}
|
2657
|
-
if (symbol.appenddocs) {
|
2658
|
-
attrib("appenddocs", symbol.appenddocs);
|
2659
|
-
}
|
2660
|
-
if ( symbol.__ui5.resource ) {
|
2661
|
-
attrib("resource", symbol.__ui5.resource);
|
2662
|
-
}
|
2663
|
-
if ( symbol.__ui5.module ) {
|
2664
|
-
attrib("module", symbol.__ui5.module);
|
2665
|
-
attrib("export", undefined, '', true);
|
2666
|
-
}
|
2667
|
-
if ( symbol.virtual ) {
|
2668
|
-
attrib("abstract", true, false, /* raw = */true);
|
2669
|
-
}
|
2670
|
-
if ( symbol.final_ ) {
|
2671
|
-
attrib("final", true, false, /* raw = */true);
|
2672
|
-
}
|
2673
|
-
if ( symbol.scope === 'static' ) {
|
2674
|
-
attrib("static", true, false, /* raw = */true);
|
2675
|
-
}
|
2676
|
-
attrib("visibility", visibility(symbol), 'public');
|
2677
|
-
if ( symbol.since ) {
|
2678
|
-
attrib("since", extractVersion(symbol.since));
|
2679
|
-
}
|
2680
|
-
if ( symbol.augments && symbol.augments.length ) {
|
2681
|
-
tag("extends", symbol.augments.sort().join(",")); // TODO what about multiple inheritance?
|
2682
|
-
}
|
2683
|
-
interfaceList("implements", symbol.implements);
|
2684
|
-
tag("description", normalizeWS(symbol.classdesc || (symbol.kind === 'class' ? '' : symbol.description)), true);
|
2685
|
-
tagWithSince("experimental", symbol.experimental);
|
2686
|
-
tagWithSince("deprecated", symbol.deprecated);
|
2687
|
-
if ( symbol.tags && symbol.tags.some(function(tag) { return tag.title === 'ui5-metamodel'; }) ) {
|
2688
|
-
attrib('ui5-metamodel', true, false, /* raw = */true);
|
2689
|
-
}
|
2690
|
-
|
2691
|
-
var skipMembers = false;
|
2692
|
-
var i, j, member, param;
|
2693
|
-
|
2694
|
-
if ( kind === 'class' ) {
|
2695
|
-
|
2696
|
-
if ( symbol.__ui5.stereotype || hasSettings(symbol) ) {
|
2697
|
-
|
2698
|
-
tag("ui5-metadata");
|
2699
|
-
|
2700
|
-
if ( symbol.__ui5.stereotype ) {
|
2701
|
-
attrib("stereotype", symbol.__ui5.stereotype);
|
2702
|
-
}
|
2703
|
-
|
2704
|
-
writeMetadata(symbol);
|
2705
|
-
|
2706
|
-
closeTag("ui5-metadata");
|
2707
|
-
}
|
2708
|
-
|
2709
|
-
|
2710
|
-
// IF @hideconstructor tag is present we omit the whole constructor
|
2711
|
-
if ( !symbol.hideconstructor ) {
|
2712
|
-
|
2713
|
-
tag("constructor");
|
2714
|
-
attrib("visibility", visibility(symbol));
|
2715
|
-
if (symbol.params && symbol.params.length > 0) {
|
2716
|
-
collection("parameters");
|
2717
|
-
for (j = 0; j < symbol.params.length; j++) {
|
2718
|
-
param = symbol.params[j];
|
2719
|
-
if (param.name.indexOf('.') >= 0) {
|
2720
|
-
continue;
|
2721
|
-
}
|
2722
|
-
tag("parameter");
|
2723
|
-
attrib("name", param.name);
|
2724
|
-
attrib("type", listTypes(param.type));
|
2725
|
-
attrib("optional", !!param.optional, false, /* raw = */true);
|
2726
|
-
if (param.defaultvalue !== undefined) {
|
2727
|
-
attrib("defaultValue", param.defaultvalue, undefined, /* raw = */true);
|
2728
|
-
}
|
2729
|
-
if (param.since) {
|
2730
|
-
attrib("since", extractVersion(param.since));
|
2731
|
-
}
|
2732
|
-
|
2733
|
-
writeParameterProperties(param, symbol.params);
|
2734
|
-
tag("description", normalizeWS(param.description), true);
|
2735
|
-
tagWithSince("experimental", param.experimental);
|
2736
|
-
tagWithSince("deprecated", param.deprecated);
|
2737
|
-
closeTag("parameter");
|
2738
|
-
}
|
2739
|
-
endCollection("parameters");
|
2740
|
-
}
|
2741
|
-
exceptions(symbol);
|
2742
|
-
tag("description", normalizeWS(symbol.description), true);
|
2743
|
-
// tagWithSince("experimental", symbol.experimental); // TODO repeat from class?
|
2744
|
-
// tagWithSince("deprecated", symbol.deprecated); // TODO repeat from class?
|
2745
|
-
examples(symbol); // TODO here or for class?
|
2746
|
-
referencesList(symbol); // TODO here or for class?
|
2747
|
-
// secTags(symbol); // TODO repeat from class?
|
2748
|
-
closeTag("constructor");
|
2749
|
-
|
2750
|
-
}
|
2751
|
-
} else if ( kind === 'namespace' ) {
|
2752
|
-
if ( symbol.__ui5.stereotype || symbol.__ui5.metadata ) {
|
2753
|
-
tag("ui5-metadata");
|
2754
|
-
|
2755
|
-
if ( symbol.__ui5.stereotype ) {
|
2756
|
-
attrib("stereotype", symbol.__ui5.stereotype);
|
2757
|
-
}
|
2758
|
-
|
2759
|
-
if ( symbol.__ui5.metadata && symbol.__ui5.metadata.basetype ) {
|
2760
|
-
attrib("basetype", symbol.__ui5.metadata.basetype);
|
2761
|
-
}
|
2762
|
-
|
2763
|
-
if ( symbol.__ui5.metadata && symbol.__ui5.metadata.pattern ) {
|
2764
|
-
attrib("pattern", symbol.__ui5.metadata.pattern);
|
2765
|
-
}
|
2766
|
-
|
2767
|
-
if ( symbol.__ui5.metadata && symbol.__ui5.metadata.range ) {
|
2768
|
-
attrib("range", symbol.__ui5.metadata.range, null, /* raw = */ true);
|
2769
|
-
}
|
2770
|
-
|
2771
|
-
closeTag("ui5-metadata");
|
2772
|
-
}
|
2773
|
-
} else if ( kind === 'typedef' ) {
|
2774
|
-
// typedefs have their own property structure
|
2775
|
-
skipMembers = true;
|
2776
|
-
if ( symbol.properties && symbol.properties.length > 0 ) {
|
2777
|
-
collection("properties");
|
2778
|
-
symbol.properties.forEach(function(prop) {
|
2779
|
-
tag("property");
|
2780
|
-
attrib("name", prop.name);
|
2781
|
-
attrib("type", listTypes(prop.type));
|
2782
|
-
attrib("readonly", prop.readonly);
|
2783
|
-
attrib("visibility", visibility(symbol), 'public'); // properties inherit visibility of typedef
|
2784
|
-
tag("description", normalizeWS(prop.description), true);
|
2785
|
-
closeTag("property")
|
2786
|
-
});
|
2787
|
-
endCollection("properties");
|
2788
|
-
}
|
2789
|
-
} else if ( kind === 'function' ) {
|
2790
|
-
methodSignature(symbol);
|
2791
|
-
}
|
2792
|
-
|
2793
|
-
if ( !skipMembers ) {
|
2794
|
-
var ownProperties = childrenOfKind(symbol, "property").own.sort(sortByAlias);
|
2795
|
-
if ( ownProperties.length > 0 ) {
|
2796
|
-
collection("properties");
|
2797
|
-
for ( i = 0; i < ownProperties.length; i++ ) {
|
2798
|
-
member = ownProperties[i];
|
2799
|
-
if (!member.slot) {
|
2800
|
-
tag("property");
|
2801
|
-
attrib("name", member.name);
|
2802
|
-
if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) {
|
2803
|
-
attrib("module", member.__ui5.module);
|
2804
|
-
attrib("export", undefined, '', true);
|
2805
|
-
}
|
2806
|
-
|
2807
|
-
if (member.noattribute) {
|
2808
|
-
attrib("noattribute", true);
|
2809
|
-
}
|
2810
|
-
|
2811
|
-
if (member.readonly) {
|
2812
|
-
attrib("readonly", member.readonly, null);
|
2813
|
-
}
|
2814
|
-
|
2815
|
-
attrib("visibility", visibility(member), 'public');
|
2816
|
-
if ( member.scope === 'static' ) {
|
2817
|
-
attrib("static", true, false, /* raw = */true);
|
2818
|
-
}
|
2819
|
-
if ( member.since ) {
|
2820
|
-
attrib("since", extractVersion(member.since));
|
2821
|
-
}
|
2822
|
-
|
2823
|
-
if ( member.formEvents ) {
|
2824
|
-
attrib("formEvents", member.formEvents);
|
2825
|
-
}
|
2826
|
-
|
2827
|
-
if ( member.formEvents ) {
|
2828
|
-
attrib("formProperty", member.formProperty);
|
2829
|
-
}
|
2830
|
-
|
2831
|
-
var type = listTypes(member.type);
|
2832
|
-
attrib("type", type);
|
2833
|
-
|
2834
|
-
if ((type === "object" || type === "Object") && visibility(member) === "public") {
|
2835
|
-
attrib("noattribute", true);
|
2836
|
-
}
|
2837
|
-
|
2838
|
-
tag("description", normalizeWS(member.description), true);
|
2839
|
-
if (member.defaultvalue) {
|
2840
|
-
attrib("defaultValue", member.defaultvalue);
|
2841
|
-
}
|
2842
|
-
|
2843
|
-
tagWithSince("experimental", member.experimental);
|
2844
|
-
tagWithSince("deprecated", member.deprecated);
|
2845
|
-
examples(member);
|
2846
|
-
referencesList(member);
|
2847
|
-
if ( member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource ) {
|
2848
|
-
attrib("resource", member.__ui5.resource);
|
2849
|
-
}
|
2850
|
-
closeTag("property");
|
2851
|
-
}
|
2852
|
-
}
|
2853
|
-
endCollection("properties");
|
2854
|
-
collection("slots");
|
2855
|
-
for (i = 0; i < ownProperties.length; i++) {
|
2856
|
-
member = ownProperties[i];
|
2857
|
-
if (member.slot) {
|
2858
|
-
tag("property");
|
2859
|
-
attrib("name", member.name);
|
2860
|
-
if (member.propertyName) {
|
2861
|
-
attrib("propertyName", member.propertyName);
|
2862
|
-
}
|
2863
|
-
if (member.__ui5.module && member.__ui5.module !== symbol.__ui5.module) {
|
2864
|
-
attrib("module", member.__ui5.module);
|
2865
|
-
attrib("export", undefined, '', true);
|
2866
|
-
}
|
2867
|
-
attrib("visibility", visibility(member), 'public');
|
2868
|
-
if (member.scope === 'static') {
|
2869
|
-
attrib("static", true, false, /* raw = */true);
|
2870
|
-
}
|
2871
|
-
if (member.since) {
|
2872
|
-
attrib("since", extractVersion(member.since));
|
2873
|
-
}
|
2874
|
-
attrib("type", listTypes(member.type));
|
2875
|
-
tag("description", normalizeWS(member.description), true);
|
2876
|
-
if (member.defaultvalue) {
|
2877
|
-
attrib("defaultValue", member.defaultvalue);
|
2878
|
-
}
|
2879
|
-
|
2880
|
-
tagWithSince("experimental", member.experimental);
|
2881
|
-
tagWithSince("deprecated", member.deprecated);
|
2882
|
-
examples(member);
|
2883
|
-
referencesList(member);
|
2884
|
-
if (member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource) {
|
2885
|
-
attrib("resource", member.__ui5.resource);
|
2886
|
-
}
|
2887
|
-
closeTag("property");
|
2888
|
-
}
|
2889
|
-
}
|
2890
|
-
endCollection("slots");
|
2891
|
-
}
|
2892
|
-
|
2893
|
-
var ownEvents = childrenOfKind(symbol, 'event').own.sort(sortByAlias);
|
2894
|
-
if ( ownEvents.length > 0 ) {
|
2895
|
-
collection("events");
|
2896
|
-
for (i = 0; i < ownEvents.length; i++ ) {
|
2897
|
-
member = ownEvents[i];
|
2898
|
-
tag("event");
|
2899
|
-
attrib("name", member.name);
|
2900
|
-
if ( member.__ui5.module && member.__ui5.module !== symbol.__ui5.module ) {
|
2901
|
-
attrib("module", member.__ui5.module);
|
2902
|
-
attrib("export", undefined, '', true);
|
2903
|
-
}
|
2904
|
-
if (member.allowPreventDefault) {
|
2905
|
-
attrib("allowPreventDefault", true);
|
2906
|
-
}
|
2907
|
-
if (member.native) {
|
2908
|
-
attrib("native", true);
|
2909
|
-
}
|
2910
|
-
attrib("visibility", visibility(member), 'public');
|
2911
|
-
if ( member.scope === 'static' ) {
|
2912
|
-
attrib("static", true, false, /* raw = */true);
|
2913
|
-
}
|
2914
|
-
if ( member.since ) {
|
2915
|
-
attrib("since", extractVersion(member.since));
|
2916
|
-
}
|
2917
|
-
|
2918
|
-
if ( member.params && member.params.length > 0 ) {
|
2919
|
-
collection("parameters");
|
2920
|
-
for (j = 0; j < member.params.length; j++) {
|
2921
|
-
param = member.params[j];
|
2922
|
-
if ( param.name.indexOf('.') >= 0 ) {
|
2923
|
-
continue;
|
2924
|
-
}
|
2925
|
-
|
2926
|
-
tag("parameter");
|
2927
|
-
attrib("name", param.name);
|
2928
|
-
attrib("type", listTypes(param.type));
|
2929
|
-
if ( param.since ) {
|
2930
|
-
attrib("since", extractVersion(param.since));
|
2931
|
-
}
|
2932
|
-
writeParameterProperties(param, member.params);
|
2933
|
-
tag("description", normalizeWS(param.description), true);
|
2934
|
-
tagWithSince("experimental", param.experimental);
|
2935
|
-
tagWithSince("deprecated", param.deprecated);
|
2936
|
-
closeTag("parameter");
|
2937
|
-
}
|
2938
|
-
endCollection("parameters");
|
2939
|
-
}
|
2940
|
-
tag("description", normalizeWS(member.description), true);
|
2941
|
-
tagWithSince("deprecated", member.deprecated);
|
2942
|
-
tagWithSince("experimental", member.experimental);
|
2943
|
-
examples(member);
|
2944
|
-
referencesList(member);
|
2945
|
-
//secTags(member);
|
2946
|
-
if ( member.__ui5.resource && member.__ui5.resource !== symbol.__ui5.resource ) {
|
2947
|
-
attrib("resource", member.__ui5.resource);
|
2948
|
-
}
|
2949
|
-
closeTag("event");
|
2950
|
-
}
|
2951
|
-
endCollection("events");
|
2952
|
-
}
|
2953
|
-
|
2954
|
-
var ownMethods = childrenOfKind(symbol, 'method').own.sort(sortByAlias);
|
2955
|
-
if ( ownMethods.length > 0 ) {
|
2956
|
-
collection("methods");
|
2957
|
-
for ( i = 0; i < ownMethods.length; i++ ) {
|
2958
|
-
member = ownMethods[i];
|
2959
|
-
writeMethod(member);
|
2960
|
-
if ( member.__ui5.members ) {
|
2961
|
-
// HACK: export nested static functions as siblings of the current function
|
2962
|
-
// A correct representation has to be discussed with the SDK / WebIDE
|
2963
|
-
member.__ui5.members.forEach(function($) {
|
2964
|
-
if ( $.kind === 'function' && $.scope === 'static'
|
2965
|
-
&& conf.filter($) && !$.inherited ) {
|
2966
|
-
console.error("exporting nested function '" + member.name + "." + $.name + "'");
|
2967
|
-
writeMethod($, member.name + "." + $.name);
|
2968
|
-
}
|
2969
|
-
});
|
2970
|
-
}
|
2971
|
-
}
|
2972
|
-
endCollection("methods");
|
2973
|
-
}
|
2974
|
-
|
2975
|
-
// if ( roots && symbol.__ui5.children && symbol.__ui5.children.length ) {
|
2976
|
-
// collection("children", "kind");
|
2977
|
-
// symbol.__ui5.children.forEach(writeSymbol);
|
2978
|
-
// endCollection("children");
|
2979
|
-
// }
|
2980
|
-
}
|
2981
|
-
|
2982
|
-
closeTag(kind);
|
2983
|
-
|
2984
|
-
return obj[0];
|
2985
|
-
}
|
2986
|
-
|
2987
|
-
function postProcessAPIJSON(api) {
|
2988
|
-
var modules = {};
|
2989
|
-
var symbols = api.symbols;
|
2990
|
-
var i,j,n,symbol,defaultExport;
|
2991
|
-
|
2992
|
-
// collect modules and the symbols that refer to them
|
2993
|
-
for ( i = 0; i < symbols.length; i++) {
|
2994
|
-
symbol = symbols[i];
|
2995
|
-
if ( symbol.module ) {
|
2996
|
-
modules[symbol.module] = modules[symbol.module] || [];
|
2997
|
-
modules[symbol.module].push({
|
2998
|
-
name: symbol.name,
|
2999
|
-
symbol: symbol
|
3000
|
-
});
|
3001
|
-
}
|
3002
|
-
if ( symbol.properties ) {
|
3003
|
-
for ( j = 0; j < symbol.properties.length; j++ ) {
|
3004
|
-
if ( symbol.properties[j].static && symbol.properties[j].module ) {
|
3005
|
-
modules[symbol.properties[j].module] = modules[symbol.properties[j].module] || [];
|
3006
|
-
modules[symbol.properties[j].module].push({
|
3007
|
-
name: symbol.name + "." + symbol.properties[j].name,
|
3008
|
-
symbol: symbol.properties[j]
|
3009
|
-
});
|
3010
|
-
}
|
3011
|
-
}
|
3012
|
-
}
|
3013
|
-
if ( symbol.methods ) {
|
3014
|
-
for ( j = 0; j < symbol.methods.length; j++ ) {
|
3015
|
-
if ( symbol.methods[j].static && symbol.methods[j].module ) {
|
3016
|
-
modules[symbol.methods[j].module] = modules[symbol.methods[j].module] || [];
|
3017
|
-
modules[symbol.methods[j].module].push({
|
3018
|
-
name: symbol.name + "." + symbol.methods[j].name,
|
3019
|
-
symbol: symbol.methods[j]
|
3020
|
-
});
|
3021
|
-
}
|
3022
|
-
}
|
3023
|
-
}
|
3024
|
-
}
|
3025
|
-
|
3026
|
-
for ( n in modules ) {
|
3027
|
-
|
3028
|
-
symbols = modules[n].sort(function(a,b) {
|
3029
|
-
if ( a.name === b.name ) {
|
3030
|
-
return 0;
|
3031
|
-
}
|
3032
|
-
return a.name < b.name ? -1 : 1;
|
3033
|
-
});
|
3034
|
-
|
3035
|
-
// info('resolving exports of ' + n + ": " + symbols.map(function(symbol) { return symbol.name; } ));
|
3036
|
-
var moduleNamePath = "module:" + n;
|
3037
|
-
if ( /^jquery\.sap\./.test(n) ) {
|
3038
|
-
// the jquery.sap.* modules all export 'jQuery'.
|
3039
|
-
// any API from those modules is reachable via 'jQuery.*'
|
3040
|
-
defaultExport = 'jQuery';
|
3041
|
-
} else {
|
3042
|
-
// library.js modules export the library namespace; for all other modules, the assumed default export
|
3043
|
-
// is identical to the name of the module (converted to a 'dot' name)
|
3044
|
-
defaultExport = n.replace(/\/library$/, "").replace(/\//g, ".");
|
3045
|
-
}
|
3046
|
-
|
3047
|
-
symbols.forEach(function(symbol) {
|
3048
|
-
// console.log("check ", symbol.name, "against", defaultExport, "and", moduleNamePath);
|
3049
|
-
if ( symbol.name === moduleNamePath ) {
|
3050
|
-
// symbol name is the same as the module namepath -> symbol is the default export
|
3051
|
-
symbol.symbol.export = "";
|
3052
|
-
} else if ( symbol.name.lastIndexOf(moduleNamePath + ".", 0) === 0 ) {
|
3053
|
-
// symbol name starts with the module namepath and a dot -> symbol is a named export (static)
|
3054
|
-
symbol.symbol.export = symbol.name.slice(moduleNamePath.length + 1);
|
3055
|
-
} else if ( symbol.name === defaultExport ) {
|
3056
|
-
// default export equals the symbol name
|
3057
|
-
symbol.symbol.export = "";
|
3058
|
-
//console.log(" (default):" + defaultExport);
|
3059
|
-
} else if ( symbol.name.lastIndexOf(defaultExport + ".", 0) === 0 ) {
|
3060
|
-
// default export is a prefix of the symbol name
|
3061
|
-
symbol.symbol.export = symbol.name.slice(defaultExport.length + 1);
|
3062
|
-
//console.log(" " + symbol.name.slice(defaultExport.length + 1) + ":" + symbol.name);
|
3063
|
-
} else {
|
3064
|
-
|
3065
|
-
// default export is not a prefix of the symbol name -> no way to access it in AMD
|
3066
|
-
symbol.symbol.export = undefined;
|
3067
|
-
if ( symbol.symbol.kind !== "namespace"
|
3068
|
-
|| (symbol.symbol.properties && symbol.symbol.properties.length > 0)
|
3069
|
-
|| (symbol.symbol.methods && symbol.symbol.methods.length > 0) ) {
|
3070
|
-
error("could not identify export name of '" + symbol.name + "', contained in module '" + n + "'");
|
3071
|
-
} else {
|
3072
|
-
debug("could not identify export name of namespace '" + symbol.name + "', contained in module '" + n + "'");
|
3073
|
-
}
|
3074
|
-
}
|
3075
|
-
});
|
3076
|
-
|
3077
|
-
}
|
3078
|
-
}
|
3079
|
-
|
3080
|
-
//---- add on: API XML -----------------------------------------------------------------
|
3081
|
-
|
3082
|
-
function createAPIXML(symbols, filename, options) {
|
3083
|
-
|
3084
|
-
options = options || {};
|
3085
|
-
var roots = options.roots || null;
|
3086
|
-
var legacyContent = !!options.legacyContent;
|
3087
|
-
var omitDefaults = !!options.omitDefaults;
|
3088
|
-
var addRedundancy = !!options.resolveInheritance;
|
3089
|
-
|
3090
|
-
var indent = 0;
|
3091
|
-
var output = [];
|
3092
|
-
var sIndent = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
|
3093
|
-
var tags = [];
|
3094
|
-
var ENUM = legacyContent ? "namespace" : "enum" ;
|
3095
|
-
var BASETYPE = legacyContent ? "baseType" : "extends";
|
3096
|
-
var PROPERTY = legacyContent ? "parameter" : "property";
|
3097
|
-
var unclosedStartTag = false;
|
3098
|
-
|
3099
|
-
function getAPIJSON(name) {
|
3100
|
-
|
3101
|
-
var symbol = lookup(name);
|
3102
|
-
if ( symbol && !symbol.synthetic ) {
|
3103
|
-
return createAPIJSON4Symbol(symbol, false);
|
3104
|
-
}
|
3105
|
-
if ( addRedundancy && externalSymbols[name] ) {
|
3106
|
-
debug(" using " + name + " from external dependency");
|
3107
|
-
return externalSymbols[name];
|
3108
|
-
}
|
3109
|
-
return symbol;
|
3110
|
-
}
|
3111
|
-
|
3112
|
-
function encode(s) {
|
3113
|
-
return s ? s.replace(/&/g, "&").replace(/</g, "<") : s;
|
3114
|
-
}
|
3115
|
-
|
3116
|
-
function write(args) {
|
3117
|
-
if ( arguments.length ) {
|
3118
|
-
for (var i = 0; i < arguments.length; i++)
|
3119
|
-
output.push(arguments[i]);
|
3120
|
-
}
|
3121
|
-
}
|
3122
|
-
|
3123
|
-
function writeln(args) {
|
3124
|
-
if ( indent > 0 )
|
3125
|
-
output.push(sIndent.slice(0,indent));
|
3126
|
-
if ( arguments.length ) {
|
3127
|
-
for (var i = 0; i < arguments.length; i++)
|
3128
|
-
output.push(arguments[i]);
|
3129
|
-
}
|
3130
|
-
output.push("\n");
|
3131
|
-
}
|
3132
|
-
|
3133
|
-
function rootTag(name) {
|
3134
|
-
tags = [];
|
3135
|
-
unclosedStartTag = false;
|
3136
|
-
tag(name);
|
3137
|
-
}
|
3138
|
-
|
3139
|
-
function closeRootTag(name) {
|
3140
|
-
closeTag(name);
|
3141
|
-
}
|
3142
|
-
|
3143
|
-
function namespace(alias, namespace) {
|
3144
|
-
attrib(alias, namespace);
|
3145
|
-
}
|
3146
|
-
|
3147
|
-
function tag(name, value, omitEmpty) {
|
3148
|
-
|
3149
|
-
if ( omitEmpty && !value ) {
|
3150
|
-
return;
|
3151
|
-
}
|
3152
|
-
if ( unclosedStartTag ) {
|
3153
|
-
unclosedStartTag = false;
|
3154
|
-
write('>\n');
|
3155
|
-
}
|
3156
|
-
if ( arguments.length === 1 ) { // opening tag
|
3157
|
-
if ( indent > 0 ) {
|
3158
|
-
output.push(sIndent.slice(0,indent));
|
3159
|
-
}
|
3160
|
-
write("<", name);
|
3161
|
-
unclosedStartTag = true;
|
3162
|
-
if ( legacyContent ) {
|
3163
|
-
unclosedStartTag = false;
|
3164
|
-
write(">\n");
|
3165
|
-
}
|
3166
|
-
tags.push(name);
|
3167
|
-
indent++;
|
3168
|
-
return;
|
3169
|
-
}
|
3170
|
-
if ( value == null ) {
|
3171
|
-
writeln("<", name, "/>");
|
3172
|
-
} else {
|
3173
|
-
writeln("<", name, ">", encode(String(value)), "</", name, ">");
|
3174
|
-
}
|
3175
|
-
}
|
3176
|
-
|
3177
|
-
function attrib(name, value, defaultValue) {
|
3178
|
-
var emptyTag = arguments.length === 1;
|
3179
|
-
if ( omitDefaults && arguments.length === 3 && value === defaultValue ) {
|
3180
|
-
return;
|
3181
|
-
}
|
3182
|
-
|
3183
|
-
if ( !legacyContent ) {
|
3184
|
-
write(" " + name + "=\"");
|
3185
|
-
write(emptyTag ? "true" : encode(String(value)).replace(/"/g, """));
|
3186
|
-
write("\"");
|
3187
|
-
} else {
|
3188
|
-
if ( emptyTag ) {
|
3189
|
-
writeln("<", name, "/>");
|
3190
|
-
} else {
|
3191
|
-
writeln("<", name, ">", encode(String(value)), "</", name, ">");
|
3192
|
-
}
|
3193
|
-
}
|
3194
|
-
}
|
3195
|
-
|
3196
|
-
function closeTag(name, noIndent) {
|
3197
|
-
|
3198
|
-
indent--;
|
3199
|
-
var top = tags.pop();
|
3200
|
-
if ( top != name ) {
|
3201
|
-
// ERROR?
|
3202
|
-
}
|
3203
|
-
|
3204
|
-
if ( unclosedStartTag ) {
|
3205
|
-
unclosedStartTag = false;
|
3206
|
-
write("/>\n");
|
3207
|
-
} else if ( noIndent ) {
|
3208
|
-
write("</", name, ">\n");
|
3209
|
-
} else {
|
3210
|
-
writeln("</", name, ">");
|
3211
|
-
}
|
3212
|
-
}
|
3213
|
-
|
3214
|
-
function textContent(text) {
|
3215
|
-
if ( unclosedStartTag ) {
|
3216
|
-
unclosedStartTag = false;
|
3217
|
-
write('>');
|
3218
|
-
}
|
3219
|
-
write(encode(text));
|
3220
|
-
}
|
3221
|
-
|
3222
|
-
function tagWithSince(tagName, prop) {
|
3223
|
-
if ( prop ) {
|
3224
|
-
tag(tagName);
|
3225
|
-
if ( prop.since ) {
|
3226
|
-
attrib("since", prop.since);
|
3227
|
-
}
|
3228
|
-
if ( prop.text && prop.text.trim() ) {
|
3229
|
-
textContent(prop.text);
|
3230
|
-
}
|
3231
|
-
closeTag(tagName, true);
|
3232
|
-
}
|
3233
|
-
}
|
3234
|
-
|
3235
|
-
function getAsString() {
|
3236
|
-
return output.join("");
|
3237
|
-
}
|
3238
|
-
|
3239
|
-
function writeMetadata(symbolAPI, inherited) {
|
3240
|
-
|
3241
|
-
var ui5Metadata = symbolAPI["ui5-metadata"];
|
3242
|
-
if ( !ui5Metadata ) {
|
3243
|
-
return;
|
3244
|
-
}
|
3245
|
-
|
3246
|
-
if ( addRedundancy && symbolAPI["extends"] ) {
|
3247
|
-
var baseSymbolAPI = getAPIJSON(symbolAPI["extends"]);
|
3248
|
-
if ( baseSymbolAPI ) {
|
3249
|
-
writeMetadata(baseSymbolAPI, true);
|
3250
|
-
}
|
3251
|
-
}
|
3252
|
-
|
3253
|
-
if ( ui5Metadata.specialSettings ) {
|
3254
|
-
ui5Metadata.specialSettings.forEach(function(special) {
|
3255
|
-
tag("specialSetting");
|
3256
|
-
attrib("name", special.name);
|
3257
|
-
attrib("type", special.type);
|
3258
|
-
attrib("visibility", special.visibility, 'public');
|
3259
|
-
if ( special.since ) {
|
3260
|
-
attrib("since", special.since);
|
3261
|
-
}
|
3262
|
-
if ( inherited ) {
|
3263
|
-
attrib("origin", symbolAPI.name);
|
3264
|
-
}
|
3265
|
-
tag("description", special.description, true);
|
3266
|
-
tagWithSince("experimental", special.experimental);
|
3267
|
-
tagWithSince("deprecated", special.deprecated);
|
3268
|
-
tag("methods", special.methods);
|
3269
|
-
closeTag("specialSetting");
|
3270
|
-
});
|
3271
|
-
}
|
3272
|
-
|
3273
|
-
if ( ui5Metadata.properties ) {
|
3274
|
-
ui5Metadata.properties.forEach(function(prop) {
|
3275
|
-
tag("property");
|
3276
|
-
attrib("name", prop.name);
|
3277
|
-
attrib("type", prop.type, 'string');
|
3278
|
-
if ( prop.defaultValue !== null ) {
|
3279
|
-
attrib("defaultValue", prop.defaultValue, null);
|
3280
|
-
}
|
3281
|
-
attrib("readonly", prop.readonly);
|
3282
|
-
attrib("visibility", prop.visibility, 'public');
|
3283
|
-
if ( prop.since ) {
|
3284
|
-
attrib("since", prop.since);
|
3285
|
-
}
|
3286
|
-
if ( prop.bindable ) {
|
3287
|
-
attrib("bindable", prop.bindable);
|
3288
|
-
}
|
3289
|
-
if ( inherited ) {
|
3290
|
-
attrib("origin", symbolAPI.name);
|
3291
|
-
}
|
3292
|
-
tag("description", prop.description, true);
|
3293
|
-
tagWithSince("experimental", prop.experimental);
|
3294
|
-
tagWithSince("deprecated", prop.deprecated);
|
3295
|
-
tag("methods", prop.methods);
|
3296
|
-
closeTag("property");
|
3297
|
-
});
|
3298
|
-
}
|
3299
|
-
|
3300
|
-
if ( ui5Metadata.defaultProperty ) {
|
3301
|
-
tag("defaultProperty", ui5Metadata.defaultProperty);
|
3302
|
-
}
|
3303
|
-
|
3304
|
-
if ( ui5Metadata.aggregations ) {
|
3305
|
-
ui5Metadata.aggregations.forEach(function(aggr) {
|
3306
|
-
tag("aggregation");
|
3307
|
-
attrib("name", aggr.name);
|
3308
|
-
attrib("singularName", aggr.singularName); // TODO omit default?
|
3309
|
-
attrib("type", aggr.type, 'sap.ui.core.Control');
|
3310
|
-
if ( aggr.altTypes ) {
|
3311
|
-
attrib("altTypes", aggr.altTypes.join(","));
|
3312
|
-
}
|
3313
|
-
attrib("cardinality", aggr.cardinality, '0..n');
|
3314
|
-
attrib("visibility", aggr.visibility, 'public');
|
3315
|
-
if ( aggr.since ) {
|
3316
|
-
attrib("since", aggr.since);
|
3317
|
-
}
|
3318
|
-
if ( aggr.bindable ) {
|
3319
|
-
attrib("bindable", aggr.bindable);
|
3320
|
-
}
|
3321
|
-
if ( inherited ) {
|
3322
|
-
attrib("origin", symbolAPI.name);
|
3323
|
-
}
|
3324
|
-
tag("description", aggr.description, true);
|
3325
|
-
tagWithSince("experimental", aggr.experimental);
|
3326
|
-
tagWithSince("deprecated", aggr.deprecated);
|
3327
|
-
tag("methods", aggr.methods);
|
3328
|
-
closeTag("aggregation");
|
3329
|
-
});
|
3330
|
-
}
|
3331
|
-
|
3332
|
-
if ( ui5Metadata.defaultAggregation ) {
|
3333
|
-
tag("defaultAggregation", ui5Metadata.defaultAggregation);
|
3334
|
-
}
|
3335
|
-
|
3336
|
-
if ( ui5Metadata.associations ) {
|
3337
|
-
ui5Metadata.associations.forEach(function(assoc) {
|
3338
|
-
tag("association");
|
3339
|
-
attrib("name", assoc.name);
|
3340
|
-
attrib("singularName", assoc.singularName); // TODO omit default?
|
3341
|
-
attrib("type", assoc.type, 'sap.ui.core.Control');
|
3342
|
-
attrib("cardinality", assoc.cardinality, '0..1');
|
3343
|
-
attrib("visibility", assoc.visibility, 'public');
|
3344
|
-
if ( assoc.since ) {
|
3345
|
-
attrib("since", assoc.since);
|
3346
|
-
}
|
3347
|
-
if ( inherited ) {
|
3348
|
-
attrib("origin", symbolAPI.name);
|
3349
|
-
}
|
3350
|
-
tag("description", assoc.description, true);
|
3351
|
-
tagWithSince("experimental", assoc.experimental);
|
3352
|
-
tagWithSince("deprecated", assoc.deprecated);
|
3353
|
-
tag("methods", assoc.methods);
|
3354
|
-
closeTag("association");
|
3355
|
-
});
|
3356
|
-
}
|
3357
|
-
|
3358
|
-
if ( ui5Metadata.events ) {
|
3359
|
-
ui5Metadata.events.forEach(function(event) {
|
3360
|
-
tag("event");
|
3361
|
-
attrib("name", event.name);
|
3362
|
-
attrib("visibility", event.visibility, 'public');
|
3363
|
-
if ( event.since ) {
|
3364
|
-
attrib("since", event.since);
|
3365
|
-
}
|
3366
|
-
if ( inherited ) {
|
3367
|
-
attrib("origin", symbolAPI.name);
|
3368
|
-
}
|
3369
|
-
tag("description", event.description, true);
|
3370
|
-
tagWithSince("experimental", event.experimental);
|
3371
|
-
tagWithSince("deprecated", event.deprecated);
|
3372
|
-
if ( event.parameters ) {
|
3373
|
-
tag("parameters");
|
3374
|
-
for ( var pn in event.parameters ) {
|
3375
|
-
if ( event.parameters.hasOwnProperty(pn) ) {
|
3376
|
-
var param = event.parameters[pn];
|
3377
|
-
|
3378
|
-
tag("parameter");
|
3379
|
-
attrib("name", param.name);
|
3380
|
-
attrib("type", param.type);
|
3381
|
-
if ( param.since ) {
|
3382
|
-
attrib("since", param.since);
|
3383
|
-
}
|
3384
|
-
tag("description", param.description, true);
|
3385
|
-
tagWithSince("experimental", param.experimental);
|
3386
|
-
tagWithSince("deprecated", param.deprecated);
|
3387
|
-
closeTag("parameter");
|
3388
|
-
}
|
3389
|
-
}
|
3390
|
-
closeTag("parameters");
|
3391
|
-
}
|
3392
|
-
tag("methods", event.methods, true);
|
3393
|
-
closeTag("event");
|
3394
|
-
});
|
3395
|
-
}
|
3396
|
-
|
3397
|
-
if ( ui5Metadata.annotations ) {
|
3398
|
-
ui5Metadata.annotations.forEach(function(anno) {
|
3399
|
-
tag("annotation");
|
3400
|
-
attrib("name", anno.name);
|
3401
|
-
attrib("namespace", anno.namespace); // TODO omit default?
|
3402
|
-
attrib("target", anno.target);
|
3403
|
-
attrib("annotation", anno.annotation);
|
3404
|
-
attrib("appliesTo", anno.appliesTo);
|
3405
|
-
if ( anno.since ) {
|
3406
|
-
attrib("since", anno.since);
|
3407
|
-
}
|
3408
|
-
tag("description", anno.description, true);
|
3409
|
-
tagWithSince("deprecated", anno.deprecated);
|
3410
|
-
closeTag("annotation");
|
3411
|
-
});
|
3412
|
-
}
|
3413
|
-
|
3414
|
-
}
|
3415
|
-
|
3416
|
-
function writeParameterPropertiesForMSettings(symbolAPI, inherited) {
|
3417
|
-
|
3418
|
-
var ui5Metadata = symbolAPI["ui5-metadata"];
|
3419
|
-
if ( !ui5Metadata ) {
|
3420
|
-
return;
|
3421
|
-
}
|
3422
|
-
|
3423
|
-
if ( symbolAPI["extends"] ) {
|
3424
|
-
var baseSymbolAPI = getAPIJSON(symbolAPI["extends"]);
|
3425
|
-
writeParameterPropertiesForMSettings(baseSymbolAPI, true);
|
3426
|
-
}
|
3427
|
-
|
3428
|
-
if ( ui5Metadata.specialSettings ) {
|
3429
|
-
ui5Metadata.specialSettings.forEach(function(special) {
|
3430
|
-
if ( special.visibility !== 'hidden' ) {
|
3431
|
-
tag("property");
|
3432
|
-
attrib("name", special.name);
|
3433
|
-
attrib("type", special.type);
|
3434
|
-
attrib("optional");
|
3435
|
-
if ( inherited ) {
|
3436
|
-
attrib("origin", symbolAPI.name);
|
3437
|
-
}
|
3438
|
-
tag("description", special.description, true);
|
3439
|
-
closeTag("property");
|
3440
|
-
}
|
3441
|
-
});
|
3442
|
-
}
|
3443
|
-
|
3444
|
-
if ( ui5Metadata.properties ) {
|
3445
|
-
ui5Metadata.properties.forEach(function(prop) {
|
3446
|
-
tag("property");
|
3447
|
-
attrib("name", prop.name);
|
3448
|
-
attrib("type", prop.type);
|
3449
|
-
attrib("group", prop.group, 'Misc');
|
3450
|
-
if ( prop.defaultValue !== null ) {
|
3451
|
-
attrib("defaultValue", typeof prop.defaultValue === 'string' ? "\"" + prop.defaultValue + "\"" : prop.defaultValue);
|
3452
|
-
}
|
3453
|
-
attrib("readonly", prop.readonly);
|
3454
|
-
attrib("optional");
|
3455
|
-
if ( inherited ) {
|
3456
|
-
attrib("origin", symbolAPI.name);
|
3457
|
-
}
|
3458
|
-
tag("description", prop.description, true);
|
3459
|
-
closeTag("property");
|
3460
|
-
});
|
3461
|
-
}
|
3462
|
-
|
3463
|
-
if ( ui5Metadata.aggregations ) {
|
3464
|
-
ui5Metadata.aggregations.forEach(function(aggr) {
|
3465
|
-
if ( aggr.visibility !== "hidden" ) {
|
3466
|
-
tag("property");
|
3467
|
-
attrib("name", aggr.name);
|
3468
|
-
attrib("type", aggr.type + (aggr.cardinality === '0..1' ? "" : "[]"));
|
3469
|
-
if ( aggr.altTypes ) {
|
3470
|
-
attrib("altTypes", aggr.altTypes.join(","));
|
3471
|
-
}
|
3472
|
-
attrib("optional");
|
3473
|
-
if ( inherited ) {
|
3474
|
-
attrib("origin", symbolAPI.name);
|
3475
|
-
}
|
3476
|
-
tag("description", aggr.description, true);
|
3477
|
-
closeTag("property");
|
3478
|
-
}
|
3479
|
-
});
|
3480
|
-
}
|
3481
|
-
|
3482
|
-
if ( ui5Metadata.associations ) {
|
3483
|
-
ui5Metadata.associations.forEach(function(assoc) {
|
3484
|
-
if ( assoc.visibility !== "hidden" ) {
|
3485
|
-
tag("property");
|
3486
|
-
attrib("name", assoc.name);
|
3487
|
-
attrib("type", "(" + assoc.type + "|" + "string)" + (assoc.cardinality === '0..1' ? "" : "[]"));
|
3488
|
-
attrib("optional");
|
3489
|
-
if ( inherited ) {
|
3490
|
-
attrib("origin", symbolAPI.name);
|
3491
|
-
}
|
3492
|
-
tag("description", assoc.description, true);
|
3493
|
-
closeTag("property");
|
3494
|
-
}
|
3495
|
-
});
|
3496
|
-
}
|
3497
|
-
|
3498
|
-
if ( ui5Metadata.events ) {
|
3499
|
-
ui5Metadata.events.forEach(function(event) {
|
3500
|
-
tag("property");
|
3501
|
-
attrib("name", event.name);
|
3502
|
-
attrib("type", "function|array");
|
3503
|
-
attrib("optional");
|
3504
|
-
if ( inherited ) {
|
3505
|
-
attrib("origin", symbolAPI.name);
|
3506
|
-
}
|
3507
|
-
tag("description", event.description, true);
|
3508
|
-
closeTag("property");
|
3509
|
-
});
|
3510
|
-
}
|
3511
|
-
|
3512
|
-
}
|
3513
|
-
|
3514
|
-
function writeParameterProperties(param, paramName) {
|
3515
|
-
var props = param.parameterProperties,
|
3516
|
-
prefix = paramName + '.',
|
3517
|
-
count = 0;
|
3518
|
-
|
3519
|
-
if ( props ) {
|
3520
|
-
for (var n in props ) {
|
3521
|
-
if ( props.hasOwnProperty(n) ) {
|
3522
|
-
|
3523
|
-
param = props[n];
|
3524
|
-
|
3525
|
-
if ( !legacyContent && count === 0 ) {
|
3526
|
-
tag("parameterProperties");
|
3527
|
-
}
|
3528
|
-
|
3529
|
-
count++;
|
3530
|
-
|
3531
|
-
tag(PROPERTY);
|
3532
|
-
attrib("name", legacyContent ? prefix + n : n);
|
3533
|
-
attrib("type", param.type);
|
3534
|
-
if ( param.since ) {
|
3535
|
-
attrib("since", param.since);
|
3536
|
-
}
|
3537
|
-
if ( param.optional ) {
|
3538
|
-
attrib("optional", param.optional);
|
3539
|
-
}
|
3540
|
-
|
3541
|
-
if ( !legacyContent ) {
|
3542
|
-
writeParameterProperties(param, prefix + n);
|
3543
|
-
}
|
3544
|
-
|
3545
|
-
tag("description", param.description, true);
|
3546
|
-
tagWithSince("experimental", param.experimental);
|
3547
|
-
tagWithSince("deprecated", param.deprecated);
|
3548
|
-
|
3549
|
-
closeTag(PROPERTY);
|
3550
|
-
|
3551
|
-
if ( legacyContent ) {
|
3552
|
-
writeParameterProperties(param, prefix + n);
|
3553
|
-
}
|
3554
|
-
}
|
3555
|
-
}
|
3556
|
-
}
|
3557
|
-
|
3558
|
-
if ( !legacyContent && count > 0 ) {
|
3559
|
-
closeTag("parameterProperties");
|
3560
|
-
}
|
3561
|
-
}
|
3562
|
-
|
3563
|
-
/*
|
3564
|
-
var rSplitSecTag = /^\s*\{([^\}]*)\}/;
|
3565
|
-
|
3566
|
-
function secTags($) {
|
3567
|
-
if ( !legacyContent ) {
|
3568
|
-
return;
|
3569
|
-
}
|
3570
|
-
var aTags = $.tags;
|
3571
|
-
if ( !aTags ) {
|
3572
|
-
return;
|
3573
|
-
}
|
3574
|
-
for (var iTag = 0; iTag < A_SECURITY_TAGS.length; iTag++ ) {
|
3575
|
-
var oTagDef = A_SECURITY_TAGS[iTag];
|
3576
|
-
for (var j = 0; j < aTags.length; j++ ) {
|
3577
|
-
if ( aTags[j].title.toLowerCase() === oTagDef.name.toLowerCase() ) {
|
3578
|
-
tag(oTagDef.name);
|
3579
|
-
var m = rSplitSecTag.exec(aTags[j].text);
|
3580
|
-
if ( m && m[1].trim() ) {
|
3581
|
-
var aParams = m[1].trim().split(/\s*\|\s* /); <-- remove the blank!
|
3582
|
-
for (var iParam = 0; iParam < aParams.length; iParam++ ) {
|
3583
|
-
tag(oTagDef.params[iParam], aParams[iParam]);
|
3584
|
-
}
|
3585
|
-
}
|
3586
|
-
var sDesc = aTags[j].description;
|
3587
|
-
tag("description", sDesc, true);
|
3588
|
-
closeTag(oTagDef.name);
|
3589
|
-
}
|
3590
|
-
}
|
3591
|
-
}
|
3592
|
-
}
|
3593
|
-
*/
|
3594
|
-
|
3595
|
-
function writeSymbol(symbol) {
|
3596
|
-
|
3597
|
-
var kind;
|
3598
|
-
|
3599
|
-
if ( isFirstClassSymbol(symbol) && (roots || !symbol.synthetic) ) { // dump a symbol if it as a class symbol and if either hierarchies are dumped or if it is not a synthetic symbol
|
3600
|
-
|
3601
|
-
// for the hierarchy we use only the local information
|
3602
|
-
var symbolAPI = createAPIJSON4Symbol(symbol);
|
3603
|
-
|
3604
|
-
kind = symbolAPI.kind === 'enum' ? ENUM : symbolAPI.kind;
|
3605
|
-
|
3606
|
-
tag(kind);
|
3607
|
-
|
3608
|
-
attrib("name", symbolAPI.name);
|
3609
|
-
attrib("basename", symbolAPI.basename);
|
3610
|
-
// if ( symbolAPI["resource"] ) {
|
3611
|
-
// attrib("resource");
|
3612
|
-
// }
|
3613
|
-
if ( symbolAPI["module"] ) {
|
3614
|
-
attrib("module", symbolAPI["module"]);
|
3615
|
-
}
|
3616
|
-
if ( symbolAPI["abstract"] ) {
|
3617
|
-
attrib("abstract");
|
3618
|
-
}
|
3619
|
-
if ( symbolAPI["final"] ) {
|
3620
|
-
attrib("final");
|
3621
|
-
}
|
3622
|
-
if ( symbolAPI["static"] ) {
|
3623
|
-
attrib("static");
|
3624
|
-
}
|
3625
|
-
attrib("visibility", symbolAPI.visibility, 'public');
|
3626
|
-
if ( symbolAPI.since ) {
|
3627
|
-
attrib("since", symbolAPI.since);
|
3628
|
-
}
|
3629
|
-
if ( symbolAPI["extends"] ) {
|
3630
|
-
tag(BASETYPE, symbolAPI["extends"]); // TODO what about multiple inheritance?
|
3631
|
-
}
|
3632
|
-
tag("description", symbolAPI.description, true);
|
3633
|
-
tagWithSince("experimental", symbolAPI.experimental);
|
3634
|
-
tagWithSince("deprecated", symbolAPI.deprecated);
|
3635
|
-
|
3636
|
-
if ( kind === 'class' ) {
|
3637
|
-
|
3638
|
-
var hasSettings = symbolAPI["ui5-metadata"];
|
3639
|
-
|
3640
|
-
if ( !legacyContent && symbolAPI["ui5-metadata"] ) {
|
3641
|
-
|
3642
|
-
tag("ui5-metadata");
|
3643
|
-
|
3644
|
-
if ( symbolAPI["ui5-metadata"].stereotype ) {
|
3645
|
-
attrib("stereotype", symbolAPI["ui5-metadata"].stereotype);
|
3646
|
-
}
|
3647
|
-
|
3648
|
-
writeMetadata(symbolAPI);
|
3649
|
-
|
3650
|
-
closeTag("ui5-metadata");
|
3651
|
-
|
3652
|
-
}
|
3653
|
-
|
3654
|
-
tag("constructor");
|
3655
|
-
if ( legacyContent ) {
|
3656
|
-
attrib("name", symbolAPI.basename);
|
3657
|
-
}
|
3658
|
-
attrib("visibility", symbolAPI.visibility, 'public');
|
3659
|
-
if ( symbolAPI.constructor.parameters ) {
|
3660
|
-
symbolAPI.constructor.parameters.forEach(function(param, j) {
|
3661
|
-
|
3662
|
-
tag("parameter");
|
3663
|
-
attrib("name", param.name);
|
3664
|
-
attrib("type", param.type);
|
3665
|
-
attrib("optional", param.optional, false);
|
3666
|
-
if ( param.defaultValue !== undefined ) {
|
3667
|
-
attrib("defaultValue", param.defaultValue);
|
3668
|
-
}
|
3669
|
-
if ( param.since ) {
|
3670
|
-
attrib("since", param.since);
|
3671
|
-
}
|
3672
|
-
|
3673
|
-
if ( !legacyContent ) {
|
3674
|
-
if ( hasSettings && j == 1 && /setting/i.test(param.name) && /object/i.test(param.type) ) {
|
3675
|
-
if ( addRedundancy ) {
|
3676
|
-
tag("parameterProperties");
|
3677
|
-
writeParameterPropertiesForMSettings(symbolAPI);
|
3678
|
-
closeTag("parameterProperties");
|
3679
|
-
}
|
3680
|
-
} else {
|
3681
|
-
writeParameterProperties(param, param.name);
|
3682
|
-
}
|
3683
|
-
}
|
3684
|
-
tag("description", param.description, true);
|
3685
|
-
tagWithSince("experimental", param.experimental);
|
3686
|
-
tagWithSince("deprecated", param.deprecated);
|
3687
|
-
closeTag("parameter");
|
3688
|
-
if ( legacyContent ) {
|
3689
|
-
writeParameterProperties(param, param.name);
|
3690
|
-
}
|
3691
|
-
});
|
3692
|
-
}
|
3693
|
-
|
3694
|
-
tag("description", getConstructorDescription(symbol), true);
|
3695
|
-
// tagWithSince("experimental", symbol.experimental); // TODO repeat from class?
|
3696
|
-
// tagWithSince("deprecated", symbol.deprecated); // TODO repeat from class?
|
3697
|
-
// secTags(symbol); // TODO repeat from class?
|
3698
|
-
closeTag("constructor");
|
3699
|
-
}
|
3700
|
-
|
3701
|
-
/* TODO MIGRATE or remove, if not needed
|
3702
|
-
var ownSubspaces = ( symbol.__ui5.children || [] ).filter(function($) { return $.kind === 'namespace' }).sort(sortByAlias);
|
3703
|
-
for (var i=0; i<ownSubspaces.length; i++) {
|
3704
|
-
var member = ownSubspaces[i];
|
3705
|
-
tag("namespace");
|
3706
|
-
tag("name", member.name);
|
3707
|
-
closeTag("namespace");
|
3708
|
-
}
|
3709
|
-
*/
|
3710
|
-
|
3711
|
-
if ( symbolAPI.properties ) {
|
3712
|
-
symbolAPI.properties.forEach(function(member) {
|
3713
|
-
tag("property");
|
3714
|
-
attrib("name", member.name);
|
3715
|
-
if ( member.module ) {
|
3716
|
-
attrib("module", member.module);
|
3717
|
-
}
|
3718
|
-
attrib("visibility", member.visibility, 'public');
|
3719
|
-
if ( member["static"] ) {
|
3720
|
-
attrib("static");
|
3721
|
-
}
|
3722
|
-
if ( member.since ) {
|
3723
|
-
attrib("since", member.since);
|
3724
|
-
}
|
3725
|
-
attrib("type", member.type);
|
3726
|
-
tag("description", member.description, true);
|
3727
|
-
tagWithSince("experimental", member.experimental);
|
3728
|
-
tagWithSince("deprecated", member.deprecated);
|
3729
|
-
closeTag("property");
|
3730
|
-
});
|
3731
|
-
}
|
3732
|
-
|
3733
|
-
if ( symbolAPI.events ) {
|
3734
|
-
symbolAPI.events.forEach(function(member) {
|
3735
|
-
tag("event");
|
3736
|
-
attrib("name", member.name);
|
3737
|
-
if ( member.module ) {
|
3738
|
-
attrib("module", member.module);
|
3739
|
-
}
|
3740
|
-
attrib("visibility", member.visibility, 'public');
|
3741
|
-
if ( member["static"] ) {
|
3742
|
-
attrib("static");
|
3743
|
-
}
|
3744
|
-
if ( member.since ) {
|
3745
|
-
attrib("since", member.since);
|
3746
|
-
}
|
3747
|
-
|
3748
|
-
if ( member.parameters ) {
|
3749
|
-
member.parameters.forEach(function(param) {
|
3750
|
-
|
3751
|
-
tag("parameter");
|
3752
|
-
attrib("name", param.name);
|
3753
|
-
attrib("type", param.type);
|
3754
|
-
if ( param.since ) {
|
3755
|
-
attrib("since", param.since);
|
3756
|
-
}
|
3757
|
-
if ( !legacyContent ) {
|
3758
|
-
writeParameterProperties(param, param.name);
|
3759
|
-
}
|
3760
|
-
tag("description", param.description, true);
|
3761
|
-
tagWithSince("experimental", param.experimental);
|
3762
|
-
tagWithSince("deprecated", param.deprecated);
|
3763
|
-
closeTag("parameter");
|
3764
|
-
if ( legacyContent ) {
|
3765
|
-
writeParameterProperties(param, param.name);
|
3766
|
-
}
|
3767
|
-
});
|
3768
|
-
}
|
3769
|
-
tag("description", member.description, true);
|
3770
|
-
tagWithSince("experimental", member.experimental);
|
3771
|
-
tagWithSince("deprecated", member.deprecated);
|
3772
|
-
// TODO secTags(member);
|
3773
|
-
closeTag("event");
|
3774
|
-
});
|
3775
|
-
}
|
3776
|
-
|
3777
|
-
if ( symbolAPI.methods ) {
|
3778
|
-
symbolAPI.methods.forEach(function(member) {
|
3779
|
-
|
3780
|
-
tag("method");
|
3781
|
-
attrib("name", member.name);
|
3782
|
-
if ( member.module ) {
|
3783
|
-
attrib("module", member.module);
|
3784
|
-
}
|
3785
|
-
attrib("visibility", member.visibility, 'public');
|
3786
|
-
if ( member["static"] ) {
|
3787
|
-
attrib("static");
|
3788
|
-
}
|
3789
|
-
if ( member.returnValue && member.returnValue.type ) {
|
3790
|
-
attrib("type", member.returnValue.type, 'void');
|
3791
|
-
}
|
3792
|
-
if ( member.since ) {
|
3793
|
-
attrib("since", member.since);
|
3794
|
-
}
|
3795
|
-
|
3796
|
-
if ( member.parameters ) {
|
3797
|
-
member.parameters.forEach(function(param) {
|
3798
|
-
|
3799
|
-
tag("parameter");
|
3800
|
-
attrib("name", param.name);
|
3801
|
-
attrib("type", param.type);
|
3802
|
-
if ( param.optional ) {
|
3803
|
-
attrib("optional", param.optional);
|
3804
|
-
}
|
3805
|
-
if ( param.defaultValue !== undefined ) {
|
3806
|
-
attrib("defaultValue", param.defaultValue);
|
3807
|
-
}
|
3808
|
-
if ( param.since ) {
|
3809
|
-
attrib("since", param.since);
|
3810
|
-
}
|
3811
|
-
if ( !legacyContent ) {
|
3812
|
-
writeParameterProperties(param, param.name);
|
3813
|
-
}
|
3814
|
-
tag("description", param.description, true);
|
3815
|
-
tagWithSince("experimental", param.experimental);
|
3816
|
-
tagWithSince("deprecated", param.deprecated);
|
3817
|
-
closeTag("parameter");
|
3818
|
-
if ( legacyContent ) {
|
3819
|
-
writeParameterProperties(param, param.name);
|
3820
|
-
}
|
3821
|
-
});
|
3822
|
-
}
|
3823
|
-
tag("description", member.description, true);
|
3824
|
-
tagWithSince("experimental", member.experimental);
|
3825
|
-
tagWithSince("deprecated", member.deprecated);
|
3826
|
-
// TODO secTags(member);
|
3827
|
-
closeTag("method");
|
3828
|
-
|
3829
|
-
});
|
3830
|
-
}
|
3831
|
-
|
3832
|
-
if ( roots && symbol.__ui5.children && symbol.__ui5.children.length ) {
|
3833
|
-
tag("children");
|
3834
|
-
symbol.__ui5.children.forEach(writeSymbol);
|
3835
|
-
closeTag("children");
|
3836
|
-
}
|
3837
|
-
|
3838
|
-
closeTag(kind);
|
3839
|
-
|
3840
|
-
}
|
3841
|
-
|
3842
|
-
}
|
3843
|
-
|
3844
|
-
writeln("<?xml version=\"1.0\" ?>");
|
3845
|
-
rootTag("api");
|
3846
|
-
if ( !legacyContent ) {
|
3847
|
-
namespace("xmlns", "http://www.sap.com/sap.ui.library.api.xsd");
|
3848
|
-
attrib("_version", "1.0.0");
|
3849
|
-
if ( templateConf.version ) {
|
3850
|
-
attrib("version", templateConf.version.replace(/-SNAPSHOT$/,""));
|
3851
|
-
}
|
3852
|
-
if ( templateConf.uilib ) {
|
3853
|
-
attrib("library", templateConf.uilib);
|
3854
|
-
}
|
3855
|
-
}
|
3856
|
-
|
3857
|
-
if ( roots ) {
|
3858
|
-
roots.forEach(writeSymbol);
|
3859
|
-
} else {
|
3860
|
-
// sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken
|
3861
|
-
symbols.slice(0).sort(sortByAlias).forEach(writeSymbol);
|
3862
|
-
}
|
3863
|
-
|
3864
|
-
closeRootTag("api");
|
3865
|
-
|
3866
|
-
fs.mkPath(path.dirname(filename));
|
3867
|
-
fs.writeFileSync(filename, getAsString(), 'utf8');
|
3868
|
-
}
|
3869
|
-
|
3870
|
-
//---- add on: API JS -----------------------------------------------------------------
|
3871
|
-
|
3872
|
-
function createAPIJS(symbols, filename) {
|
3873
|
-
|
3874
|
-
var output = [];
|
3875
|
-
|
3876
|
-
var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|formEvents|formProperty|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
|
3877
|
-
|
3878
|
-
function isNoKeyword($) { return !rkeywords.test($.name); }
|
3879
|
-
|
3880
|
-
function isAPI($) { return $.access === 'public' || $.access === 'protected' || !$.access }
|
3881
|
-
|
3882
|
-
function writeln(args) {
|
3883
|
-
if ( arguments.length ) {
|
3884
|
-
for (var i = 0; i < arguments.length; i++)
|
3885
|
-
output.push(arguments[i]);
|
3886
|
-
}
|
3887
|
-
output.push("\n");
|
3888
|
-
}
|
3889
|
-
|
3890
|
-
function unwrap(docletSrc) {
|
3891
|
-
if (!docletSrc) { return ''; }
|
3892
|
-
|
3893
|
-
// note: keep trailing whitespace for @examples
|
3894
|
-
// extra opening/closing stars are ignored
|
3895
|
-
// left margin is considered a star and a space
|
3896
|
-
// use the /m flag on regex to avoid having to guess what this platform's newline is
|
3897
|
-
docletSrc =
|
3898
|
-
docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars
|
3899
|
-
.replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker
|
3900
|
-
.replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker
|
3901
|
-
.replace(/\s*\\Z$/g, ''); // remove end-marker
|
3902
|
-
|
3903
|
-
return docletSrc;
|
3904
|
-
}
|
3905
|
-
|
3906
|
-
function comment($, sMetaType) {
|
3907
|
-
|
3908
|
-
var s = unwrap($.comment.toString());
|
3909
|
-
|
3910
|
-
// remove the @desc tag
|
3911
|
-
s = s.replace(/(\r\n|\r|\n)/gm, "\n");
|
3912
|
-
s = s.replace(/^\s*@desc\s*/gm, "");
|
3913
|
-
s = s.replace(/^\s*@alias[^\r\n]*(\r\n|\r|\n)?/gm, "");
|
3914
|
-
s = s.replace(/^\s*@name[^\r\n]*(\r\n|\r|\n)?/gm, "");
|
3915
|
-
s = s.replace(/^\s*@function[^\r\n]*(\r\n|\r|\n)?/gm, "");
|
3916
|
-
s = s.replace(/^\s*@author[^\r\n]*(\r\n|\r|\n)?/gm, "");
|
3917
|
-
s = s.replace(/^\s*@synthetic[^\r\n]*(\r\n|\r|\n)?/gm, "");
|
3918
|
-
s = s.replace(/^\s*<\/p><p>\s*(\r\n|\r|\n)?/gm, "\n");
|
3919
|
-
// skip empty documentation
|
3920
|
-
if ( !s ) return;
|
3921
|
-
|
3922
|
-
// for namespaces, enforce the @.memberof tag
|
3923
|
-
if ( sMetaType === "namespace" && $.memberof && s.indexOf("@memberof") < 0 ) {
|
3924
|
-
s = s + "\n@memberof " + $.memberof;
|
3925
|
-
}
|
3926
|
-
|
3927
|
-
writeln("/**\n * " + s.replace(/\n/g, "\n * ") + "\n */");
|
3928
|
-
|
3929
|
-
/*
|
3930
|
-
writeln("/**");
|
3931
|
-
writeln(s.split(/\r\n|\r|\n/g).map(function($) { return " * " + $;}).join("\r\n"));
|
3932
|
-
writeln(" * /");
|
3933
|
-
*/
|
3934
|
-
|
3935
|
-
}
|
3936
|
-
|
3937
|
-
function signature($) {
|
3938
|
-
var p = $.params,
|
3939
|
-
r = [],
|
3940
|
-
i;
|
3941
|
-
if ( p ) {
|
3942
|
-
for (i = 0; i < p.length; i++) {
|
3943
|
-
// ignore @param tags for 'virtual' params that are used to document members of config-like params
|
3944
|
-
// (e.g. like "@param param1.key ...")
|
3945
|
-
if (p[i].name && p[i].name.indexOf('.') < 0) {
|
3946
|
-
r.push(p[i].name);
|
3947
|
-
}
|
3948
|
-
}
|
3949
|
-
}
|
3950
|
-
return r.join(',');
|
3951
|
-
}
|
3952
|
-
|
3953
|
-
function qname(member,parent) {
|
3954
|
-
var r = member.memberof;
|
3955
|
-
if ( member.scope !== 'static' ) {
|
3956
|
-
r += ".prototype";
|
3957
|
-
}
|
3958
|
-
return (r ? r + "." : "") + member.name;
|
3959
|
-
}
|
3960
|
-
|
3961
|
-
var mValues = {
|
3962
|
-
"boolean" : "false",
|
3963
|
-
"int" : "0",
|
3964
|
-
"float" : "0.0",
|
3965
|
-
"number" : "0.0",
|
3966
|
-
"string" : "\"\"",
|
3967
|
-
"object" : "new Object()",
|
3968
|
-
"function" : "function() {}"
|
3969
|
-
};
|
3970
|
-
|
3971
|
-
function valueForType(type) {
|
3972
|
-
if ( type && type.names && type.names[0] ) {
|
3973
|
-
type = type.names[0];
|
3974
|
-
if ( REGEXP_ARRAY_TYPE.test(type) || type.indexOf("[]") > 0 ) {
|
3975
|
-
return "new Array()";
|
3976
|
-
} else if ( mValues[type] ) {
|
3977
|
-
return mValues[type];
|
3978
|
-
} else if ( type.indexOf(".") > 0 ) {
|
3979
|
-
return "new " + type + "()";
|
3980
|
-
} else {
|
3981
|
-
// return "/* unsupported type: " + member.type + " */ null";
|
3982
|
-
return "null";
|
3983
|
-
}
|
3984
|
-
}
|
3985
|
-
}
|
3986
|
-
|
3987
|
-
function value(member) {
|
3988
|
-
return valueForType(member.type);
|
3989
|
-
}
|
3990
|
-
|
3991
|
-
function retvalue(member) {
|
3992
|
-
//console.log(member);
|
3993
|
-
var r = valueForType(member.type || (member.returns && member.returns.length && member.returns[0] && member.returns[0].type && member.returns[0].type));
|
3994
|
-
if ( r ) {
|
3995
|
-
return "return " + r + ";";
|
3996
|
-
}
|
3997
|
-
return "";
|
3998
|
-
}
|
3999
|
-
|
4000
|
-
var sortedSymbols = symbols.slice(0).filter(function($) { return isaClass($) && isAPI($) && !$.synthetic; }).sort(sortByAlias); // sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken
|
4001
|
-
sortedSymbols.forEach(function(symbol) {
|
4002
|
-
|
4003
|
-
var sMetaType = (symbol.kind === 'member' && symbol.isEnum) ? 'enum' : symbol.kind;
|
4004
|
-
if ( sMetaType ) {
|
4005
|
-
|
4006
|
-
writeln("");
|
4007
|
-
writeln("// ---- " + symbol.longname + " --------------------------------------------------------------------------");
|
4008
|
-
writeln("");
|
4009
|
-
|
4010
|
-
var memberId, member;
|
4011
|
-
|
4012
|
-
var ownProperties = childrenOfKind(symbol, 'property').own.filter(isNoKeyword).sort(sortByAlias);
|
4013
|
-
if ( sMetaType === "class" ) {
|
4014
|
-
comment(symbol, sMetaType);
|
4015
|
-
writeln(symbol.longname + " = function(" + signature(symbol) + ") {};");
|
4016
|
-
for ( memberId in ownProperties ) {
|
4017
|
-
member = ownProperties[memberId];
|
4018
|
-
comment(member, sMetaType);
|
4019
|
-
writeln(qname(member, symbol) + " = " + value(member));
|
4020
|
-
writeln("");
|
4021
|
-
}
|
4022
|
-
} else if ( sMetaType === 'namespace' || sMetaType === 'enum' ) {
|
4023
|
-
//console.log("found namespace " + symbol.longname);
|
4024
|
-
//console.log(ownProperties);
|
4025
|
-
if ( ownProperties.length ) {
|
4026
|
-
writeln("// dummy function to make Eclipse aware of namespace");
|
4027
|
-
writeln(symbol.longname + ".toString = function() { return \"\"; };");
|
4028
|
-
}
|
4029
|
-
}
|
4030
|
-
|
4031
|
-
var ownEvents = childrenOfKind(symbol, 'event').own.filter(isNoKeyword).sort(sortByAlias);
|
4032
|
-
if ( ownEvents.length ) {
|
4033
|
-
for ( memberId in ownEvents ) {
|
4034
|
-
member = ownEvents[memberId];
|
4035
|
-
comment(member, sMetaType);
|
4036
|
-
writeln(qname(member, symbol) + " = function(" + signature(member) + ") { " + retvalue(member) + " };");
|
4037
|
-
writeln("");
|
4038
|
-
}
|
4039
|
-
}
|
4040
|
-
|
4041
|
-
var ownMethods = childrenOfKind(symbol, 'method').own.filter(isNoKeyword).sort(sortByAlias);
|
4042
|
-
if ( ownMethods.length ) {
|
4043
|
-
for ( memberId in ownMethods ) {
|
4044
|
-
member = ownMethods[memberId];
|
4045
|
-
comment(member, sMetaType);
|
4046
|
-
writeln(qname(member, symbol) + " = function(" + signature(member) + ") { " + retvalue(member) + " };");
|
4047
|
-
writeln("");
|
4048
|
-
}
|
4049
|
-
}
|
4050
|
-
|
4051
|
-
}
|
4052
|
-
});
|
4053
|
-
|
4054
|
-
writeln("// ---- static fields of namespaces ---------------------------------------------------------------------");
|
4055
|
-
|
4056
|
-
sortedSymbols.forEach(function(symbol) {
|
4057
|
-
|
4058
|
-
var sMetaType = (symbol.kind === 'member' && symbol.isEnum) ? 'enum' : symbol.kind;
|
4059
|
-
|
4060
|
-
if ( sMetaType === 'namespace' || sMetaType === 'enum' ) {
|
4061
|
-
|
4062
|
-
var ownProperties = childrenOfKind(symbol, 'property').own.filter(isNoKeyword).sort(sortByAlias);
|
4063
|
-
if ( ownProperties.length ) {
|
4064
|
-
writeln("");
|
4065
|
-
writeln("// ---- " + symbol.longname + " --------------------------------------------------------------------------");
|
4066
|
-
writeln("");
|
4067
|
-
|
4068
|
-
for (var memberId in ownProperties ) {
|
4069
|
-
var member = ownProperties[memberId];
|
4070
|
-
comment(member, sMetaType);
|
4071
|
-
writeln(qname(member, symbol) + " = " + value(member) + ";");
|
4072
|
-
writeln("");
|
4073
|
-
}
|
4074
|
-
}
|
4075
|
-
}
|
4076
|
-
|
4077
|
-
});
|
4078
|
-
|
4079
|
-
fs.mkPath(path.dirname(filename));
|
4080
|
-
fs.writeFileSync(filename, output.join(""), 'utf8');
|
4081
|
-
info(" saved as " + filename);
|
4082
|
-
}
|
4083
|
-
|
4084
|
-
// Description + Settings
|
4085
|
-
|
4086
|
-
function getConstructorDescription(symbol) {
|
4087
|
-
var description = symbol.description;
|
4088
|
-
var tags = symbol.tags;
|
4089
|
-
if ( tags ) {
|
4090
|
-
for (var i = 0; i < tags.length; i++) {
|
4091
|
-
if ( tags[i].title === "ui5-settings" && tags[i].text) {
|
4092
|
-
description += "\n</p><p>\n" + tags[i].text;
|
4093
|
-
break;
|
4094
|
-
}
|
4095
|
-
}
|
4096
|
-
}
|
4097
|
-
return description;
|
4098
|
-
}
|
4099
|
-
|
4100
|
-
|
4101
|
-
// Example
|
4102
|
-
|
4103
|
-
function makeExample(example) {
|
4104
|
-
var result = {
|
4105
|
-
caption: null,
|
4106
|
-
example: example
|
4107
|
-
},
|
4108
|
-
match = /^\s*<caption>([\s\S]+?)<\/caption>(?:[ \t]*[\n\r]*)([\s\S]+)$/i.exec(example);
|
4109
|
-
|
4110
|
-
if ( match ) {
|
4111
|
-
result.caption = match[1];
|
4112
|
-
result.example = match[2];
|
4113
|
-
}
|
4114
|
-
|
4115
|
-
return result;
|
4116
|
-
}
|
4117
|
-
|
4118
|
-
/* ---- exports ---- */
|
4119
|
-
|
4120
|
-
exports.publish = publish;
|