From b8e82e4db31bd44eec4488f8b77366c78ba92a8e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Thu, 30 Jul 2015 20:07:34 +0100 Subject: [PATCH] chore(doc-gen): render enum doctypes correctly --- .../templates/enum.template.html | 1 + .../processors/readTypeScriptModules.js | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 docs/angular.io-package/templates/enum.template.html diff --git a/docs/angular.io-package/templates/enum.template.html b/docs/angular.io-package/templates/enum.template.html new file mode 100644 index 0000000000..9c59159b29 --- /dev/null +++ b/docs/angular.io-package/templates/enum.template.html @@ -0,0 +1 @@ +{% extends 'class.template.html' -%} \ No newline at end of file diff --git a/docs/typescript-package/processors/readTypeScriptModules.js b/docs/typescript-package/processors/readTypeScriptModules.js index cadb1d8fbf..4574cf83b1 100644 --- a/docs/typescript-package/processors/readTypeScriptModules.js +++ b/docs/typescript-package/processors/readTypeScriptModules.js @@ -63,10 +63,11 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo, var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker); log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id); + exportDoc.members = []; + // Generate docs for each of the export's members if (resolvedExport.flags & ts.SymbolFlags.HasMembers) { - exportDoc.members = []; for(var memberName in resolvedExport.members) { // FIXME(alexeagle): why do generic type params appear in members? if (memberName === 'T') { @@ -91,21 +92,24 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo, exportDoc.newMember = 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; - }); + if (exportDoc.docType === 'enum') { + for(var memberName in resolvedExport.exports) { + log.silly('>>>>>> member: ' + memberName + ' from ' + exportDoc.id + ' in ' + moduleDoc.id); + var memberSymbol = resolvedExport.exports[memberName]; + var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker); + docs.push(memberDoc); + exportDoc.members.push(memberDoc); } } - if (exportDoc.docType == 'enum') { - exportDoc.members = []; - for (var etype in resolvedExport.exports) { - exportDoc.members.push(etype); - } + 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