api-builder: show metadata details on decorator docs

This commit is contained in:
Peter Bacon Darwin 2016-09-08 23:09:55 +01:00 committed by Igor Minar
parent a2089c5b4f
commit 13878efca7
2 changed files with 37 additions and 5 deletions

View File

@ -15,16 +15,36 @@ include {$ relativePath(doc.path, '_util-fns') $}
div(layout="row" layout-xs="column" class="row-margin ng-cloak") div(layout="row" layout-xs="column" class="row-margin ng-cloak")
div(flex="20" flex-xs="100") div(flex="20" flex-xs="100")
h2(class="h2-api-docs") Variable Export h2(class="h2-api-docs") Description
div(class="code-links" flex="80" flex-xs="100") div(class="code-links" flex="80" flex-xs="100")
pre.prettyprint.no-bg
code.
export {$ doc.name $}(options : {@link {$ doc.decoratorType $} {$ doc.decoratorType | escape $}}){$ params.returnType(doc.returnType) $}
:marked :marked
{%- if not doc.notYetDocumented %} {%- if not doc.notYetDocumented %}
{$ doc.description | indentForMarkdown(6) | trimBlankLines $} {$ doc.description | indentForMarkdown(6) | trimBlankLines $}
{% endif %} {% endif %}
{% if doc.metadataDoc and doc.metadataDoc.members.length %}
div(layout="row" layout-xs="column" class="metadata" class="row-margin ng-cloak")
div(flex="20" flex-xs="100")
h2(class="h2-api-docs") Metadata Properties
div(class="code-links" flex="80" flex-xs="100")
{% for metadata in doc.metadataDoc.members %}{% if not metadata.internal %}
a(name="{$ metadata.name $}-anchor" class="anchor-offset")
pre(class="prettyprint no-bg" ng-class="{ 'anchor-focused': appCtrl.isApiDocMemberFocused('{$ metadata.name $}') }")
code(class="api-doc-code").
{$ metadata.name $}{$ params.paramList(metadata.parameters) | indent(8, false) | trim $}{$ params.returnType(metadata.returnType) $}
:marked
{%- if not metadata.notYetDocumented %}
{$ metadata.description | indentForMarkdown(6) | replace('### Example', '') | replace('## Example', '') | replace('# Example', '') | trimBlankLines $}
{% endif -%}
{% if not loop.last %}
.hr(class="hr-margin")
{% endif %}
{% endif %}{% endfor %}
{% endif %}
p.location-badge. p.location-badge.
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc) $} exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc) $}

View File

@ -6,7 +6,7 @@ module.exports = function mergeDecoratorDocs() {
$runBefore: ['docs-processed'], $runBefore: ['docs-processed'],
docsToMergeInfo: [ docsToMergeInfo: [
{ nameTemplate: _.template('${name}Decorator'), decoratorProperty: 'decoratorInterfaceDoc' }, { nameTemplate: _.template('${name}Decorator'), decoratorProperty: 'decoratorInterfaceDoc' },
{ nameTemplate: _.template('${name}Metadata'), decoratorProperty: 'metadataDoc' }, { nameTemplate: _.template('${name}Metadata'), decoratorProperty: 'metadataDoc', useFields: ['howToUse', 'whatItDoes'] },
{ nameTemplate: _.template('${name}MetadataType'), decoratorProperty: 'metadataInterfaceDoc' }, { nameTemplate: _.template('${name}MetadataType'), decoratorProperty: 'metadataInterfaceDoc' },
{ nameTemplate: _.template('${name}MetadataFactory'), decoratorProperty: 'metadataFactoryDoc' } { nameTemplate: _.template('${name}MetadataFactory'), decoratorProperty: 'metadataFactoryDoc' }
], ],
@ -21,7 +21,10 @@ module.exports = function mergeDecoratorDocs() {
var makeDecorator = getMakeDecoratorCall(doc); var makeDecorator = getMakeDecoratorCall(doc);
if (makeDecorator) { if (makeDecorator) {
doc.docType = 'decorator'; doc.docType = 'decorator';
// get the type of the decorator metadata
doc.decoratorType = makeDecorator.arguments[0].text; doc.decoratorType = makeDecorator.arguments[0].text;
// clear the symbol type named (e.g. ComponentMetadataFactory) since it is not needed
doc.symbolTypeName = undefined;
// keep track of the docs that need to be merged into this decorator doc // keep track of the docs that need to be merged into this decorator doc
docsToMergeInfo.forEach(function(info) { docsToMergeInfo.forEach(function(info) {
@ -35,13 +38,22 @@ module.exports = function mergeDecoratorDocs() {
if (docsToMerge[doc.name]) { if (docsToMerge[doc.name]) {
var decoratorDoc = docsToMerge[doc.name].decoratorDoc; var decoratorDoc = docsToMerge[doc.name].decoratorDoc;
var property = docsToMerge[doc.name].property; var property = docsToMerge[doc.name].property;
var useFields = docsToMerge[doc.name].useFields;
// attach this document to its decorator // attach this document to its decorator
decoratorDoc[property] = doc; decoratorDoc[property] = doc;
// Copy over fields from the merged doc if specified
if (useFields) {
useFields.forEach(function(field) {
decoratorDoc[field] = doc[field];
});
}
// remove doc from its module doc's exports // remove doc from its module doc's exports
doc.moduleDoc.exports = doc.moduleDoc.exports.filter(function(exportDoc) { return exportDoc !== doc; }); doc.moduleDoc.exports = doc.moduleDoc.exports.filter(function(exportDoc) { return exportDoc !== doc; });
// remove from the overall list of docs to be rendered // remove from the overall list of docs to be rendered
return false; return false;
} }