chore(api): show exportAs name in documentation (#2433)

This commit is contained in:
Paul Gschwendtner
2017-01-03 18:30:48 +01:00
committed by Kara
parent 5692c78a09
commit 8b2a226c04
2 changed files with 17 additions and 0 deletions
+12
View File
@@ -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);
}
@@ -1,6 +1,11 @@
<h3 class="docs-api-h3 docs-api-class-name">{$ class.name $}</h3>
<p class="docs-api-class-description">{$ class.description $}</p>
{%- if class.directiveExportAs -%}
<span class="docs-api-h4 docs-api-class-export-label">Exported as:</span>
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
{%- endif -%}
{$ propertyList(class.properties) $}
{$ methodList(class.methods) $}