From a6b88063f23dc1e79efa0d511fed42a7fafc7a70 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Fri, 18 Sep 2015 11:59:37 +0100 Subject: [PATCH] feat(angular.io-package): add docType info into jade-data docs --- .../processors/addJadeDataDocsProcessor.js | 4 +++- .../addJadeDataDocsProcessor.spec.js | 21 ++++++++++--------- .../templates/jade-data.template.html | 11 +++++++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js b/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js index 185ce1892c..fb6a655991 100644 --- a/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js +++ b/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js @@ -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) @@ -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) }; }) diff --git a/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.spec.js b/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.spec.js index d93c8fe4bc..0aaa09a746 100644 --- a/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.spec.js +++ b/public/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.spec.js @@ -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' } @@ -28,8 +28,8 @@ describe('addJadeDataDocsProcessor', function() { docType : 'jade-data', originalDoc : docs[0], data : [ - { name : 'index', title : 'X Y', intro : 'some description second line' }, - { name : 'MyClass-class', title : 'MyClass', varType : undefined } + { name : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' }, + { name : 'someObj-var', title : 'someObj', varType : 'MyClass', docType: 'var' } ] }); }); @@ -52,12 +52,13 @@ describe('addJadeDataDocsProcessor', function() { docs = processor.$process(docs); 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 : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' }, + { 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' } ]); - });}); + }); +}); diff --git a/public/api-builder/angular.io-package/templates/jade-data.template.html b/public/api-builder/angular.io-package/templates/jade-data.template.html index 3cefa7980e..f19196de1e 100644 --- a/public/api-builder/angular.io-package/templates/jade-data.template.html +++ b/public/api-builder/angular.io-package/templates/jade-data.template.html @@ -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 -%} }