chore(doc-gen/angular.io): sort exports alphabetically

This commit is contained in:
Peter Bacon Darwin 2015-09-16 14:41:51 +01:00 committed by Naomi Black
parent 457b689bf0
commit 608f35b4a7
2 changed files with 36 additions and 2 deletions

View File

@ -48,13 +48,18 @@ module.exports = function addJadeDataDocsProcessor() {
}];
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
var modulePageInfo = _.map(doc.exports, function(exportDoc) {
var modulePageInfo = _(doc.exports)
.map(function(exportDoc) {
return {
name: exportDoc.name + '-' + exportDoc.docType,
title: exportDoc.name,
varType: exportDoc.symbolTypeName && titleCase(exportDoc.symbolTypeName)
};
});
})
.sortBy('name')
.value();
//COMBINE PAGE DATA
var allPageData = indexPageInfo.concat(modulePageInfo);

View File

@ -32,4 +32,33 @@ describe('addJadeDataDocsProcessor', function() {
{ name : 'MyClass-class', title : 'MyClass', varType : undefined }
] });
});
it('should sort the exports into alphabetical order', function() {
var docs = [
{
docType: 'module',
id: 'someModule',
exports: [
{ name: 'Beta', docType: 'class'},
{ name: 'Alpha', docType: 'class'},
{ name: 'Gamma', docType: 'class'},
{ name: 'Nu', docType: 'class'},
{ name: 'Mu', docType: 'class'}
],
fileInfo: { baseName: 'x_y' },
description: 'some description\nsecond line'
}
];
docs = processor.$process(docs);
expect(docs[1].data).toEqual([
{ name : 'index', title : 'X Y', intro : 'some description second line' },
{ name: 'Alpha-class', title: 'Alpha', varType : undefined },
{ name: 'Beta-class', title: 'Beta', varType : undefined },
{ name: 'Gamma-class', title: 'Gamma', varType : undefined },
{ name: 'Mu-class', title: 'Mu', varType : undefined },
{ name: 'Nu-class', title: 'Nu', varType : undefined }
]);
});
});