2018-05-23 17:20:14 -04:00
|
|
|
module.exports = function computeApiBreadCrumbs(API_DOC_TYPES_TO_RENDER) {
|
2018-02-08 10:00:53 -05:00
|
|
|
return {
|
|
|
|
$runAfter: ['paths-computed'],
|
|
|
|
$runBefore: ['rendering-docs'],
|
|
|
|
$process(docs) {
|
|
|
|
// Compute the breadcrumb for each doc by processing its containers
|
|
|
|
docs.forEach(doc => {
|
2018-05-23 17:20:14 -04:00
|
|
|
if (API_DOC_TYPES_TO_RENDER.indexOf(doc.docType) !== -1) {
|
|
|
|
doc.breadCrumbs = [];
|
|
|
|
doc.breadCrumbs.push({ text: 'API', path: '/api' });
|
2018-08-13 05:56:03 -04:00
|
|
|
if (isSecondaryEntryPoint(doc)) {
|
|
|
|
doc.breadCrumbs.push(createPackageBreadcrumb(doc));
|
|
|
|
}
|
|
|
|
if (doc.moduleDoc) {
|
|
|
|
if (isSecondaryEntryPoint(doc.moduleDoc)) {
|
|
|
|
doc.breadCrumbs.push(createPackageBreadcrumb(doc.moduleDoc));
|
|
|
|
}
|
|
|
|
doc.breadCrumbs.push({ text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path });
|
|
|
|
}
|
2018-05-23 17:20:14 -04:00
|
|
|
doc.breadCrumbs.push({ text: doc.name, path: doc.path });
|
2018-02-08 10:00:53 -05:00
|
|
|
}
|
2018-08-13 05:56:03 -04:00
|
|
|
|
2018-02-08 10:00:53 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-08-13 05:56:03 -04:00
|
|
|
function isSecondaryEntryPoint(doc) {
|
|
|
|
return doc.docType === 'package' && !doc.isPrimaryPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createPackageBreadcrumb(doc) {
|
|
|
|
return { text: doc.packageInfo.primary.name, path: doc.packageInfo.primary.path };
|
|
|
|
}
|