From b9b58f7ed93b0e87aa5ef8e318ce0df100519b36 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sun, 17 May 2015 22:09:33 +0100 Subject: [PATCH] chore(doc-gen): speed up class member sorting --- .../processors/readTypeScriptModules.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/dgeni-package/processors/readTypeScriptModules.js b/docs/dgeni-package/processors/readTypeScriptModules.js index 1a5b2133a2..c4b88a4069 100644 --- a/docs/dgeni-package/processors/readTypeScriptModules.js +++ b/docs/dgeni-package/processors/readTypeScriptModules.js @@ -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