2017-07-28 08:09:26 +00:00
|
|
|
/**
|
|
|
|
* Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-07-11 15:57:26 +00:00
|
|
|
class Documentation {
|
|
|
|
/**
|
2018-02-09 03:59:46 +00:00
|
|
|
* @param {!Array<!Documentation.Class>} classesArray
|
2017-07-11 15:57:26 +00:00
|
|
|
*/
|
|
|
|
constructor(classesArray) {
|
|
|
|
this.classesArray = classesArray;
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Class>} */
|
2017-07-11 15:57:26 +00:00
|
|
|
this.classes = new Map();
|
2017-08-21 23:39:04 +00:00
|
|
|
for (const cls of classesArray)
|
2017-07-11 15:57:26 +00:00
|
|
|
this.classes.set(cls.name, cls);
|
|
|
|
}
|
|
|
|
}
|
2017-07-07 16:36:45 +00:00
|
|
|
|
|
|
|
Documentation.Class = class {
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
2017-07-14 05:52:02 +00:00
|
|
|
* @param {!Array<!Documentation.Member>} membersArray
|
2017-07-07 16:36:45 +00:00
|
|
|
*/
|
2017-07-14 05:52:02 +00:00
|
|
|
constructor(name, membersArray) {
|
2017-07-07 16:36:45 +00:00
|
|
|
this.name = name;
|
2017-07-14 05:52:02 +00:00
|
|
|
this.membersArray = membersArray;
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Member>} */
|
2017-07-14 05:52:02 +00:00
|
|
|
this.members = new Map();
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Member>} */
|
2017-07-14 05:52:02 +00:00
|
|
|
this.properties = new Map();
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Member>} */
|
2017-07-07 16:36:45 +00:00
|
|
|
this.methods = new Map();
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Member>} */
|
2017-07-14 20:03:21 +00:00
|
|
|
this.events = new Map();
|
2017-08-21 23:39:04 +00:00
|
|
|
for (const member of membersArray) {
|
2017-07-14 05:52:02 +00:00
|
|
|
this.members.set(member.name, member);
|
2018-11-21 22:49:08 +00:00
|
|
|
if (member.kind === 'method')
|
2017-07-14 05:52:02 +00:00
|
|
|
this.methods.set(member.name, member);
|
2018-11-21 22:49:08 +00:00
|
|
|
else if (member.kind === 'property')
|
2017-07-14 05:52:02 +00:00
|
|
|
this.properties.set(member.name, member);
|
2018-11-21 22:49:08 +00:00
|
|
|
else if (member.kind === 'event')
|
2017-07-14 20:03:21 +00:00
|
|
|
this.events.set(member.name, member);
|
2017-07-14 05:52:02 +00:00
|
|
|
}
|
2017-07-07 16:36:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-14 05:52:02 +00:00
|
|
|
Documentation.Member = class {
|
2017-07-11 15:57:26 +00:00
|
|
|
/**
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {string} kind
|
2017-07-11 15:57:26 +00:00
|
|
|
* @param {string} name
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {!Documentation.Type} type
|
|
|
|
* @param {!Array<!Documentation.Member>} argsArray
|
2017-07-11 15:57:26 +00:00
|
|
|
*/
|
2018-11-21 22:49:08 +00:00
|
|
|
constructor(kind, name, type, argsArray) {
|
|
|
|
this.kind = kind;
|
2017-07-11 15:57:26 +00:00
|
|
|
this.name = name;
|
2018-11-21 22:49:08 +00:00
|
|
|
this.type = type;
|
2017-07-13 22:15:31 +00:00
|
|
|
this.argsArray = argsArray;
|
2018-11-21 22:49:08 +00:00
|
|
|
/** @type {!Map<string, !Documentation.Member>} */
|
2017-07-13 22:15:31 +00:00
|
|
|
this.args = new Map();
|
2017-08-21 23:39:04 +00:00
|
|
|
for (const arg of argsArray)
|
2017-07-13 22:15:31 +00:00
|
|
|
this.args.set(arg.name, arg);
|
2017-07-11 15:57:26 +00:00
|
|
|
}
|
2017-07-14 05:52:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {!Array<!Documentation.Member>} argsArray
|
|
|
|
* @param {?Documentation.Type} returnType
|
2017-07-14 05:52:02 +00:00
|
|
|
* @return {!Documentation.Member}
|
|
|
|
*/
|
2018-11-21 22:49:08 +00:00
|
|
|
static createMethod(name, argsArray, returnType) {
|
|
|
|
return new Documentation.Member('method', name, returnType, argsArray,);
|
2017-07-14 05:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {!Documentation.Type}
|
2017-07-14 05:52:02 +00:00
|
|
|
* @return {!Documentation.Member}
|
|
|
|
*/
|
2018-11-21 22:49:08 +00:00
|
|
|
static createProperty(name, type) {
|
|
|
|
return new Documentation.Member('property', name, type, []);
|
2017-07-14 05:52:02 +00:00
|
|
|
}
|
2017-07-14 20:03:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @return {!Documentation.Member}
|
|
|
|
*/
|
|
|
|
static createEvent(name) {
|
2018-11-21 22:49:08 +00:00
|
|
|
return new Documentation.Member('event', name, null, []);
|
2017-07-14 20:03:21 +00:00
|
|
|
}
|
2017-07-11 15:57:26 +00:00
|
|
|
};
|
|
|
|
|
2018-11-21 22:49:08 +00:00
|
|
|
Documentation.Type = class {
|
2017-07-07 16:36:45 +00:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {!Array<!Documentation.Member>=} properties
|
2017-07-07 16:36:45 +00:00
|
|
|
*/
|
2018-11-21 22:49:08 +00:00
|
|
|
constructor(name, properties = []) {
|
2017-07-07 16:36:45 +00:00
|
|
|
this.name = name;
|
2018-11-21 22:49:08 +00:00
|
|
|
this.properties = properties;
|
2017-07-07 16:36:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Documentation;
|
2017-07-11 15:57:26 +00:00
|
|
|
|