diff --git a/tools/dgeni/processors/categorizer.js b/tools/dgeni/processors/categorizer.js index 5390f2314b9..ddcb00ecd31 100644 --- a/tools/dgeni/processors/categorizer.js +++ b/tools/dgeni/processors/categorizer.js @@ -28,6 +28,7 @@ module.exports = function categorizer() { doc.classDoc.methods = [doc]; } else if (isDirective(doc)) { doc.isDirective = true; + doc.directiveExportAs = getDirectiveExportAs(doc); } else if (isService(doc)) { doc.isService = true; } else if (isNgModule(doc)) { @@ -117,6 +118,17 @@ function getDirectiveOutputAlias(doc) { return isDirectiveOutput(doc) ? doc.decorators.find(d => d.name == 'Output').arguments[0] : ''; } +function getDirectiveExportAs(doc) { + let metadata = doc.decorators + .find(d => d.name === 'Component' || d.name === 'Directive').arguments[0]; + + // Use a Regex to determine the exportAs metadata because we can't parse the JSON due to + // environment variables inside of the JSON. + let exportMatches = /exportAs\s*:\s*(?:"|')(\w+)(?:"|')/g.exec(metadata); + + return exportMatches && exportMatches[1]; +} + function hasMemberDecorator(doc, decoratorName) { return doc.docType == 'member' && hasDecorator(doc, decoratorName); } diff --git a/tools/dgeni/templates/class.template.html b/tools/dgeni/templates/class.template.html index ae2084207e7..b40c52021b8 100644 --- a/tools/dgeni/templates/class.template.html +++ b/tools/dgeni/templates/class.template.html @@ -1,6 +1,11 @@
{$ class.description $}
+{%- if class.directiveExportAs -%} +Exported as: +{$ class.directiveExportAs $} +{%- endif -%} + {$ propertyList(class.properties) $} {$ methodList(class.methods) $}