diff --git a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js index 62eb6c2225..622b4d3202 100644 --- a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js +++ b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js @@ -8,11 +8,27 @@ module.exports = function computeApiBreadCrumbs(API_DOC_TYPES_TO_RENDER) { if (API_DOC_TYPES_TO_RENDER.indexOf(doc.docType) !== -1) { doc.breadCrumbs = []; doc.breadCrumbs.push({ text: 'API', path: '/api' }); - if (doc.moduleDoc) doc.breadCrumbs.push({ text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path }); + 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 }); + } doc.breadCrumbs.push({ text: doc.name, path: doc.path }); } + }); } }; }; +function isSecondaryEntryPoint(doc) { + return doc.docType === 'package' && !doc.isPrimaryPackage; +} + +function createPackageBreadcrumb(doc) { + return { text: doc.packageInfo.primary.name, path: doc.packageInfo.primary.path }; +} diff --git a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js index 256d7c44d2..2266cc149b 100644 --- a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js +++ b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js @@ -17,11 +17,17 @@ describe('angular-api-package: computeApiBreadCrumbs processor', () => { const API_DOC_TYPES_TO_RENDER = ['class', 'interface', 'package']; const processor = processorFactory(API_DOC_TYPES_TO_RENDER); + const httpPackage = { docType: 'package', name: '@angular/http', id: 'http', path: 'http', isPrimaryPackage: true }; + const httpTestingPackage = { docType: 'package', name: '@angular/http/testing', id: 'http/testing', path: 'http/testing', packageInfo: { primary: httpPackage } }; + const testRequestClass = { docType: 'class', name: 'TestRequest', path: 'http/testing/test-request', moduleDoc: httpTestingPackage }; + const docs = [ { docType: 'class', name: 'ClassA', path: 'module-1/class-a', moduleDoc: { id: 'moduleOne', path: 'module-1' } }, { docType: 'interface', name: 'InterfaceB', path: 'module-2/interface-b', moduleDoc: { id: 'moduleTwo', path: 'module-2' } }, { docType: 'guide', name: 'Guide One', path: 'guide/guide-1' }, - { docType: 'package', name: 'testing', id: 'http/testing', path: 'http/testing' }, + httpPackage, + httpTestingPackage, + testRequestClass ]; processor.$process(docs); @@ -38,7 +44,18 @@ describe('angular-api-package: computeApiBreadCrumbs processor', () => { expect(docs[2].breadCrumbs).toBeUndefined(); expect(docs[3].breadCrumbs).toEqual([ { text: 'API', path: '/api' }, - { text: 'testing', path: 'http/testing' }, + { text: '@angular/http', path: 'http' }, + ]); + expect(docs[4].breadCrumbs).toEqual([ + { text: 'API', path: '/api' }, + { text: '@angular/http', path: 'http' }, + { text: '@angular/http/testing', path: 'http/testing' }, + ]); + expect(docs[5].breadCrumbs).toEqual([ + { text: 'API', path: '/api' }, + { text: '@angular/http', path: 'http' }, + { text: '@angular/http/testing', path: 'http/testing' }, + { text: 'TestRequest', path: 'http/testing/test-request' }, ]); }); });