Store api members as object map instead of array.

This commit is contained in:
Maximilian Krög
2020-02-04 21:34:00 +01:00
parent 0c04293d5f
commit 2e4f989d7b

View File

@@ -21,15 +21,11 @@ exports.defineTags = function(dictionary) {
* from the documentation. * from the documentation.
*/ */
const api = []; const api = {};
const classes = {}; const classes = {};
const types = {}; const types = {};
const modules = {}; const modules = {};
function hasApiMembers(doclet) {
return doclet.longname.split('#')[0] == this.longname;
}
function includeAugments(doclet) { function includeAugments(doclet) {
// Make sure that `observables` and `fires` are taken from an already processed `class` doclet. // Make sure that `observables` and `fires` are taken from an already processed `class` doclet.
// This is necessary because JSDoc generates multiple doclets with the same longname. // This is necessary because JSDoc generates multiple doclets with the same longname.
@@ -116,7 +112,7 @@ exports.handlers = {
const doclet = e.doclet; const doclet = e.doclet;
if (doclet.stability) { if (doclet.stability) {
modules[doclet.longname.split(/[~\.]/).shift()] = true; modules[doclet.longname.split(/[~\.]/).shift()] = true;
api.push(doclet); api[doclet.longname.split('#')[0]] = true;
} }
if (doclet.kind == 'class') { if (doclet.kind == 'class') {
if (!(doclet.longname in classes)) { if (!(doclet.longname in classes)) {
@@ -159,7 +155,7 @@ exports.handlers = {
if (doclet.isEnum || doclet.kind == 'typedef') { if (doclet.isEnum || doclet.kind == 'typedef') {
continue; continue;
} }
if (doclet.kind == 'class' && api.some(hasApiMembers, doclet)) { if (doclet.kind == 'class' && doclet.longname in api) {
// Mark undocumented classes with documented members as unexported. // Mark undocumented classes with documented members as unexported.
// This is used in ../template/tmpl/container.tmpl to hide the // This is used in ../template/tmpl/container.tmpl to hide the
// constructor from the docs. // constructor from the docs.