From 963a4d0dc8ad67a108158e2a0c24181df3e0bd51 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Wed, 4 Oct 2017 23:10:40 +0100 Subject: [PATCH] build(aio): sort API list alphabetically (#19566) Closes #19559 PR Close #19566 --- .../processors/generateApiListDoc.js | 4 +++- .../processors/generateApiListDoc.spec.js | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.js b/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.js index f2311adcc1..a4a7ada49e 100644 --- a/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.js +++ b/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.js @@ -26,7 +26,9 @@ function getModuleInfo(moduleDoc) { title: moduleName, items: moduleDoc.exports // Ignore internals and private exports (indicated by the ɵ prefix) - .filter(doc => !doc.internal && !doc.privateExport).map(getExportInfo) + .filter(doc => !doc.internal && !doc.privateExport) + .map(getExportInfo) + .sort((a, b) => a.name === b.name ? 0 : a.name > b.name ? 1 : -1) }; } diff --git a/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.spec.js b/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.spec.js index 1eb09830ca..bbc4108e44 100644 --- a/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.spec.js +++ b/aio/tools/transforms/angular-api-package/processors/generateApiListDoc.spec.js @@ -113,7 +113,6 @@ describe('generateApiListDoc processor', () => { ]); }); - it('should convert security to a boolean securityRisk', () => { const processor = processorFactory(); const docs = [ @@ -129,7 +128,6 @@ describe('generateApiListDoc processor', () => { ]); }); - it('should convert stability tags to the stable string property', () => { const processor = processorFactory(); const docs = [ @@ -148,5 +146,24 @@ describe('generateApiListDoc processor', () => { { docType: 'class', title: 'DddDdd', name: 'dddddd', path: 'ddd', stability: '', securityRisk: false }, ]); }); + + it('should sort items in each group alphabetically', () => { + const processor = processorFactory(); + const docs = [ + { docType: 'module', id: '@angular/common/index', exports: [ + { docType: 'class', name: 'DddDdd', path: 'uuu' }, + { docType: 'class', name: 'BbbBbb', path: 'vvv' }, + { docType: 'class', name: 'AaaAaa', path: 'xxx' }, + { docType: 'class', name: 'CccCcc', path: 'yyy' }, + ]} + ]; + processor.$process(docs); + expect(docs[1].data[0].items).toEqual([ + { docType: 'class', title: 'AaaAaa', name: 'aaaaaa', path: 'xxx', stability: '', securityRisk: false }, + { docType: 'class', title: 'BbbBbb', name: 'bbbbbb', path: 'vvv', stability: '', securityRisk: false }, + { docType: 'class', title: 'CccCcc', name: 'cccccc', path: 'yyy', stability: '', securityRisk: false }, + { docType: 'class', title: 'DddDdd', name: 'dddddd', path: 'uuu', stability: '', securityRisk: false }, + ]); + }); });