-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate sequence diagrams from code blocks (#35)
Close #35
- Loading branch information
Showing
8 changed files
with
142 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ flowchartDiagrams: | |
enable: false | ||
options: "" | ||
|
||
sequenceDiagrams: | ||
enable: false | ||
options: "" | ||
|
||
--- | ||
|
||
<!--more--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: "JS Sequence Diagrams" | ||
date: 2015-03-04T21:57:45+08:00 | ||
draft: false | ||
|
||
sequenceDiagrams: | ||
enable: true | ||
options: "{theme: 'hand'}" | ||
--- | ||
|
||
## Usage | ||
|
||
```sequence | ||
Andrew->China: Says Hello | ||
Note right of China: China thinks\nabout it | ||
China-->Andrew: How are you? | ||
Andrew->>China: I am good thanks! | ||
``` | ||
|
||
<!--more--> | ||
|
||
```sequence | ||
Andrew->China: Says Hello | ||
Note right of China: China thinks\nabout it | ||
China-->Andrew: How are you? | ||
Andrew->>China: I am good thanks! | ||
``` | ||
|
||
## Configuration | ||
|
||
Configure for all home and regular pages: | ||
|
||
```toml | ||
[params.sequenceDiagrams] | ||
enable = true | ||
options = "{theme: 'hand'}" | ||
``` | ||
|
||
Configure for a single post in the front matter (**Params in front matter have higher precedence**): | ||
|
||
```yml | ||
sequenceDiagrams: | ||
enable: true | ||
options: "{theme: 'hand'}" | ||
``` | ||
### Options | ||
```js | ||
options = { | ||
// Change the styling of the diagram, typically one of 'simple', 'hand'. New themes can be registered with registerTheme(...). | ||
theme: string, | ||
|
||
// CSS style to apply to the diagram's svg tag. (Only supported if using snap.svg) | ||
css_class: string, | ||
} | ||
``` | ||
|
||
See more information from https://github.com/bramp/js-sequence-diagrams. | ||
|
||
## Examples | ||
|
||
```sequence | ||
Title: Here is a title | ||
A->B: Normal line | ||
B-->C: Dashed line | ||
C->>D: Open arrow | ||
D-->>A: Dashed open arrow | ||
``` | ||
|
||
```sequence | ||
Title: Here is a title | ||
A->B: Normal line | ||
B-->C: Dashed line | ||
C->>D: Open arrow | ||
D-->>A: Dashed open arrow | ||
``` | ||
|
||
--- | ||
|
||
```sequence | ||
# Example of a comment. | ||
Note left of A: Note to the\n left of A | ||
Note right of A: Note to the\n right of A | ||
Note over A: Note over A | ||
Note over A,B: Note over both A and B | ||
``` | ||
|
||
```sequence | ||
# Example of a comment. | ||
Note left of A: Note to the\n left of A | ||
Note right of A: Note to the\n right of A | ||
Note over A: Note over A | ||
Note over A,B: Note over both A and B | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,22 @@ | |
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/raphael.min.js" integrity="sha256-67By+NpOtm9ka1R6xpUefeGOY8kWWHHRAKlvaTJ7ONI=" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/release/flowchart.min.js" integrity="sha256-zNGWjubXoY6rb5MnmpBNefO0RgoVYfle9p0tvOQM+6k=" crossorigin="anonymous"></script> | ||
{{- end -}} | ||
|
||
<!-- js-sequence-diagrams --> | ||
{{- if and (or .Params.sequenceDiagrams.enable (and .Site.Params.sequenceDiagrams.enable (ne .Params.sequenceDiagrams.enable false))) (or .IsPage .IsHome) -}} | ||
<script> | ||
{{- if .Params.sequenceDiagrams.options -}} | ||
window.sequenceDiagramsOptions = {{ .Params.sequenceDiagrams.options | safeJS }}; | ||
{{- else if .Site.Params.sequenceDiagrams.options -}} | ||
window.sequenceDiagramsOptions = {{ .Site.Params.sequenceDiagrams.options | safeJS }}; | ||
{{- end -}} | ||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/webfontloader.js" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/snap.svg-min.js" integrity="sha256-oI+elz+sIm+jpn8F/qEspKoKveTc5uKeFHNNVexe6d8=" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/underscore-min.js" integrity="sha256-obZACiHd7gkOk9iIL/pimWMTJ4W/pBsKu+oZnSeBIek=" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/bramp/[email protected]/dist/sequence-diagram-min.js" integrity="sha384-8748Vn52gHJYJI0XEuPB2QlPVNUkJlJn9tHqKec6J3q2r9l8fvRxrgn/E5ZHV0sP" crossorigin="anonymous"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bramp/[email protected]/dist/sequence-diagram-min.css" integrity="sha384-6QbLKJMz5dS3adWSeINZe74uSydBGFbnzaAYmp+tKyq60S7H2p6V7g1TysM5lAaF" crossorigin="anonymous"> | ||
{{- end }} | ||
<script type="text/javascript" src="{{ "dist/even.min.js?v=3.0.1" | relURL }}"></script> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ $(document).ready(function () { | |
}) | ||
|
||
Even.flowchart() | ||
Even.sequence() | ||
|
||
hljs.initHighlighting() | ||
Even.highlight() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.