fix(api-builder): tighten up check for decorator (#3369)
This commit is contained in:
parent
9386a6606f
commit
0cc9ad2acd
|
@ -38,27 +38,27 @@ function processExportDoc(exportDoc) {
|
||||||
stability = 'deprecated';
|
stability = 'deprecated';
|
||||||
exportDoc.showDeprecatedNotes = true;
|
exportDoc.showDeprecatedNotes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var howToUse = '';
|
var howToUse = '';
|
||||||
if(_.has(exportDoc, 'howToUse')) {
|
if(_.has(exportDoc, 'howToUse')) {
|
||||||
var howToUseArray = exportDoc.tags.tags.filter(function(tag) {
|
var howToUseArray = exportDoc.tags.tags.filter(function(tag) {
|
||||||
return tag.tagName === 'howToUse'
|
return tag.tagName === 'howToUse'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove line breaks, there should only be one tag
|
// Remove line breaks, there should only be one tag
|
||||||
howToUse = howToUseArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
howToUse = howToUseArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
||||||
}
|
}
|
||||||
|
|
||||||
var whatItDoes = '';
|
var whatItDoes = '';
|
||||||
if(_.has(exportDoc, 'whatItDoes')) {
|
if(_.has(exportDoc, 'whatItDoes')) {
|
||||||
var whatItDoesArray = exportDoc.tags.tags.filter(function(tag) {
|
var whatItDoesArray = exportDoc.tags.tags.filter(function(tag) {
|
||||||
return tag.tagName === 'whatItDoes'
|
return tag.tagName === 'whatItDoes'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove line breaks, there should only be one tag
|
// Remove line breaks, there should only be one tag
|
||||||
whatItDoes = whatItDoesArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
whatItDoes = whatItDoesArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// SECURITY STATUS
|
// SECURITY STATUS
|
||||||
// Supported tags:
|
// Supported tags:
|
||||||
// @security
|
// @security
|
||||||
|
@ -68,13 +68,13 @@ function processExportDoc(exportDoc) {
|
||||||
var securityArray = exportDoc.tags.tags.filter(function(tag) {
|
var securityArray = exportDoc.tags.tags.filter(function(tag) {
|
||||||
return tag.tagName === 'security'
|
return tag.tagName === 'security'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove line breaks, there should only be one tag
|
// Remove line breaks, there should only be one tag
|
||||||
security = securityArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
security = securityArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
|
||||||
|
|
||||||
exportDoc.showSecurityNotes = true;
|
exportDoc.showSecurityNotes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {stability: stability, howToUse: howToUse, whatItDoes: whatItDoes, security: security};
|
return {stability: stability, howToUse: howToUse, whatItDoes: whatItDoes, security: security};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ module.exports = function addJadeDataDocsProcessor() {
|
||||||
*
|
*
|
||||||
* Modules must be public and have content
|
* Modules must be public and have content
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_.forEach(docs, function(doc) {
|
_.forEach(docs, function(doc) {
|
||||||
if (doc.docType === 'module' && !doc.internal && doc.exports.length) {
|
if (doc.docType === 'module' && !doc.internal && doc.exports.length) {
|
||||||
modules.push(doc);
|
modules.push(doc);
|
||||||
|
@ -124,15 +124,15 @@ module.exports = function addJadeDataDocsProcessor() {
|
||||||
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
|
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
|
||||||
docType: 'module'
|
docType: 'module'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
var decorators = {};
|
var decorators = {};
|
||||||
|
|
||||||
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
|
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
|
||||||
var modulePageInfo = _(doc.exports)
|
var modulePageInfo = _(doc.exports)
|
||||||
.map(function(exportDoc) {
|
.map(function(exportDoc) {
|
||||||
// if it ends with "Decorator", we store it in the map
|
// if it ends with "Decorator", we store it in the map
|
||||||
// to later merge with the token
|
// to later merge with the token
|
||||||
if (exportDoc.name.endsWith("Decorator")) {
|
if (exportDoc.name.endsWith("Decorator") && exportDoc.callMember) {
|
||||||
var p = processExportDoc(exportDoc.callMember);
|
var p = processExportDoc(exportDoc.callMember);
|
||||||
decorators[exportDoc.name] = {
|
decorators[exportDoc.name] = {
|
||||||
stability : p.stability,
|
stability : p.stability,
|
||||||
|
@ -146,7 +146,7 @@ module.exports = function addJadeDataDocsProcessor() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var p = processExportDoc(exportDoc);
|
var p = processExportDoc(exportDoc);
|
||||||
|
|
||||||
// Data inserted into jade-data.template.html
|
// Data inserted into jade-data.template.html
|
||||||
var dataDoc = {
|
var dataDoc = {
|
||||||
name: exportDoc.name + '-' + exportDoc.docType,
|
name: exportDoc.name + '-' + exportDoc.docType,
|
||||||
|
@ -158,23 +158,23 @@ module.exports = function addJadeDataDocsProcessor() {
|
||||||
whatItDoes: p.whatItDoes,
|
whatItDoes: p.whatItDoes,
|
||||||
security: p.security
|
security: p.security
|
||||||
};
|
};
|
||||||
|
|
||||||
if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName);
|
if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName);
|
||||||
if (exportDoc.originalModule) dataDoc.originalModule = exportDoc.originalModule;
|
if (exportDoc.originalModule) dataDoc.originalModule = exportDoc.originalModule;
|
||||||
|
|
||||||
return dataDoc;
|
return dataDoc;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(function(s) { return !!s; }) // filter out all null values
|
.filter(function(s) { return !!s; }) // filter out all null values
|
||||||
.sortBy('name')
|
.sortBy('name')
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
// find a matching symbol for every decorator item
|
// find a matching symbol for every decorator item
|
||||||
// and merge the data
|
// and merge the data
|
||||||
_.forEach(Object.keys(decorators), function(name) {
|
_.forEach(Object.keys(decorators), function(name) {
|
||||||
var varToken = name.split("Decorator")[0];
|
var varToken = name.split("Decorator")[0];
|
||||||
var c = modulePageInfo.filter(function(n) { return n.exportDoc.name === varToken; });
|
var c = modulePageInfo.filter(function(n) { return n.exportDoc.name === varToken; });
|
||||||
|
|
||||||
c[0].docType = decorators[name].docType;
|
c[0].docType = decorators[name].docType;
|
||||||
Object.assign(c[0].exportDoc, decorators[name]);
|
Object.assign(c[0].exportDoc, decorators[name]);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue