feat(angular.io-package): add docType info into jade-data docs

This commit is contained in:
Peter Bacon Darwin 2015-09-18 11:59:37 +01:00 committed by Jay Traband
parent fd26ee8fbe
commit a6b88063f2
3 changed files with 22 additions and 14 deletions

View File

@ -44,7 +44,8 @@ module.exports = function addJadeDataDocsProcessor() {
title: _.map(path.basename(doc.fileInfo.baseName).split('_'), function(part) { title: _.map(path.basename(doc.fileInfo.baseName).split('_'), function(part) {
return titleCase(part); return titleCase(part);
}).join(' '), }).join(' '),
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," ") intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
docType: 'module'
}]; }];
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS) // GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
@ -53,6 +54,7 @@ module.exports = function addJadeDataDocsProcessor() {
return { return {
name: exportDoc.name + '-' + exportDoc.docType, name: exportDoc.name + '-' + exportDoc.docType,
title: exportDoc.name, title: exportDoc.name,
docType: exportDoc.docType,
varType: exportDoc.symbolTypeName && titleCase(exportDoc.symbolTypeName) varType: exportDoc.symbolTypeName && titleCase(exportDoc.symbolTypeName)
}; };
}) })

View File

@ -15,7 +15,7 @@ describe('addJadeDataDocsProcessor', function() {
{ {
docType: 'module', docType: 'module',
id: 'someModule', id: 'someModule',
exports: [{ name: 'MyClass', docType: 'class'}], exports: [{ name: 'someObj', docType: 'var', symbolTypeName: 'MyClass'}],
fileInfo: { baseName: 'x_y' }, fileInfo: { baseName: 'x_y' },
description: 'some description\nsecond line' description: 'some description\nsecond line'
} }
@ -28,8 +28,8 @@ describe('addJadeDataDocsProcessor', function() {
docType : 'jade-data', docType : 'jade-data',
originalDoc : docs[0], originalDoc : docs[0],
data : [ data : [
{ name : 'index', title : 'X Y', intro : 'some description second line' }, { name : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' },
{ name : 'MyClass-class', title : 'MyClass', varType : undefined } { name : 'someObj-var', title : 'someObj', varType : 'MyClass', docType: 'var' }
] }); ] });
}); });
@ -52,12 +52,13 @@ describe('addJadeDataDocsProcessor', function() {
docs = processor.$process(docs); docs = processor.$process(docs);
expect(docs[1].data).toEqual([ expect(docs[1].data).toEqual([
{ name : 'index', title : 'X Y', intro : 'some description second line' }, { name : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' },
{ name: 'Alpha-class', title: 'Alpha', varType : undefined }, { name: 'Alpha-class', title: 'Alpha', varType : undefined, docType: 'class' },
{ name: 'Beta-class', title: 'Beta', varType : undefined }, { name: 'Beta-class', title: 'Beta', varType : undefined, docType: 'class' },
{ name: 'Gamma-class', title: 'Gamma', varType : undefined }, { name: 'Gamma-class', title: 'Gamma', varType : undefined, docType: 'class' },
{ name: 'Mu-class', title: 'Mu', varType : undefined }, { name: 'Mu-class', title: 'Mu', varType : undefined, docType: 'class' },
{ name: 'Nu-class', title: 'Nu', varType : undefined } { name: 'Nu-class', title: 'Nu', varType : undefined, docType: 'class' }
]); ]);
});}); });
});

View File

@ -1,9 +1,14 @@
{ {
{%- for item in doc.data %} {%- for item in doc.data %}
"{$ item.name $}" : { "{$ item.name $}" : {
"title" : "{$ item.title $}"{% if item.intro %}, "title" : "{$ item.title $}",
"intro" : "{$ item.intro $}"{% endif %}{% if item.varType %}, {%- if item.intro %}
"varType" : "{$ item.varType $}"{% endif %} "intro" : "{$ item.intro $}",
{%- endif %}
{%- if item.varType %}
"varType" : "{$ item.varType $}",
{%- endif %}
"docType": "{$ item.docType $}"
}{% if not loop.last %},{% endif %} }{% if not loop.last %},{% endif %}
{% endfor -%} {% endfor -%}
} }