Modernization of build environment, better linting, adjustment after stricter static rules, cleanup of package.json

This commit is contained in:
knsv
2015-10-17 12:46:36 +02:00
parent 632a564158
commit 315923d1d3
33 changed files with 21673 additions and 21181 deletions

View File

@@ -2,15 +2,10 @@
* Created by knut on 14-11-18.
*/
describe('when parsing an info graph it',function() {
var parseError;
var ex;
beforeEach(function () {
ex = require('./parser/example').parser;
ex.yy = require('./exampleDb');
parseError = function(err, hash) {
log.debug('Syntax error:' + err);
};
//ex.yy.parseError = parseError;
});
it('should handle an info definition', function () {

View File

@@ -6,6 +6,7 @@ var message = '';
var info = false;
exports.setMessage = function(txt){
log.debug('Setting message to: '+txt);
message = txt;
};
@@ -22,5 +23,5 @@ exports.getInfo = function(){
};
exports.parseError = function(err,hash){
mermaidAPI.parseError(err,hash);
global.mermaidAPI.parseError(err,hash);
};

View File

@@ -14,14 +14,13 @@ exports.draw = function (txt, id, ver) {
var parser;
parser = exampleParser.parser;
parser.yy = db;
log.debug('Renering example diagram');
// Parse the graph definition
parser.parse(txt);
// Fetch the default direction, use TD if none was found
var svg = d3.select('#'+id);
var textstring = 'mermaid!';
var g = svg.append('g');
g.append('text') // text label for the x axis

View File

@@ -2,6 +2,7 @@
* Created by knut on 14-11-03.
*/
var log = require('../../logger').create();
var d3 = require('../../d3');
var vertices = {};
var edges = [];
var classes = [];
@@ -64,7 +65,7 @@ exports.addVertex = function (id, text, type, style) {
* @param linktext
*/
exports.addLink = function (start, end, type, linktext) {
//log.debug('Got edge', start, end);
log.debug('Got edge', start, end);
var edge = {start: start, end: end, type: undefined, text: ''};
linktext = type.text;
@@ -89,8 +90,6 @@ exports.addLink = function (start, end, type, linktext) {
* @param style
*/
exports.updateLink = function (pos, style) {
var position = pos.substr(1);
if(pos === 'default'){
edges.defaultStyle = style;
}else{
@@ -178,7 +177,7 @@ var setLink = function(id, linkStr){
exports.getTooltip = function(id){
return tooltips[id];
};
var clickEvents = [];
/**
* Called by parser when a graph definition is found, stores the direction of the chart.
* @param dir
@@ -243,7 +242,7 @@ var setupToolTips = function(element){
var nodes = svg.selectAll('g.node');
nodes
.on('mouseover', function(d) {
.on('mouseover', function() {
var el = d3.select(this);
var title = el.attr('title');
// Dont try to draw a tooltip if no data is provided
@@ -261,7 +260,7 @@ var setupToolTips = function(element){
el.classed('hover',true);
})
.on('mouseout', function(d) {
.on('mouseout', function() {
tooltipElem.transition()
.duration(500)
.style('opacity', 0);
@@ -386,17 +385,17 @@ var indexNodes = function (id, pos) {
exports.getDepthFirstPos = function (pos) {
return posCrossRef[pos];
};
exports.indexNodes = function (id) {
exports.indexNodes = function () {
secCount = -1;
if(subGraphs.length>0){
indexNodes('none',subGraphs.length-1,0);
}
};
exports.getSubGraphs = function (list) {
exports.getSubGraphs = function () {
return subGraphs;
};
exports.parseError = function(err,hash){
mermaidAPI.parseError(err,hash);
global.mermaidAPI.parseError(err,hash);
};

View File

@@ -2,13 +2,11 @@
* Created by knut on 14-11-18.
*/
describe('when parsing a gantt diagram it',function() {
var parseError, gantt;
var gantt;
beforeEach(function () {
gantt = require('./parser/gantt').parser;
gantt.yy = require('./ganttDb');
parseError = function(err, hash) {
log.debug('Syntax error:' + err);
};
//ex.yy.parseError = parseError;
});

View File

@@ -237,5 +237,5 @@ exports.addTask = function(descr,data){
};
exports.parseError = function(err,hash){
mermaidAPI.parseError(err,hash);
global.mermaidAPI.parseError(err,hash);
};

View File

@@ -1,9 +1,9 @@
/**
* Created by knut on 14-11-18.
*/
var log = require('../../logger').create();
//var log = require('../../logger').create();
describe('when using the ganttDb',function() {
var parseError, gantt, gDb;
var gDb;
var moment = require('moment');
beforeEach(function () {
@@ -11,9 +11,6 @@ describe('when using the ganttDb',function() {
gDb = require('./ganttDb');
gDb.clear();
parseError = function(err, hash) {
log.debug('Syntax error:' + err);
};
//ex.yy.parseError = parseError;
});

View File

@@ -2,7 +2,7 @@ var gantt = require('./parser/gantt').parser;
gantt.yy = require('./ganttDb');
var d3 = require('../../d3');
var moment = require('moment');
var log = require('../../logger').create();
//var log = require('../../logger').create();
var daysInChart;
var conf = {
@@ -51,7 +51,7 @@ module.exports.draw = function (text, id) {
var dateFormat = d3.time.format('%Y-%m-%d');
//var dateFormat = d3.time.format('%Y-%m-%d');
var startDate = d3.min(taskArray, function (d) {
return d.startTime;
@@ -90,7 +90,7 @@ module.exports.draw = function (text, id) {
}
var title = svg.append('text')
svg.append('text')
.text(gantt.yy.getTitle())
.attr('x', w / 2)
.attr('y', conf.titleTopMargin)
@@ -117,9 +117,9 @@ module.exports.draw = function (text, id) {
}
function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w, h) {
function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w, h) { //eslint-disable-line no-unused-vars
var bigRects = svg.append('g')
svg.append('g')
.selectAll('rect')
.data(theArray)
.enter()
@@ -128,11 +128,11 @@ module.exports.draw = function (text, id) {
.attr('y', function (d, i) {
return i * theGap + theTopPad - 2;
})
.attr('width', function (d) {
.attr('width', function () {
return w - theSidePad / 2;
})
.attr('height', theGap)
.attr('class', function (d) {
.attr('class', function (d) { //eslint-disable-line no-unused-vars
for (var i = 0; i < categories.length; i++) {
if (d.type === categories[i]) {
return 'section section' + (i % conf.numberSectionStyles);
@@ -148,7 +148,7 @@ module.exports.draw = function (text, id) {
.enter();
var innerRects = rectangles.append('rect')
rectangles.append('rect')
.attr('rx', 3)
.attr('ry', 3)
.attr('x', function (d) {
@@ -198,7 +198,7 @@ module.exports.draw = function (text, id) {
;
var rectText = rectangles.append('text')
rectangles.append('text')
.text(function (d) {
return d.task;
})
@@ -332,7 +332,7 @@ module.exports.draw = function (text, id) {
xAxis = xAxis.ticks(d3.time.monday.range);
}
var grid = svg.append('g')
svg.append('g')
.attr('class', 'grid')
.attr('transform', 'translate(' + theSidePad + ', ' + (h - 50) + ')')
.call(xAxis)
@@ -344,7 +344,7 @@ module.exports.draw = function (text, id) {
.attr('dy', '1em');
}
function vertLabels(theGap, theTopPad, theSidePad, theBarHeight, theColorScale) {
function vertLabels(theGap, theTopPad) {
var numOccurances = [];
var prevGap = 0;
@@ -352,7 +352,7 @@ module.exports.draw = function (text, id) {
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)];
}
var axisText = svg.append('g') //without doing this, impossible to put grid lines behind text
svg.append('g') //without doing this, impossible to put grid lines behind text
.selectAll('text')
.data(numOccurances)
.enter()
@@ -389,7 +389,7 @@ module.exports.draw = function (text, id) {
var today = new Date();
var todayLine = todayG.append('line')
todayG.append('line')
.attr('x1', timeScale(today) + theSidePad)
.attr('x2', timeScale(today) + theSidePad)
.attr('y1', conf.titleTopMargin)

View File

@@ -81,7 +81,7 @@ exports.addNote = function (actor, placement, message){
exports.parseError = function(err,hash){
mermaidAPI.parseError(err,hash);
global.mermaidAPI.parseError(err,hash);
};
exports.apply = function(param){

View File

@@ -2,7 +2,7 @@
* Created by knut on 14-11-18.
*/
var proxyquire = require('proxyquire');
var log = require('../../logger').create();
//var log = require('../../logger').create();
var sq = require('./parser/sequenceDiagram').parser;
var newD3;
@@ -20,7 +20,6 @@ var sd = proxyquire('./sequenceRenderer', { '../../d3': d3 });
var str;
describe('when parsing a sequenceDiagram',function() {
var parseError;
beforeEach(function () {
sq.yy = require('./sequenceDb');
sq.yy.clear();
@@ -335,7 +334,7 @@ describe('when parsing a sequenceDiagram',function() {
});});
describe('when checking the bounds in a sequenceDiagram',function() {
var parseError, _d3, conf;
var conf;
beforeEach(function () {
sq.yy = require('./sequenceDb');
sq.yy.clear();
@@ -485,11 +484,19 @@ describe('when checking the bounds in a sequenceDiagram',function() {
});
describe('when rendering a sequenceDiagram',function() {
var parseError, _d3, conf;
var conf;
beforeEach(function () {
sq.yy = require('./sequenceDb');
sq.yy.clear();
var MockBrowser = require('mock-browser').mocks.MockBrowser;
var mock = new MockBrowser();
delete global.mermaid_config;
// and in the run-code inside some object
global.document = mock.getDocument();
global.window = mock.getWindow();
//parseError = function(err, hash) {
// log.debug('Syntax error:' + err);
@@ -499,16 +506,16 @@ describe('when rendering a sequenceDiagram',function() {
newD3 = function() {
var o = {
append: function (type) {
append: function () {
return newD3();
},
attr: function (key, val) {
attr: function () {
return this;
},
style: function (key, val) {
style: function () {
return this;
},
text: function (txt) {
text: function () {
return this;
},
0:{
@@ -682,7 +689,7 @@ describe('when rendering a sequenceDiagram',function() {
});
describe('when rendering a sequenceDiagram with actor mirror activated',function() {
var parseError, _d3, conf;
var conf;
beforeEach(function () {
sq.yy = require('./sequenceDb');
sq.yy.clear();
@@ -694,16 +701,16 @@ describe('when rendering a sequenceDiagram with actor mirror activated',function
newD3 = function() {
var o = {
append: function (type) {
append: function () {
return newD3();
},
attr: function (key, val) {
attr: function () {
return this;
},
style: function (key, val) {
style: function () {
return this;
},
text: function (txt) {
text: function () {
return this;
},
0:{

View File

@@ -37,7 +37,7 @@ exports.bounds = {
startx:undefined,
stopx :undefined,
starty:undefined,
stopy :undefined,
stopy :undefined
},
verticalPos:0,
@@ -48,7 +48,7 @@ exports.bounds = {
startx:undefined,
stopx :undefined,
starty:undefined,
stopy :undefined,
stopy :undefined
};
this.verticalPos =0;
},

View File

@@ -1,7 +1,7 @@
/**
* Created by knut on 14-12-20.
*/
var log = require('../../logger').create();
//var log = require('../../logger').create();
exports.drawRect = function(elem , rectData){
var rectElem = elem.append('rect');
rectElem.attr('x', rectData.x);