-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from nao1215/introduce/mermaid
Introduce mermaid sequence
- Loading branch information
Showing
17 changed files
with
1,291 additions
and
25 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
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,21 @@ | ||
## Sequence Diagram | ||
```mermaid | ||
sequenceDiagram | ||
participant Sophia | ||
participant David | ||
participant Subaru | ||
Sophia->>David: Please wake up Subaru | ||
David-->>Sophia: OK | ||
loop until Subaru wake up | ||
David->>Subaru: Wake up! | ||
Subaru-->>David: zzz | ||
David->>Subaru: Hey!!! | ||
break if Subaru wake up | ||
Subaru-->>David: ...... | ||
end | ||
end | ||
David-->>Sophia: wake up, wake up | ||
``` |
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,49 @@ | ||
//go:build linux || darwin | ||
|
||
// Package main is generating mermaid sequence diagram. | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/nao1215/markdown" | ||
"github.com/nao1215/markdown/mermaid/sequence" | ||
) | ||
|
||
//go:generate go run main.go | ||
|
||
func main() { | ||
f, err := os.Create("generated.md") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
diagram := sequence.NewDiagram(os.Stdout). | ||
Participant("Sophia"). | ||
Participant("David"). | ||
Participant("Subaru"). | ||
LF(). | ||
SyncRequest("Sophia", "David", "Please wake up Subaru"). | ||
SyncResponse("David", "Sophia", "OK"). | ||
LF(). | ||
LoopStart("until Subaru wake up"). | ||
SyncRequest("David", "Subaru", "Wake up!"). | ||
SyncResponse("Subaru", "David", "zzz"). | ||
SyncRequest("David", "Subaru", "Hey!!!"). | ||
BreakStart("if Subaru wake up"). | ||
SyncResponse("Subaru", "David", "......"). | ||
BreakEnd(). | ||
LoopEnd(). | ||
LF(). | ||
SyncResponse("David", "Sophia", "wake up, wake up"). | ||
String() //nolint | ||
|
||
err = markdown.NewMarkdown(f). | ||
H2("Sequence Diagram"). | ||
CodeBlocks(markdown.SyntaxHighlightMermaid, diagram). | ||
Build() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
} |
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
Oops, something went wrong.