fix: merge the decorator data with the symbol
This commit is contained in:
parent
053ecc2b10
commit
ec72c8007e
@ -19,57 +19,8 @@ var titleCase = function(text) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function addJadeDataDocsProcessor() {
|
|
||||||
return {
|
|
||||||
$runAfter: ['adding-extra-docs'],
|
|
||||||
$runBefore: ['extra-docs-added'],
|
|
||||||
$process: function(docs) {
|
|
||||||
var extraDocs = [];
|
|
||||||
var modules = [];
|
|
||||||
var data = {};
|
|
||||||
|
|
||||||
var appDataDoc = {
|
|
||||||
id: 'api-list-data',
|
|
||||||
aliases: ['api-list-data'],
|
|
||||||
docType: 'api-list-data',
|
|
||||||
data: data
|
|
||||||
};
|
|
||||||
extraDocs.push(appDataDoc);
|
|
||||||
|
|
||||||
// create additional doc for auditing
|
|
||||||
var appDataAuditDoc = {
|
|
||||||
id: 'api-list-audit',
|
|
||||||
aliases: ['api-list-audit'],
|
|
||||||
docType: 'api-list-audit',
|
|
||||||
data: data
|
|
||||||
};
|
|
||||||
extraDocs.push(appDataAuditDoc);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create Data for Modules
|
|
||||||
*
|
|
||||||
* Modules must be public and have content
|
|
||||||
*/
|
|
||||||
|
|
||||||
_.forEach(docs, function(doc) {
|
|
||||||
if (doc.docType === 'module' && !doc.internal && doc.exports.length) {
|
|
||||||
modules.push(doc);
|
|
||||||
|
|
||||||
// GET DATA FOR INDEX PAGE OF MODULE SECTION
|
|
||||||
var indexPageInfo = [{
|
|
||||||
name: 'index',
|
|
||||||
title: _.map(path.basename(doc.fileInfo.baseName).split('_'), function(part) {
|
|
||||||
return titleCase(part);
|
|
||||||
}).join(' '),
|
|
||||||
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
|
|
||||||
docType: 'module'
|
|
||||||
}];
|
|
||||||
|
|
||||||
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
|
|
||||||
var modulePageInfo = _(doc.exports)
|
|
||||||
.map(function(exportDoc) {
|
|
||||||
|
|
||||||
|
function processExportDoc(exportDoc) {
|
||||||
// STABILITY STATUS
|
// STABILITY STATUS
|
||||||
// Supported tags:
|
// Supported tags:
|
||||||
// @stable
|
// @stable
|
||||||
@ -124,25 +75,110 @@ module.exports = function addJadeDataDocsProcessor() {
|
|||||||
exportDoc.showSecurityNotes = true;
|
exportDoc.showSecurityNotes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {stability: stability, howToUse: howToUse, whatItDoes: whatItDoes, security: security};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function addJadeDataDocsProcessor() {
|
||||||
|
return {
|
||||||
|
$runAfter: ['adding-extra-docs'],
|
||||||
|
$runBefore: ['extra-docs-added'],
|
||||||
|
$process: function(docs) {
|
||||||
|
var extraDocs = [];
|
||||||
|
var modules = [];
|
||||||
|
var data = {};
|
||||||
|
|
||||||
|
var appDataDoc = {
|
||||||
|
id: 'api-list-data',
|
||||||
|
aliases: ['api-list-data'],
|
||||||
|
docType: 'api-list-data',
|
||||||
|
data: data
|
||||||
|
};
|
||||||
|
extraDocs.push(appDataDoc);
|
||||||
|
|
||||||
|
// create additional doc for auditing
|
||||||
|
var appDataAuditDoc = {
|
||||||
|
id: 'api-list-audit',
|
||||||
|
aliases: ['api-list-audit'],
|
||||||
|
docType: 'api-list-audit',
|
||||||
|
data: data
|
||||||
|
};
|
||||||
|
extraDocs.push(appDataAuditDoc);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create Data for Modules
|
||||||
|
*
|
||||||
|
* Modules must be public and have content
|
||||||
|
*/
|
||||||
|
|
||||||
|
_.forEach(docs, function(doc) {
|
||||||
|
if (doc.docType === 'module' && !doc.internal && doc.exports.length) {
|
||||||
|
modules.push(doc);
|
||||||
|
|
||||||
|
// GET DATA FOR INDEX PAGE OF MODULE SECTION
|
||||||
|
var indexPageInfo = [{
|
||||||
|
name: 'index',
|
||||||
|
title: _.map(path.basename(doc.fileInfo.baseName).split('_'), function(part) {
|
||||||
|
return titleCase(part);
|
||||||
|
}).join(' '),
|
||||||
|
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
|
||||||
|
docType: 'module'
|
||||||
|
}];
|
||||||
|
|
||||||
|
var decorators = {};
|
||||||
|
|
||||||
|
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
|
||||||
|
var modulePageInfo = _(doc.exports)
|
||||||
|
.map(function(exportDoc) {
|
||||||
|
// if it ends with "Decorator", we store it in the map
|
||||||
|
// to later merge with the token
|
||||||
|
if (exportDoc.name.endsWith("Decorator")) {
|
||||||
|
var p = processExportDoc(exportDoc.callMember);
|
||||||
|
decorators[exportDoc.name] = {
|
||||||
|
stability : p.stability,
|
||||||
|
howToUse : p.howToUse,
|
||||||
|
whatItDoes : p.whatItDoes,
|
||||||
|
security : p.security,
|
||||||
|
description : exportDoc.callMember.description,
|
||||||
|
docType: 'decorator'
|
||||||
|
};
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
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,
|
||||||
title: exportDoc.name,
|
title: exportDoc.name,
|
||||||
docType: exportDoc.docType,
|
docType: exportDoc.docType,
|
||||||
exportDoc: exportDoc,
|
exportDoc: exportDoc,
|
||||||
stability: stability,
|
stability: p.stability,
|
||||||
howToUse: howToUse,
|
howToUse: p.howToUse,
|
||||||
whatItDoes: whatItDoes,
|
whatItDoes: p.whatItDoes,
|
||||||
security: 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
|
||||||
.sortBy('name')
|
.sortBy('name')
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
|
// find a matching symbol for every decorator item
|
||||||
|
// and merge the data
|
||||||
|
_.forEach(Object.keys(decorators), function(name) {
|
||||||
|
var varToken = name.split("Decorator")[0];
|
||||||
|
var c = modulePageInfo.filter(function(n) { return n.exportDoc.name === varToken; });
|
||||||
|
|
||||||
|
c[0].docType = decorators[name].docType;
|
||||||
|
Object.assign(c[0].exportDoc, decorators[name]);
|
||||||
|
});
|
||||||
|
|
||||||
doc.childPages = modulePageInfo;
|
doc.childPages = modulePageInfo;
|
||||||
|
|
||||||
// ADD TO APP DATA DOC
|
// ADD TO APP DATA DOC
|
||||||
@ -162,7 +198,6 @@ module.exports = function addJadeDataDocsProcessor() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return docs.concat(extraDocs);
|
return docs.concat(extraDocs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user