From 2a0bc3b2e80a65a6e5be2805a77602fb7a58111c Mon Sep 17 00:00:00 2001 From: Tyler Long Date: Sun, 10 Sep 2017 21:51:48 +0800 Subject: [PATCH] Add export default to *Db.js --- CONTRIBUTING.md | 88 -------------------- src/diagrams/classDiagram/classDb.js | 13 +++ src/diagrams/flowchart/flowRenderer.js | 26 +++--- src/diagrams/flowchart/graphDb.js | 23 +++++ src/diagrams/gantt/ganttDb.js | 13 +++ src/diagrams/gitGraph/gitGraphAst.js | 20 +++++ src/diagrams/gitGraph/gitGraphParser.spec.js | 4 +- src/diagrams/sequenceDiagram/sequenceDb.js | 18 ++++ 8 files changed, 102 insertions(+), 103 deletions(-) delete mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index bbd86efb7..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,88 +0,0 @@ -# How to contribute - -Great that you want to be involved in this project! Contributing is fun and contributions are GREAT! :) - -This page is currently a starting point and is not so rigorous to start with. - -Some important guidlines: - -* The work will be organized using the issues list - * In the list there will be the bugs/enhancements etc we are working with in the project - * There will be milestones outlineing the roadmap ahead - * There will issues marked with help wanted - -The issue list and the items marked with **help wanted** is a good starting point if you want to do some work. - - -## Guidelines for avoiding duplicate work - -Contributing is great. It is not so fun when you are done with your issue and just before you're about to push your -change you can't because someone else just pushed the same fix so you have wasted your time. The guidelines below are in -place to prevent this: - -* Comment in the issue that you are working on it. You will then be added as an assignee (eventually). -* When you pick an issue to work on. - * Check that the issue not assigned - * Also check the comments so that no one has started working on it before beeing officially assigned. - - -## Submitting changes - -Please send a GitHub Pull Request with a clear list of what you've done (read more about pull requests). When you send -a pull request, we will love you forever if you include jasmine tests. We can always use more test coverage. - -Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: - -$ git commit -m "A brief summary of the commit -> -> A paragraph describing what changed and its impact." -Coding conventions -Start reading our code and you'll get the hang of it. We optimize for readability: - -This is open source software. Consider the people who will read your code, and make it look nice for them. It's sort of -like driving a car: Perhaps you love doing donuts when you're alone, but with passengers the goal is to make the ride as -smooth as possible. - -So that we can consistently serve images from the CDN, always use image_path or image_tag when referring to images. -Never prepend "/images/" when using image_path or image_tag. -Also for the CDN, always use cwd-relative paths rather than root-relative paths in image URLs in any CSS. So instead of -url('/images/blah.gif'), use url('../images/blah.gif'). - -# Build instructions - -Fork, then: - -``` -yarn install -``` - -Then the dependencies will have been installed. You use gulp and yarn calls as build tools. - -The following targets are probably interesting: - -* jison - compiles the jison grammars to parser files - -for instance: -``` -gulp jison -``` - -To build: - -``` -yarn build -``` - -To run the tests: - -``` -yarn test -``` - -Make sure you have Chrome browser installed. We use Chrome headless for testing. - -Manual test: - -``` -open dist/demo/index.html -``` diff --git a/src/diagrams/classDiagram/classDb.js b/src/diagrams/classDiagram/classDb.js index dc07d9825..934665133 100644 --- a/src/diagrams/classDiagram/classDb.js +++ b/src/diagrams/classDiagram/classDb.js @@ -77,3 +77,16 @@ export const relationType = { COMPOSITION: 2, DEPENDENCY: 3 } + +export default { + addClass, + clear, + getClass, + getClasses, + getRelations, + addRelation, + addMembers, + cleanupLabel, + lineType, + relationType +} diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index 5b384a41b..07d86795d 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -1,4 +1,4 @@ -import graph from './graphDb' +import graphDb from './graphDb' import flow from './parser/flow' import dot from './parser/dot' import d3 from '../../d3' @@ -217,18 +217,18 @@ export const addEdges = function (edges, g) { */ export const getClasses = function (text, isDot) { var parser - graph.clear() + graphDb.clear() if (isDot) { parser = dot.parser } else { parser = flow.parser } - parser.yy = graph + parser.yy = graphDb // Parse the graph definition parser.parse(text) - var classes = graph.getClasses() + var classes = graphDb.getClasses() // Add default class if undefined if (typeof (classes.default) === 'undefined') { @@ -249,13 +249,13 @@ export const getClasses = function (text, isDot) { export const draw = function (text, id, isDot) { logger.debug('Drawing flowchart') var parser - graph.clear() + graphDb.clear() if (isDot) { parser = dot.parser } else { parser = flow.parser } - parser.yy = graph + parser.yy = graphDb // Parse the graph definition try { @@ -266,7 +266,7 @@ export const draw = function (text, id, isDot) { // Fetch the default direction, use TD if none was found var dir - dir = graph.getDirection() + dir = graphDb.getDirection() if (typeof dir === 'undefined') { dir = 'TD' } @@ -287,17 +287,17 @@ export const draw = function (text, id, isDot) { }) var subG - var subGraphs = graph.getSubGraphs() + var subGraphs = graphDb.getSubGraphs() var i = 0 for (i = subGraphs.length - 1; i >= 0; i--) { subG = subGraphs[i] - graph.addVertex(subG.id, subG.title, 'group', undefined) + graphDb.addVertex(subG.id, subG.title, 'group', undefined) } // Fetch the verices/nodes and edges/links from the parsed graph definition - var vert = graph.getVertices() + var vert = graphDb.getVertices() - var edges = graph.getEdges() + var edges = graphDb.getEdges() i = 0 var j @@ -430,7 +430,7 @@ export const draw = function (text, id, isDot) { element.selectAll('g.node') .attr('title', function () { - return graph.getTooltip(this.id) + return graphDb.getTooltip(this.id) }) if (conf.useMaxWidth) { @@ -451,7 +451,7 @@ export const draw = function (text, id, isDot) { } // Index nodes - graph.indexNodes('subGraph' + i) + graphDb.indexNodes('subGraph' + i) for (i = 0; i < subGraphs.length; i++) { subG = subGraphs[i] diff --git a/src/diagrams/flowchart/graphDb.js b/src/diagrams/flowchart/graphDb.js index a68680251..88de54322 100644 --- a/src/diagrams/flowchart/graphDb.js +++ b/src/diagrams/flowchart/graphDb.js @@ -396,3 +396,26 @@ export const indexNodes = function () { export const getSubGraphs = function () { return subGraphs } + +export default { + addVertex, + addLink, + updateLinkInterpolate, + updateLink, + addClass, + setDirection, + setClass, + getTooltip, + setClickEvent, + bindFunctions, + getDirection, + getVertices, + getEdges, + getClasses, + clear, + defaultStyle, + addSubGraph, + getDepthFirstPos, + indexNodes, + getSubGraphs +} diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index 1c82ca836..a1f727503 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -348,3 +348,16 @@ var compileTasks = function () { } return allProcessed } + +export default { + clear, + setDateFormat, + getDateFormat, + setTitle, + getTitle, + addSection, + getTasks, + addTask, + findTaskById, + addTaskOrg +} diff --git a/src/diagrams/gitGraph/gitGraphAst.js b/src/diagrams/gitGraph/gitGraphAst.js index ed3fcec4e..58debd3d7 100644 --- a/src/diagrams/gitGraph/gitGraphAst.js +++ b/src/diagrams/gitGraph/gitGraphAst.js @@ -206,3 +206,23 @@ export const getCommitsArray = function () { export const getCurrentBranch = function () { return curBranch } export const getDirection = function () { return direction } export const getHead = function () { return head } + +export default { + setDirection, + setOptions, + getOptions, + commit, + branch, + merge, + checkout, + reset, + prettyPrint, + clear, + getBranchesAsObjArray, + getBranches, + getCommits, + getCommitsArray, + getCurrentBranch, + getDirection, + getHead +} diff --git a/src/diagrams/gitGraph/gitGraphParser.spec.js b/src/diagrams/gitGraph/gitGraphParser.spec.js index 6887d8165..2783efd02 100644 --- a/src/diagrams/gitGraph/gitGraphParser.spec.js +++ b/src/diagrams/gitGraph/gitGraphParser.spec.js @@ -1,10 +1,10 @@ /* eslint-env jasmine */ -import ast from './gitGraphAst' +import gitGraphAst from './gitGraphAst' import { parser } from './parser/gitGraph' describe('when parsing a gitGraph', function () { beforeEach(function () { - parser.yy = ast + parser.yy = gitGraphAst parser.yy.clear() }) it('should handle a gitGraph defintion', function () { diff --git a/src/diagrams/sequenceDiagram/sequenceDb.js b/src/diagrams/sequenceDiagram/sequenceDb.js index 3cf4b1c66..be8f1aac1 100644 --- a/src/diagrams/sequenceDiagram/sequenceDb.js +++ b/src/diagrams/sequenceDiagram/sequenceDb.js @@ -152,3 +152,21 @@ export const apply = function (param) { } } } + +export default { + addActor, + addMessage, + addSignal, + getMessages, + getActors, + getActor, + getActorKeys, + getTitle, + clear, + LINETYPE, + ARROWTYPE, + PLACEMENT, + addNote, + setTitle, + apply +}