-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
796 additions
and
57 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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ func main() { | |
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
|
||
teachers := er.NewEntity( | ||
"teachers", | ||
|
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,15 @@ | ||
## Flowchart | ||
```mermaid | ||
--- | ||
title: mermaid flowchart builder | ||
--- | ||
flowchart TB | ||
A["Node A"] | ||
B(["Node B"]) | ||
C[["Node C"]] | ||
D[("Database")] | ||
A-->B | ||
B-->|"send original data"|D | ||
B-->C | ||
C-. "send filtered data" .-> D | ||
``` |
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,46 @@ | ||
//go:build linux || darwin | ||
|
||
// Package main is generating flowchart. | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
|
||
"github.com/nao1215/markdown" | ||
"github.com/nao1215/markdown/mermaid/flowchart" | ||
) | ||
|
||
//go:generate go run main.go | ||
|
||
func main() { | ||
f, err := os.Create("generated.md") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
|
||
fc := flowchart.NewFlowchart( | ||
io.Discard, | ||
flowchart.WithTitle("mermaid flowchart builder"), | ||
flowchart.WithOrientalTopToBottom(), | ||
). | ||
NodeWithText("A", "Node A"). | ||
StadiumNode("B", "Node B"). | ||
SubroutineNode("C", "Node C"). | ||
DatabaseNode("D", "Database"). | ||
LinkWithArrowHead("A", "B"). | ||
LinkWithArrowHeadAndText("B", "D", "send original data"). | ||
LinkWithArrowHead("B", "C"). | ||
DottedLinkWithText("C", "D", "send filtered data"). | ||
String() | ||
|
||
err = markdown.NewMarkdown(f). | ||
H2("Flowchart"). | ||
CodeBlocks(markdown.SyntaxHighlightMermaid, fc). | ||
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
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,12 @@ | ||
// Package internal package is used to store the internal implementation of the mermaid package. | ||
package internal | ||
|
||
import "runtime" | ||
|
||
// LineFeed return line feed for current OS. | ||
func LineFeed() string { | ||
if runtime.GOOS == "windows" { | ||
return "\r\n" | ||
} | ||
return "\n" | ||
} |
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,28 @@ | ||
// Package internal package is used to store the internal implementation of the mermaid package. | ||
package internal | ||
|
||
import ( | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func TestLineFeed(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("should return line feed for current OS", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
got := LineFeed() | ||
|
||
switch runtime.GOOS { | ||
case "windows": | ||
if got != "\r\n" { | ||
t.Errorf("expected \\r\\n, but got %s", got) | ||
} | ||
default: | ||
if got != "\n" { | ||
t.Errorf("expected \\n, but got %s", got) | ||
} | ||
} | ||
}) | ||
} |
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.