Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit bd41a16

Browse files
chore(api-builder): add a service to disambiguate docs by module
1 parent be51fb3 commit bd41a16

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tools/api-builder/links-package/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ module.exports = new Package('links', [])
1010
.factory(require('dgeni-packages/links/services/getDocFromAlias'))
1111
.factory(require('./services/getLinkInfo'))
1212
.factory(require('./services/parseArgString'))
13+
.factory(require('./services/moduleScopeLinkDisambiguator'))
1314
.factory(require('./services/getApiFragmentFileName'))
1415

1516
.config(function(inlineTagProcessor, linkInlineTagDef, linkDevGuideInlineTagDef, exampleInlineTagDef, exampleTabsInlineTagDef) {
1617
inlineTagProcessor.inlineTagDefinitions.push(linkInlineTagDef);
1718
inlineTagProcessor.inlineTagDefinitions.push(linkDevGuideInlineTagDef);
1819
inlineTagProcessor.inlineTagDefinitions.push(exampleInlineTagDef);
1920
inlineTagProcessor.inlineTagDefinitions.push(exampleTabsInlineTagDef);
21+
})
22+
23+
.config(function(getLinkInfo, moduleScopeLinkDisambiguator) {
24+
getLinkInfo.disambiguators.push(moduleScopeLinkDisambiguator);
2025
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var _ = require('lodash');
2+
3+
module.exports = function moduleScopeLinkDisambiguator() {
4+
return function(url, title, currentDoc, docs) {
5+
if (docs.length > 1) {
6+
// filter out target docs that are not in the same module as the source doc
7+
var filteredDocs = _.filter(docs, function(doc) {
8+
return doc.moduleDoc === currentDoc.moduleDoc;
9+
});
10+
// if all target docs are in a different module then just return the full collection of ambiguous docs
11+
return filteredDocs.length > 0 ? filteredDocs : docs;
12+
}
13+
return docs;
14+
};
15+
};

0 commit comments

Comments
 (0)