mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 09:36:41 +02:00
fix warnings per code climate
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,4 +7,6 @@ bower_components
|
|||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
coverage
|
coverage
|
||||||
|
|
||||||
|
test/tmp_*
|
||||||
|
@@ -271,16 +271,14 @@ var _drawTextCandidateFunc = (function() {
|
|||||||
.attr('x', x + width / 2).attr('y', y + height / 2 + 5)
|
.attr('x', x + width / 2).attr('y', y + height / 2 + 5)
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.text(content);
|
.text(content);
|
||||||
for (var key in textAttrs) {
|
_setTextAttrs(text, textAttrs);
|
||||||
text.attr(key, textAttrs[key]);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function byTspan(content, g, x, y, width, height, textAttrs) {
|
function byTspan(content, g, x, y, width, height, textAttrs) {
|
||||||
var text = g.append('text')
|
var text = g.append('text')
|
||||||
.attr('x', x + width / 2).attr('y', y)
|
.attr('x', x + width / 2).attr('y', y)
|
||||||
.style('text-anchor', 'middle');
|
.style('text-anchor', 'middle');
|
||||||
var tspan = text.append('tspan')
|
text.append('tspan')
|
||||||
.attr('x', x + width / 2).attr('dy', '0')
|
.attr('x', x + width / 2).attr('dy', '0')
|
||||||
.text(content);
|
.text(content);
|
||||||
|
|
||||||
@@ -293,16 +291,13 @@ var _drawTextCandidateFunc = (function() {
|
|||||||
if (tspans.length > 0 && tspans[0].length > 0) {
|
if (tspans.length > 0 && tspans[0].length > 0) {
|
||||||
tspans = tspans[0];
|
tspans = tspans[0];
|
||||||
//set y of <text> to the mid y of the first line
|
//set y of <text> to the mid y of the first line
|
||||||
text.attr('y', y + (height/2.- text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.))
|
text.attr('y', y + (height/2.0 - text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.0))
|
||||||
.attr("dominant-baseline", "central")
|
.attr("dominant-baseline", "central")
|
||||||
.attr("alignment-baseline", "central")
|
.attr("alignment-baseline", "central");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_setTextAttrs(text, textAttrs);
|
||||||
for (var key in textAttrs) {
|
}
|
||||||
text.attr(key, textAttrs[key]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function byFo(content, g, x, y, width, height, textAttrs) {
|
function byFo(content, g, x, y, width, height, textAttrs) {
|
||||||
var s = g.append('switch');
|
var s = g.append('switch');
|
||||||
@@ -315,14 +310,19 @@ var _drawTextCandidateFunc = (function() {
|
|||||||
|
|
||||||
text.append('div').style('display', 'table-cell')
|
text.append('div').style('display', 'table-cell')
|
||||||
.style('text-align', 'center').style('vertical-align', 'middle')
|
.style('text-align', 'center').style('vertical-align', 'middle')
|
||||||
.text(content)
|
.text(content);
|
||||||
|
|
||||||
byTspan(content, s, x, y, width, height, textAttrs);
|
byTspan(content, s, x, y, width, height, textAttrs);
|
||||||
|
_setTextAttrs(text, textAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
for (var key in textAttrs) {
|
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||||
text.attr(key, textAttrs[key]);
|
for (var key in fromTextAttrsDict) {
|
||||||
|
if (fromTextAttrsDict.hasOwnProperty(key)) {
|
||||||
|
toText.attr(key, fromTextAttrsDict[key]);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return function(conf) {
|
return function(conf) {
|
||||||
return conf.textPlacement==='fo' ? byFo : (
|
return conf.textPlacement==='fo' ? byFo : (
|
||||||
|
@@ -47,7 +47,7 @@ test('output of single png', function(t) {
|
|||||||
|
|
||||||
var expected = ['test.mermaid.png']
|
var expected = ['test.mermaid.png']
|
||||||
|
|
||||||
opt = clone(singleFile)
|
var opt = clone(singleFile)
|
||||||
opt.outputDir += '_png'
|
opt.outputDir += '_png'
|
||||||
opt.png = true
|
opt.png = true
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ test('output of multiple png', function(t) {
|
|||||||
var expected = ['test.mermaid.png', 'test2.mermaid.png',
|
var expected = ['test.mermaid.png', 'test2.mermaid.png',
|
||||||
'gantt.mermaid.png', 'sequence.mermaid.png']
|
'gantt.mermaid.png', 'sequence.mermaid.png']
|
||||||
|
|
||||||
opt = clone(multiFile)
|
var opt = clone(multiFile)
|
||||||
opt.outputDir += '_png'
|
opt.outputDir += '_png'
|
||||||
opt.png = true
|
opt.png = true
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ test('output of single svg', function(t) {
|
|||||||
|
|
||||||
var expected = ['test.mermaid.svg']
|
var expected = ['test.mermaid.svg']
|
||||||
|
|
||||||
opt = clone(singleFile)
|
var opt = clone(singleFile)
|
||||||
opt.outputDir += '_svg'
|
opt.outputDir += '_svg'
|
||||||
opt.svg = true
|
opt.svg = true
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ test('output of multiple svg', function(t) {
|
|||||||
var expected = ['test.mermaid.svg', 'test2.mermaid.svg',
|
var expected = ['test.mermaid.svg', 'test2.mermaid.svg',
|
||||||
'gantt.mermaid.svg', 'sequence.mermaid.svg']
|
'gantt.mermaid.svg', 'sequence.mermaid.svg']
|
||||||
|
|
||||||
opt = clone(multiFile)
|
var opt = clone(multiFile)
|
||||||
opt.outputDir += '_svg'
|
opt.outputDir += '_svg'
|
||||||
opt.svg = true
|
opt.svg = true
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ function verifyFiles(expected, dir, t) {
|
|||||||
}
|
}
|
||||||
, function(err) {
|
, function(err) {
|
||||||
t.notOk(err, 'all files passed')
|
t.notOk(err, 'all files passed')
|
||||||
var delete_tmps = true
|
var delete_tmps = false
|
||||||
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); }
|
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); }
|
||||||
_rimraf(dir, function(rmerr) {
|
_rimraf(dir, function(rmerr) {
|
||||||
t.notOk(rmerr, 'cleaned up')
|
t.notOk(rmerr, 'cleaned up')
|
||||||
|
Reference in New Issue
Block a user