-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Draft implementation of info diagram
* Fix for issue #109
- Loading branch information
Showing
12 changed files
with
2,244 additions
and
44 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
describe('when parsing an info graph it',function() { | ||
var parseError; | ||
beforeEach(function () { | ||
ex = require('./parser/example').parser; | ||
ex.yy = require('./exampleDb'); | ||
parseError = function(err, hash) { | ||
console.log('Syntax error:' + err); | ||
}; | ||
ex.yy.parseError = parseError; | ||
}); | ||
|
||
it('should handle an info definition', function () { | ||
var str = 'info\nsay: hello'; | ||
|
||
ex.parse(str); | ||
}); | ||
it('should handle an showMessage statement definition', function () { | ||
var str = 'info\nshowInfo'; | ||
|
||
ex.parse(str); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Created by knut on 15-01-14. | ||
*/ | ||
|
||
var message = ''; | ||
var info = false; | ||
|
||
exports.setMessage = function(txt){ | ||
message = txt; | ||
}; | ||
|
||
exports.getMessage = function(){ | ||
return message; | ||
}; | ||
|
||
exports.setInfo = function(inf){ | ||
info = inf; | ||
}; | ||
|
||
exports.getInfo = function(){ | ||
return info; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Created by knut on 14-12-11. | ||
*/ | ||
var db = require('./exampleDb'); | ||
var exampleParser = require('./parser/example.js'); | ||
|
||
|
||
/** | ||
* Draws a an info picture in the tag with id: id based on the graph definition in text. | ||
* @param text | ||
* @param id | ||
*/ | ||
exports.draw = function (txt, id, ver) { | ||
var parser; | ||
parser = exampleParser.parser; | ||
parser.yy = db; | ||
|
||
// 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 | ||
.attr("x", 100) | ||
.attr("y", 40) | ||
.attr('class','version') | ||
.attr('font-size','32px') | ||
.style("text-anchor", "middle") | ||
.text('mermaid '+ ver); | ||
|
||
/* | ||
var box = exports.bounds.getBounds(); | ||
var height = box.stopy-box.starty+2*conf.diagramMarginY; | ||
var width = box.stopx-box.startx+2*conf.diagramMarginX;*/ | ||
|
||
svg.attr("height",100); | ||
svg.attr("width", 400 ); | ||
//svg.attr("viewBox", '0 0 300 150'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** js sequence diagrams | ||
* http://bramp.github.io/js-sequence-diagrams/ | ||
* (c) 2012-2013 Andrew Brampton (bramp.net) | ||
* Simplified BSD license. | ||
*/ | ||
%lex | ||
|
||
%options case-insensitive | ||
|
||
%{ | ||
// Pre-lexer code can go here | ||
%} | ||
|
||
%% | ||
|
||
[\n]+ return 'NL'; | ||
"showInfo" return 'showInfo'; | ||
"info" return 'info'; | ||
"say" return 'say'; | ||
":"[^#\n;]+ return 'TXT'; | ||
<<EOF>> return 'EOF'; | ||
. return 'INVALID'; | ||
|
||
/lex | ||
|
||
%start start | ||
|
||
%% /* language grammar */ | ||
|
||
start | ||
: info document 'EOF' { return yy; } | ||
; | ||
|
||
document | ||
: /* empty */ | ||
| document line | ||
; | ||
|
||
line | ||
: statement { } | ||
| 'NL' | ||
; | ||
|
||
statement | ||
: showInfo { yy.setInfo(true); } | ||
| message { yy.setMessage($1); } | ||
; | ||
|
||
message | ||
: 'say' TXT { $$ = $1.substring(1).trim().replace(/\\n/gm, "\n"); } | ||
; | ||
|
||
%% |
Oops, something went wrong.