build(aio): fix mergeDecoratorDocs processor

This commit is contained in:
Peter Bacon Darwin 2017-06-29 21:31:59 +01:00 committed by Pete Bacon Darwin
parent 99b38f52cb
commit 92c18d167e
2 changed files with 16 additions and 27 deletions

View File

@ -83,13 +83,14 @@ module.exports = function mergeDecoratorDocs(log) {
if (docsToMerge[doc.name]) {
// We have found an `XxxDecorator` document that will hold the call signature of the decorator
var decoratorDoc = docsToMerge[doc.name];
var callMember = doc.members.filter(function(member) { return member.isCallMember; })[0];
log.debug(
'mergeDecoratorDocs: merging', doc.name, 'into', decoratorDoc.name,
doc.callMember.description.substring(0, 50));
callMember.description.substring(0, 50));
// Merge the documentation found in this call signature into the original decorator
decoratorDoc.description = doc.callMember.description;
decoratorDoc.howToUse = doc.callMember.howToUse;
decoratorDoc.whatItDoes = doc.callMember.whatItDoes;
decoratorDoc.description = callMember.description;
decoratorDoc.howToUse = callMember.howToUse;
decoratorDoc.whatItDoes = callMember.whatItDoes;
// remove doc from its module doc's exports
doc.moduleDoc.exports =
@ -108,8 +109,8 @@ module.exports = function mergeDecoratorDocs(log) {
function getMakeDecoratorCall(doc, type) {
var makeDecoratorFnName = 'make' + (type || '') + 'Decorator';
var initializer = doc.exportSymbol && doc.exportSymbol.valueDeclaration &&
doc.exportSymbol.valueDeclaration.initializer;
var initializer = doc.declaration &&
doc.declaration.initializer;
if (initializer) {
// There appear to be two forms of initializer:

View File

@ -15,10 +15,7 @@ describe('mergeDecoratorDocs processor', () => {
name: 'Component',
docType: 'const',
description: 'A description of the metadata for the Component decorator',
exportSymbol: {
valueDeclaration:
{initializer: {expression: {text: 'makeDecorator'}, arguments: [{text: 'X'}]}}
},
declaration: {initializer: {expression: {text: 'makeDecorator'}, arguments: [{text: 'X'}]}},
members: [
{ name: 'templateUrl', description: 'A description of the templateUrl property' }
],
@ -29,34 +26,25 @@ describe('mergeDecoratorDocs processor', () => {
name: 'ComponentDecorator',
docType: 'interface',
description: 'A description of the interface for the call signature for the Component decorator',
callMember: {
members: [{
isCallMember: true,
description: 'The actual description of the call signature',
whatItDoes: 'Does something cool...',
howToUse: 'Use it like this...'
},
}],
moduleDoc
};
decoratorDocWithTypeAssertion = {
name: 'Y',
docType: 'var',
exportSymbol: {
valueDeclaration: {
initializer: {
expression:
{type: {}, expression: {text: 'makeDecorator'}, arguments: [{text: 'Y'}]}
}
}
},
docType: 'const',
declaration: { initializer: { expression: {type: {}, expression: {text: 'makeDecorator'}, arguments: [{text: 'Y'}]} } },
moduleDoc
};
otherDoc = {
name: 'Y',
docType: 'var',
exportSymbol: {
valueDeclaration:
{initializer: {expression: {text: 'otherCall'}, arguments: [{text: 'param1'}]}}
},
docType: 'const',
declaration: {initializer: {expression: {text: 'otherCall'}, arguments: [{text: 'param1'}]}},
moduleDoc
};
@ -68,7 +56,7 @@ describe('mergeDecoratorDocs processor', () => {
processor.$process([decoratorDoc, metadataDoc, decoratorDocWithTypeAssertion, otherDoc]);
expect(decoratorDoc.docType).toEqual('decorator');
expect(decoratorDocWithTypeAssertion.docType).toEqual('decorator');
expect(otherDoc.docType).toEqual('var');
expect(otherDoc.docType).toEqual('const');
});
it('should extract the "type" of the decorator meta data', () => {