From ebede9b9107ab4bc5457df21614a995e744f080e Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Sun, 6 Oct 2019 16:06:15 +0200 Subject: [PATCH] #945 Log removal --- src/diagrams/state/parser/stateDiagram.jison | 44 ++++++++++---------- src/diagrams/state/shapes.js | 6 --- src/diagrams/state/stateDb.js | 6 +-- src/diagrams/state/stateRenderer.js | 24 ++++------- 4 files changed, 31 insertions(+), 49 deletions(-) diff --git a/src/diagrams/state/parser/stateDiagram.jison b/src/diagrams/state/parser/stateDiagram.jison index 000f26b4b..cbb2aea91 100644 --- a/src/diagrams/state/parser/stateDiagram.jison +++ b/src/diagrams/state/parser/stateDiagram.jison @@ -38,7 +38,7 @@ \#[^\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'; } \d+ return 'WIDTH'; \s+"width" {this.popState();} @@ -49,33 +49,33 @@ .*"[[join]]" {this.popState();yytext=yytext.slice(0,-8).trim();console.warn('Fork Join: ',yytext);return 'JOIN';} ["] this.begin("STATE_STRING"); "as"\s* {this.popState();this.pushState('STATE_ID');return "AS";} -[^\n\{]* {this.popState();console.log('STATE_ID', yytext);return "ID";} +[^\n\{]* {this.popState();/* console.log('STATE_ID', yytext);*/return "ID";} ["] this.popState(); -[^"]* { console.log('Long description:', yytext);return "STATE_DESCR";} -[^\n\s\{]+ {console.log('COMPOSIT_STATE', yytext);return 'COMPOSIT_STATE';} +[^"]* { /*console.log('Long description:', yytext);*/return "STATE_DESCR";} +[^\n\s\{]+ {/*console.log('COMPOSIT_STATE', yytext);*/return 'COMPOSIT_STATE';} \n {this.popState();} -\{ {this.popState();this.pushState('struct'); console.log('begin struct', yytext);return 'STRUCT_START';} -\} { console.log('Ending struct'); this.popState(); return 'STRUCT_STOP';}} +\{ {this.popState();this.pushState('struct'); /*console.log('begin struct', yytext);*/return 'STRUCT_START';} +\} { /*console.log('Ending struct');*/ this.popState(); return 'STRUCT_STOP';}} [\n] /* nothing */ "note"\s+ { this.begin('NOTE'); return 'note'; } -"left of" { this.popState();this.pushState('NOTE_ID');console.log('Got dir');return 'left_of';} +"left of" { this.popState();this.pushState('NOTE_ID');return 'left_of';} "right of" { this.popState();this.pushState('NOTE_ID');return 'right_of';} \" { this.popState();this.pushState('FLOATING_NOTE');} \s*"as"\s* {this.popState();this.pushState('FLOATING_NOTE_ID');return "AS";} ["] /**/ -[^"]* { console.log('Floating note text: ', yytext);return "NOTE_TEXT";} -[^\n]* {this.popState();console.log('Floating note ID', yytext);return "ID";} -\s*[^:\n\s\-]+ { this.popState();this.pushState('NOTE_TEXT');console.log('Got ID for note', yytext);return 'ID';} -\s*":"[^:\n;]+ { this.popState();console.log('Got NOTE_TEXT for note',yytext);yytext = yytext.substr(2).trim();return 'NOTE_TEXT';} -\s*[^:;]+"end note" { this.popState();console.log('Got NOTE_TEXT for note',yytext);yytext = yytext.slice(0,-8).trim();return 'NOTE_TEXT';} +[^"]* { /*console.log('Floating note text: ', yytext);*/return "NOTE_TEXT";} +[^\n]* {this.popState();/*console.log('Floating note ID', yytext);*/return "ID";} +\s*[^:\n\s\-]+ { this.popState();this.pushState('NOTE_TEXT');/*console.log('Got ID for note', yytext);*/return 'ID';} +\s*":"[^:\n;]+ { this.popState();/*console.log('Got NOTE_TEXT for note',yytext);*/yytext = yytext.substr(2).trim();return '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'; } -"[*]" { console.log('EDGE_STATE=',yytext); return 'EDGE_STATE';} -[^:\n\s\-\{]+ { console.log('=>ID=',yytext); return 'ID';} -// \s*":"[^\+\->:\n;]+ { yytext = yytext.trim(); console.log('Descr = ', yytext); return 'DESCR'; } -\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'; } +"[*]" { /*console.log('EDGE_STATE=',yytext);*/ return 'EDGE_STATE';} +[^:\n\s\-\{]+ { /*console.log('=>ID=',yytext);*/ return 'ID';} +// \s*":"[^\+\->:\n;]+ { yytext = yytext.trim(); /*console.log('Descr = ', yytext);*/ return 'DESCR'; } +\s*":"[^:\n;]+ { yytext = yytext.trim(); /*console.log('Descr = ', yytext);*/ return 'DESCR'; } "-->" return '-->'; "--" return 'CONCURRENT'; <> 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 diff --git a/src/diagrams/state/shapes.js b/src/diagrams/state/shapes.js index 718deb2fa..92ffc6c11 100644 --- a/src/diagrams/state/shapes.js +++ b/src/diagrams/state/shapes.js @@ -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, diff --git a/src/diagrams/state/stateDb.js b/src/diagrams/state/stateDb.js index c2749087a..b84d66fad 100644 --- a/src/diagrams/state/stateDb.js +++ b/src/diagrams/state/stateDb.js @@ -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 }); diff --git a/src/diagrams/state/stateRenderer.js b/src/diagrams/state/stateRenderer.js index 8276c36ca..467393224 100644 --- a/src/diagrams/state/stateRenderer.js +++ b/src/diagrams/state/stateRenderer.js @@ -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; };