-
-
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.
Merge pull request #35 from nao1215/nchika/add-example-code
Add example code
- Loading branch information
Showing
14 changed files
with
536 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
## Entity Relationship Diagram | ||
```mermaid | ||
erDiagram | ||
teachers ||--o{ students : "Teacher has many students" | ||
teachers }|..|| schools : "School has many teachers" | ||
schools { | ||
int id PK,UK "School ID" | ||
string name "School Name" | ||
int teacher_id FK,UK "Teacher ID" | ||
} | ||
students { | ||
int id PK,UK "Student ID" | ||
string name "Student Name" | ||
int teacher_id FK,UK "Teacher ID" | ||
} | ||
teachers { | ||
int id PK,UK "Teacher ID" | ||
string name "Teacher Name" | ||
} | ||
teachers ||--o{ students : "Teacher has many students" | ||
teachers }|..|| schools : "School has many teachers" | ||
schools { | ||
int id PK,UK "School ID" | ||
string name "School Name" | ||
int teacher_id FK,UK "Teacher ID" | ||
} | ||
students { | ||
int id PK,UK "Student ID" | ||
string name "Student Name" | ||
int teacher_id FK,UK "Teacher ID" | ||
} | ||
teachers { | ||
int id PK,UK "Teacher ID" | ||
string name "Teacher Name" | ||
} | ||
``` |
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,118 @@ | ||
//go:build linux || darwin | ||
|
||
package arch_test | ||
|
||
import ( | ||
"io" | ||
"os" | ||
|
||
"github.com/nao1215/markdown" | ||
"github.com/nao1215/markdown/mermaid/arch" | ||
) | ||
|
||
// ExampleArchitecture skip this test on Windows. | ||
// The newline codes in the comment section where | ||
// the expected values are written are represented as '\n', | ||
// causing failures when testing on Windows. | ||
func ExampleArchitecture() { | ||
diagram := arch.NewArchitecture(io.Discard). | ||
Service("left_disk", arch.IconDisk, "Disk"). | ||
Service("top_disk", arch.IconDisk, "Disk"). | ||
Service("bottom_disk", arch.IconDisk, "Disk"). | ||
Service("top_gateway", arch.IconInternet, "Gateway"). | ||
Service("bottom_gateway", arch.IconInternet, "Gateway"). | ||
Junction("junctionCenter"). | ||
Junction("junctionRight"). | ||
LF(). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "left_disk", | ||
Position: arch.PositionRight, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionCenter", | ||
Position: arch.PositionLeft, | ||
Arrow: arch.ArrowNone, | ||
}). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "top_disk", | ||
Position: arch.PositionBottom, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionCenter", | ||
Position: arch.PositionTop, | ||
Arrow: arch.ArrowNone, | ||
}). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "bottom_disk", | ||
Position: arch.PositionTop, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionCenter", | ||
Position: arch.PositionBottom, | ||
Arrow: arch.ArrowNone, | ||
}). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "junctionCenter", | ||
Position: arch.PositionRight, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionRight", | ||
Position: arch.PositionLeft, | ||
Arrow: arch.ArrowNone, | ||
}). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "top_gateway", | ||
Position: arch.PositionBottom, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionRight", | ||
Position: arch.PositionTop, | ||
Arrow: arch.ArrowNone, | ||
}). | ||
Edges( | ||
arch.Edge{ | ||
ServiceID: "bottom_gateway", | ||
Position: arch.PositionTop, | ||
Arrow: arch.ArrowNone, | ||
}, | ||
arch.Edge{ | ||
ServiceID: "junctionRight", | ||
Position: arch.PositionBottom, | ||
Arrow: arch.ArrowNone, | ||
}).String() //nolint | ||
|
||
markdown.NewMarkdown(os.Stdout). | ||
H2("Architecture Diagram"). | ||
CodeBlocks(markdown.SyntaxHighlightMermaid, diagram). | ||
Build() //nolint | ||
|
||
// Output: | ||
//## Architecture Diagram | ||
//```mermaid | ||
//architecture-beta | ||
// service left_disk(disk)[Disk] | ||
// service top_disk(disk)[Disk] | ||
// service bottom_disk(disk)[Disk] | ||
// service top_gateway(internet)[Gateway] | ||
// service bottom_gateway(internet)[Gateway] | ||
// junction junctionCenter | ||
// junction junctionRight | ||
// | ||
// left_disk:R -- L:junctionCenter | ||
// top_disk:B -- T:junctionCenter | ||
// bottom_disk:T -- B:junctionCenter | ||
// junctionCenter:R -- L:junctionRight | ||
// top_gateway:B -- T:junctionRight | ||
// bottom_gateway:T -- B:junctionRight | ||
//``` | ||
} |
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.