Merge pull request #10617 from MoonE/apidoc-performance
Improve apidoc generation performance
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -42,62 +42,62 @@ exports.handlers = {
|
|||||||
|
|
||||||
parseComplete: function(e) {
|
parseComplete: function(e) {
|
||||||
let ancestors, candidate, candidates, doclet, i, j, k, l, key;
|
let ancestors, candidate, candidates, doclet, i, j, k, l, key;
|
||||||
let incompleteDoclet, stability, incomplete, incompletes;
|
let stability, incomplete, incompletes;
|
||||||
const doclets = e.doclets;
|
const doclets = e.doclets;
|
||||||
for (i = doclets.length - 1; i >= 0; --i) {
|
for (i = doclets.length - 1; i >= 0; --i) {
|
||||||
doclet = doclets[i];
|
doclet = doclets[i];
|
||||||
if (doclet.augments) {
|
|
||||||
ancestors = [].concat(doclet.augments);
|
|
||||||
}
|
|
||||||
incompletes = incompleteByClass[doclet.longname];
|
incompletes = incompleteByClass[doclet.longname];
|
||||||
if (ancestors && incompletes) {
|
if (!doclet.augments || !incompletes) {
|
||||||
// collect ancestors from the whole hierarchy
|
continue;
|
||||||
for (j = 0; j < ancestors.length; ++j) {
|
}
|
||||||
candidates = lookup[ancestors[j]];
|
ancestors = doclet.augments.slice();
|
||||||
if (candidates) {
|
// collect ancestors from the whole hierarchy
|
||||||
for (k = candidates.length - 1; k >= 0; --k) {
|
for (j = 0; j < ancestors.length; ++j) {
|
||||||
candidate = candidates[k];
|
candidates = lookup[ancestors[j]];
|
||||||
if (candidate.augments) {
|
if (candidates) {
|
||||||
ancestors = ancestors.concat(candidate.augments);
|
for (k = candidates.length - 1; k >= 0; --k) {
|
||||||
}
|
candidate = candidates[k];
|
||||||
|
if (candidate.augments) {
|
||||||
|
Array.prototype.push.apply(ancestors, candidate.augments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// walk through all inheritDoc members
|
}
|
||||||
for (j = incompletes.length - 1; j >= 0; --j) {
|
// walk through all inheritDoc members
|
||||||
incomplete = incompletes[j];
|
let incompleteDoclet;
|
||||||
candidates = lookup[doclet.longname + '#' + incomplete];
|
for (j = incompletes.length - 1; j >= 0; --j) {
|
||||||
if (candidates) {
|
incomplete = incompletes[j];
|
||||||
// get the incomplete doclet that needs to be augmented
|
candidates = lookup[doclet.longname + '#' + incomplete];
|
||||||
for (k = candidates.length - 1; k >= 0; --k) {
|
if (candidates) {
|
||||||
incompleteDoclet = candidates[k];
|
// get the incomplete doclet that needs to be augmented
|
||||||
if (incompleteDoclet.inheritdoc) {
|
for (k = candidates.length - 1; k >= 0; --k) {
|
||||||
break;
|
incompleteDoclet = candidates[k];
|
||||||
}
|
if (incompleteDoclet.inheritdoc) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find the documented ancestor
|
}
|
||||||
for (k = ancestors.length - 1; k >= 0; --k) {
|
// find the documented ancestor
|
||||||
candidates = lookup[ancestors[k] + '#' + incomplete];
|
for (k = ancestors.length - 1; k >= 0; --k) {
|
||||||
if (candidates) {
|
candidates = lookup[ancestors[k] + '#' + incomplete];
|
||||||
for (l = candidates.length - 1; l >= 0; --l) {
|
if (candidates) {
|
||||||
candidate = candidates[l];
|
for (l = candidates.length - 1; l >= 0; --l) {
|
||||||
if (candidate && !candidate.inheritdoc) {
|
candidate = candidates[l];
|
||||||
stability = candidate.stability || incompleteDoclet.stability;
|
if (candidate && !candidate.inheritdoc) {
|
||||||
if (stability) {
|
stability = candidate.stability || incompleteDoclet.stability;
|
||||||
incompleteDoclet.stability = stability;
|
if (stability) {
|
||||||
for (key in candidate) {
|
incompleteDoclet.stability = stability;
|
||||||
if (candidate.hasOwnProperty(key) &&
|
for (key in candidate) {
|
||||||
keepKeys.indexOf(key) == -1) {
|
if (candidate.hasOwnProperty(key) &&
|
||||||
incompleteDoclet[key] = candidate[key];
|
keepKeys.indexOf(key) == -1) {
|
||||||
}
|
incompleteDoclet[key] = candidate[key];
|
||||||
}
|
}
|
||||||
// We have found a matching parent doc and applied it so we
|
|
||||||
// don't want to ignore this doclet anymore.
|
|
||||||
incompleteDoclet.ignore = false;
|
|
||||||
// We found a match so we can stop break
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
// We have found a matching parent doc and applied it so we
|
||||||
|
// don't want to ignore this doclet anymore.
|
||||||
|
incompleteDoclet.ignore = false;
|
||||||
|
// We found a match so we can stop break
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -477,6 +477,7 @@ exports.publish = function(taffyData, opts, tutorials) {
|
|||||||
// index page displays information from package.json and lists files
|
// index page displays information from package.json and lists files
|
||||||
const files = find({kind: 'file'});
|
const files = find({kind: 'file'});
|
||||||
|
|
||||||
|
view.navigationHtml = helper.resolveLinks(view.partial('navigation.tmpl'));
|
||||||
generate('Index',
|
generate('Index',
|
||||||
[{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files),
|
[{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files),
|
||||||
indexUrl);
|
indexUrl);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ var version = obj.packageInfo.version;
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wrap" class="clearfix">
|
<div id="wrap" class="clearfix">
|
||||||
<?js= this.partial('navigation.tmpl', this) ?>
|
<?js= this.navigationHtml ?>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<h1 class="page-title" data-filename="<?js= filename ?>"><?js= title ?></h1>
|
<h1 class="page-title" data-filename="<?js= filename ?>"><?js= title ?></h1>
|
||||||
<div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
|
<div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
|
||||||
|
|||||||
Reference in New Issue
Block a user