mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 02:39:41 +02:00
Added logger for dealing with issue #179
Added markdown files for the documentation. parseError exposed from the mermaidAPI
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/* global window */
|
||||
|
||||
var log = require('../../logger').create();
|
||||
var dagreD3;
|
||||
//console.log('setting up dagre-d3');
|
||||
//log.debug('setting up dagre-d3');
|
||||
if (require) {
|
||||
try {
|
||||
dagreD3 = require("dagre-d3");
|
||||
//console.log('Got it (dagre-d3)');
|
||||
} catch (e) {console.log('Could not load dagre-d3');}
|
||||
//log.debug('Got it (dagre-d3)');
|
||||
} catch (e) {log.debug('Could not load dagre-d3');}
|
||||
}
|
||||
|
||||
if (!dagreD3) {
|
||||
|
@@ -6,6 +6,8 @@ var flow = require('./parser/flow');
|
||||
var dot = require('./parser/dot');
|
||||
var d3 = require('../../d3');
|
||||
var dagreD3 = require('./dagre-d3');
|
||||
var log = require('../../logger').create();
|
||||
|
||||
var conf = {
|
||||
};
|
||||
module.exports.setConf = function(cnf){
|
||||
@@ -49,7 +51,7 @@ exports.addVertices = function (vert, g) {
|
||||
*/
|
||||
var classStr = '';
|
||||
|
||||
//console.log(vertice.classes);
|
||||
//log.debug(vertice.classes);
|
||||
|
||||
if(vertice.classes.length >0){
|
||||
classStr = vertice.classes.join(" ");
|
||||
@@ -230,7 +232,7 @@ exports.getClasses = function (text, isDot) {
|
||||
* @param id
|
||||
*/
|
||||
exports.draw = function (text, id,isDot) {
|
||||
|
||||
log.debug('Drawing flowchart');
|
||||
var parser;
|
||||
graph.clear();
|
||||
if(isDot){
|
||||
@@ -283,7 +285,7 @@ exports.draw = function (text, id,isDot) {
|
||||
// Fetch the verices/nodes and edges/links from the parsed graph definition
|
||||
var vert = graph.getVertices();
|
||||
|
||||
//console.log(vert);
|
||||
//log.debug(vert);
|
||||
var edges = graph.getEdges();
|
||||
|
||||
i = 0;
|
||||
@@ -294,7 +296,7 @@ exports.draw = function (text, id,isDot) {
|
||||
d3.selectAll('cluster').append('text');
|
||||
|
||||
for(j=0;j<subG.nodes.length;j++){
|
||||
//console.log('Setting node',subG.nodes[j],' to subgraph '+id);
|
||||
//log.debug('Setting node',subG.nodes[j],' to subgraph '+id);
|
||||
g.setParent(subG.nodes[j],subG.id);
|
||||
}
|
||||
}
|
||||
@@ -438,7 +440,7 @@ exports.draw = function (text, id,isDot) {
|
||||
|
||||
if (subG.title !== 'undefined') {
|
||||
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect');
|
||||
//console.log('looking up: #' + id + ' #' + subG.id)
|
||||
//log.debug('looking up: #' + id + ' #' + subG.id)
|
||||
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id);
|
||||
|
||||
var xPos = clusterRects[0].x.baseVal.value;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
*/
|
||||
|
||||
var log = require('../../logger').create();
|
||||
var vertices = {};
|
||||
var edges = [];
|
||||
var classes = [];
|
||||
@@ -63,7 +63,7 @@ exports.addVertex = function (id, text, type, style) {
|
||||
* @param linktext
|
||||
*/
|
||||
exports.addLink = function (start, end, type, linktext) {
|
||||
//console.log('Got edge', start, end);
|
||||
//log.debug('Got edge', start, end);
|
||||
var edge = {start: start, end: end, type: undefined, text: ''};
|
||||
linktext = type.text;
|
||||
|
||||
@@ -158,7 +158,7 @@ exports.setClickEvent = function (id,functionName) {
|
||||
}
|
||||
});
|
||||
}else{
|
||||
//console.log('Checking now for ::'+id);
|
||||
//log.debug('Checking now for ::'+id);
|
||||
if(typeof vertices[id] !== 'undefined'){
|
||||
funs.push(function(){
|
||||
var elem = document.getElementById(id);
|
||||
@@ -166,7 +166,7 @@ exports.setClickEvent = function (id,functionName) {
|
||||
elem.onclick = function(){eval(functionName+'(\'' + id + '\')');}; // jshint ignore:line
|
||||
}
|
||||
else{
|
||||
//console.log('id was null: '+id);
|
||||
//log.debug('id was null: '+id);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -251,8 +251,8 @@ exports.addSubGraph = function (list, title) {
|
||||
|
||||
|
||||
var subGraph = {id:'subGraph'+subCount, nodes:nodeList,title:title};
|
||||
//console.log('subGraph:' + subGraph.title + subGraph.id);
|
||||
//console.log(subGraph.nodes);
|
||||
//log.debug('subGraph:' + subGraph.title + subGraph.id);
|
||||
//log.debug(subGraph.nodes);
|
||||
subGraphs.push(subGraph);
|
||||
subCount = subCount + 1;
|
||||
return subGraph.id;
|
||||
@@ -262,11 +262,11 @@ var getPosForId = function(id){
|
||||
var i;
|
||||
for(i=0;i<subGraphs.length;i++){
|
||||
if(subGraphs[i].id===id){
|
||||
//console.log('Found pos for ',id,' ',i);
|
||||
//log.debug('Found pos for ',id,' ',i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
//console.log('No pos found for ',id,' ',i);
|
||||
//log.debug('No pos found for ',id,' ',i);
|
||||
return -1;
|
||||
};
|
||||
var secCount = -1;
|
||||
@@ -332,5 +332,5 @@ exports.getSubGraphs = function (list) {
|
||||
};
|
||||
|
||||
exports.parseError = function(err,hash){
|
||||
mermaid.parseError(err,hash);
|
||||
mermaidAPI.parseError(err,hash);
|
||||
};
|
@@ -10,7 +10,7 @@ describe('when parsing ',function(){
|
||||
flow.parser.yy = require('../graphDb');
|
||||
flow.parser.yy.clear();
|
||||
/*flow.parser.parse.parseError= function parseError(str, hash) {
|
||||
console.logconsole.log(str);
|
||||
log.debugconsole.log(str);
|
||||
}*/
|
||||
});
|
||||
|
||||
@@ -1054,7 +1054,7 @@ describe('when parsing ',function(){
|
||||
expect(edges.length).toBe(0);
|
||||
expect(vert['i-d'].styles.length).toBe(0);
|
||||
});
|
||||
//console.log(flow.parser.parse('graph TD;style Q background:#fff;'));
|
||||
//log.debug(flow.parser.parse('graph TD;style Q background:#fff;'));
|
||||
it('should handle styles for vertices',function(){
|
||||
var res = flow.parser.parse('graph TD;style Q background:#fff;');
|
||||
|
||||
@@ -1067,7 +1067,7 @@ describe('when parsing ',function(){
|
||||
expect(vert['Q'].styles[0]).toBe('background:#fff');
|
||||
});
|
||||
|
||||
//console.log(flow.parser.parse('graph TD;style Q background:#fff;'));
|
||||
//log.debug(flow.parser.parse('graph TD;style Q background:#fff;'));
|
||||
it('should handle styles for edges',function(){
|
||||
var res = flow.parser.parse('graph TD;a-->b;\nstyle #0 stroke: #f66;');
|
||||
|
||||
|
Reference in New Issue
Block a user