build(aio): fix mergeDecoratorDocs processor
This commit is contained in:
parent
99b38f52cb
commit
92c18d167e
|
@ -83,13 +83,14 @@ module.exports = function mergeDecoratorDocs(log) {
|
||||||
if (docsToMerge[doc.name]) {
|
if (docsToMerge[doc.name]) {
|
||||||
// We have found an `XxxDecorator` document that will hold the call signature of the decorator
|
// We have found an `XxxDecorator` document that will hold the call signature of the decorator
|
||||||
var decoratorDoc = docsToMerge[doc.name];
|
var decoratorDoc = docsToMerge[doc.name];
|
||||||
|
var callMember = doc.members.filter(function(member) { return member.isCallMember; })[0];
|
||||||
log.debug(
|
log.debug(
|
||||||
'mergeDecoratorDocs: merging', doc.name, 'into', decoratorDoc.name,
|
'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
|
// Merge the documentation found in this call signature into the original decorator
|
||||||
decoratorDoc.description = doc.callMember.description;
|
decoratorDoc.description = callMember.description;
|
||||||
decoratorDoc.howToUse = doc.callMember.howToUse;
|
decoratorDoc.howToUse = callMember.howToUse;
|
||||||
decoratorDoc.whatItDoes = doc.callMember.whatItDoes;
|
decoratorDoc.whatItDoes = callMember.whatItDoes;
|
||||||
|
|
||||||
// remove doc from its module doc's exports
|
// remove doc from its module doc's exports
|
||||||
doc.moduleDoc.exports =
|
doc.moduleDoc.exports =
|
||||||
|
@ -108,8 +109,8 @@ module.exports = function mergeDecoratorDocs(log) {
|
||||||
function getMakeDecoratorCall(doc, type) {
|
function getMakeDecoratorCall(doc, type) {
|
||||||
var makeDecoratorFnName = 'make' + (type || '') + 'Decorator';
|
var makeDecoratorFnName = 'make' + (type || '') + 'Decorator';
|
||||||
|
|
||||||
var initializer = doc.exportSymbol && doc.exportSymbol.valueDeclaration &&
|
var initializer = doc.declaration &&
|
||||||
doc.exportSymbol.valueDeclaration.initializer;
|
doc.declaration.initializer;
|
||||||
|
|
||||||
if (initializer) {
|
if (initializer) {
|
||||||
// There appear to be two forms of initializer:
|
// There appear to be two forms of initializer:
|
||||||
|
|
|
@ -15,10 +15,7 @@ describe('mergeDecoratorDocs processor', () => {
|
||||||
name: 'Component',
|
name: 'Component',
|
||||||
docType: 'const',
|
docType: 'const',
|
||||||
description: 'A description of the metadata for the Component decorator',
|
description: 'A description of the metadata for the Component decorator',
|
||||||
exportSymbol: {
|
declaration: {initializer: {expression: {text: 'makeDecorator'}, arguments: [{text: 'X'}]}},
|
||||||
valueDeclaration:
|
|
||||||
{initializer: {expression: {text: 'makeDecorator'}, arguments: [{text: 'X'}]}}
|
|
||||||
},
|
|
||||||
members: [
|
members: [
|
||||||
{ name: 'templateUrl', description: 'A description of the templateUrl property' }
|
{ name: 'templateUrl', description: 'A description of the templateUrl property' }
|
||||||
],
|
],
|
||||||
|
@ -29,34 +26,25 @@ describe('mergeDecoratorDocs processor', () => {
|
||||||
name: 'ComponentDecorator',
|
name: 'ComponentDecorator',
|
||||||
docType: 'interface',
|
docType: 'interface',
|
||||||
description: 'A description of the interface for the call signature for the Component decorator',
|
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',
|
description: 'The actual description of the call signature',
|
||||||
whatItDoes: 'Does something cool...',
|
whatItDoes: 'Does something cool...',
|
||||||
howToUse: 'Use it like this...'
|
howToUse: 'Use it like this...'
|
||||||
},
|
}],
|
||||||
moduleDoc
|
moduleDoc
|
||||||
};
|
};
|
||||||
|
|
||||||
decoratorDocWithTypeAssertion = {
|
decoratorDocWithTypeAssertion = {
|
||||||
name: 'Y',
|
name: 'Y',
|
||||||
docType: 'var',
|
docType: 'const',
|
||||||
exportSymbol: {
|
declaration: { initializer: { expression: {type: {}, expression: {text: 'makeDecorator'}, arguments: [{text: 'Y'}]} } },
|
||||||
valueDeclaration: {
|
|
||||||
initializer: {
|
|
||||||
expression:
|
|
||||||
{type: {}, expression: {text: 'makeDecorator'}, arguments: [{text: 'Y'}]}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
moduleDoc
|
moduleDoc
|
||||||
};
|
};
|
||||||
otherDoc = {
|
otherDoc = {
|
||||||
name: 'Y',
|
name: 'Y',
|
||||||
docType: 'var',
|
docType: 'const',
|
||||||
exportSymbol: {
|
declaration: {initializer: {expression: {text: 'otherCall'}, arguments: [{text: 'param1'}]}},
|
||||||
valueDeclaration:
|
|
||||||
{initializer: {expression: {text: 'otherCall'}, arguments: [{text: 'param1'}]}}
|
|
||||||
},
|
|
||||||
moduleDoc
|
moduleDoc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,7 +56,7 @@ describe('mergeDecoratorDocs processor', () => {
|
||||||
processor.$process([decoratorDoc, metadataDoc, decoratorDocWithTypeAssertion, otherDoc]);
|
processor.$process([decoratorDoc, metadataDoc, decoratorDocWithTypeAssertion, otherDoc]);
|
||||||
expect(decoratorDoc.docType).toEqual('decorator');
|
expect(decoratorDoc.docType).toEqual('decorator');
|
||||||
expect(decoratorDocWithTypeAssertion.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', () => {
|
it('should extract the "type" of the decorator meta data', () => {
|
||||||
|
|
Loading…
Reference in New Issue