mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-18 03:34:12 +01:00
Merge branch 'develop'
This commit is contained in:
3
.github/pr-labeler.yml
vendored
Normal file
3
.github/pr-labeler.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
'Type: Bug / Error': 'bug/*'
|
||||||
|
'Type: Enhancement': 'feature/*'
|
||||||
|
'Type: Other': 'other/*'
|
||||||
19
.github/release-drafter.yml
vendored
Normal file
19
.github/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name-template: '$NEXT_PATCH_VERSION'
|
||||||
|
tag-template: '$NEXT_PATCH_VERSION'
|
||||||
|
categories:
|
||||||
|
- title: '🚀 Features'
|
||||||
|
labels:
|
||||||
|
- 'Type: Enhancement'
|
||||||
|
- title: '🐛 Bug Fixes'
|
||||||
|
labels:
|
||||||
|
- 'Type: Bug / Error'
|
||||||
|
- title: '🧰 Maintenance'
|
||||||
|
label: 'Type: Other'
|
||||||
|
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
|
||||||
|
no-changes-template: 'This release contains minor changes and bugfixes.'
|
||||||
|
template: |
|
||||||
|
# Release Notes
|
||||||
|
|
||||||
|
$CHANGES
|
||||||
|
|
||||||
|
🎉 **Thanks to all contributors helping with this release!** 🎉
|
||||||
13
.github/workflows/pr-labeler.yml
vendored
Normal file
13
.github/workflows/pr-labeler.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Apply labels to PR
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr-labeler:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Label PR
|
||||||
|
uses: TimonVS/pr-labeler-action@v3
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
15
.github/workflows/release-draft.yml
vendored
Normal file
15
.github/workflows/release-draft.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
name: Draft Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
draft-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Draft Release
|
||||||
|
uses: toolmantim/release-drafter@v5.2.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -8,15 +8,12 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [10.x]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: 10.x
|
||||||
- name: Install Yarn
|
- name: Install Yarn
|
||||||
run: npm i yarn --global
|
run: npm i yarn --global
|
||||||
|
|
||||||
@@ -24,7 +21,7 @@ jobs:
|
|||||||
run: npm i json --global
|
run: npm i json --global
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: yarn install
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
46
.github/workflows/release-publish.yml
vendored
Normal file
46
.github/workflows/release-publish.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
name: Publish release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: fregante/setup-git-token@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 10.x
|
||||||
|
- name: Install Yarn
|
||||||
|
run: npm i yarn --global
|
||||||
|
|
||||||
|
- name: Install Json
|
||||||
|
run: npm i json --global
|
||||||
|
|
||||||
|
- name: Install Packages
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Prepare release
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF:10}
|
||||||
|
echo "Preparing release $VERSION"
|
||||||
|
git checkout -t origin/release/$VERSION
|
||||||
|
npm version --no-git-tag-version --allow-same-version $VERSION
|
||||||
|
git add package.json
|
||||||
|
git commit -m "Bump version $VERSION"
|
||||||
|
git checkout -t origin/master
|
||||||
|
git merge -m "Release $VERSION" --no-ff release/$VERSION
|
||||||
|
git push --no-verify
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
|
||||||
|
npm publish
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"typescript.format.enable": false,
|
|
||||||
"typescript.reportStyleChecksAsWarnings": false,
|
|
||||||
"typescript.validate.enable": false,
|
|
||||||
"javascript.validate.enable": false,
|
|
||||||
"editor.formatOnSave": false,
|
|
||||||
"editor.snippetSuggestions": "top"
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,7 @@ module.exports = {
|
|||||||
[
|
[
|
||||||
'@babel/preset-env',
|
'@babel/preset-env',
|
||||||
{
|
{
|
||||||
targets: {
|
targets: "defaults, ie >= 11, current node"
|
||||||
node: 'current'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util';
|
import { imgSnapshotTest } from '../../helpers/util';
|
||||||
|
|
||||||
describe('Class diagram', () => {
|
describe('Class diagram', () => {
|
||||||
it('should render a simple class diagram', () => {
|
it('1: should render a simple class diagram', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
classDiagram
|
classDiagram
|
||||||
@@ -33,7 +33,8 @@ describe('Class diagram', () => {
|
|||||||
);
|
);
|
||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
});
|
});
|
||||||
it('should render a simple class diagrams with cardinality', () => {
|
|
||||||
|
it('2: should render a simple class diagrams with cardinality', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
classDiagram
|
classDiagram
|
||||||
@@ -132,4 +133,34 @@ describe('Class diagram', () => {
|
|||||||
);
|
);
|
||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('4: should render a simple class diagram with comments', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
classDiagram
|
||||||
|
%% this is a comment
|
||||||
|
Class01 <|-- AveryLongClass : Cool
|
||||||
|
<<interface>> Class01
|
||||||
|
Class03 *-- Class04
|
||||||
|
Class05 o-- Class06
|
||||||
|
Class07 .. Class08
|
||||||
|
Class09 --> C2 : Where am i?
|
||||||
|
Class09 --* C3
|
||||||
|
Class09 --|> Class07
|
||||||
|
Class07 : equals()
|
||||||
|
Class07 : Object[] elementData
|
||||||
|
Class01 : size()
|
||||||
|
Class01 : int chimp
|
||||||
|
Class01 : int gorilla
|
||||||
|
Class08 <--> C2: Cool label
|
||||||
|
class Class10 {
|
||||||
|
<<service>>
|
||||||
|
int id
|
||||||
|
test()
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
cy.get('svg');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ describe('Flowcart', () => {
|
|||||||
{ flowchart: { htmlLabels: false } }
|
{ flowchart: { htmlLabels: false } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('2: should render a simple flowchart with htmlLabels', () => {
|
it('2: should render a simple flowchart with htmlLabels', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`graph TD
|
`graph TD
|
||||||
@@ -26,6 +27,7 @@ describe('Flowcart', () => {
|
|||||||
{ flowchart: { htmlLabels: true } }
|
{ flowchart: { htmlLabels: true } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('3: should render a simple flowchart with line breaks', () => {
|
it('3: should render a simple flowchart with line breaks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -99,6 +101,7 @@ describe('Flowcart', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('6: should render a flowchart full of icons', () => {
|
it('6: should render a flowchart full of icons', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -178,6 +181,7 @@ describe('Flowcart', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('8: should render subgraphs', () => {
|
it('8: should render subgraphs', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -190,7 +194,7 @@ describe('Flowcart', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('9: should render subgraphs with a title startign with a digit', () => {
|
it('9: should render subgraphs with a title starting with a digit', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
graph TB
|
graph TB
|
||||||
@@ -237,7 +241,7 @@ describe('Flowcart', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('11: should render a flowchart with ling sames and class definitoins', () => {
|
it('11: should render a flowchart with long names and class definitions', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`graph LR
|
`graph LR
|
||||||
sid-B3655226-6C29-4D00-B685-3D5C734DC7E1["
|
sid-B3655226-6C29-4D00-B685-3D5C734DC7E1["
|
||||||
@@ -356,6 +360,7 @@ describe('Flowcart', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('13: should render hexagons', () => {
|
it('13: should render hexagons', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -377,4 +382,18 @@ describe('Flowcart', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('14: should render a simple flowchart with comments', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`graph TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
%% this is a comment
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{ flowchart: { htmlLabels: false } }
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -322,7 +322,20 @@ class Color{
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Comments can be entered within a class diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any class diagram syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
classDiagram
|
||||||
|
%% This whole line is a comment classDiagram class Shape <<interface>>
|
||||||
|
class Shape{
|
||||||
|
<<interface>>
|
||||||
|
noOfVertices
|
||||||
|
draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
|
|||||||
@@ -424,6 +424,16 @@ Beginners tip, a full example using interactive links in a html context:
|
|||||||
</body>
|
</body>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Comments
|
||||||
|
|
||||||
|
Comments can be entered within a flow diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any flow syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
graph LR
|
||||||
|
%% this is a comment A -- text --> B{node}
|
||||||
|
A -- text --> B -- text2 --> C
|
||||||
|
```
|
||||||
|
|
||||||
## Styling and classes
|
## Styling and classes
|
||||||
|
|
||||||
### Styling links
|
### Styling links
|
||||||
|
|||||||
@@ -173,6 +173,23 @@ More info in: http://momentjs.com/docs/#/parsing/string-format/
|
|||||||
|
|
||||||
More info in: https://github.com/mbostock/d3/wiki/Time-Formatting
|
More info in: https://github.com/mbostock/d3/wiki/Time-Formatting
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Comments can be entered within a gantt chart, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
gantt
|
||||||
|
title A Gantt Diagram
|
||||||
|
%% this is a comment
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
section Section
|
||||||
|
A task :a1, 2014-01-01, 30d
|
||||||
|
Another task :after a1 , 20d
|
||||||
|
section Another
|
||||||
|
Task in sec :2014-01-12 , 12d
|
||||||
|
another task : 24d
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<meta name="description" content="Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.">
|
<meta name="description" content="Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
||||||
<script src="//cdn.jsdelivr.net/npm/mermaid@8.4.1/dist/mermaid.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/mermaid@8.4.3/dist/mermaid.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
|||||||
@@ -271,7 +271,16 @@ sequenceDiagram
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Comments can be entered within a sequence diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
sequenceDiagram
|
||||||
|
Alice->>John: Hello John, how are you?
|
||||||
|
%% this is a comment
|
||||||
|
John-->>Alice: Great!
|
||||||
|
```
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
|
|||||||
@@ -322,6 +322,21 @@ As in plantUml you can specify concurrency using the -- symbol.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
Comments can be entered within a state diagram chart, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
stateDiagram
|
||||||
|
[*] --> Still
|
||||||
|
Still --> [*]
|
||||||
|
%% this is a comment
|
||||||
|
Still --> Moving
|
||||||
|
Moving --> Still %% another comment
|
||||||
|
Moving --> Crash
|
||||||
|
Crash --> [*]
|
||||||
|
```
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
Styling of the a state diagram is done by defining a number of css classes. During rendering these classes are extracted from the file located at src/themes/state.scss
|
Styling of the a state diagram is done by defining a number of css classes. During rendering these classes are extracted from the file located at src/themes/state.scss
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ describe('class diagram, ', function() {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle relation definition of different types and directions', function () {
|
it('should handle relation definition of different types and directions', function () {
|
||||||
const str =
|
const str =
|
||||||
'classDiagram\n' +
|
'classDiagram\n' +
|
||||||
@@ -76,6 +77,7 @@ describe('class diagram, ', function() {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle parsing of method statements grouped by brackets', function () {
|
it('should handle parsing of method statements grouped by brackets', function () {
|
||||||
const str =
|
const str =
|
||||||
'classDiagram\n' +
|
'classDiagram\n' +
|
||||||
@@ -124,9 +126,106 @@ describe('class diagram, ', function() {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle a comment', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'%% Comment\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when fetching data from an classDiagram graph it', function() {
|
it('should handle comments at the start', function () {
|
||||||
|
const str =
|
||||||
|
'%% Comment\n' +
|
||||||
|
'classDiagram\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}';
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle comments at the end', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'\n}' +
|
||||||
|
'%% Comment\n';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle comments at the end no trailing newline', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}\n' +
|
||||||
|
'%% Comment';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle a comment with multiple line feeds', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n\n\n' +
|
||||||
|
'%% Comment\n\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle a comment with mermaid class diagram code in them', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n' +
|
||||||
|
'%% Comment Class01 <|-- Class02\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle a comment inside brackets', function () {
|
||||||
|
const str =
|
||||||
|
'classDiagram\n' +
|
||||||
|
'class Class1 {\n' +
|
||||||
|
'%% Comment Class01 <|-- Class02\n' +
|
||||||
|
'int : test\n' +
|
||||||
|
'string : foo\n' +
|
||||||
|
'test()\n' +
|
||||||
|
'foo()\n' +
|
||||||
|
'}';
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when fetching data from a classDiagram graph it', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
parser.yy = classDb;
|
parser.yy = classDb;
|
||||||
parser.yy.clear();
|
parser.yy.clear();
|
||||||
@@ -144,6 +243,7 @@ describe('class diagram, ', function() {
|
|||||||
expect(relations[0].relation.type2).toBe('none');
|
expect(relations[0].relation.type2).toBe('none');
|
||||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle relation definitions AGGREGATION and dotted line', function () {
|
it('should handle relation definitions AGGREGATION and dotted line', function () {
|
||||||
const str = 'classDiagram\n' + 'Class01 o.. Class02';
|
const str = 'classDiagram\n' + 'Class01 o.. Class02';
|
||||||
|
|
||||||
@@ -157,6 +257,7 @@ describe('class diagram, ', function() {
|
|||||||
expect(relations[0].relation.type2).toBe('none');
|
expect(relations[0].relation.type2).toBe('none');
|
||||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.DOTTED_LINE);
|
expect(relations[0].relation.lineType).toBe(classDb.lineType.DOTTED_LINE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle relation definitions COMPOSITION on both sides', function () {
|
it('should handle relation definitions COMPOSITION on both sides', function () {
|
||||||
const str = 'classDiagram\n' + 'Class01 *--* Class02';
|
const str = 'classDiagram\n' + 'Class01 *--* Class02';
|
||||||
|
|
||||||
@@ -170,6 +271,7 @@ describe('class diagram, ', function() {
|
|||||||
expect(relations[0].relation.type2).toBe(classDb.relationType.COMPOSITION);
|
expect(relations[0].relation.type2).toBe(classDb.relationType.COMPOSITION);
|
||||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle relation definitions no types', function () {
|
it('should handle relation definitions no types', function () {
|
||||||
const str = 'classDiagram\n' + 'Class01 -- Class02';
|
const str = 'classDiagram\n' + 'Class01 -- Class02';
|
||||||
|
|
||||||
@@ -183,6 +285,7 @@ describe('class diagram, ', function() {
|
|||||||
expect(relations[0].relation.type2).toBe('none');
|
expect(relations[0].relation.type2).toBe('none');
|
||||||
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle relation definitions with type only on right side', function () {
|
it('should handle relation definitions with type only on right side', function () {
|
||||||
const str = 'classDiagram\n' + 'Class01 --|> Class02';
|
const str = 'classDiagram\n' + 'Class01 --|> Class02';
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
%x string struct
|
%x string struct
|
||||||
|
|
||||||
%%
|
%%
|
||||||
\%\%[^\n]* /* do nothing */
|
\%\%[^\n]*\n* /* do nothing */
|
||||||
\n+ return 'NEWLINE';
|
\n+ return 'NEWLINE';
|
||||||
\s+ /* skip whitespace */
|
\s+ /* skip whitespace */
|
||||||
"classDiagram" return 'CLASS_DIAGRAM';
|
"classDiagram" return 'CLASS_DIAGRAM';
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ describe('[Comments] when parsing', () => {
|
|||||||
flow.parser.yy.clear();
|
flow.parser.yy.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a comments', function() {
|
it('should handle comments', function() {
|
||||||
const res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');
|
const res = flow.parser.parse('graph TD;\n%% Comment\n A-->B;');
|
||||||
|
|
||||||
const vert = flow.parser.yy.getVertices();
|
const vert = flow.parser.yy.getVertices();
|
||||||
const edges = flow.parser.yy.getEdges();
|
const edges = flow.parser.yy.getEdges();
|
||||||
@@ -27,7 +27,7 @@ describe('[Comments] when parsing', () => {
|
|||||||
expect(edges[0].text).toBe('');
|
expect(edges[0].text).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle comments a at the start', function() {
|
it('should handle comments at the start', function() {
|
||||||
const res = flow.parser.parse('%% Comment\ngraph TD;\n A-->B;');
|
const res = flow.parser.parse('%% Comment\ngraph TD;\n A-->B;');
|
||||||
|
|
||||||
const vert = flow.parser.yy.getVertices();
|
const vert = flow.parser.yy.getVertices();
|
||||||
@@ -43,7 +43,7 @@ describe('[Comments] when parsing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle comments at the end', function() {
|
it('should handle comments at the end', function() {
|
||||||
const res = flow.parser.parse('graph TD;\n A-->B\n %% Comment at the find\n');
|
const res = flow.parser.parse('graph TD;\n A-->B\n %% Comment at the end\n');
|
||||||
|
|
||||||
const vert = flow.parser.yy.getVertices();
|
const vert = flow.parser.yy.getVertices();
|
||||||
const edges = flow.parser.yy.getEdges();
|
const edges = flow.parser.yy.getEdges();
|
||||||
@@ -117,7 +117,7 @@ describe('[Comments] when parsing', () => {
|
|||||||
expect(edges[0].text).toBe('');
|
expect(edges[0].text).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a comments with blank rows in-between', function() {
|
it('should handle a comment with blank rows in-between', function() {
|
||||||
const res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B;');
|
const res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B;');
|
||||||
|
|
||||||
const vert = flow.parser.yy.getVertices();
|
const vert = flow.parser.yy.getVertices();
|
||||||
@@ -132,7 +132,7 @@ describe('[Comments] when parsing', () => {
|
|||||||
expect(edges[0].text).toBe('');
|
expect(edges[0].text).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a comments mermaid flowchart code in them', function() {
|
it('should handle a comment with mermaid flowchart code in them', function() {
|
||||||
const res = flow.parser.parse(
|
const res = flow.parser.parse(
|
||||||
'graph TD;\n\n\n %% Test od>Odd shape]-->|Two line<br>edge comment|ro;\n A-->B;'
|
'graph TD;\n\n\n %% Test od>Odd shape]-->|Two line<br>edge comment|ro;\n A-->B;'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
%x string
|
%x string
|
||||||
%x dir
|
%x dir
|
||||||
%%
|
%%
|
||||||
\%\%[^\n]* /* do nothing */
|
\%\%[^\n]*\n* /* do nothing */
|
||||||
["] this.begin("string");
|
["] this.begin("string");
|
||||||
<string>["] this.popState();
|
<string>["] this.popState();
|
||||||
<string>[^"]* return "STR";
|
<string>[^"]* return "STR";
|
||||||
@@ -460,13 +460,6 @@ text: textToken
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
commentText: commentToken
|
|
||||||
{$$=$1;}
|
|
||||||
| commentText commentToken
|
|
||||||
{$$=$1+''+$2;}
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
keywords
|
keywords
|
||||||
: STYLE | LINKSTYLE | CLASSDEF | CLASS | CLICK | GRAPH | DIR | subgraph | end | DOWN | UP;
|
: STYLE | LINKSTYLE | CLASSDEF | CLASS | CLICK | GRAPH | DIR | subgraph | end | DOWN | UP;
|
||||||
|
|
||||||
@@ -516,8 +509,6 @@ linkStyleStatement
|
|||||||
{$$ = $1;yy.updateLinkInterpolate($3,$7);}
|
{$$ = $1;yy.updateLinkInterpolate($3,$7);}
|
||||||
;
|
;
|
||||||
|
|
||||||
commentStatement: PCT PCT commentText;
|
|
||||||
|
|
||||||
numList: NUM
|
numList: NUM
|
||||||
{$$ = [$1]}
|
{$$ = [$1]}
|
||||||
| numList COMMA NUM
|
| numList COMMA NUM
|
||||||
@@ -539,8 +530,6 @@ styleComponent: ALPHA | COLON | MINUS | NUM | UNIT | SPACE | HEX | BRKT | DOT |
|
|||||||
|
|
||||||
/* Token lists */
|
/* Token lists */
|
||||||
|
|
||||||
commentToken : textToken | graphCodeTokens ;
|
|
||||||
|
|
||||||
textToken : textNoTagsToken | TAGSTART | TAGEND | '==' | '--' | PCT | DEFAULT;
|
textToken : textNoTagsToken | TAGSTART | TAGEND | '==' | '--' | PCT | DEFAULT;
|
||||||
|
|
||||||
textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ;
|
textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ;
|
||||||
|
|||||||
Reference in New Issue
Block a user