chore(doc-gen): speed up class member sorting

This commit is contained in:
Peter Bacon Darwin 2015-05-17 22:09:33 +01:00
parent 33f5aafd6c
commit b9b58f7ed9
1 changed files with 10 additions and 4 deletions

View File

@ -34,9 +34,7 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
var ignoreExportsMatching = convertToRegexCollection(this.ignoreExportsMatching);
var hidePrivateMembers = this.hidePrivateMembers;
var addMember = this.sortClassMembers ? insertSorted : function(collection, item) {
collection.push(item);
};
var sortClassMembers = this.sortClassMembers;
var basePath = path.resolve(readFilesProcessor.basePath, this.basePath);
var filesPaths = expandSourceFiles(this.sourceFiles, basePath);
@ -79,9 +77,17 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
docs.push(memberDoc);
} else if (!hidePrivateMembers || memberSymbol.name.charAt(0) !== '_') {
docs.push(memberDoc);
addMember(exportDoc.members, memberDoc, 'name');
exportDoc.members.push(memberDoc);
}
}
if (sortClassMembers) {
exportDoc.members.sort(function(a, b) {
if (a.name > b.name) return 1;
if (a.name < b.name) return -1;
return 0;
});
}
}
// Add this export doc to its module doc