Inclusion of tape tests in new test target for travis

This commit is contained in:
knsv 2014-12-21 11:25:31 +01:00
parent a83639addd
commit 307c599a0e
9 changed files with 268 additions and 112 deletions

152
dist/mermaid.full.js vendored
View File

@ -13004,8 +13004,11 @@ module.exports={
"version": "0.2.16", "version": "0.2.16",
"description": "Markdownish syntax for generating flowcharts", "description": "Markdownish syntax for generating flowcharts",
"main": "src/main.js", "main": "src/main.js",
"bin": {
"mermaid": "./bin/mermaid.js"
},
"scripts": { "scripts": {
"test": "gulp coverage" "test": "gulp test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -13014,11 +13017,18 @@ module.exports={
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"chalk": "^0.5.1",
"dagre-d3": "~0.3.2",
"he": "^0.5.0", "he": "^0.5.0",
"dagre-d3": "~0.3.2" "minimist": "^1.1.0",
"mkdirp": "^0.5.0",
"semver": "^4.1.1",
"which": "^1.0.8"
}, },
"devDependencies": { "devDependencies": {
"async": "^0.9.0",
"browserify": "~6.2.0", "browserify": "~6.2.0",
"clone": "^0.2.0",
"codeclimate-test-reporter": "0.0.4", "codeclimate-test-reporter": "0.0.4",
"d3": "~3.4.13", "d3": "~3.4.13",
"dagre-d3": "~0.3.2", "dagre-d3": "~0.3.2",
@ -13055,7 +13065,9 @@ module.exports={
"mock-browser": "^0.90.27", "mock-browser": "^0.90.27",
"path": "^0.4.9", "path": "^0.4.9",
"phantomjs": "^1.9.12", "phantomjs": "^1.9.12",
"rewire": "^2.1.3" "rewire": "^2.1.3",
"rimraf": "^2.2.8",
"tape": "^3.0.3"
} }
} }
@ -15746,44 +15758,48 @@ case 4:return 10;
break; break;
case 5:return 16; case 5:return 16;
break; break;
case 6:return 18; case 6:return 16;
break; break;
case 7:return 24; case 7:return 16;
break; break;
case 8:return 25; case 8:return 18;
break; break;
case 9:return 21; case 9:return 24;
break; break;
case 10:return 19; case 10:return 25;
break; break;
case 11:return 14; case 11:return 21;
break; break;
case 12:return 4; case 12:return 19;
break; break;
case 13:return 23; case 13:return 14;
break; break;
case 14:return 17; case 14:return 4;
break; break;
case 15:return 30; case 15:return 23;
break; break;
case 16:return 29; case 16:return 17;
break; break;
case 17:return 32; case 17:return 30;
break; break;
case 18:return 31; case 18:return 29;
break; break;
case 19:return 33; case 19:return 32;
break; break;
case 20:return 'CMT'; case 20:return 31;
break; break;
case 21:return 6; case 21:return 33;
break; break;
case 22:return 'INVALID'; case 22:return 'CMT';
break;
case 23:return 6;
break;
case 24:return 'INVALID';
break; break;
} }
}, },
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i], rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i],
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"inclusive":true}} conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"inclusive":true}}
}); });
return lexer; return lexer;
})(); })();
@ -15907,6 +15923,7 @@ var conf = {
height:65, height:65,
// Margin around loop boxes // Margin around loop boxes
boxMargin:10, boxMargin:10,
boxTextMargin:15,
noteMargin:10, noteMargin:10,
// Space between messages // Space between messages
@ -15961,15 +15978,23 @@ exports.bounds = {
}, },
insert:function(startx,starty,stopx,stopy){ insert:function(startx,starty,stopx,stopy){
this.updateVal(exports.bounds.data,'startx',startx,Math.min); var _startx, _starty, _stopx, _stopy;
this.updateVal(exports.bounds.data,'starty',starty,Math.min);
this.updateVal(exports.bounds.data,'stopx' ,stopx ,Math.max); _startx = Math.min(startx,stopx);
this.updateVal(exports.bounds.data,'stopy' ,stopy ,Math.max); _stopx = Math.max(startx,stopx);
_starty = Math.min(starty,stopy);
_stopy = Math.max(starty,stopy);
this.updateVal(exports.bounds.data,'startx',_startx,Math.min);
this.updateVal(exports.bounds.data,'starty',_starty,Math.min);
this.updateVal(exports.bounds.data,'stopx' ,_stopx ,Math.max);
this.updateVal(exports.bounds.data,'stopy' ,_stopy ,Math.max);
this.updateLoops(_startx,_starty,_stopx,_stopy);
this.updateLoops(startx,starty,stopx,stopy);
}, },
newLoop:function(){ newLoop:function(title){
this.list.push({startx:undefined,starty:undefined,stopx:undefined,stopy:undefined}); this.list.push({startx:undefined,starty:this.verticalPos,stopx:undefined,stopy:undefined, title:title});
}, },
endLoop:function(){ endLoop:function(){
var loop = this.list.pop(); var loop = this.list.pop();
@ -16016,12 +16041,13 @@ var drawNote = function(elem, startx, verticalPos, msg){
exports.bounds.insert(startx, verticalPos, startx + conf.width, verticalPos + 2*conf.noteMargin + textHeight); exports.bounds.insert(startx, verticalPos, startx + conf.width, verticalPos + 2*conf.noteMargin + textHeight);
rectElem.attr('height',textHeight+ 2*conf.noteMargin); rectElem.attr('height',textHeight+ 2*conf.noteMargin);
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin);
}; };
/** /**
* Draws an actor in the diagram with the attaced line * Draws an actor in the diagram with the attaced line
* @param center - The center of the the actor * @param center - The center of the the actor
* @param pos The position if the actor in the liost of actors * @param pos The position if the actor in the list of actors
* @param description The text in the box * @param description The text in the box
*/ */
exports.drawLoop = function(elem,bounds){ exports.drawLoop = function(elem,bounds){
@ -16033,14 +16059,31 @@ exports.drawLoop = function(elem,bounds){
.attr("x2", stopx ) .attr("x2", stopx )
.attr("y2", stopy ) .attr("y2", stopy )
.attr("stroke-width", 2) .attr("stroke-width", 2)
.attr("stroke", "#339999"); .attr("stroke", "#339933");
}; };
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty); drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy ); drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy ); drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy ); drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
var txt = svgDraw.getTextObj();
txt.text = "Loop";
txt.x = bounds.startx;
txt.y = bounds.starty;
txt.labelMargin = 1.5 * conf.boxMargin;
svgDraw.drawLabel(g,txt);
txt = svgDraw.getTextObj();
txt.text = bounds.title;
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
txt.y = bounds.starty + 1.5 * conf.boxMargin;
txt.anchor = 'middle';
svgDraw.drawText(g,txt);
}; };
/** /**
* Setup arrow head and define the marker. The result is appended to the svg. * Setup arrow head and define the marker. The result is appended to the svg.
*/ */
@ -16068,6 +16111,7 @@ var insertArrowHead = function(elem){
var drawMessage = function(elem, startx, stopx, verticalPos, msg){ var drawMessage = function(elem, startx, stopx, verticalPos, msg){
var g = elem.append("g"); var g = elem.append("g");
var txtCenter = startx + (stopx-startx)/2; var txtCenter = startx + (stopx-startx)/2;
//Make an SVG Container //Make an SVG Container
//Draw the line //Draw the line
if(msg.type !== 2) { if(msg.type !== 2) {
@ -16101,8 +16145,6 @@ var drawMessage = function(elem, startx, stopx, verticalPos, msg){
.attr("y", verticalPos - 10) .attr("y", verticalPos - 10)
.style("text-anchor", "middle") .style("text-anchor", "middle")
.text(msg.message); .text(msg.message);
//console.log('Setting message bounds');
exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos()); exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos());
} }
else{ else{
@ -16208,6 +16250,7 @@ module.exports.draw = function (text, id) {
switch(msg.type){ switch(msg.type){
case sq.yy.LINETYPE.NOTE: case sq.yy.LINETYPE.NOTE:
exports.bounds.bumpVerticalPos(conf.boxMargin); exports.bounds.bumpVerticalPos(conf.boxMargin);
startx = actors[msg.from].x; startx = actors[msg.from].x;
stopx = actors[msg.to].x; stopx = actors[msg.to].x;
@ -16221,14 +16264,15 @@ module.exports.draw = function (text, id) {
} }
break; break;
case sq.yy.LINETYPE.LOOP_START: case sq.yy.LINETYPE.LOOP_START:
//var loop = exports.bounds.newLoop(); exports.bounds.bumpVerticalPos(conf.boxMargin);
exports.bounds.newLoop(); exports.bounds.newLoop(msg.message);
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
break; break;
case sq.yy.LINETYPE.LOOP_END: case sq.yy.LINETYPE.LOOP_END:
var loopData = exports.bounds.endLoop(); var loopData = exports.bounds.endLoop();
//var loopData = loopList.pop();
//loopData.stopy = exports.bounds.getVerticalPos();
exports.drawLoop(diagram, loopData); exports.drawLoop(diagram, loopData);
exports.bounds.bumpVerticalPos(conf.boxMargin);
break; break;
default: default:
exports.bounds.bumpVerticalPos(conf.messageMargin); exports.bounds.bumpVerticalPos(conf.messageMargin);
@ -16272,7 +16316,8 @@ exports.drawText = function(elem , textData){
var textElem = elem.append('text'); var textElem = elem.append('text');
textElem.attr('x', textData.x); textElem.attr('x', textData.x);
textElem.attr('y', textData.y); textElem.attr('y', textData.y);
textElem.style('text-anchor', 'start'); textElem.style('text-anchor', textData.anchor);
textElem.style('fill', textData.fill);
textData.text.split('<br>').forEach(function(rowText){ textData.text.split('<br>').forEach(function(rowText){
var span = textElem.append('tspan'); var span = textElem.append('tspan');
@ -16284,14 +16329,37 @@ exports.drawText = function(elem , textData){
return textElem; return textElem;
}; };
exports.drawLabel = function(elem , txtObject){
var rectData = exports.getNoteRect();
rectData.x = txtObject.x;
rectData.y = txtObject.y;
rectData.width = 50;
rectData.height = 20;
rectData.fill = '#339933';
rectData.stroke = 'none';
//rectData.color = 'white';
var label = exports.drawRect(elem, rectData);
txtObject.y = txtObject.y + txtObject.labelMargin;
txtObject.x = txtObject.x + 0.5*txtObject.labelMargin;
txtObject.fill = 'white';
exports.drawText(elem, txtObject);
//return textElem;
};
exports.getTextObj = function(){ exports.getTextObj = function(){
var rect = { var rect = {
x: 0, x: 0,
y: 0, y: 0,
'fill':'black',
'text-anchor': 'start', 'text-anchor': 'start',
style: '#666', style: '#666',
width: 100, width: 100,
height: 100, height: 100,
textMargin:0,
rx: 0, rx: 0,
ry: 0 ry: 0
}; };
@ -16305,6 +16373,7 @@ exports.getNoteRect = function(){
fill: '#EDF2AE', fill: '#EDF2AE',
stroke: '#666', stroke: '#666',
width: 100, width: 100,
anchor:'start',
height: 100, height: 100,
rx: 0, rx: 0,
ry: 0 ry: 0
@ -16345,7 +16414,9 @@ var init = function () {
// Check if previously processed // Check if previously processed
if(!element.getAttribute("data-processed")) { if(!element.getAttribute("data-processed")) {
element.setAttribute("data-processed", true); element.setAttribute("data-processed", true);
} else continue; } else {
continue;
}
var id; var id;
@ -16378,6 +16449,7 @@ var init = function () {
break; break;
case 'sequenceDiagram': case 'sequenceDiagram':
seq.draw(txt,id); seq.draw(txt,id);
//classes = flowRenderer.getClasses(txt, true);
// TODO - Get styles for sequence diagram // TODO - Get styles for sequence diagram
utils.cloneCssStyles(element.firstChild, classes); utils.cloneCssStyles(element.firstChild, classes);
break; break;
@ -16413,7 +16485,7 @@ if(typeof document !== 'undefined'){
// Check presence of config object // Check presence of config object
if(typeof mermaid_config !== 'undefined'){ if(typeof mermaid_config !== 'undefined'){
// Check if property startOnLoad is set // Check if property startOnLoad is set
if(equals(true,mermaid_config.startOnLoad)){ if(equals(true, mermaid_config.startOnLoad)){
init(); init();
} }
} }

File diff suppressed because one or more lines are too long

152
dist/mermaid.slim.js vendored
View File

@ -12972,8 +12972,11 @@ module.exports={
"version": "0.2.16", "version": "0.2.16",
"description": "Markdownish syntax for generating flowcharts", "description": "Markdownish syntax for generating flowcharts",
"main": "src/main.js", "main": "src/main.js",
"bin": {
"mermaid": "./bin/mermaid.js"
},
"scripts": { "scripts": {
"test": "gulp coverage" "test": "gulp test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -12982,11 +12985,18 @@ module.exports={
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"chalk": "^0.5.1",
"dagre-d3": "~0.3.2",
"he": "^0.5.0", "he": "^0.5.0",
"dagre-d3": "~0.3.2" "minimist": "^1.1.0",
"mkdirp": "^0.5.0",
"semver": "^4.1.1",
"which": "^1.0.8"
}, },
"devDependencies": { "devDependencies": {
"async": "^0.9.0",
"browserify": "~6.2.0", "browserify": "~6.2.0",
"clone": "^0.2.0",
"codeclimate-test-reporter": "0.0.4", "codeclimate-test-reporter": "0.0.4",
"d3": "~3.4.13", "d3": "~3.4.13",
"dagre-d3": "~0.3.2", "dagre-d3": "~0.3.2",
@ -13023,7 +13033,9 @@ module.exports={
"mock-browser": "^0.90.27", "mock-browser": "^0.90.27",
"path": "^0.4.9", "path": "^0.4.9",
"phantomjs": "^1.9.12", "phantomjs": "^1.9.12",
"rewire": "^2.1.3" "rewire": "^2.1.3",
"rimraf": "^2.2.8",
"tape": "^3.0.3"
} }
} }
@ -15714,44 +15726,48 @@ case 4:return 10;
break; break;
case 5:return 16; case 5:return 16;
break; break;
case 6:return 18; case 6:return 16;
break; break;
case 7:return 24; case 7:return 16;
break; break;
case 8:return 25; case 8:return 18;
break; break;
case 9:return 21; case 9:return 24;
break; break;
case 10:return 19; case 10:return 25;
break; break;
case 11:return 14; case 11:return 21;
break; break;
case 12:return 4; case 12:return 19;
break; break;
case 13:return 23; case 13:return 14;
break; break;
case 14:return 17; case 14:return 4;
break; break;
case 15:return 30; case 15:return 23;
break; break;
case 16:return 29; case 16:return 17;
break; break;
case 17:return 32; case 17:return 30;
break; break;
case 18:return 31; case 18:return 29;
break; break;
case 19:return 33; case 19:return 32;
break; break;
case 20:return 'CMT'; case 20:return 31;
break; break;
case 21:return 6; case 21:return 33;
break; break;
case 22:return 'INVALID'; case 22:return 'CMT';
break;
case 23:return 6;
break;
case 24:return 'INVALID';
break; break;
} }
}, },
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i], rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i],
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"inclusive":true}} conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"inclusive":true}}
}); });
return lexer; return lexer;
})(); })();
@ -15875,6 +15891,7 @@ var conf = {
height:65, height:65,
// Margin around loop boxes // Margin around loop boxes
boxMargin:10, boxMargin:10,
boxTextMargin:15,
noteMargin:10, noteMargin:10,
// Space between messages // Space between messages
@ -15929,15 +15946,23 @@ exports.bounds = {
}, },
insert:function(startx,starty,stopx,stopy){ insert:function(startx,starty,stopx,stopy){
this.updateVal(exports.bounds.data,'startx',startx,Math.min); var _startx, _starty, _stopx, _stopy;
this.updateVal(exports.bounds.data,'starty',starty,Math.min);
this.updateVal(exports.bounds.data,'stopx' ,stopx ,Math.max); _startx = Math.min(startx,stopx);
this.updateVal(exports.bounds.data,'stopy' ,stopy ,Math.max); _stopx = Math.max(startx,stopx);
_starty = Math.min(starty,stopy);
_stopy = Math.max(starty,stopy);
this.updateVal(exports.bounds.data,'startx',_startx,Math.min);
this.updateVal(exports.bounds.data,'starty',_starty,Math.min);
this.updateVal(exports.bounds.data,'stopx' ,_stopx ,Math.max);
this.updateVal(exports.bounds.data,'stopy' ,_stopy ,Math.max);
this.updateLoops(_startx,_starty,_stopx,_stopy);
this.updateLoops(startx,starty,stopx,stopy);
}, },
newLoop:function(){ newLoop:function(title){
this.list.push({startx:undefined,starty:undefined,stopx:undefined,stopy:undefined}); this.list.push({startx:undefined,starty:this.verticalPos,stopx:undefined,stopy:undefined, title:title});
}, },
endLoop:function(){ endLoop:function(){
var loop = this.list.pop(); var loop = this.list.pop();
@ -15984,12 +16009,13 @@ var drawNote = function(elem, startx, verticalPos, msg){
exports.bounds.insert(startx, verticalPos, startx + conf.width, verticalPos + 2*conf.noteMargin + textHeight); exports.bounds.insert(startx, verticalPos, startx + conf.width, verticalPos + 2*conf.noteMargin + textHeight);
rectElem.attr('height',textHeight+ 2*conf.noteMargin); rectElem.attr('height',textHeight+ 2*conf.noteMargin);
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin);
}; };
/** /**
* Draws an actor in the diagram with the attaced line * Draws an actor in the diagram with the attaced line
* @param center - The center of the the actor * @param center - The center of the the actor
* @param pos The position if the actor in the liost of actors * @param pos The position if the actor in the list of actors
* @param description The text in the box * @param description The text in the box
*/ */
exports.drawLoop = function(elem,bounds){ exports.drawLoop = function(elem,bounds){
@ -16001,14 +16027,31 @@ exports.drawLoop = function(elem,bounds){
.attr("x2", stopx ) .attr("x2", stopx )
.attr("y2", stopy ) .attr("y2", stopy )
.attr("stroke-width", 2) .attr("stroke-width", 2)
.attr("stroke", "#339999"); .attr("stroke", "#339933");
}; };
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty); drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy ); drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy ); drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy ); drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
var txt = svgDraw.getTextObj();
txt.text = "Loop";
txt.x = bounds.startx;
txt.y = bounds.starty;
txt.labelMargin = 1.5 * conf.boxMargin;
svgDraw.drawLabel(g,txt);
txt = svgDraw.getTextObj();
txt.text = bounds.title;
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
txt.y = bounds.starty + 1.5 * conf.boxMargin;
txt.anchor = 'middle';
svgDraw.drawText(g,txt);
}; };
/** /**
* Setup arrow head and define the marker. The result is appended to the svg. * Setup arrow head and define the marker. The result is appended to the svg.
*/ */
@ -16036,6 +16079,7 @@ var insertArrowHead = function(elem){
var drawMessage = function(elem, startx, stopx, verticalPos, msg){ var drawMessage = function(elem, startx, stopx, verticalPos, msg){
var g = elem.append("g"); var g = elem.append("g");
var txtCenter = startx + (stopx-startx)/2; var txtCenter = startx + (stopx-startx)/2;
//Make an SVG Container //Make an SVG Container
//Draw the line //Draw the line
if(msg.type !== 2) { if(msg.type !== 2) {
@ -16069,8 +16113,6 @@ var drawMessage = function(elem, startx, stopx, verticalPos, msg){
.attr("y", verticalPos - 10) .attr("y", verticalPos - 10)
.style("text-anchor", "middle") .style("text-anchor", "middle")
.text(msg.message); .text(msg.message);
//console.log('Setting message bounds');
exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos()); exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos());
} }
else{ else{
@ -16176,6 +16218,7 @@ module.exports.draw = function (text, id) {
switch(msg.type){ switch(msg.type){
case sq.yy.LINETYPE.NOTE: case sq.yy.LINETYPE.NOTE:
exports.bounds.bumpVerticalPos(conf.boxMargin); exports.bounds.bumpVerticalPos(conf.boxMargin);
startx = actors[msg.from].x; startx = actors[msg.from].x;
stopx = actors[msg.to].x; stopx = actors[msg.to].x;
@ -16189,14 +16232,15 @@ module.exports.draw = function (text, id) {
} }
break; break;
case sq.yy.LINETYPE.LOOP_START: case sq.yy.LINETYPE.LOOP_START:
//var loop = exports.bounds.newLoop(); exports.bounds.bumpVerticalPos(conf.boxMargin);
exports.bounds.newLoop(); exports.bounds.newLoop(msg.message);
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
break; break;
case sq.yy.LINETYPE.LOOP_END: case sq.yy.LINETYPE.LOOP_END:
var loopData = exports.bounds.endLoop(); var loopData = exports.bounds.endLoop();
//var loopData = loopList.pop();
//loopData.stopy = exports.bounds.getVerticalPos();
exports.drawLoop(diagram, loopData); exports.drawLoop(diagram, loopData);
exports.bounds.bumpVerticalPos(conf.boxMargin);
break; break;
default: default:
exports.bounds.bumpVerticalPos(conf.messageMargin); exports.bounds.bumpVerticalPos(conf.messageMargin);
@ -16240,7 +16284,8 @@ exports.drawText = function(elem , textData){
var textElem = elem.append('text'); var textElem = elem.append('text');
textElem.attr('x', textData.x); textElem.attr('x', textData.x);
textElem.attr('y', textData.y); textElem.attr('y', textData.y);
textElem.style('text-anchor', 'start'); textElem.style('text-anchor', textData.anchor);
textElem.style('fill', textData.fill);
textData.text.split('<br>').forEach(function(rowText){ textData.text.split('<br>').forEach(function(rowText){
var span = textElem.append('tspan'); var span = textElem.append('tspan');
@ -16252,14 +16297,37 @@ exports.drawText = function(elem , textData){
return textElem; return textElem;
}; };
exports.drawLabel = function(elem , txtObject){
var rectData = exports.getNoteRect();
rectData.x = txtObject.x;
rectData.y = txtObject.y;
rectData.width = 50;
rectData.height = 20;
rectData.fill = '#339933';
rectData.stroke = 'none';
//rectData.color = 'white';
var label = exports.drawRect(elem, rectData);
txtObject.y = txtObject.y + txtObject.labelMargin;
txtObject.x = txtObject.x + 0.5*txtObject.labelMargin;
txtObject.fill = 'white';
exports.drawText(elem, txtObject);
//return textElem;
};
exports.getTextObj = function(){ exports.getTextObj = function(){
var rect = { var rect = {
x: 0, x: 0,
y: 0, y: 0,
'fill':'black',
'text-anchor': 'start', 'text-anchor': 'start',
style: '#666', style: '#666',
width: 100, width: 100,
height: 100, height: 100,
textMargin:0,
rx: 0, rx: 0,
ry: 0 ry: 0
}; };
@ -16273,6 +16341,7 @@ exports.getNoteRect = function(){
fill: '#EDF2AE', fill: '#EDF2AE',
stroke: '#666', stroke: '#666',
width: 100, width: 100,
anchor:'start',
height: 100, height: 100,
rx: 0, rx: 0,
ry: 0 ry: 0
@ -16313,7 +16382,9 @@ var init = function () {
// Check if previously processed // Check if previously processed
if(!element.getAttribute("data-processed")) { if(!element.getAttribute("data-processed")) {
element.setAttribute("data-processed", true); element.setAttribute("data-processed", true);
} else continue; } else {
continue;
}
var id; var id;
@ -16346,6 +16417,7 @@ var init = function () {
break; break;
case 'sequenceDiagram': case 'sequenceDiagram':
seq.draw(txt,id); seq.draw(txt,id);
//classes = flowRenderer.getClasses(txt, true);
// TODO - Get styles for sequence diagram // TODO - Get styles for sequence diagram
utils.cloneCssStyles(element.firstChild, classes); utils.cloneCssStyles(element.firstChild, classes);
break; break;
@ -16381,7 +16453,7 @@ if(typeof document !== 'undefined'){
// Check presence of config object // Check presence of config object
if(typeof mermaid_config !== 'undefined'){ if(typeof mermaid_config !== 'undefined'){
// Check if property startOnLoad is set // Check if property startOnLoad is set
if(equals(true,mermaid_config.startOnLoad)){ if(equals(true, mermaid_config.startOnLoad)){
init(); init();
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,7 @@ gulp.task('jison2', function() {
}); });
gulp.task('dist', ['slimDist', 'fullDist','jasmine']); gulp.task('dist', ['slimDist', 'fullDist','jasmine']);
gulp.task('rdist', ['slimDist', 'fullDist']);
var jasmine = require('gulp-jasmine'); var jasmine = require('gulp-jasmine');
@ -166,3 +167,5 @@ gulp.task('lint', function() {
.pipe(jshint()) .pipe(jshint())
.pipe(jshint.reporter(stylish)); .pipe(jshint.reporter(stylish));
}); });
gulp.task('test',['coverage','tape']);

View File

@ -7,7 +7,7 @@
"mermaid": "./bin/mermaid.js" "mermaid": "./bin/mermaid.js"
}, },
"scripts": { "scripts": {
"test": "gulp coverage" "test": "gulp test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -19,6 +19,8 @@
\%%[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */
"participant" return 'participant'; "participant" return 'participant';
"loop" return 'loop'; "loop" return 'loop';
"alt" return 'loop';
"else" return 'loop';
"end" return 'end'; "end" return 'end';
"left of" return 'left_of'; "left of" return 'left_of';
"right of" return 'right_of'; "right of" return 'right_of';

View File

@ -639,44 +639,48 @@ case 4:return 10;
break; break;
case 5:return 16; case 5:return 16;
break; break;
case 6:return 18; case 6:return 16;
break; break;
case 7:return 24; case 7:return 16;
break; break;
case 8:return 25; case 8:return 18;
break; break;
case 9:return 21; case 9:return 24;
break; break;
case 10:return 19; case 10:return 25;
break; break;
case 11:return 14; case 11:return 21;
break; break;
case 12:return 4; case 12:return 19;
break; break;
case 13:return 23; case 13:return 14;
break; break;
case 14:return 17; case 14:return 4;
break; break;
case 15:return 30; case 15:return 23;
break; break;
case 16:return 29; case 16:return 17;
break; break;
case 17:return 32; case 17:return 30;
break; break;
case 18:return 31; case 18:return 29;
break; break;
case 19:return 33; case 19:return 32;
break; break;
case 20:return 'CMT'; case 20:return 31;
break; break;
case 21:return 6; case 21:return 33;
break; break;
case 22:return 'INVALID'; case 22:return 'CMT';
break;
case 23:return 6;
break;
case 24:return 'INVALID';
break; break;
} }
}, },
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i], rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:loop\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:[^\->:\n,]+)/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^#\n]+)/i,/^(?:%%)/i,/^(?:$)/i,/^(?:.)/i],
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"inclusive":true}} conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"inclusive":true}}
}); });
return lexer; return lexer;
})(); })();

View File

@ -29,7 +29,9 @@ var init = function () {
// Check if previously processed // Check if previously processed
if(!element.getAttribute("data-processed")) { if(!element.getAttribute("data-processed")) {
element.setAttribute("data-processed", true); element.setAttribute("data-processed", true);
} else continue; } else {
continue;
}
var id; var id;
@ -62,6 +64,7 @@ var init = function () {
break; break;
case 'sequenceDiagram': case 'sequenceDiagram':
seq.draw(txt,id); seq.draw(txt,id);
//classes = flowRenderer.getClasses(txt, true);
// TODO - Get styles for sequence diagram // TODO - Get styles for sequence diagram
utils.cloneCssStyles(element.firstChild, classes); utils.cloneCssStyles(element.firstChild, classes);
break; break;
@ -97,7 +100,7 @@ if(typeof document !== 'undefined'){
// Check presence of config object // Check presence of config object
if(typeof mermaid_config !== 'undefined'){ if(typeof mermaid_config !== 'undefined'){
// Check if property startOnLoad is set // Check if property startOnLoad is set
if(equals(true,mermaid_config.startOnLoad)){ if(equals(true, mermaid_config.startOnLoad)){
init(); init();
} }
} }