#945 Log removal

This commit is contained in:
Knut Sveidqvist 2019-10-06 16:06:15 +02:00
parent b12791d3e0
commit ebede9b910
4 changed files with 31 additions and 49 deletions

View File

@ -38,7 +38,7 @@
<INITIAL,ID,STATE,struct,LINE>\#[^\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>\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>["] this.begin("STATE_STRING");
<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>[^"]* { console.log('Long description:', yytext);return "STATE_DESCR";}
<STATE>[^\n\s\{]+ {console.log('COMPOSIT_STATE', yytext);return 'COMPOSIT_STATE';}
<STATE_STRING>[^"]* { /*console.log('Long description:', yytext);*/return "STATE_DESCR";}
<STATE>[^\n\s\{]+ {/*console.log('COMPOSIT_STATE', yytext);*/return 'COMPOSIT_STATE';}
<STATE>\n {this.popState();}
<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';}}
<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>[\n] /* nothing */
<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>\" { this.popState();this.pushState('FLOATING_NOTE');}
<FLOATING_NOTE>\s*"as"\s* {this.popState();this.pushState('FLOATING_NOTE_ID');return "AS";}
<FLOATING_NOTE>["] /**/
<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";}
<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*[^:;]+"end note" { this.popState();console.log('Got NOTE_TEXT for note',yytext);yytext = yytext.slice(0,-8).trim();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";}
<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*[^:;]+"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'; }
"hide empty description" { console.log('HIDE_EMPTY', yytext,'#');return 'HIDE_EMPTY'; }
<INITIAL,struct>"[*]" { console.log('EDGE_STATE=',yytext); return 'EDGE_STATE';}
<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'; }
"stateDiagram"\s+ { /*console.log('Got state diagram', yytext,'#');*/return 'SD'; }
"hide empty description" { /*console.log('HIDE_EMPTY', yytext,'#');*/return 'HIDE_EMPTY'; }
<INITIAL,struct>"[*]" { /*console.log('EDGE_STATE=',yytext);*/ return 'EDGE_STATE';}
<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>"-->" return '-->';
<struct>"--" return 'CONCURRENT';
<<EOF>> return 'NL';
@ -92,7 +92,7 @@
start
: SPACE 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
@ -112,7 +112,7 @@ line
;
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
{
/*console.warn('got id', $1);yy.addRelation($1, $3);*/
@ -128,7 +128,7 @@ statement
| COMPOSIT_STATE
| 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 }
}
| STATE_DESCR AS ID { $$={id: $3, type: 'default', description: $1.trim()};}
@ -148,7 +148,7 @@ statement
}
| 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()}};
}
| note NOTE_TEXT AS ID

View File

@ -3,8 +3,6 @@ import idCache from './id-cache.js';
import stateDb from './stateDb';
import utils from '../../utils';
console.warn('ID cache', idCache);
// TODO Move conf object to main conf in mermaidAPI
const conf = {
dividerMargin: 10,
@ -249,7 +247,6 @@ const _drawLongText = (_text, x, y, g) => {
export const drawNote = (text, g) => {
g.attr('class', 'note');
console.warn('Text of note', text);
const note = g
.append('rect')
.attr('x', 0)
@ -257,7 +254,6 @@ export const drawNote = (text, g) => {
const rectElem = g.append('g');
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
console.warn('Text of note', text, textWidth);
note.attr('height', textHeight + 2 * conf.noteMargin);
note.attr('width', textWidth + conf.noteMargin * 2);
@ -271,8 +267,6 @@ export const drawNote = (text, g) => {
* @param {*} stateDef
*/
export const drawState = function(elem, stateDef, graph, doc) {
console.warn('Rendering class ', stateDef);
const id = stateDef.id;
const stateInfo = {
id: id,

View File

@ -2,7 +2,7 @@ import { logger } from '../../logger';
let rootDoc = [];
const setRootDoc = o => {
console.warn('Setting root doc', o);
logger.info('Setting root doc', o);
rootDoc = o;
};
@ -47,7 +47,6 @@ let endCnt = 0;
* @param style
*/
export const addState = function(id, type, doc, descr, note) {
console.warn('Add state', id);
if (typeof currentDocument.states[id] === 'undefined') {
currentDocument.states[id] = {
id: id,
@ -83,7 +82,7 @@ export const getStates = function() {
return currentDocument.states;
};
export const logDocuments = function() {
console.warn('Documents = ', documents);
logger.info('Documents = ', documents);
};
export const getRelations = function() {
return currentDocument.relations;
@ -104,7 +103,6 @@ export const addRelation = function(_id1, _id2, title) {
id2 = 'end' + startCnt;
type2 = 'end';
}
console.log(id1, id2, title);
addState(id1, type1);
addState(id2, type2);
currentDocument.relations.push({ id1, id2, title });

View File

@ -113,7 +113,8 @@ const renderDoc = (doc, diagram, parentId) => {
compound: true,
// acyclicer: 'greedy',
rankdir: 'LR',
ranker: 'tight-tree'
ranker: 'tight-tree',
ranksep: '20'
// isMultiGraph: false
});
else {
@ -139,13 +140,11 @@ const renderDoc = (doc, diagram, parentId) => {
const relations = stateDb.getRelations();
const keys = Object.keys(states);
console.warn('rendering doc 2', states, relations);
total = keys.length;
let first = true;
for (let i = 0; i < keys.length; i++) {
const stateDef = states[keys[i]];
console.warn('keys[i]', keys[i]);
let node;
if (stateDef.doc) {
@ -162,9 +161,7 @@ const renderDoc = (doc, diagram, parentId) => {
node.width = boxBounds.width;
node.height = boxBounds.height + 10;
transformationLog[stateDef.id] = { y: 35 };
console.warn('Here2');
} else {
console.warn('Here');
// sub = addIdAndBox(sub, stateDef);
let boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
@ -177,7 +174,6 @@ const renderDoc = (doc, diagram, parentId) => {
if (stateDef.note) {
// Draw note note
console.warn('Def=', stateDef);
const noteDef = {
descriptions: [],
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) {
console.warn('Rendering edge', relation);
graph.setEdge(relation.id1, relation.id2, {
relation: relation,
width: getLabelWidth(relation.title),
height: 16,
labelpos: 'c'
});
console.warn(getGraphId(relation.id1), relation.id2, {
relation: relation
});
});
dagre.layout(graph);
console.warn('Graph after layout', graph.nodes());
logger.debug('Graph after layout', graph.nodes());
graph.nodes().forEach(function(v) {
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(
'transform',
'translate(' +
@ -254,12 +246,11 @@ const renderDoc = (doc, diagram, parentId) => {
divider.setAttribute('x2', pWidth - pShift);
});
} 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();
console.warn('Node before labels ', stateBox.width);
graph.edges().forEach(function(e) {
if (typeof e !== 'undefined' && typeof graph.edge(e) !== 'undefined') {
@ -269,7 +260,6 @@ const renderDoc = (doc, diagram, parentId) => {
});
stateBox = diagram.node().getBBox();
console.warn('Node after labels ', stateBox.width);
const stateInfo = {
id: parentId ? parentId : 'root',
label: parentId ? parentId : 'root',
@ -280,7 +270,7 @@ const renderDoc = (doc, diagram, parentId) => {
stateInfo.width = stateBox.width + 2 * conf.padding;
stateInfo.height = stateBox.height + 2 * conf.padding;
console.warn('Doc rendered', stateInfo, graph);
logger.info('Doc rendered', stateInfo, graph);
return stateInfo;
};