Pete Bacon Darwin e7b392bf3a build(aio): improve automatic linking of code items (#24000)
This commit adds new link disambiguators that mean that more
code links can be generated automatically in a sensible way.

The best example is the use of properties within class, interface and
enum documentation.

PR Close #24000
2018-06-13 16:47:40 -07:00

20 lines
609 B
JavaScript

/**
* This link disambiguator looks for matching docs that have a common container with the
* originatingDoc and will return just those.
*/
module.exports = function disambiguateByContainer() {
return _disambiguate;
};
function _disambiguate(alias, originatingDoc, docs) {
if (originatingDoc) {
const filteredDocs = docs.filter(doc => doc.containerDoc === originatingDoc);
if (filteredDocs.length === 0) {
// No docs match so let's look at the containers container
return _disambiguate(alias, originatingDoc.containerDoc, docs);
}
return filteredDocs;
}
return docs;
}