Simple module to plot sequence diagram in ascii fashion. Similar (but not the same) to websequenceDiagram syntax
sample.txt:
title A basic sample
non valid lines are ignored
note right of A: sciiii
A->A: Takes a coffee
alt no coffee left
A-->B: get me a coffee
B->A:no
A->+B: sudo blabla
B-->-A: :)
else
opt sunny day
A->B: ultimate FRISBEEE???
end
end
sample.js:
#!/usr/bin/env node
var data=fs.readFileSync('sample.txt');
require('seqDiag2Ascii').buildFromString(data.toString(), function(err){
if(err){
console.log(err.failedLines);
}
s.print();
/*s.print(function(str){
});*/
});
Output:
A basic sample
A B
| |
| |
|/======= |
||sciiii| |
|======== |
|= |
||Takes a coffee |
|z |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|Alt|[no coffee left] | |
|~~~~ | |
| | get me a coffee | |
| |--------------------->| |
| | no | |
| |z---------------------| |
| | sudo blabla | |
| |--------------------->| |
| | :) | |
| |z---------------------| |
|xxxxxxxxxxxxxxxxxxxxxxxxxx|
|~~~~~~~~~~~~~~~~~~~~~~~~~~|
||Opt|[sunny day] |||
||~~~~ |||
||| ultimate FRISBEEE??? |||
|||--------------------->|||
|~~~~~~~~~~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| |
sample1.txt:
alt want an optional inside
opt want a loop inside
loop want a alt inside
alt want an else
else
A->B:You want it you got it
end
end
end
output:
A B
| |
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|Opt|[want a loop inside] | |
|~~~~ | | |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
||Loop|[want a alt inside] | ||
||~~~~~ | ||
||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||
|||Alt|[want an else] | |||
|||~~~~ | |||
|||xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|||
||| | You want it you got it | |||
||| |----------------------->| |||
||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| |
resizedByActor.txt:
A->B:test
Afezfzef->Bfezfzf:s
A B Afezfzef Bfezfzf
| | | |
| | | |
| test | | |
|----->| | |
| | | s |
| | |------->|
| | | |
| | | |
entities
- arrowBody:'-'
- noteHLine:'='
- noteVerticalLine:'|'
- wsc:' '
- compositeHLine:'~'
- alternativeMiddleLine:'x'
- paddingDeeperComposite:0
printer
- wsc:' ',
- verticalLine:'|'
Example of usage:
s.configure({
printer:{
wsc:' '
},
entities:{
paddingDeeperComposite:1
}
});
clone this project from github:
git clone http://github.com/mpech/seqDiag2Ascii.git
or install it directly
npm install mpech/seqDiag2Ascii
Run tests by hand :)