Simplify API

This commit is contained in:
Tyler Long 2018-03-11 22:38:13 +08:00
parent 0d0cdd0542
commit a0b589979d
3 changed files with 4 additions and 19 deletions

View File

@ -3,13 +3,14 @@ import * as d3 from 'd3'
import db from './exampleDb'
import exampleParser from './parser/example.js'
import { logger } from '../../logger'
import { version } from '../../../package.json'
/**
* Draws a an info picture in the tag with id: id based on the graph definition in text.
* @param text
* @param id
*/
export const draw = function (txt, id, ver) {
export const draw = function (txt, id) {
const parser = exampleParser.parser
parser.yy = db
logger.debug('Renering example diagram')
@ -27,7 +28,7 @@ export const draw = function (txt, id, ver) {
.attr('class', 'version')
.attr('font-size', '32px')
.style('text-anchor', 'middle')
.text('mermaid ' + ver)
.text('mermaid ' + version)
svg.attr('height', 100)
svg.attr('width', 400)

View File

@ -6,7 +6,6 @@ import he from 'he'
import mermaidAPI from './mermaidAPI'
import { logger } from './logger'
import pkg from '../package.json'
let nextId = 0
@ -106,10 +105,6 @@ const init = function () {
}
}
const version = function () {
return 'v' + pkg.version
}
const initialize = function (config) {
logger.debug('Initializing mermaid')
if (typeof config.mermaid !== 'undefined') {
@ -167,7 +162,6 @@ const mermaid = {
init,
initialize,
version,
contentLoaded
}

View File

@ -35,7 +35,6 @@ import classDb from './diagrams/classDiagram/classDb'
import gitGraphParser from './diagrams/gitGraph/parser/gitGraph'
import gitGraphRenderer from './diagrams/gitGraph/gitGraphRenderer'
import gitGraphAst from './diagrams/gitGraph/gitGraphAst'
import pkg from '../package.json'
import darkTheme from './themes/dark/index.scss'
import defaultTheme from './themes/default/index.scss'
@ -295,15 +294,6 @@ function parse (text) {
parser.parse(text)
}
/**
* ## version
* Function returning version information
* @returns {string} A string containing the version info
*/
export const version = function () {
return pkg.version
}
export const encodeEntities = function (text) {
let txt = text
@ -432,7 +422,7 @@ const render = function (id, txt, cb, container) {
break
case 'info':
config.info.arrowMarkerAbsolute = config.arrowMarkerAbsolute
info.draw(txt, id, version())
info.draw(txt, id)
break
}