UNPKG

5.99 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/knsv/mermaid.svg?branch=master)](https://travis-ci.org/knsv/mermaid)
2[![Coverage Status](https://coveralls.io/repos/github/knsv/mermaid/badge.svg?branch=master)](https://coveralls.io/github/knsv/mermaid?branch=master)
3[![Join the chat at https://gitter.im/knsv/mermaid](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/knsv/mermaid?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
5# mermaid
6
7## Special note regarding version 8.2
8
9In version 8.2 a security improvement was introduced. A securityLevel configuration was introduced which sets the level of trust to be used on the parsed diagrams.
10
11* **`strict`**: (default) tags in text are encoded, click functionality is disabled
12* `loose`: tags in text are allowed, click functionality is enabledClosed issues:
13
14⚠️ **Note** : This changes the default behaviour of mermaid so that after upgrade to 8.2, if the securityLevel is not configured, tags in flowcharts are encoded as tags and clicking is prohibited.
15
16If your application is taking resposibility for the diagram source security you can set the securityLevel accordingly. By doing this clicks and tags are again allowed.
17
18```javascript
19 mermaidAPI.initialize({
20 securityLevel: 'loose'
21 });
22```
23
24**🖖 Keep a steady pulse: mermaid needs more Collaborators [#866](https://github.com/knsv/mermaid/issues/866)**
25
26![banner](./img/header.png)
27
28Generation of diagrams and flowcharts from text in a similar manner as markdown.
29
30Ever wanted to simplify documentation and avoid heavy tools like Visio when explaining your code?
31
32This is why mermaid was born, a simple markdown-like script language for generating charts from text via javascript.
33
34**Mermaid was nomiated and won the JS Open Source Awards (2019) in the catory The most existing use of technology!!! Thanks to all involved, people committing pull requests, people answering questions and special thanks to Tyler Long who is helping me maintain the project.**
35
36### Flowchart
37
38```
39graph TD;
40 A-->B;
41 A-->C;
42 B-->D;
43 C-->D;
44```
45![Flowchart](./img/flow.png)
46
47
48### Sequence diagram
49
50```
51sequenceDiagram
52 participant Alice
53 participant Bob
54 Alice->>John: Hello John, how are you?
55 loop Healthcheck
56 John->>John: Fight against hypochondria
57 end
58 Note right of John: Rational thoughts <br/>prevail!
59 John-->>Alice: Great!
60 John->>Bob: How about you?
61 Bob-->>John: Jolly good!
62```
63![Sequence diagram](./img/sequence.png)
64
65
66### Gantt diagram
67
68```
69gantt
70dateFormat YYYY-MM-DD
71title Adding GANTT diagram to mermaid
72excludes weekdays 2014-01-10
73
74section A section
75Completed task :done, des1, 2014-01-06,2014-01-08
76Active task :active, des2, 2014-01-09, 3d
77Future task : des3, after des2, 5d
78Future task2 : des4, after des3, 5d
79```
80![Gantt diagram](./img/gantt.png)
81
82
83### Class diagram - :exclamation: experimental
84
85```
86classDiagram
87Class01 <|-- AveryLongClass : Cool
88Class03 *-- Class04
89Class05 o-- Class06
90Class07 .. Class08
91Class09 --> C2 : Where am i?
92Class09 --* C3
93Class09 --|> Class07
94Class07 : equals()
95Class07 : Object[] elementData
96Class01 : size()
97Class01 : int chimp
98Class01 : int gorilla
99Class08 <--> C2: Cool label
100```
101![Class diagram](./img/class.png)
102
103
104### Git graph - :exclamation: experimental
105
106```
107gitGraph:
108options
109{
110 "nodeSpacing": 150,
111 "nodeRadius": 10
112}
113end
114commit
115branch newbranch
116checkout newbranch
117commit
118commit
119checkout master
120commit
121commit
122merge newbranch
123
124```
125
126![Git graph](./img/git.png)
127
128
129## Installation
130
131### CDN
132
133```
134https://unpkg.com/mermaid@<version>/dist/
135```
136
137Replace `<version>` with expected version number.
138
139Example: https://unpkg.com/mermaid@7.1.0/dist/
140
141### Node.js
142
143```
144yarn add mermaid
145```
146
147
148## Documentation
149
150https://mermaidjs.github.io
151
152
153## Sibling projects
154
155- [mermaid CLI](https://github.com/mermaidjs/mermaid.cli)
156- [mermaid live editor](https://github.com/mermaidjs/mermaid-live-editor)
157- [mermaid webpack demo](https://github.com/mermaidjs/mermaid-webpack-demo)
158- [mermaid Parcel demo](https://github.com/mermaidjs/mermaid-parcel-demo)
159
160
161# Request for assistance
162
163Things are piling up and I have hard time keeping up. To remedy this
164it would be great if we could form a core team of developers to cooperate
165with the future development mermaid.
166
167As part of this team you would get write access to the repository and would
168represent the project when answering questions and issues.
169
170Together we could continue the work with things like:
171* adding more types of diagrams like mindmaps, ert diagrams etc
172* improving existing diagrams
173
174Don't hesitate to contact me if you want to get involved.
175
176
177# For contributors
178
179## Setup
180
181 yarn install
182
183
184## Build
185
186 yarn build:watch
187
188
189## Lint
190
191 yarn lint
192
193We use [JavaScript Standard Style](https://github.com/feross/standard).
194We recommend you installing [editor plugins](https://github.com/feross/standard#are-there-text-editor-plugins) so you can get real time lint result.
195
196
197## Test
198
199 yarn test
200
201Manual test in browser:
202
203 open dist/index.html
204
205
206## Release
207
208For those who have the permission to do so:
209
210Update version number in `package.json`.
211
212 npm publish
213
214Command above generates files into the `dist` folder and publishes them to npmjs.org.
215
216
217# Credits
218
219Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!
220
221Thanks also to the [js-sequence-diagram](http://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the sequence diagrams. Thanks to Jessica Peter for inspiration and starting point for gantt rendering.
222
223*Mermaid was created by Knut Sveidqvist for easier documentation.*
224
225*[Tyler Long](https://github.com/tylerlong) has became a collaborator since April 2017.*
226
227Here is the full list of the projects [contributors](https://github.com/knsv/mermaid/graphs/contributors).