From c0f058f5cf5f2b5826ddc5b991fb619f3317c9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Tue, 4 Feb 2020 21:45:26 +0100 Subject: [PATCH] Variable should be reset on each loop but wasn't The ancestors variable is always set once the first augmented doclet is found. The incompleteDoclet variable is also not reset between loops. --- config/jsdoc/api/plugins/inheritdoc.js | 90 +++++++++++++------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/config/jsdoc/api/plugins/inheritdoc.js b/config/jsdoc/api/plugins/inheritdoc.js index 7bc5636a23..6284a731ee 100755 --- a/config/jsdoc/api/plugins/inheritdoc.js +++ b/config/jsdoc/api/plugins/inheritdoc.js @@ -42,62 +42,62 @@ exports.handlers = { parseComplete: function(e) { let ancestors, candidate, candidates, doclet, i, j, k, l, key; - let incompleteDoclet, stability, incomplete, incompletes; + let stability, incomplete, incompletes; const doclets = e.doclets; for (i = doclets.length - 1; i >= 0; --i) { doclet = doclets[i]; - if (doclet.augments) { - ancestors = [].concat(doclet.augments); - } incompletes = incompleteByClass[doclet.longname]; - if (ancestors && incompletes) { - // collect ancestors from the whole hierarchy - for (j = 0; j < ancestors.length; ++j) { - candidates = lookup[ancestors[j]]; - if (candidates) { - for (k = candidates.length - 1; k >= 0; --k) { - candidate = candidates[k]; - if (candidate.augments) { - ancestors = ancestors.concat(candidate.augments); - } + if (!doclet.augments || !incompletes) { + continue; + } + ancestors = doclet.augments.slice(); + // collect ancestors from the whole hierarchy + for (j = 0; j < ancestors.length; ++j) { + candidates = lookup[ancestors[j]]; + if (candidates) { + 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) { - incomplete = incompletes[j]; - candidates = lookup[doclet.longname + '#' + incomplete]; - if (candidates) { - // get the incomplete doclet that needs to be augmented - for (k = candidates.length - 1; k >= 0; --k) { - incompleteDoclet = candidates[k]; - if (incompleteDoclet.inheritdoc) { - break; - } + } + // walk through all inheritDoc members + let incompleteDoclet; + for (j = incompletes.length - 1; j >= 0; --j) { + incomplete = incompletes[j]; + candidates = lookup[doclet.longname + '#' + incomplete]; + if (candidates) { + // get the incomplete doclet that needs to be augmented + for (k = candidates.length - 1; k >= 0; --k) { + incompleteDoclet = candidates[k]; + if (incompleteDoclet.inheritdoc) { + break; } } - // find the documented ancestor - for (k = ancestors.length - 1; k >= 0; --k) { - candidates = lookup[ancestors[k] + '#' + incomplete]; - if (candidates) { - for (l = candidates.length - 1; l >= 0; --l) { - candidate = candidates[l]; - if (candidate && !candidate.inheritdoc) { - stability = candidate.stability || incompleteDoclet.stability; - if (stability) { - incompleteDoclet.stability = stability; - for (key in candidate) { - if (candidate.hasOwnProperty(key) && - keepKeys.indexOf(key) == -1) { - incompleteDoclet[key] = candidate[key]; - } + } + // find the documented ancestor + for (k = ancestors.length - 1; k >= 0; --k) { + candidates = lookup[ancestors[k] + '#' + incomplete]; + if (candidates) { + for (l = candidates.length - 1; l >= 0; --l) { + candidate = candidates[l]; + if (candidate && !candidate.inheritdoc) { + stability = candidate.stability || incompleteDoclet.stability; + if (stability) { + incompleteDoclet.stability = stability; + for (key in candidate) { + if (candidate.hasOwnProperty(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; } } }