mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
#1704 Test and lint
This commit is contained in:
@@ -31,16 +31,18 @@ flowchart TD
|
|||||||
subcontainer-child--> subcontainer-sibling
|
subcontainer-child--> subcontainer-sibling
|
||||||
end
|
end
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 50%; height: 400px;">
|
<div class="mermaid" style="width: 50%; height: 400px;">
|
||||||
flowchart TB
|
flowchart TB
|
||||||
subgraph container_Beta
|
b-->B
|
||||||
process_C-->Process_D
|
a-->c
|
||||||
end
|
subgraph B
|
||||||
subgraph container_Alpha
|
c
|
||||||
process_A-->process_B
|
end
|
||||||
process_A-->|messages|process_C
|
subgraph A
|
||||||
|
a
|
||||||
|
b
|
||||||
|
B
|
||||||
end
|
end
|
||||||
process_B-->|via_AWSBatch|container_Beta
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||||
flowchart TB
|
flowchart TB
|
||||||
|
@@ -414,7 +414,6 @@ export const defaultStyle = function() {
|
|||||||
* Clears the internal graph db so that a new graph can be parsed.
|
* Clears the internal graph db so that a new graph can be parsed.
|
||||||
*/
|
*/
|
||||||
export const addSubGraph = function(_id, list, _title) {
|
export const addSubGraph = function(_id, list, _title) {
|
||||||
// logger.warn('addSubgraph', _id, list, _title);
|
|
||||||
let id = _id.trim();
|
let id = _id.trim();
|
||||||
let title = _title;
|
let title = _title;
|
||||||
if (_id === _title && _title.match(/\s/)) {
|
if (_id === _title && _title.match(/\s/)) {
|
||||||
@@ -454,8 +453,25 @@ export const addSubGraph = function(_id, list, _title) {
|
|||||||
subCount = subCount + 1;
|
subCount = subCount + 1;
|
||||||
const subGraph = { id: id, nodes: nodeList, title: title.trim(), classes: [] };
|
const subGraph = { id: id, nodes: nodeList, title: title.trim(), classes: [] };
|
||||||
|
|
||||||
|
console.log('Adding', subGraph.id, subGraph.nodes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an id from all subgraphs
|
||||||
|
*/
|
||||||
|
// const del = _id => {
|
||||||
|
// subGraphs.forEach(sg => {
|
||||||
|
// const pos = sg.nodes.indexOf(_id);
|
||||||
|
// if (pos >= 0) {
|
||||||
|
// sg.nodes.splice(pos, 1);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// // Removes the members of this subgraph from any other subgraphs, a node only belong to one subgraph
|
||||||
|
// subGraph.nodes.forEach(_id => del(_id));
|
||||||
|
|
||||||
// Remove the members in the new subgraph if they already belong to another subgraph
|
// Remove the members in the new subgraph if they already belong to another subgraph
|
||||||
subGraph.nodes.nodes = makeUniq(subGraph, subGraphs);
|
subGraph.nodes = makeUniq(subGraph, subGraphs).nodes;
|
||||||
subGraphs.push(subGraph);
|
subGraphs.push(subGraph);
|
||||||
subGraphLookup[id] = subGraph;
|
subGraphLookup[id] = subGraph;
|
||||||
return id;
|
return id;
|
||||||
@@ -670,7 +686,6 @@ const exists = (allSgs, _id) => {
|
|||||||
const makeUniq = (sg, allSubgraphs) => {
|
const makeUniq = (sg, allSubgraphs) => {
|
||||||
const res = [];
|
const res = [];
|
||||||
sg.nodes.forEach((_id, pos) => {
|
sg.nodes.forEach((_id, pos) => {
|
||||||
console.log('Checking: ', _id);
|
|
||||||
if (!exists(allSubgraphs, _id)) {
|
if (!exists(allSubgraphs, _id)) {
|
||||||
res.push(sg.nodes[pos]);
|
res.push(sg.nodes[pos]);
|
||||||
}
|
}
|
||||||
|
@@ -244,8 +244,9 @@ describe('when parsing subgraphs', function() {
|
|||||||
const res = flow.parser.parse(`flowchart TB
|
const res = flow.parser.parse(`flowchart TB
|
||||||
subgraph A
|
subgraph A
|
||||||
b-->B
|
b-->B
|
||||||
a-->c
|
a
|
||||||
end
|
end
|
||||||
|
a-->c
|
||||||
subgraph B
|
subgraph B
|
||||||
c
|
c
|
||||||
end`);
|
end`);
|
||||||
|
Reference in New Issue
Block a user