Skip to content

Commit

Permalink
chore(doc-gen): add docType info into _data.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin authored and naomiblack committed Sep 17, 2015
1 parent 608f35b commit 19274e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module.exports = function addJadeDataDocsProcessor() {
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," ")
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
docType: 'module'
}];

// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
Expand All @@ -53,6 +54,7 @@ module.exports = function addJadeDataDocsProcessor() {
return {
name: exportDoc.name + '-' + exportDoc.docType,
title: exportDoc.name,
docType: exportDoc.docType,
varType: exportDoc.symbolTypeName && titleCase(exportDoc.symbolTypeName)
};
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('addJadeDataDocsProcessor', function() {
{
docType: 'module',
id: 'someModule',
exports: [{ name: 'MyClass', docType: 'class'}],
exports: [{ name: 'someObj', docType: 'var', symbolTypeName: 'MyClass'}],
fileInfo: { baseName: 'x_y' },
description: 'some description\nsecond line'
}
Expand All @@ -29,7 +29,7 @@ describe('addJadeDataDocsProcessor', function() {
originalDoc : docs[0],
data : [
{ name : 'index', title : 'X Y', intro : 'some description second line' },
{ name : 'MyClass-class', title : 'MyClass', varType : undefined }
{ name : 'someObj-var', title : 'someObj', varType : 'MyClass', docType: 'var' }
] });
});

Expand All @@ -53,11 +53,11 @@ describe('addJadeDataDocsProcessor', function() {

expect(docs[1].data).toEqual([
{ name : 'index', title : 'X Y', intro : 'some description second line' },
{ name: 'Alpha-class', title: 'Alpha', varType : undefined },
{ name: 'Beta-class', title: 'Beta', varType : undefined },
{ name: 'Gamma-class', title: 'Gamma', varType : undefined },
{ name: 'Mu-class', title: 'Mu', varType : undefined },
{ name: 'Nu-class', title: 'Nu', varType : undefined }
{ name: 'Alpha-class', title: 'Alpha', varType : undefined, docType: 'class' },
{ name: 'Beta-class', title: 'Beta', varType : undefined, docType: 'class' },
{ name: 'Gamma-class', title: 'Gamma', varType : undefined, docType: 'class' },
{ name: 'Mu-class', title: 'Mu', varType : undefined, docType: 'class' },
{ name: 'Nu-class', title: 'Nu', varType : undefined, docType: 'class' }
]);

});
Expand Down
11 changes: 8 additions & 3 deletions docs/angular.io-package/templates/jade-data.template.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
{%- for item in doc.data %}
"{$ item.name $}" : {
"title" : "{$ item.title $}"{% if item.intro %},
"intro" : "{$ item.intro $}"{% endif %}{% if item.varType %},
"varType" : "{$ item.varType $}"{% endif %}
"title" : "{$ item.title $}",
{%- if item.intro %}
"intro" : "{$ item.intro $}",
{%- endif %}
{%- if item.varType %}
"varType" : "{$ item.varType $}",
{%- endif %}
"docType": "{$ item.docType $}"
}{% if not loop.last %},{% endif %}
{% endfor -%}
}

0 comments on commit 19274e7

Please sign in to comment.