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