angular-cn/tools/api-builder/links-package/services/moduleScopeLinkDisambiguator.js
Peter Bacon Darwin 285ecf495f chore(api-builder): add configurable link disambuators & put to work
closes #1852
Add configurable link disambuators
Add a service to disambiguate docs by module
Add a service to disambiguate docs that are deprecated
2016-07-14 14:33:55 -07:00

16 lines
567 B
JavaScript

var _ = require('lodash');
module.exports = function moduleScopeLinkDisambiguator() {
return function(url, title, currentDoc, docs) {
if (docs.length > 1) {
// filter out target docs that are not in the same module as the source doc
var filteredDocs = _.filter(docs, function(doc) {
return doc.moduleDoc === currentDoc.moduleDoc;
});
// if all target docs are in a different module then just return the full collection of ambiguous docs
return filteredDocs.length > 0 ? filteredDocs : docs;
}
return docs;
};
};