Merge remote-tracking branch 'MERMAID/develop' into docs/bug-3417-change_src_docs_only

This commit is contained in:
Ashley Engelund (weedySeaDragon @ github)
2022-09-07 06:36:13 -07:00
16 changed files with 104 additions and 107 deletions

View File

@@ -17,15 +17,6 @@
* Traditional Object.assign would have clobbered foo in config_0 with foo in config_1. If src is a * Traditional Object.assign would have clobbered foo in config_0 with foo in config_1. If src is a
* destructured array of objects and dst is not an array, assignWithDepth will apply each element * destructured array of objects and dst is not an array, assignWithDepth will apply each element
* of src to dst in order. * of src to dst in order.
* @param dst
* @param src
* @param config
* @param dst
* @param src
* @param config
* @param dst
* @param src
* @param config
* @param {any} dst - The destination of the merge * @param {any} dst - The destination of the merge
* @param {any} src - The source object(s) to merge into destination * @param {any} src - The source object(s) to merge into destination
* @param {{ depth: number; clobber: boolean }} [config={ depth: 2, clobber: false }] - Depth: depth * @param {{ depth: number; clobber: boolean }} [config={ depth: 2, clobber: false }] - Depth: depth

View File

@@ -163,9 +163,9 @@ export const validate = (graph) => {
}; };
/** /**
* Finds a child that is not a cluster. When faking a edge between a node and a cluster. * Finds a child that is not a cluster. When faking an edge between a node and a cluster.
* *
* @param {Finds a} id * @param id
* @param {any} graph * @param {any} graph
*/ */
export const findNonClusterChild = (id, graph) => { export const findNonClusterChild = (id, graph) => {
@@ -235,7 +235,7 @@ export const adjustClustersAndEdges = (graph, depth) => {
edges.forEach((edge) => { edges.forEach((edge) => {
// log.debug('Edge, decendants: ', edge, decendants[id]); // log.debug('Edge, decendants: ', edge, decendants[id]);
// Check if any edge leaves the cluster (not the actual cluster, thats a link from the box) // Check if any edge leaves the cluster (not the actual cluster, that's a link from the box)
if (edge.v !== id && edge.w !== id) { if (edge.v !== id && edge.w !== id) {
// Any edge where either the one of the nodes is decending to the cluster but not the other // Any edge where either the one of the nodes is decending to the cluster but not the other
// if (decendants[id].indexOf(edge.v) < 0 && decendants[id].indexOf(edge.w) < 0) { // if (decendants[id].indexOf(edge.v) < 0 && decendants[id].indexOf(edge.w) < 0) {

View File

@@ -568,10 +568,9 @@ function drawInsideBoundary(diagram, parentBoundaryAlias, parentBounds, currentB
/** /**
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text. * Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
* *
* @param {any} text * @param {any} _text
* @param _text
* @param {any} id * @param {any} id
* @param _version * @param {any} _version
* @param diagObj * @param diagObj
*/ */
export const draw = function (_text, id, _version, diagObj) { export const draw = function (_text, id, _version, diagObj) {

View File

@@ -142,8 +142,7 @@ const insertMarkers = function (elem) {
* *
* @param {string} text * @param {string} text
* @param {string} id * @param {string} id
* @param version * @param {any} _version
* @param _version
* @param diagObj * @param diagObj
*/ */
export const draw = function (text, id, _version, diagObj) { export const draw = function (text, id, _version, diagObj) {

View File

@@ -32,7 +32,7 @@ export const setConf = function (cnf) {
* @param groupNode The svg group node for the entity * @param groupNode The svg group node for the entity
* @param entityTextNode The svg node for the entity label text * @param entityTextNode The svg node for the entity label text
* @param attributes An array of attributes defined for the entity (each attribute has a type and a name) * @param attributes An array of attributes defined for the entity (each attribute has a type and a name)
* @returns The bounding box of the entity, after attributes have been added * @returns {object} The bounding box of the entity, after attributes have been added. The bounding box has a .width and .height
*/ */
const drawAttributes = (groupNode, entityTextNode, attributes) => { const drawAttributes = (groupNode, entityTextNode, attributes) => {
const heightPadding = conf.entityPadding / 3; // Padding internal to attribute boxes const heightPadding = conf.entityPadding / 3; // Padding internal to attribute boxes
@@ -307,7 +307,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
* @param svgNode The svg node that contains the diagram * @param svgNode The svg node that contains the diagram
* @param entities The entities to be drawn * @param entities The entities to be drawn
* @param graph The graph that contains the vertex and edge definitions post-layout * @param graph The graph that contains the vertex and edge definitions post-layout
* @returns The first entity that was inserted * @returns {object} The first entity that was inserted
*/ */
const drawEntities = function (svgNode, entities, graph) { const drawEntities = function (svgNode, entities, graph) {
const keys = Object.keys(entities); const keys = Object.keys(entities);
@@ -545,7 +545,6 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
* @param text The text of the diagram * @param text The text of the diagram
* @param id The unique id of the DOM node that contains the diagram * @param id The unique id of the DOM node that contains the diagram
* @param _version * @param _version
* @param diag
* @param diagObj * @param diagObj
*/ */
export const draw = function (text, id, _version, diagObj) { export const draw = function (text, id, _version, diagObj) {

View File

@@ -25,7 +25,6 @@ export const setConf = function (cnf) {
* @param g The graph that is to be drawn. * @param g The graph that is to be drawn.
* @param svgId * @param svgId
* @param root * @param root
* @param doc
* @param _doc * @param _doc
* @param diagObj * @param diagObj
*/ */

View File

@@ -348,6 +348,21 @@ describe('when parsing a gitGraph', function () {
expect(Object.keys(parser.yy.getBranches()).length).toBe(2); expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
}); });
it('should allow branch names starting with numbers', function () {
const str = `gitGraph:
commit
%% branch names starting with numbers are not recommended, but are supported by git
branch 1.0.1
`;
parser.parse(str);
const commits = parser.yy.getCommits();
expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe('1.0.1');
expect(parser.yy.getDirection()).toBe('LR');
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
});
it('should handle new branch checkout', function () { it('should handle new branch checkout', function () {
const str = `gitGraph: const str = `gitGraph:
commit commit

View File

@@ -290,13 +290,13 @@ const drawCommits = (svg, commits, modifyGraph) => {
}; };
/** /**
* Detect if there are other commits between commit1s x-position and commit2s x-position on the same * Detect if there are other commits between commit1's x-position and commit2's x-position on the same
* branch as commit2. * branch as commit2.
* *
* @param {any} commit1 * @param {any} commit1
* @param {any} commit2 * @param {any} commit2
* @param allCommits * @param allCommits
* @returns * @returns {boolean} if there are commits between commit1's x-position and commit2's x-position
*/ */
const hasOverlappingCommits = (commit1, commit2, allCommits) => { const hasOverlappingCommits = (commit1, commit2, allCommits) => {
const commit1Pos = commitPos[commit2.id]; const commit1Pos = commitPos[commit2.id];
@@ -322,7 +322,7 @@ const hasOverlappingCommits = (commit1, commit2, allCommits) => {
* @param {any} y1 * @param {any} y1
* @param {any} y2 * @param {any} y2
* @param {any} _depth * @param {any} _depth
* @returns * @returns {number} y value between y1 and y2
*/ */
const findLane = (y1, y2, _depth) => { const findLane = (y1, y2, _depth) => {
const depth = _depth || 0; const depth = _depth || 0;
@@ -347,7 +347,7 @@ const findLane = (y1, y2, _depth) => {
}; };
/** /**
* This function draw the lines between the commits. They were arrows initially. * Draw the lines between the commits. They were arrows initially.
* *
* @param {any} svg * @param {any} svg
* @param {any} commit1 * @param {any} commit1
@@ -453,12 +453,10 @@ const drawArrows = (svg, commits) => {
}; };
/** /**
* This function adds the branches and the branches' labels to the svg. * Adds the branches and the branches' labels to the svg.
* *
* @param svg * @param svg
* @param commitid
* @param branches * @param branches
* @param direction
*/ */
const drawBranches = (svg, branches) => { const drawBranches = (svg, branches) => {
const gitGraphConfig = getConfig().gitGraph; const gitGraphConfig = getConfig().gitGraph;
@@ -510,10 +508,6 @@ const drawBranches = (svg, branches) => {
}; };
/** /**
* @param svg
* @param commit
* @param direction
* @param branchColor
* @param txt * @param txt
* @param id * @param id
* @param ver * @param ver

View File

@@ -33,7 +33,6 @@ accDescr\s*"{"\s* { this.begin("ac
<acc_descr_multiline>[\}] { this.popState(); } <acc_descr_multiline>[\}] { this.popState(); }
<acc_descr_multiline>[^\}]* return "acc_descr_multiline_value"; <acc_descr_multiline>[^\}]* return "acc_descr_multiline_value";
(\r?\n)+ /*{console.log('New line');return 'NL';}*/ return 'NL'; (\r?\n)+ /*{console.log('New line');return 'NL';}*/ return 'NL';
\s+ /* skip all whitespace */
\#[^\n]* /* skip comments */ \#[^\n]* /* skip comments */
\%%[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */
"gitGraph" return 'GG'; "gitGraph" return 'GG';
@@ -61,9 +60,10 @@ accDescr\s*"{"\s* { this.begin("ac
["] this.begin("string"); ["] this.begin("string");
<string>["] this.popState(); <string>["] this.popState();
<string>[^"]* return 'STR'; <string>[^"]* return 'STR';
[0-9]+ return 'NUM'; [0-9]+(?=\s|$) return 'NUM';
[a-zA-Z][-_\./a-zA-Z0-9]*[-_a-zA-Z0-9] return 'ID'; \w[-\./\w]*[-\w] return 'ID'; // only a subset of https://git-scm.com/docs/git-check-ref-format
<<EOF>> return 'EOF'; <<EOF>> return 'EOF';
\s+ /* skip all whitespace */ // lowest priority so we can use lookaheads in earlier regex
/lex /lex

View File

@@ -1,4 +1,5 @@
import * as mindmapDB from './mindmapDb'; import * as mindmapDB from './mindmapDb';
import { setLogLevel } from '../../logger';
describe('when parsing a mindmap ', function () { describe('when parsing a mindmap ', function () {
let mindmap; let mindmap;
@@ -6,9 +7,10 @@ describe('when parsing a mindmap ', function () {
mindmap = require('./parser/mindmap').parser; mindmap = require('./parser/mindmap').parser;
mindmap.yy = require('./mindmapDb'); mindmap.yy = require('./mindmapDb');
mindmap.yy.clear(); mindmap.yy.clear();
setLogLevel('trace');
}); });
describe('hiearchy', function () { describe('hiearchy', function () {
it('should handle a simple root definition', function () { it('MMP-1 should handle a simple root definition abc122', function () {
let str = `mindmap let str = `mindmap
root`; root`;
@@ -16,7 +18,7 @@ describe('when parsing a mindmap ', function () {
// console.log('Time for checks', mindmap.yy.getMindmap().descr); // console.log('Time for checks', mindmap.yy.getMindmap().descr);
expect(mindmap.yy.getMindmap().descr).toEqual('root'); expect(mindmap.yy.getMindmap().descr).toEqual('root');
}); });
it('should handle a hierachial mindmap definition', function () { it('MMP-2 should handle a hierachial mindmap definition', function () {
let str = `mindmap let str = `mindmap
root root
child1 child1
@@ -31,7 +33,7 @@ describe('when parsing a mindmap ', function () {
expect(mm.children[1].descr).toEqual('child2'); expect(mm.children[1].descr).toEqual('child2');
}); });
it('should handle a simple root definition with a shape and without an id abc123', function () { it('3 should handle a simple root definition with a shape and without an id abc123', function () {
let str = `mindmap let str = `mindmap
(root)`; (root)`;
@@ -40,7 +42,7 @@ describe('when parsing a mindmap ', function () {
expect(mindmap.yy.getMindmap().descr).toEqual('root'); expect(mindmap.yy.getMindmap().descr).toEqual('root');
}); });
it('should handle a deeper hierachial mindmap definition', function () { it('MMP-4 should handle a deeper hierachial mindmap definition', function () {
let str = `mindmap let str = `mindmap
root root
child1 child1
@@ -55,7 +57,7 @@ describe('when parsing a mindmap ', function () {
expect(mm.children[0].children[0].descr).toEqual('leaf1'); expect(mm.children[0].children[0].descr).toEqual('leaf1');
expect(mm.children[1].descr).toEqual('child2'); expect(mm.children[1].descr).toEqual('child2');
}); });
it('Multiple roots are illegal', function () { it('5 Multiple roots are illegal', function () {
let str = `mindmap let str = `mindmap
root root
fakeRoot`; fakeRoot`;
@@ -70,7 +72,7 @@ describe('when parsing a mindmap ', function () {
); );
} }
}); });
it('real root in wrong place', function () { it('MMP-6 real root in wrong place', function () {
let str = `mindmap let str = `mindmap
root root
fakeRoot fakeRoot
@@ -88,7 +90,7 @@ describe('when parsing a mindmap ', function () {
}); });
}); });
describe('nodes', function () { describe('nodes', function () {
it('should handle an id and type for a node definition', function () { it('MMP-7 should handle an id and type for a node definition', function () {
let str = `mindmap let str = `mindmap
root[The root] root[The root]
`; `;
@@ -99,7 +101,7 @@ describe('when parsing a mindmap ', function () {
expect(mm.descr).toEqual('The root'); expect(mm.descr).toEqual('The root');
expect(mm.type).toEqual(mindmap.yy.nodeType.RECT); expect(mm.type).toEqual(mindmap.yy.nodeType.RECT);
}); });
it('should handle an id and type for a node definition', function () { it('MMP-8 should handle an id and type for a node definition', function () {
let str = `mindmap let str = `mindmap
root root
theId(child1)`; theId(child1)`;
@@ -113,7 +115,7 @@ describe('when parsing a mindmap ', function () {
expect(child.nodeId).toEqual('theId'); expect(child.nodeId).toEqual('theId');
expect(child.type).toEqual(mindmap.yy.nodeType.ROUNDED_RECT); expect(child.type).toEqual(mindmap.yy.nodeType.ROUNDED_RECT);
}); });
it('should handle an id and type for a node definition', function () { it('MMP-9 should handle an id and type for a node definition', function () {
let str = `mindmap let str = `mindmap
root root
theId(child1)`; theId(child1)`;
@@ -127,10 +129,10 @@ root
expect(child.nodeId).toEqual('theId'); expect(child.nodeId).toEqual('theId');
expect(child.type).toEqual(mindmap.yy.nodeType.ROUNDED_RECT); expect(child.type).toEqual(mindmap.yy.nodeType.ROUNDED_RECT);
}); });
it('mutiple types (circle)', function () { it('MMP-10 mutiple types (circle)', function () {
let str = `mindmap let str = `mindmap
root((the root)) root((the root))
`; `;
mindmap.parse(str); mindmap.parse(str);
const mm = mindmap.yy.getMindmap(); const mm = mindmap.yy.getMindmap();
@@ -139,7 +141,7 @@ root
expect(mm.type).toEqual(mindmap.yy.nodeType.CIRCLE); expect(mm.type).toEqual(mindmap.yy.nodeType.CIRCLE);
}); });
it('mutiple types (cloud)', function () { it('MMP-11 mutiple types (cloud)', function () {
let str = `mindmap let str = `mindmap
root)the root( root)the root(
`; `;
@@ -150,7 +152,7 @@ root
expect(mm.children.length).toEqual(0); expect(mm.children.length).toEqual(0);
expect(mm.type).toEqual(mindmap.yy.nodeType.CLOUD); expect(mm.type).toEqual(mindmap.yy.nodeType.CLOUD);
}); });
it('mutiple types (bang)', function () { it('MMP-12 mutiple types (bang)', function () {
let str = `mindmap let str = `mindmap
root))the root(( root))the root((
`; `;
@@ -163,7 +165,7 @@ root
}); });
}); });
describe('decorations', function () { describe('decorations', function () {
it('should be possible to set an icon for the node', function () { it('MMP-13 should be possible to set an icon for the node', function () {
let str = `mindmap let str = `mindmap
root[The root] root[The root]
::icon(bomb) ::icon(bomb)
@@ -177,7 +179,7 @@ root
expect(mm.type).toEqual(mindmap.yy.nodeType.RECT); expect(mm.type).toEqual(mindmap.yy.nodeType.RECT);
expect(mm.icon).toEqual('bomb'); expect(mm.icon).toEqual('bomb');
}); });
it('should be possible to set classes for the node', function () { it('MMP-14 should be possible to set classes for the node', function () {
let str = `mindmap let str = `mindmap
root[The root] root[The root]
:::m-4 p-8 :::m-4 p-8
@@ -191,7 +193,7 @@ root
expect(mm.type).toEqual(mindmap.yy.nodeType.RECT); expect(mm.type).toEqual(mindmap.yy.nodeType.RECT);
expect(mm.class).toEqual('m-4 p-8'); expect(mm.class).toEqual('m-4 p-8');
}); });
it('should be possible to set both classes and icon for the node', function () { it('MMP-15 should be possible to set both classes and icon for the node', function () {
let str = `mindmap let str = `mindmap
root[The root] root[The root]
:::m-4 p-8 :::m-4 p-8
@@ -207,7 +209,7 @@ root
expect(mm.class).toEqual('m-4 p-8'); expect(mm.class).toEqual('m-4 p-8');
expect(mm.icon).toEqual('bomb'); expect(mm.icon).toEqual('bomb');
}); });
it('should be possible to set both classes and icon for the node', function () { it('MMP-16 should be possible to set both classes and icon for the node', function () {
let str = `mindmap let str = `mindmap
root[The root] root[The root]
::icon(bomb) ::icon(bomb)
@@ -225,7 +227,7 @@ root
}); });
}); });
describe('descriptions', function () { describe('descriptions', function () {
it('should be possible to use node syntax in the descriptions', function () { it('MMP-17 should be possible to use node syntax in the descriptions', function () {
let str = `mindmap let str = `mindmap
root["String containing []"] root["String containing []"]
`; `;
@@ -234,7 +236,7 @@ root
expect(mm.nodeId).toEqual('root'); expect(mm.nodeId).toEqual('root');
expect(mm.descr).toEqual('String containing []'); expect(mm.descr).toEqual('String containing []');
}); });
it('should be possible to use node syntax in the descriptions in children', function () { it('MMP-18 should be possible to use node syntax in the descriptions in children', function () {
let str = `mindmap let str = `mindmap
root["String containing []"] root["String containing []"]
child1["String containing ()"] child1["String containing ()"]
@@ -246,7 +248,7 @@ root
expect(mm.children.length).toEqual(1); expect(mm.children.length).toEqual(1);
expect(mm.children[0].descr).toEqual('String containing ()'); expect(mm.children[0].descr).toEqual('String containing ()');
}); });
it('should be possible to have a child after a class assignment', function () { it('MMP-19 should be possible to have a child after a class assignment', function () {
let str = `mindmap let str = `mindmap
root(Root) root(Root)
Child(Child) Child(Child)
@@ -266,7 +268,7 @@ root
expect(child.children[1].nodeId).toEqual('b'); expect(child.children[1].nodeId).toEqual('b');
}); });
}); });
it('should be possible to have meaningless empty rows in a mindmap abc124', function () { it('MMP-20 should be possible to have meaningless empty rows in a mindmap abc124', function () {
let str = `mindmap let str = `mindmap
root(Root) root(Root)
Child(Child) Child(Child)
@@ -285,7 +287,7 @@ root
expect(child.children.length).toEqual(2); expect(child.children.length).toEqual(2);
expect(child.children[1].nodeId).toEqual('b'); expect(child.children[1].nodeId).toEqual('b');
}); });
it('should be possible to have comments in a mindmap', function () { it('MMP-21 should be possible to have comments in a mindmap', function () {
let str = `mindmap let str = `mindmap
root(Root) root(Root)
Child(Child) Child(Child)
@@ -306,7 +308,7 @@ root
expect(child.children[1].nodeId).toEqual('b'); expect(child.children[1].nodeId).toEqual('b');
}); });
it('should be possible to have comments at the end of a line', function () { it('MMP-22 should be possible to have comments at the end of a line', function () {
let str = `mindmap let str = `mindmap
root(Root) root(Root)
Child(Child) Child(Child)

View File

@@ -1,6 +1,6 @@
/** Created by knut on 15-01-14. */ /** Created by knut on 15-01-14. */
import { sanitizeText, getConfig } from '../../diagram-api/diagramAPI'; import { sanitizeText, getConfig } from '../../diagram-api/diagramAPI';
import { log } from '../../logger'; import { log as _log } from '../../logger';
let nodes = []; let nodes = [];
let cnt = 0; let cnt = 0;
@@ -25,7 +25,7 @@ export const getMindmap = () => {
return nodes.length > 0 ? nodes[0] : null; return nodes.length > 0 ? nodes[0] : null;
}; };
export const addNode = (level, id, descr, type) => { export const addNode = (level, id, descr, type) => {
console.info('addNode', level, id, descr, type); log.info('addNode', level, id, descr, type);
const conf = getConfig(); const conf = getConfig();
const node = { const node = {
id: cnt++, id: cnt++,
@@ -132,7 +132,8 @@ export const type2Str = (type) => {
return 'no-border'; return 'no-border';
} }
}; };
// Expose logger to grammar
export const log = _log;
export const getNodeById = (id) => nodes[id]; export const getNodeById = (id) => nodes[id];
export const getElementById = (id) => elements[id]; export const getElementById = (id) => elements[id];
// export default { // export default {

View File

@@ -22,7 +22,6 @@ function drawNodes(svg, mindmap, section, conf) {
} }
/** /**
* @param {any} svg The svg element to draw the diagram onto
* @param edgesElem * @param edgesElem
* @param mindmap * @param mindmap
* @param parent * @param parent
@@ -149,8 +148,6 @@ const mergeTrees = (node, trees) => {
/** /**
* @param node * @param node
* @param isRoot
* @param parent
* @param conf * @param conf
*/ */
function layoutMindmap(node, conf) { function layoutMindmap(node, conf) {
@@ -201,7 +198,6 @@ function layoutMindmap(node, conf) {
} }
/** /**
* @param node * @param node
* @param isRoot
* @param conf * @param conf
*/ */
function positionNodes(node, conf) { function positionNodes(node, conf) {

View File

@@ -17,20 +17,21 @@
%% %%
\s*\%\%.*\n {console.log('Found comment',yytext);} \s*\%\%.* {yy.log.trace('Found comment',yytext);}
// \%\%[^\n]*\n /* skip comments */ // \%\%[^\n]*\n /* skip comments */
"mindmap" return 'MINDMAP'; "mindmap" return 'MINDMAP';
":::" { this.begin('CLASS'); } ":::" { this.begin('CLASS'); }
<CLASS>.+ { this.popState();return 'CLASS'; } <CLASS>.+ { this.popState();return 'CLASS'; }
<CLASS>\n { this.popState();} <CLASS>\n { this.popState();}
[\n\s]*"::icon(" { this.begin('ICON'); } // [\s]*"::icon(" { this.begin('ICON'); }
[\n]+ /* return 'NL'; */ "::icon(" { yy.log.trace('Begin icon');this.begin('ICON'); }
[\n]+ return 'NL';
<ICON>[^\)]+ { return 'ICON'; } <ICON>[^\)]+ { return 'ICON'; }
<ICON>\) {this.popState();} <ICON>\) {yy.log.trace('end icon');this.popState();}
"-)" { console.log('Exploding node'); this.begin('NODE');return 'NODE_DSTART'; } "-)" { yy.log.trace('Exploding node'); this.begin('NODE');return 'NODE_DSTART'; }
"(-" { console.log('Cloud'); this.begin('NODE');return 'NODE_DSTART'; } "(-" { yy.log.trace('Cloud'); this.begin('NODE');return 'NODE_DSTART'; }
"))" { console.log('Explosion Bang'); this.begin('NODE');return 'NODE_DSTART'; } "))" { yy.log.trace('Explosion Bang'); this.begin('NODE');return 'NODE_DSTART'; }
")" { console.log('Cloud Bang'); this.begin('NODE');return 'NODE_DSTART'; } ")" { yy.log.trace('Cloud Bang'); this.begin('NODE');return 'NODE_DSTART'; }
"((" { this.begin('NODE');return 'NODE_DSTART'; } "((" { this.begin('NODE');return 'NODE_DSTART'; }
"(" { this.begin('NODE');return 'NODE_DSTART'; } "(" { this.begin('NODE');return 'NODE_DSTART'; }
"[" { this.begin('NODE');return 'NODE_DSTART'; } "[" { this.begin('NODE');return 'NODE_DSTART'; }
@@ -38,18 +39,18 @@
// !(-\() return 'NODE_ID'; // !(-\() return 'NODE_ID';
[^\(\[\n\-\)]+ return 'NODE_ID'; [^\(\[\n\-\)]+ return 'NODE_ID';
<<EOF>> return 'EOF'; <<EOF>> return 'EOF';
<NODE>["] { console.log('Starting NSTR');this.begin("NSTR");} <NODE>["] { yy.log.trace('Starting NSTR');this.begin("NSTR");}
<NSTR>[^"]+ { console.log('description:', yytext); return "NODE_DESCR";} <NSTR>[^"]+ { yy.log.trace('description:', yytext); return "NODE_DESCR";}
<NSTR>["] {this.popState();} <NSTR>["] {this.popState();}
<NODE>[\)]\) {this.popState();console.log('node end ))');return "NODE_DEND";} <NODE>[\)]\) {this.popState();yy.log.trace('node end ))');return "NODE_DEND";}
<NODE>[\)] {this.popState();console.log('node end )');return "NODE_DEND";} <NODE>[\)] {this.popState();yy.log.trace('node end )');return "NODE_DEND";}
<NODE>[\]] {this.popState();console.log('node end ...');return "NODE_DEND";} <NODE>[\]] {this.popState();yy.log.trace('node end ...',yytext);return "NODE_DEND";}
<NODE>"(-" {this.popState();console.log('node end (-');return "NODE_DEND";} <NODE>"(-" {this.popState();yy.log.trace('node end (-');return "NODE_DEND";}
<NODE>"-)" {this.popState();console.log('node end (-');return "NODE_DEND";} <NODE>"-)" {this.popState();yy.log.trace('node end (-');return "NODE_DEND";}
<NODE>"((" {this.popState();console.log('node end ((');return "NODE_DEND";} <NODE>"((" {this.popState();yy.log.trace('node end ((');return "NODE_DEND";}
<NODE>"(" {this.popState();console.log('node end ((');return "NODE_DEND";} <NODE>"(" {this.popState();yy.log.trace('node end ((');return "NODE_DEND";}
<NODE>[^\)\]\(]+ { console.log('Long description:', yytext); return 'NODE_DESCR';} <NODE>[^\)\]\(]+ { yy.log.trace('Long description:', yytext); return 'NODE_DESCR';}
<NODE>.+(?!\(\() { console.log('Long description:', yytext); return 'NODE_DESCR';} <NODE>.+(?!\(\() { yy.log.trace('Long description:', yytext); return 'NODE_DESCR';}
// [\[] return 'NODE_START'; // [\[] return 'NODE_START';
// .+ return 'TXT' ; // .+ return 'TXT' ;
@@ -62,29 +63,33 @@
start start
// %{ : info document 'EOF' { return yy; } } // %{ : info document 'EOF' { return yy; } }
: MINDMAP document { return yy; } : MINDMAP document { return yy; }
| MINDMAP NL document { return yy; }
| SPACELIST MINDMAP document { return yy; } | SPACELIST MINDMAP document { return yy; }
; ;
stop
: NL {yy.log.trace('Stop NL ');}
| EOF {yy.log.trace('Stop EOF ');}
| stop NL {yy.log.trace('Stop NL2 ');}
| stop EOF {yy.log.trace('Stop EOF2 ');}
;
document document
: document line : document statement stop
| line | statement stop
;
line
: statement { }
; ;
statement statement
: SPACELIST node { yy.addNode($1.length, $2.id, $2.descr, $2.type); } : SPACELIST node { yy.log.trace('Node: ',$2.id);yy.addNode($1.length, $2.id, $2.descr, $2.type); }
| SPACELIST ICON { yy.decorateNode({icon: $2}); } | SPACELIST ICON { yy.log.trace('Icon: ',$2);yy.decorateNode({icon: $2}); }
| SPACELIST EOF | SPACELIST CLASS { yy.decorateNode({class: $2}); }
| SPACELIST NL | node { yy.log.trace('Node: ',$1.id);yy.addNode(0, $1.id, $1.descr, $1.type); }
| node { console.log($1.id);yy.addNode(0, $1.id, $1.descr, $1.type); }
| ICON { yy.decorateNode({icon: $1}); } | ICON { yy.decorateNode({icon: $1}); }
| SPACELIST CLASS { yy.decorateNode({class: $2}); } | CLASS { yy.decorateNode({class: $1}); }
| CLASS { yy.decorateNode({class: $1}); } | SPACELIST
| EOF
; ;
node node
:nodeWithId :nodeWithId
|nodeWithoutId |nodeWithoutId
@@ -92,12 +97,12 @@ node
nodeWithoutId nodeWithoutId
: NODE_DSTART NODE_DESCR NODE_DEND : NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $2, descr: $2, type: yy.getType($1, $3) }; } { yy.log.trace("node found ..", $1); $$ = { id: $2, descr: $2, type: yy.getType($1, $3) }; }
; ;
nodeWithId nodeWithId
: NODE_ID { $$ = { id: $1, descr: $1, type: yy.nodeType.DEFAULT }; } : NODE_ID { $$ = { id: $1, descr: $1, type: yy.nodeType.DEFAULT }; }
| NODE_ID NODE_DSTART NODE_DESCR NODE_DEND | NODE_ID NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $1, descr: $3, type: yy.getType($2, $4) }; } { yy.log.trace("node found ..", $1); $$ = { id: $1, descr: $3, type: yy.getType($2, $4) }; }
; ;
%% %%

View File

@@ -326,7 +326,7 @@ const boundMessage = function (diagram, msgModel) {
* *
* @param {any} diagram - The parent of the message element * @param {any} diagram - The parent of the message element
* @param {any} msgModel - The model containing fields describing a message * @param {any} msgModel - The model containing fields describing a message
* @param {float} lineStarty - The Y coordinate at which the message line starts * @param {number} lineStarty - The Y coordinate at which the message line starts
* @param diagObj * @param diagObj
*/ */
const drawMessage = function (diagram, msgModel, lineStarty, diagObj) { const drawMessage = function (diagram, msgModel, lineStarty, diagObj) {
@@ -582,8 +582,7 @@ function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoop
/** /**
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text. * Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
* *
* @param {any} text The text of the diagram * @param {any} _text The text of the diagram
* @param _text
* @param {any} id The id of the diagram which will be used as a DOM element id¨ * @param {any} id The id of the diagram which will be used as a DOM element id¨
* @param {any} _version Mermaid version from package.json * @param {any} _version Mermaid version from package.json
* @param {any} diagObj A stanard diagram containing the db and the text and type etc of the diagram * @param {any} diagObj A stanard diagram containing the db and the text and type etc of the diagram

View File

@@ -66,9 +66,9 @@ export const drawSimpleState = (g, stateDef) => {
/** /**
* Draws a state with descriptions * Draws a state with descriptions
* *
* @param {any} g * @param {any} g The d3 svg object to add the state to
* @param {any} stateDef * @param {any} stateDef
* @returns * @returns {any} The d3 svg state
*/ */
export const drawDescrState = (g, stateDef) => { export const drawDescrState = (g, stateDef) => {
const addTspan = function (textEl, txt, isFirst) { const addTspan = function (textEl, txt, isFirst) {

View File

@@ -37,8 +37,6 @@ export const calculateSvgSizeAttrs = function (height, width, useMaxWidth) {
* @param {SVGSVGElement} svgElem The SVG Element to configure * @param {SVGSVGElement} svgElem The SVG Element to configure
* @param {number} height The height of the SVG * @param {number} height The height of the SVG
* @param {number} width The width of the SVG * @param {number} width The width of the SVG
* @param tx
* @param ty
* @param {boolean} useMaxWidth Whether or not to use max-width and set width to 100% * @param {boolean} useMaxWidth Whether or not to use max-width and set width to 100%
*/ */
export const configureSvgSize = function (svgElem, height, width, useMaxWidth) { export const configureSvgSize = function (svgElem, height, width, useMaxWidth) {