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
|
2019-01-28 23:12:45 +00:00
|
|
|
* @param {?string=} extendsName
|
|
|
|
* @param {string=} comment
|
2017-07-07 16:36:45 +00:00
|
|
|
*/
|
2019-01-28 23:12:45 +00:00
|
|
|
constructor(name, membersArray, extendsName = null, comment = '') {
|
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();
|
2019-04-19 22:33:06 +00:00
|
|
|
/** @type {!Array<!Documentation.Member>} */
|
|
|
|
this.propertiesArray = [];
|
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();
|
2019-04-19 22:33:06 +00:00
|
|
|
/** @type {!Array<!Documentation.Member>} */
|
|
|
|
this.methodsArray = [];
|
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();
|
2019-04-19 22:33:06 +00:00
|
|
|
/** @type {!Array<!Documentation.Member>} */
|
|
|
|
this.eventsArray = [];
|
2019-01-28 23:12:45 +00:00
|
|
|
this.comment = comment;
|
|
|
|
this.extends = extendsName;
|
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);
|
2019-04-19 22:33:06 +00:00
|
|
|
if (member.kind === 'method') {
|
2017-07-14 05:52:02 +00:00
|
|
|
this.methods.set(member.name, member);
|
2019-04-19 22:33:06 +00:00
|
|
|
this.methodsArray.push(member);
|
|
|
|
} else if (member.kind === 'property') {
|
2017-07-14 05:52:02 +00:00
|
|
|
this.properties.set(member.name, member);
|
2019-04-19 22:33:06 +00:00
|
|
|
this.propertiesArray.push(member);
|
|
|
|
} else if (member.kind === 'event') {
|
2017-07-14 20:03:21 +00:00
|
|
|
this.events.set(member.name, member);
|
2019-04-19 22:33:06 +00:00
|
|
|
this.eventsArray.push(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
|
2019-01-28 23:12:45 +00:00
|
|
|
* @param {?Documentation.Type} type
|
2018-11-21 22:49:08 +00:00
|
|
|
* @param {!Array<!Documentation.Member>} argsArray
|
2017-07-11 15:57:26 +00:00
|
|
|
*/
|
2019-01-28 23:12:45 +00:00
|
|
|
constructor(kind, name, type, argsArray, comment = '', returnComment = '', required = true) {
|
2018-11-21 22:49:08 +00:00
|
|
|
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;
|
2019-01-28 23:12:45 +00:00
|
|
|
this.comment = comment;
|
|
|
|
this.returnComment = returnComment;
|
2017-07-13 22:15:31 +00:00
|
|
|
this.argsArray = argsArray;
|
2019-01-28 23:12:45 +00:00
|
|
|
this.required = required;
|
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}
|
|
|
|
*/
|
2019-01-28 23:12:45 +00:00
|
|
|
static createMethod(name, argsArray, returnType, returnComment, comment) {
|
|
|
|
return new Documentation.Member('method', name, returnType, argsArray, comment, returnComment);
|
2017-07-14 05:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
2019-01-28 23:12:45 +00:00
|
|
|
* @param {!Documentation.Type} type
|
|
|
|
* @param {string=} comment
|
|
|
|
* @param {boolean=} required
|
2017-07-14 05:52:02 +00:00
|
|
|
* @return {!Documentation.Member}
|
|
|
|
*/
|
2019-01-28 23:12:45 +00:00
|
|
|
static createProperty(name, type, comment, required) {
|
|
|
|
return new Documentation.Member('property', name, type, [], comment, undefined, required);
|
2017-07-14 05:52:02 +00:00
|
|
|
}
|
2017-07-14 20:03:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
2019-01-28 23:12:45 +00:00
|
|
|
* @param {?Documentation.Type=} type
|
|
|
|
* @param {string=} comment
|
2017-07-14 20:03:21 +00:00
|
|
|
* @return {!Documentation.Member}
|
|
|
|
*/
|
2019-01-28 23:12:45 +00:00
|
|
|
static createEvent(name, type = null, comment) {
|
|
|
|
return new Documentation.Member('event', name, type, [], comment);
|
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
|
|
|
|