mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
Refactor by renaming
This commit is contained in:
@@ -18,15 +18,15 @@ import { logger, setLogLevel } from './logger'
|
|||||||
import flowDb from './diagrams/flowchart/flowDb'
|
import flowDb from './diagrams/flowchart/flowDb'
|
||||||
import utils from './utils'
|
import utils from './utils'
|
||||||
import flowRenderer from './diagrams/flowchart/flowRenderer'
|
import flowRenderer from './diagrams/flowchart/flowRenderer'
|
||||||
import seq from './diagrams/sequenceDiagram/sequenceRenderer'
|
import sequenceRenderer from './diagrams/sequenceDiagram/sequenceRenderer'
|
||||||
import example from './diagrams/example/exampleRenderer'
|
import exampleRenderer from './diagrams/example/exampleRenderer'
|
||||||
import exampleParser from './diagrams/example/parser/example'
|
import exampleParser from './diagrams/example/parser/example'
|
||||||
import flowParser from './diagrams/flowchart/parser/flow'
|
import flowParser from './diagrams/flowchart/parser/flow'
|
||||||
import dotParser from './diagrams/flowchart/parser/dot'
|
import dotParser from './diagrams/flowchart/parser/dot'
|
||||||
import sequenceParser from './diagrams/sequenceDiagram/parser/sequenceDiagram'
|
import sequenceParser from './diagrams/sequenceDiagram/parser/sequenceDiagram'
|
||||||
import sequenceDb from './diagrams/sequenceDiagram/sequenceDb'
|
import sequenceDb from './diagrams/sequenceDiagram/sequenceDb'
|
||||||
import exampleDb from './diagrams/example/exampleDb'
|
import exampleDb from './diagrams/example/exampleDb'
|
||||||
import gantt from './diagrams/gantt/ganttRenderer'
|
import ganttRenderer from './diagrams/gantt/ganttRenderer'
|
||||||
import ganttParser from './diagrams/gantt/parser/gantt'
|
import ganttParser from './diagrams/gantt/parser/gantt'
|
||||||
import ganttDb from './diagrams/gantt/ganttDb'
|
import ganttDb from './diagrams/gantt/ganttDb'
|
||||||
import classParser from './diagrams/classDiagram/parser/classDiagram'
|
import classParser from './diagrams/classDiagram/parser/classDiagram'
|
||||||
@@ -260,7 +260,7 @@ function parse (text) {
|
|||||||
parser = gitGraphParser
|
parser = gitGraphParser
|
||||||
parser.parser.yy = gitGraphAst
|
parser.parser.yy = gitGraphAst
|
||||||
break
|
break
|
||||||
case 'graph':
|
case 'flowchart':
|
||||||
parser = flowParser
|
parser = flowParser
|
||||||
parser.parser.yy = flowDb
|
parser.parser.yy = flowDb
|
||||||
break
|
break
|
||||||
@@ -395,7 +395,7 @@ const render = function (id, txt, cb, container) {
|
|||||||
gitGraphRenderer.setConf(config.gitGraph)
|
gitGraphRenderer.setConf(config.gitGraph)
|
||||||
gitGraphRenderer.draw(txt, id, false)
|
gitGraphRenderer.draw(txt, id, false)
|
||||||
break
|
break
|
||||||
case 'graph':
|
case 'flowchart':
|
||||||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
flowRenderer.setConf(config.flowchart)
|
flowRenderer.setConf(config.flowchart)
|
||||||
flowRenderer.draw(txt, id, false)
|
flowRenderer.draw(txt, id, false)
|
||||||
@@ -407,13 +407,13 @@ const render = function (id, txt, cb, container) {
|
|||||||
break
|
break
|
||||||
case 'sequenceDiagram':
|
case 'sequenceDiagram':
|
||||||
config.sequenceDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.sequenceDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
seq.setConf(config.sequenceDiagram)
|
sequenceRenderer.setConf(config.sequenceDiagram)
|
||||||
seq.draw(txt, id)
|
sequenceRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
case 'gantt':
|
case 'gantt':
|
||||||
config.gantt.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.gantt.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
gantt.setConf(config.gantt)
|
ganttRenderer.setConf(config.gantt)
|
||||||
gantt.draw(txt, id)
|
ganttRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
case 'classDiagram':
|
case 'classDiagram':
|
||||||
config.classDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.classDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
@@ -422,7 +422,7 @@ const render = function (id, txt, cb, container) {
|
|||||||
break
|
break
|
||||||
case 'example':
|
case 'example':
|
||||||
config.example.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.example.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
example.draw(txt, id)
|
exampleRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,6 @@ const mermaidAPI = {
|
|||||||
render,
|
render,
|
||||||
parse,
|
parse,
|
||||||
initialize,
|
initialize,
|
||||||
detectType: utils.detectType,
|
|
||||||
getConfig
|
getConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ export const detectType = function (text) {
|
|||||||
if (text.match(/^\s*gitGraph/)) {
|
if (text.match(/^\s*gitGraph/)) {
|
||||||
return 'gitGraph'
|
return 'gitGraph'
|
||||||
}
|
}
|
||||||
return 'graph'
|
return 'flowchart'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -5,18 +5,18 @@ describe('when detecting chart type ', function () {
|
|||||||
it('should handle a graph defintion', function () {
|
it('should handle a graph defintion', function () {
|
||||||
const str = 'graph TB\nbfs1:queue'
|
const str = 'graph TB\nbfs1:queue'
|
||||||
const type = utils.detectType(str)
|
const type = utils.detectType(str)
|
||||||
expect(type).toBe('graph')
|
expect(type).toBe('flowchart')
|
||||||
})
|
})
|
||||||
it('should handle a graph defintion with leading spaces', function () {
|
it('should handle a graph defintion with leading spaces', function () {
|
||||||
const str = ' graph TB\nbfs1:queue'
|
const str = ' graph TB\nbfs1:queue'
|
||||||
const type = utils.detectType(str)
|
const type = utils.detectType(str)
|
||||||
expect(type).toBe('graph')
|
expect(type).toBe('flowchart')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle a graph defintion with leading spaces and newline', function () {
|
it('should handle a graph defintion with leading spaces and newline', function () {
|
||||||
const str = ' \n graph TB\nbfs1:queue'
|
const str = ' \n graph TB\nbfs1:queue'
|
||||||
const type = utils.detectType(str)
|
const type = utils.detectType(str)
|
||||||
expect(type).toBe('graph')
|
expect(type).toBe('flowchart')
|
||||||
})
|
})
|
||||||
it('should handle a graph defintion for gitGraph', function () {
|
it('should handle a graph defintion for gitGraph', function () {
|
||||||
const str = ' \n gitGraph TB:\nbfs1:queue'
|
const str = ' \n gitGraph TB:\nbfs1:queue'
|
||||||
|
Reference in New Issue
Block a user