Skip to content

Commit

Permalink
Add short name func
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddddO committed Sep 5, 2021
1 parent a3b3ed5 commit 6989beb
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,50 @@ func main() {
- [ ] リリース
- [x] finish

## etc
### short name version

```go
package main

import (
g "github.com/ddddddO/gdag"
)

func main() {
var goal *g.Node = g.G("ゴール(目的)")

var design *g.Node = g.T("設計")
reviewDesign := g.T("レビュー対応")

developFeature1 := g.T("feature1開発")
developFeature1.N("xxが担当")
reviewDevelopFeature1 := g.T("レビュー対応")

developFeature2 := g.T("feature2開発")
developFeature2.N("yyが担当")
reviewDevelopFeature2 := g.T("レビュー対応")

prepareInfra := g.T("インフラ準備")
prepareInfra.N("zzが担当")

test := g.T("結合テスト")
release := g.T("リリース")
finish := g.T("finish")

goal.C(design).C(reviewDesign).C(developFeature1).C(reviewDevelopFeature1).C(test)
reviewDesign.C(developFeature2).C(reviewDevelopFeature2).C(test)
reviewDesign.C(prepareInfra).C(test)
test.C(release).C(finish)

g.D(design, reviewDesign, developFeature2, finish)

if err := g.GUML(goal); err != nil {
panic(err)
}
}
```


# Reference
- [about DAG](https://nave-kazu.hatenablog.com/entry/2015/11/30/154810)
36 changes: 36 additions & 0 deletions gdag_short.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package gdag

// G is short name of Goal func.
func G(text string) *Node {
return Goal(text)
}

// T is short name of Task func.
func T(text string) *Node {
return Task(text)
}

// D is short name of Done func.
func D(nodes ...*Node) {
Done(nodes...)
}

// C is short name of Con func.
func (upstream *Node) C(current *Node) *Node {
return upstream.Con(current)
}

// N is short name of Note func.
func (current *Node) N(note string) {
current.Note(note)
}

// GUML is short name of GenerateUML func.
func GUML(node *Node) error {
return GenerateUML(node)
}

// GCL is short name of GenerateCheckList func.
func GCL(node *Node) error {
return GenerateCheckList(node)
}
140 changes: 140 additions & 0 deletions gdag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,146 @@ func Example() {
// @enduml
}

func ExampleGenerateUML() {
var goal *g.Node = g.Goal("ゴール(目的)")

var design *g.Node = g.Task("設計")
reviewDesign := g.Task("レビュー対応")

developFeature1 := g.Task("feature1開発")
developFeature1.Note("xxが担当")
reviewDevelopFeature1 := g.Task("レビュー対応")

developFeature2 := g.Task("feature2開発")
developFeature2.Note("yyが担当")
reviewDevelopFeature2 := g.Task("レビュー対応")

prepareInfra := g.Task("インフラ準備")
prepareInfra.Note("zzが担当")

test := g.Task("結合テスト")
release := g.Task("リリース")
finish := g.Task("finish")

goal.Con(design).Con(reviewDesign).Con(developFeature1).Con(reviewDevelopFeature1).Con(test)
reviewDesign.Con(developFeature2).Con(reviewDevelopFeature2).Con(test)
reviewDesign.Con(prepareInfra).Con(test)
test.Con(release).Con(finish)

g.Done(design, reviewDesign, developFeature2, finish)

if err := g.GenerateUML(goal); err != nil {
panic(err)
}
// Output:
// @startuml
// rectangle "ゴール(目的)" as 12
// usecase "設計" as 13 #DarkGray
// usecase "レビュー対応" as 14 #DarkGray
// usecase "feature1開発" as 15
// note left
// xxが担当
// end note
// usecase "レビュー対応" as 16
// usecase "結合テスト" as 20
// usecase "リリース" as 21
// usecase "finish" as 22 #DarkGray
// usecase "feature2開発" as 17 #DarkGray
// note left
// yyが担当
// end note
// usecase "レビュー対応" as 18
// usecase "インフラ準備" as 19
// note left
// zzが担当
// end note
//
// 12 --> 13
// 13 --> 14
// 14 --> 15
// 15 --> 16
// 16 --> 20
// 20 --> 21
// 21 --> 22
// 14 --> 17
// 17 --> 18
// 18 --> 20
// 14 --> 19
// 19 --> 20
//
// @enduml
}

func ExampleGUML() {
var goal *g.Node = g.G("ゴール(目的)")

var design *g.Node = g.T("設計")
reviewDesign := g.T("レビュー対応")

developFeature1 := g.T("feature1開発")
developFeature1.N("xxが担当")
reviewDevelopFeature1 := g.T("レビュー対応")

developFeature2 := g.T("feature2開発")
developFeature2.N("yyが担当")
reviewDevelopFeature2 := g.T("レビュー対応")

prepareInfra := g.T("インフラ準備")
prepareInfra.N("zzが担当")

test := g.T("結合テスト")
release := g.T("リリース")
finish := g.T("finish")

goal.C(design).C(reviewDesign).C(developFeature1).C(reviewDevelopFeature1).C(test)
reviewDesign.C(developFeature2).C(reviewDevelopFeature2).C(test)
reviewDesign.C(prepareInfra).C(test)
test.C(release).C(finish)

g.D(design, reviewDesign, developFeature2, finish)

if err := g.GUML(goal); err != nil {
panic(err)
}
// Output:
// @startuml
// rectangle "ゴール(目的)" as 23
// usecase "設計" as 24 #DarkGray
// usecase "レビュー対応" as 25 #DarkGray
// usecase "feature1開発" as 26
// note left
// xxが担当
// end note
// usecase "レビュー対応" as 27
// usecase "結合テスト" as 31
// usecase "リリース" as 32
// usecase "finish" as 33 #DarkGray
// usecase "feature2開発" as 28 #DarkGray
// note left
// yyが担当
// end note
// usecase "レビュー対応" as 29
// usecase "インフラ準備" as 30
// note left
// zzが担当
// end note
//
// 23 --> 24
// 24 --> 25
// 25 --> 26
// 26 --> 27
// 27 --> 31
// 31 --> 32
// 32 --> 33
// 25 --> 28
// 28 --> 29
// 29 --> 31
// 25 --> 30
// 30 --> 31
//
// @enduml
}

func ExampleGenerateCheckList() {
goal := g.Goal("ゴール(目的)")

Expand Down

0 comments on commit 6989beb

Please sign in to comment.