mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-03 15:46:43 +02:00
#945 Log removal
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
<INITIAL,ID,STATE,struct,LINE>\#[^\n]* /* skip comments */
|
<INITIAL,ID,STATE,struct,LINE>\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
|
|
||||||
"scale"\s+ { this.pushState('SCALE'); console.log('Got scale', yytext);return 'scale'; }
|
"scale"\s+ { this.pushState('SCALE'); /* console.log('Got scale', yytext);*/ return 'scale'; }
|
||||||
<SCALE>\d+ return 'WIDTH';
|
<SCALE>\d+ return 'WIDTH';
|
||||||
<SCALE>\s+"width" {this.popState();}
|
<SCALE>\s+"width" {this.popState();}
|
||||||
|
|
||||||
@@ -49,33 +49,33 @@
|
|||||||
<STATE>.*"[[join]]" {this.popState();yytext=yytext.slice(0,-8).trim();console.warn('Fork Join: ',yytext);return 'JOIN';}
|
<STATE>.*"[[join]]" {this.popState();yytext=yytext.slice(0,-8).trim();console.warn('Fork Join: ',yytext);return 'JOIN';}
|
||||||
<STATE>["] this.begin("STATE_STRING");
|
<STATE>["] this.begin("STATE_STRING");
|
||||||
<STATE>"as"\s* {this.popState();this.pushState('STATE_ID');return "AS";}
|
<STATE>"as"\s* {this.popState();this.pushState('STATE_ID');return "AS";}
|
||||||
<STATE_ID>[^\n\{]* {this.popState();console.log('STATE_ID', yytext);return "ID";}
|
<STATE_ID>[^\n\{]* {this.popState();/* console.log('STATE_ID', yytext);*/return "ID";}
|
||||||
<STATE_STRING>["] this.popState();
|
<STATE_STRING>["] this.popState();
|
||||||
<STATE_STRING>[^"]* { console.log('Long description:', yytext);return "STATE_DESCR";}
|
<STATE_STRING>[^"]* { /*console.log('Long description:', yytext);*/return "STATE_DESCR";}
|
||||||
<STATE>[^\n\s\{]+ {console.log('COMPOSIT_STATE', yytext);return 'COMPOSIT_STATE';}
|
<STATE>[^\n\s\{]+ {/*console.log('COMPOSIT_STATE', yytext);*/return 'COMPOSIT_STATE';}
|
||||||
<STATE>\n {this.popState();}
|
<STATE>\n {this.popState();}
|
||||||
<INITIAL,STATE>\{ {this.popState();this.pushState('struct'); console.log('begin struct', yytext);return 'STRUCT_START';}
|
<INITIAL,STATE>\{ {this.popState();this.pushState('struct'); /*console.log('begin struct', yytext);*/return 'STRUCT_START';}
|
||||||
<struct>\} { console.log('Ending struct'); this.popState(); return 'STRUCT_STOP';}}
|
<struct>\} { /*console.log('Ending struct');*/ this.popState(); return 'STRUCT_STOP';}}
|
||||||
<struct>[\n] /* nothing */
|
<struct>[\n] /* nothing */
|
||||||
|
|
||||||
<INITIAL,struct>"note"\s+ { this.begin('NOTE'); return 'note'; }
|
<INITIAL,struct>"note"\s+ { this.begin('NOTE'); return 'note'; }
|
||||||
<NOTE>"left of" { this.popState();this.pushState('NOTE_ID');console.log('Got dir');return 'left_of';}
|
<NOTE>"left of" { this.popState();this.pushState('NOTE_ID');return 'left_of';}
|
||||||
<NOTE>"right of" { this.popState();this.pushState('NOTE_ID');return 'right_of';}
|
<NOTE>"right of" { this.popState();this.pushState('NOTE_ID');return 'right_of';}
|
||||||
<NOTE>\" { this.popState();this.pushState('FLOATING_NOTE');}
|
<NOTE>\" { this.popState();this.pushState('FLOATING_NOTE');}
|
||||||
<FLOATING_NOTE>\s*"as"\s* {this.popState();this.pushState('FLOATING_NOTE_ID');return "AS";}
|
<FLOATING_NOTE>\s*"as"\s* {this.popState();this.pushState('FLOATING_NOTE_ID');return "AS";}
|
||||||
<FLOATING_NOTE>["] /**/
|
<FLOATING_NOTE>["] /**/
|
||||||
<FLOATING_NOTE>[^"]* { console.log('Floating note text: ', yytext);return "NOTE_TEXT";}
|
<FLOATING_NOTE>[^"]* { /*console.log('Floating note text: ', yytext);*/return "NOTE_TEXT";}
|
||||||
<FLOATING_NOTE_ID>[^\n]* {this.popState();console.log('Floating note ID', yytext);return "ID";}
|
<FLOATING_NOTE_ID>[^\n]* {this.popState();/*console.log('Floating note ID', yytext);*/return "ID";}
|
||||||
<NOTE_ID>\s*[^:\n\s\-]+ { this.popState();this.pushState('NOTE_TEXT');console.log('Got ID for note', yytext);return 'ID';}
|
<NOTE_ID>\s*[^:\n\s\-]+ { this.popState();this.pushState('NOTE_TEXT');/*console.log('Got ID for note', yytext);*/return 'ID';}
|
||||||
<NOTE_TEXT>\s*":"[^:\n;]+ { this.popState();console.log('Got NOTE_TEXT for note',yytext);yytext = yytext.substr(2).trim();return 'NOTE_TEXT';}
|
<NOTE_TEXT>\s*":"[^:\n;]+ { this.popState();/*console.log('Got NOTE_TEXT for note',yytext);*/yytext = yytext.substr(2).trim();return 'NOTE_TEXT';}
|
||||||
<NOTE_TEXT>\s*[^:;]+"end note" { this.popState();console.log('Got NOTE_TEXT for note',yytext);yytext = yytext.slice(0,-8).trim();return 'NOTE_TEXT';}
|
<NOTE_TEXT>\s*[^:;]+"end note" { this.popState();/*console.log('Got NOTE_TEXT for note',yytext);*/yytext = yytext.slice(0,-8).trim();return 'NOTE_TEXT';}
|
||||||
|
|
||||||
"stateDiagram"\s+ { console.log('Got state diagram', yytext,'#');return 'SD'; }
|
"stateDiagram"\s+ { /*console.log('Got state diagram', yytext,'#');*/return 'SD'; }
|
||||||
"hide empty description" { console.log('HIDE_EMPTY', yytext,'#');return 'HIDE_EMPTY'; }
|
"hide empty description" { /*console.log('HIDE_EMPTY', yytext,'#');*/return 'HIDE_EMPTY'; }
|
||||||
<INITIAL,struct>"[*]" { console.log('EDGE_STATE=',yytext); return 'EDGE_STATE';}
|
<INITIAL,struct>"[*]" { /*console.log('EDGE_STATE=',yytext);*/ return 'EDGE_STATE';}
|
||||||
<INITIAL,struct>[^:\n\s\-\{]+ { console.log('=>ID=',yytext); return 'ID';}
|
<INITIAL,struct>[^:\n\s\-\{]+ { /*console.log('=>ID=',yytext);*/ return 'ID';}
|
||||||
// <INITIAL,struct>\s*":"[^\+\->:\n;]+ { yytext = yytext.trim(); console.log('Descr = ', yytext); return 'DESCR'; }
|
// <INITIAL,struct>\s*":"[^\+\->:\n;]+ { yytext = yytext.trim(); /*console.log('Descr = ', yytext);*/ return 'DESCR'; }
|
||||||
<INITIAL,struct>\s*":"[^:\n;]+ { yytext = yytext.trim(); console.log('Descr = ', yytext); return 'DESCR'; }
|
<INITIAL,struct>\s*":"[^:\n;]+ { yytext = yytext.trim(); /*console.log('Descr = ', yytext);*/ return 'DESCR'; }
|
||||||
<INITIAL,struct>"-->" return '-->';
|
<INITIAL,struct>"-->" return '-->';
|
||||||
<struct>"--" return 'CONCURRENT';
|
<struct>"--" return 'CONCURRENT';
|
||||||
<<EOF>> return 'NL';
|
<<EOF>> return 'NL';
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
start
|
start
|
||||||
: SPACE start
|
: SPACE start
|
||||||
| NL start
|
| NL start
|
||||||
| SD document { console.warn('Root document', $2); yy.setRootDoc($2);return $2; }
|
| SD document { /*console.warn('Root document', $2);*/ yy.setRootDoc($2);return $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
document
|
document
|
||||||
@@ -112,7 +112,7 @@ line
|
|||||||
;
|
;
|
||||||
|
|
||||||
statement
|
statement
|
||||||
: idStatement DESCR { console.warn('got id and descr', $1, $2.trim());$$={ stmt: 'state', id: $1, type: 'default', description: $2.trim()};}
|
: idStatement DESCR { /*console.warn('got id and descr', $1, $2.trim());*/$$={ stmt: 'state', id: $1, type: 'default', description: $2.trim()};}
|
||||||
| idStatement '-->' idStatement
|
| idStatement '-->' idStatement
|
||||||
{
|
{
|
||||||
/*console.warn('got id', $1);yy.addRelation($1, $3);*/
|
/*console.warn('got id', $1);yy.addRelation($1, $3);*/
|
||||||
@@ -128,7 +128,7 @@ statement
|
|||||||
| COMPOSIT_STATE
|
| COMPOSIT_STATE
|
||||||
| COMPOSIT_STATE STRUCT_START document STRUCT_STOP
|
| COMPOSIT_STATE STRUCT_START document STRUCT_STOP
|
||||||
{
|
{
|
||||||
console.warn('Adding document for state without id ', $1);
|
/* console.warn('Adding document for state without id ', $1);*/
|
||||||
$$={ stmt: 'state', id: $1, type: 'default', description: '', doc: $3 }
|
$$={ stmt: 'state', id: $1, type: 'default', description: '', doc: $3 }
|
||||||
}
|
}
|
||||||
| STATE_DESCR AS ID { $$={id: $3, type: 'default', description: $1.trim()};}
|
| STATE_DESCR AS ID { $$={id: $3, type: 'default', description: $1.trim()};}
|
||||||
@@ -148,7 +148,7 @@ statement
|
|||||||
}
|
}
|
||||||
| note notePosition ID NOTE_TEXT
|
| note notePosition ID NOTE_TEXT
|
||||||
{
|
{
|
||||||
console.warn('got NOTE, position: ', $2.trim(), 'id = ', $3.trim(), 'note: ', $4);
|
/*console.warn('got NOTE, position: ', $2.trim(), 'id = ', $3.trim(), 'note: ', $4);*/
|
||||||
$$={ stmt: 'state', id: $3.trim(), note:{position: $2.trim(), text: $4.trim()}};
|
$$={ stmt: 'state', id: $3.trim(), note:{position: $2.trim(), text: $4.trim()}};
|
||||||
}
|
}
|
||||||
| note NOTE_TEXT AS ID
|
| note NOTE_TEXT AS ID
|
||||||
|
@@ -3,8 +3,6 @@ import idCache from './id-cache.js';
|
|||||||
import stateDb from './stateDb';
|
import stateDb from './stateDb';
|
||||||
import utils from '../../utils';
|
import utils from '../../utils';
|
||||||
|
|
||||||
console.warn('ID cache', idCache);
|
|
||||||
|
|
||||||
// TODO Move conf object to main conf in mermaidAPI
|
// TODO Move conf object to main conf in mermaidAPI
|
||||||
const conf = {
|
const conf = {
|
||||||
dividerMargin: 10,
|
dividerMargin: 10,
|
||||||
@@ -249,7 +247,6 @@ const _drawLongText = (_text, x, y, g) => {
|
|||||||
|
|
||||||
export const drawNote = (text, g) => {
|
export const drawNote = (text, g) => {
|
||||||
g.attr('class', 'note');
|
g.attr('class', 'note');
|
||||||
console.warn('Text of note', text);
|
|
||||||
const note = g
|
const note = g
|
||||||
.append('rect')
|
.append('rect')
|
||||||
.attr('x', 0)
|
.attr('x', 0)
|
||||||
@@ -257,7 +254,6 @@ export const drawNote = (text, g) => {
|
|||||||
const rectElem = g.append('g');
|
const rectElem = g.append('g');
|
||||||
|
|
||||||
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
|
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
|
||||||
console.warn('Text of note', text, textWidth);
|
|
||||||
note.attr('height', textHeight + 2 * conf.noteMargin);
|
note.attr('height', textHeight + 2 * conf.noteMargin);
|
||||||
note.attr('width', textWidth + conf.noteMargin * 2);
|
note.attr('width', textWidth + conf.noteMargin * 2);
|
||||||
|
|
||||||
@@ -271,8 +267,6 @@ export const drawNote = (text, g) => {
|
|||||||
* @param {*} stateDef
|
* @param {*} stateDef
|
||||||
*/
|
*/
|
||||||
export const drawState = function(elem, stateDef, graph, doc) {
|
export const drawState = function(elem, stateDef, graph, doc) {
|
||||||
console.warn('Rendering class ', stateDef);
|
|
||||||
|
|
||||||
const id = stateDef.id;
|
const id = stateDef.id;
|
||||||
const stateInfo = {
|
const stateInfo = {
|
||||||
id: id,
|
id: id,
|
||||||
|
@@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
|||||||
|
|
||||||
let rootDoc = [];
|
let rootDoc = [];
|
||||||
const setRootDoc = o => {
|
const setRootDoc = o => {
|
||||||
console.warn('Setting root doc', o);
|
logger.info('Setting root doc', o);
|
||||||
rootDoc = o;
|
rootDoc = o;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,7 +47,6 @@ let endCnt = 0;
|
|||||||
* @param style
|
* @param style
|
||||||
*/
|
*/
|
||||||
export const addState = function(id, type, doc, descr, note) {
|
export const addState = function(id, type, doc, descr, note) {
|
||||||
console.warn('Add state', id);
|
|
||||||
if (typeof currentDocument.states[id] === 'undefined') {
|
if (typeof currentDocument.states[id] === 'undefined') {
|
||||||
currentDocument.states[id] = {
|
currentDocument.states[id] = {
|
||||||
id: id,
|
id: id,
|
||||||
@@ -83,7 +82,7 @@ export const getStates = function() {
|
|||||||
return currentDocument.states;
|
return currentDocument.states;
|
||||||
};
|
};
|
||||||
export const logDocuments = function() {
|
export const logDocuments = function() {
|
||||||
console.warn('Documents = ', documents);
|
logger.info('Documents = ', documents);
|
||||||
};
|
};
|
||||||
export const getRelations = function() {
|
export const getRelations = function() {
|
||||||
return currentDocument.relations;
|
return currentDocument.relations;
|
||||||
@@ -104,7 +103,6 @@ export const addRelation = function(_id1, _id2, title) {
|
|||||||
id2 = 'end' + startCnt;
|
id2 = 'end' + startCnt;
|
||||||
type2 = 'end';
|
type2 = 'end';
|
||||||
}
|
}
|
||||||
console.log(id1, id2, title);
|
|
||||||
addState(id1, type1);
|
addState(id1, type1);
|
||||||
addState(id2, type2);
|
addState(id2, type2);
|
||||||
currentDocument.relations.push({ id1, id2, title });
|
currentDocument.relations.push({ id1, id2, title });
|
||||||
|
@@ -113,7 +113,8 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
compound: true,
|
compound: true,
|
||||||
// acyclicer: 'greedy',
|
// acyclicer: 'greedy',
|
||||||
rankdir: 'LR',
|
rankdir: 'LR',
|
||||||
ranker: 'tight-tree'
|
ranker: 'tight-tree',
|
||||||
|
ranksep: '20'
|
||||||
// isMultiGraph: false
|
// isMultiGraph: false
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
@@ -139,13 +140,11 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
const relations = stateDb.getRelations();
|
const relations = stateDb.getRelations();
|
||||||
|
|
||||||
const keys = Object.keys(states);
|
const keys = Object.keys(states);
|
||||||
console.warn('rendering doc 2', states, relations);
|
|
||||||
|
|
||||||
total = keys.length;
|
total = keys.length;
|
||||||
let first = true;
|
let first = true;
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
const stateDef = states[keys[i]];
|
const stateDef = states[keys[i]];
|
||||||
console.warn('keys[i]', keys[i]);
|
|
||||||
|
|
||||||
let node;
|
let node;
|
||||||
if (stateDef.doc) {
|
if (stateDef.doc) {
|
||||||
@@ -162,9 +161,7 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
node.width = boxBounds.width;
|
node.width = boxBounds.width;
|
||||||
node.height = boxBounds.height + 10;
|
node.height = boxBounds.height + 10;
|
||||||
transformationLog[stateDef.id] = { y: 35 };
|
transformationLog[stateDef.id] = { y: 35 };
|
||||||
console.warn('Here2');
|
|
||||||
} else {
|
} else {
|
||||||
console.warn('Here');
|
|
||||||
// sub = addIdAndBox(sub, stateDef);
|
// sub = addIdAndBox(sub, stateDef);
|
||||||
let boxBounds = sub.node().getBBox();
|
let boxBounds = sub.node().getBBox();
|
||||||
node.width = boxBounds.width;
|
node.width = boxBounds.width;
|
||||||
@@ -177,7 +174,6 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
|
|
||||||
if (stateDef.note) {
|
if (stateDef.note) {
|
||||||
// Draw note note
|
// Draw note note
|
||||||
console.warn('Def=', stateDef);
|
|
||||||
const noteDef = {
|
const noteDef = {
|
||||||
descriptions: [],
|
descriptions: [],
|
||||||
id: stateDef.id + '-note',
|
id: stateDef.id + '-note',
|
||||||
@@ -205,27 +201,23 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('Count=', graph.nodeCount());
|
logger.info('Count=', graph.nodeCount());
|
||||||
relations.forEach(function(relation) {
|
relations.forEach(function(relation) {
|
||||||
console.warn('Rendering edge', relation);
|
|
||||||
graph.setEdge(relation.id1, relation.id2, {
|
graph.setEdge(relation.id1, relation.id2, {
|
||||||
relation: relation,
|
relation: relation,
|
||||||
width: getLabelWidth(relation.title),
|
width: getLabelWidth(relation.title),
|
||||||
height: 16,
|
height: 16,
|
||||||
labelpos: 'c'
|
labelpos: 'c'
|
||||||
});
|
});
|
||||||
console.warn(getGraphId(relation.id1), relation.id2, {
|
|
||||||
relation: relation
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dagre.layout(graph);
|
dagre.layout(graph);
|
||||||
|
|
||||||
console.warn('Graph after layout', graph.nodes());
|
logger.debug('Graph after layout', graph.nodes());
|
||||||
|
|
||||||
graph.nodes().forEach(function(v) {
|
graph.nodes().forEach(function(v) {
|
||||||
if (typeof v !== 'undefined' && typeof graph.node(v) !== 'undefined') {
|
if (typeof v !== 'undefined' && typeof graph.node(v) !== 'undefined') {
|
||||||
console.warn('Node ' + v + ': ' + JSON.stringify(graph.node(v)));
|
logger.debug('Node ' + v + ': ' + JSON.stringify(graph.node(v)));
|
||||||
d3.select('#' + v).attr(
|
d3.select('#' + v).attr(
|
||||||
'transform',
|
'transform',
|
||||||
'translate(' +
|
'translate(' +
|
||||||
@@ -254,12 +246,11 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
divider.setAttribute('x2', pWidth - pShift);
|
divider.setAttribute('x2', pWidth - pShift);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn('No Node ' + v + ': ' + JSON.stringify(graph.node(v)));
|
logger.debug('No Node ' + v + ': ' + JSON.stringify(graph.node(v)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let stateBox = diagram.node().getBBox();
|
let stateBox = diagram.node().getBBox();
|
||||||
console.warn('Node before labels ', stateBox.width);
|
|
||||||
|
|
||||||
graph.edges().forEach(function(e) {
|
graph.edges().forEach(function(e) {
|
||||||
if (typeof e !== 'undefined' && typeof graph.edge(e) !== 'undefined') {
|
if (typeof e !== 'undefined' && typeof graph.edge(e) !== 'undefined') {
|
||||||
@@ -269,7 +260,6 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
stateBox = diagram.node().getBBox();
|
stateBox = diagram.node().getBBox();
|
||||||
console.warn('Node after labels ', stateBox.width);
|
|
||||||
const stateInfo = {
|
const stateInfo = {
|
||||||
id: parentId ? parentId : 'root',
|
id: parentId ? parentId : 'root',
|
||||||
label: parentId ? parentId : 'root',
|
label: parentId ? parentId : 'root',
|
||||||
@@ -280,7 +270,7 @@ const renderDoc = (doc, diagram, parentId) => {
|
|||||||
stateInfo.width = stateBox.width + 2 * conf.padding;
|
stateInfo.width = stateBox.width + 2 * conf.padding;
|
||||||
stateInfo.height = stateBox.height + 2 * conf.padding;
|
stateInfo.height = stateBox.height + 2 * conf.padding;
|
||||||
|
|
||||||
console.warn('Doc rendered', stateInfo, graph);
|
logger.info('Doc rendered', stateInfo, graph);
|
||||||
return stateInfo;
|
return stateInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user