chore(doc-gen): add spaces when removing linebreaks for Jade _data.json files

Closes #3623

Closes #3997
This commit is contained in:
Peter Bacon Darwin 2015-09-04 21:42:25 +01:00
parent 34b91c62c5
commit 9d42b52d2c
3 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,8 @@
var Package = require('dgeni').Package;
module.exports = function mockPackage() {
return new Package('mockPackage', [require('../')])
.factory('log', function() { return require('dgeni/lib/mocks/log')(false); })
};

View File

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

View File

@ -0,0 +1,35 @@
var mockPackage = require('../mocks/mockPackage');
var Dgeni = require('dgeni');
describe('addJadeDataDocsProcessor', function() {
var dgeni, injector, processor;
beforeEach(function() {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
processor = injector.get('addJadeDataDocsProcessor');
});
it('should add a doc for each module', function() {
var docs = [
{
docType: 'module',
id: 'someModule',
exports: [{ name: 'MyClass', docType: 'class'}],
fileInfo: { baseName: 'x_y' },
description: 'some description\nsecond line'
}
];
docs = processor.$process(docs);
expect(docs[1]).toEqual({
id : 'someModule-data',
aliases : [ 'someModule-data' ],
docType : 'jade-data',
originalDoc : docs[0],
data : [
{ name : 'index', title : 'X Y', intro : 'some description second line' },
{ name : 'MyClass-class', title : 'MyClass', varType : undefined }
] });
});
});