mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 06:20:07 +02:00
Refactor by renaming
This commit is contained in:
@@ -104,7 +104,7 @@ const config = {
|
|||||||
* ### sequenceDiagram
|
* ### sequenceDiagram
|
||||||
* The object containing configurations specific for sequence diagrams
|
* The object containing configurations specific for sequence diagrams
|
||||||
*/
|
*/
|
||||||
sequenceDiagram: {
|
sequence: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **diagramMarginX** - margin to the right and left of the sequence diagram
|
* **diagramMarginX** - margin to the right and left of the sequence diagram
|
||||||
@@ -244,8 +244,8 @@ const config = {
|
|||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
classDiagram: {},
|
class: {},
|
||||||
gitGraph: {},
|
git: {},
|
||||||
example: {}
|
example: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ function parse (text) {
|
|||||||
let parser
|
let parser
|
||||||
|
|
||||||
switch (graphType) {
|
switch (graphType) {
|
||||||
case 'gitGraph':
|
case 'git':
|
||||||
parser = gitGraphParser
|
parser = gitGraphParser
|
||||||
parser.parser.yy = gitGraphAst
|
parser.parser.yy = gitGraphAst
|
||||||
break
|
break
|
||||||
@@ -264,11 +264,11 @@ function parse (text) {
|
|||||||
parser = flowParser
|
parser = flowParser
|
||||||
parser.parser.yy = flowDb
|
parser.parser.yy = flowDb
|
||||||
break
|
break
|
||||||
case 'dotGraph':
|
case 'dot':
|
||||||
parser = dotParser
|
parser = dotParser
|
||||||
parser.parser.yy = flowDb
|
parser.parser.yy = flowDb
|
||||||
break
|
break
|
||||||
case 'sequenceDiagram':
|
case 'sequence':
|
||||||
parser = sequenceParser
|
parser = sequenceParser
|
||||||
parser.parser.yy = sequenceDb
|
parser.parser.yy = sequenceDb
|
||||||
break
|
break
|
||||||
@@ -280,7 +280,7 @@ function parse (text) {
|
|||||||
parser = ganttParser
|
parser = ganttParser
|
||||||
parser.parser.yy = ganttDb
|
parser.parser.yy = ganttDb
|
||||||
break
|
break
|
||||||
case 'classDiagram':
|
case 'class':
|
||||||
parser = classParser
|
parser = classParser
|
||||||
parser.parser.yy = classDb
|
parser.parser.yy = classDb
|
||||||
break
|
break
|
||||||
@@ -390,9 +390,9 @@ const render = function (id, txt, cb, container) {
|
|||||||
const element = d3.select('#d' + id).node()
|
const element = d3.select('#d' + id).node()
|
||||||
const graphType = utils.detectType(txt)
|
const graphType = utils.detectType(txt)
|
||||||
switch (graphType) {
|
switch (graphType) {
|
||||||
case 'gitGraph':
|
case 'git':
|
||||||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
gitGraphRenderer.setConf(config.gitGraph)
|
gitGraphRenderer.setConf(config.git)
|
||||||
gitGraphRenderer.draw(txt, id, false)
|
gitGraphRenderer.draw(txt, id, false)
|
||||||
break
|
break
|
||||||
case 'flowchart':
|
case 'flowchart':
|
||||||
@@ -400,14 +400,14 @@ const render = function (id, txt, cb, container) {
|
|||||||
flowRenderer.setConf(config.flowchart)
|
flowRenderer.setConf(config.flowchart)
|
||||||
flowRenderer.draw(txt, id, false)
|
flowRenderer.draw(txt, id, false)
|
||||||
break
|
break
|
||||||
case 'dotGraph':
|
case 'dot':
|
||||||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
flowRenderer.setConf(config.flowchart)
|
flowRenderer.setConf(config.flowchart)
|
||||||
flowRenderer.draw(txt, id, true)
|
flowRenderer.draw(txt, id, true)
|
||||||
break
|
break
|
||||||
case 'sequenceDiagram':
|
case 'sequence':
|
||||||
config.sequenceDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.sequence.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
sequenceRenderer.setConf(config.sequenceDiagram)
|
sequenceRenderer.setConf(config.sequence)
|
||||||
sequenceRenderer.draw(txt, id)
|
sequenceRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
case 'gantt':
|
case 'gantt':
|
||||||
@@ -415,9 +415,9 @@ const render = function (id, txt, cb, container) {
|
|||||||
ganttRenderer.setConf(config.gantt)
|
ganttRenderer.setConf(config.gantt)
|
||||||
ganttRenderer.draw(txt, id)
|
ganttRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
case 'classDiagram':
|
case 'class':
|
||||||
config.classDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute
|
||||||
classRenderer.setConf(config.classDiagram)
|
classRenderer.setConf(config.class)
|
||||||
classRenderer.draw(txt, id)
|
classRenderer.draw(txt, id)
|
||||||
break
|
break
|
||||||
case 'example':
|
case 'example':
|
||||||
|
@@ -20,11 +20,11 @@ import * as d3 from 'd3'
|
|||||||
export const detectType = function (text) {
|
export const detectType = function (text) {
|
||||||
text = text.replace(/^\s*%%.*\n/g, '\n')
|
text = text.replace(/^\s*%%.*\n/g, '\n')
|
||||||
if (text.match(/^\s*sequenceDiagram/)) {
|
if (text.match(/^\s*sequenceDiagram/)) {
|
||||||
return 'sequenceDiagram'
|
return 'sequence'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.match(/^\s*digraph/)) {
|
if (text.match(/^\s*digraph/)) {
|
||||||
return 'dotGraph'
|
return 'dot'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.match(/^\s*info/)) {
|
if (text.match(/^\s*info/)) {
|
||||||
@@ -36,11 +36,11 @@ export const detectType = function (text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (text.match(/^\s*classDiagram/)) {
|
if (text.match(/^\s*classDiagram/)) {
|
||||||
return 'classDiagram'
|
return 'class'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.match(/^\s*gitGraph/)) {
|
if (text.match(/^\s*gitGraph/)) {
|
||||||
return 'gitGraph'
|
return 'git'
|
||||||
}
|
}
|
||||||
return 'flowchart'
|
return 'flowchart'
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ describe('when detecting chart type ', function () {
|
|||||||
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'
|
||||||
const type = utils.detectType(str)
|
const type = utils.detectType(str)
|
||||||
expect(type).toBe('gitGraph')
|
expect(type).toBe('git')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user