Documentation
¶
Overview ¶
Package sequence is mermaid sequence diagram builder.
Index ¶
- type Diagram
- func (d *Diagram) Activate(participant string) *Diagram
- func (d *Diagram) Actor(actor string) *Diagram
- func (d *Diagram) AltElse(description string) *Diagram
- func (d *Diagram) AltEnd() *Diagram
- func (d *Diagram) AltStart(description string) *Diagram
- func (d *Diagram) AsyncRequest(from, to, message string) *Diagram
- func (d *Diagram) AsyncRequestWithActivation(from, to, message string) *Diagram
- func (d *Diagram) AsyncRequestf(from, to, format string, args ...any) *Diagram
- func (d *Diagram) AsyncRequestfWithActivation(from, to, format string, args ...any) *Diagram
- func (d *Diagram) AsyncResponse(from, to, message string) *Diagram
- func (d *Diagram) AsyncResponseWithActivation(from, to, message string) *Diagram
- func (d *Diagram) AsyncResponsef(from, to, format string, args ...any) *Diagram
- func (d *Diagram) AsyncResponsefWithActivation(from, to, format string, args ...any) *Diagram
- func (d *Diagram) AutoNumber() *Diagram
- func (d *Diagram) BoxEnd() *Diagram
- func (d *Diagram) BoxStart(participant []string) *Diagram
- func (d *Diagram) BreakEnd() *Diagram
- func (d *Diagram) BreakStart(description string) *Diagram
- func (d *Diagram) Build() error
- func (d *Diagram) CreateActor(actor string) *Diagram
- func (d *Diagram) CreateParticipant(participant string) *Diagram
- func (d *Diagram) CriticalEnd() *Diagram
- func (d *Diagram) CriticalOption(description string) *Diagram
- func (d *Diagram) CriticalStart(description string) *Diagram
- func (d *Diagram) Deactivate(participant string) *Diagram
- func (d *Diagram) DestroyActor(actor string) *Diagram
- func (d *Diagram) DestroyParticipant(participant string) *Diagram
- func (d *Diagram) Error() error
- func (d *Diagram) LF() *Diagram
- func (d *Diagram) LoopEnd() *Diagram
- func (d *Diagram) LoopStart(description string) *Diagram
- func (d *Diagram) NoteLeftOf(participant, message string) *Diagram
- func (d *Diagram) NoteOver(participant, message string) *Diagram
- func (d *Diagram) NoteRightOf(participant, message string) *Diagram
- func (d *Diagram) OptEnd() *Diagram
- func (d *Diagram) OptStart(description string) *Diagram
- func (d *Diagram) ParallelAnd(description string) *Diagram
- func (d *Diagram) ParallelEnd() *Diagram
- func (d *Diagram) ParallelStart(description string) *Diagram
- func (d *Diagram) Participant(participant string) *Diagram
- func (d *Diagram) RequestError(from, to, message string) *Diagram
- func (d *Diagram) RequestErrorf(from, to, format string, args ...any) *Diagram
- func (d *Diagram) ResponseError(from, to, message string) *Diagram
- func (d *Diagram) ResponseErrorf(from, to, format string, args ...any) *Diagram
- func (d *Diagram) String() string
- func (d *Diagram) SyncRequest(from, to, message string) *Diagram
- func (d *Diagram) SyncRequestWithActivation(from, to, message string) *Diagram
- func (d *Diagram) SyncRequestf(from, to, format string, args ...any) *Diagram
- func (d *Diagram) SyncRequestfWithActivation(from, to, format string, args ...any) *Diagram
- func (d *Diagram) SyncResponse(from, to, message string) *Diagram
- func (d *Diagram) SyncResponseWithActivation(from, to, message string) *Diagram
- func (d *Diagram) SyncResponsef(from, to, format string, args ...any) *Diagram
- func (d *Diagram) SyncResponsefWithActivation(from, to, format string, args ...any) *Diagram
- type NotePosition
- type Option
- func WithActorFontFamily(actorFontFamily string) Option
- func WithActorFontSize(actorFontSize uint) Option
- func WithActorFontWeight(actorFontWeight string) Option
- func WithBottomMariginAdjustment(bottomMariginAdjustment uint) Option
- func WithMessageFontFamily(messageFontFamily string) Option
- func WithMessageFontSize(messageFontSize uint) Option
- func WithMessageFontWeight(messageFontWeight string) Option
- func WithMirrorActors(mirrorActors bool) Option
- func WithNoteAlign(noteAlign string) Option
- func WithNoteFontFamily(noteFontFamily string) Option
- func WithNoteFontSize(noteFontSize uint) Option
- func WithNoteFontWeight(noteFontWeight string) Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagram ¶
type Diagram struct {
// contains filtered or unexported fields
}
Diagram is a sequence diagram builder.
Example ¶
ExampleDiagram skips 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.
package main
import (
"os"
md "github.com/nao1215/markdown"
"github.com/nao1215/markdown/mermaid/sequence"
)
func main() {
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()
_ = md.NewMarkdown(os.Stdout).
H2("Sequence Diagram").
CodeBlocks(md.SyntaxHighlightMermaid, diagram).
Build()
}
Output: ## 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 ```
func NewDiagram ¶
NewDiagram returns a new Diagram. Currently, there is no option (method) provided to change the configuration.
func (*Diagram) AsyncRequest ¶
AsyncRequest add a async request to the sequence diagram.
func (*Diagram) AsyncRequestWithActivation ¶
AsyncRequestWithActivation add a async request to the sequence diagram.
func (*Diagram) AsyncRequestf ¶
AsyncRequestf add a async request to the sequence diagram.
func (*Diagram) AsyncRequestfWithActivation ¶
AsyncRequestfWithActivation add a async request to the sequence diagram.
func (*Diagram) AsyncResponse ¶
AsyncResponse add a async response to the sequence diagram.
func (*Diagram) AsyncResponseWithActivation ¶
AsyncResponseWithActivation add a async response to the sequence diagram.
func (*Diagram) AsyncResponsef ¶
AsyncResponsef add a async response to the sequence diagram.
func (*Diagram) AsyncResponsefWithActivation ¶
AsyncResponsefWithActivation add a async response to the sequence diagram.
func (*Diagram) AutoNumber ¶
AutoNumber add auto number to the sequence diagram.
func (*Diagram) BreakStart ¶
BreakStart add a break to the sequence diagram.
func (*Diagram) CreateActor ¶
CreateActor add a participant to the sequence diagram.
func (*Diagram) CreateParticipant ¶
CreateParticipant add a participant to the sequence diagram.
func (*Diagram) CriticalEnd ¶
CriticalEnd add a critical to the sequence diagram.
func (*Diagram) CriticalOption ¶
CriticalOption add a critical opiton to the sequence diagram.
func (*Diagram) CriticalStart ¶
CriticalStart add a critical to the sequence diagram.
func (*Diagram) Deactivate ¶
Deactivate add a participant to the sequence diagram.
func (*Diagram) DestroyActor ¶
DestroyActor add a participant to the sequence diagram.
func (*Diagram) DestroyParticipant ¶
DestroyParticipant add a participant to the sequence diagram.
func (*Diagram) NoteLeftOf ¶
NoteLeftOf add a note to the sequence diagram.
func (*Diagram) NoteRightOf ¶
NoteRightOf add a note to the sequence diagram.
func (*Diagram) ParallelAnd ¶
ParallelAnd add a parallel to the sequence diagram.
func (*Diagram) ParallelEnd ¶
ParallelEnd add a parallel to the sequence diagram.
func (*Diagram) ParallelStart ¶
ParallelStart add a parallel to the sequence diagram.
func (*Diagram) Participant ¶
Participant add a participant to the sequence diagram.
func (*Diagram) RequestError ¶
RequestError add a request error to the sequence diagram.
func (*Diagram) RequestErrorf ¶
RequestErrorf add a request error to the sequence diagram.
func (*Diagram) ResponseError ¶
ResponseError add a response error to the sequence diagram.
func (*Diagram) ResponseErrorf ¶
ResponseErrorf add a response error to the sequence diagram.
func (*Diagram) SyncRequest ¶
SyncRequest add a request to the sequence diagram.
func (*Diagram) SyncRequestWithActivation ¶
SyncRequestWithActivation add a request to the sequence diagram.
func (*Diagram) SyncRequestf ¶
SyncRequestf add a request to the sequence diagram.
func (*Diagram) SyncRequestfWithActivation ¶
SyncRequestfWithActivation add a request to the sequence diagram.
func (*Diagram) SyncResponse ¶
SyncResponse add a response to the sequence diagram.
func (*Diagram) SyncResponseWithActivation ¶
SyncResponseWithActivation add a response to the sequence diagram.
func (*Diagram) SyncResponsef ¶
SyncResponsef add a response to the sequence diagram.
type NotePosition ¶
type NotePosition string
NotePosition is a note position.
const ( // NotePositionOver is a note position. NotePositionOver NotePosition = "over" // NotePositionRight is a note position. NotePositionRight NotePosition = "right of" // NotePositionLeft is a note position. NotePositionLeft NotePosition = "left of" )
type Option ¶ added in v0.2.0
type Option func(*config)
Option sets the options for the Diagram struct.
func WithActorFontFamily ¶ added in v0.2.0
WithActorFontFamily sets the actorFontFamily configuration.
func WithActorFontSize ¶ added in v0.2.0
WithActorFontSize sets the actorFontSize configuration.
func WithActorFontWeight ¶ added in v0.2.0
WithActorFontWeight sets the actorFontWeight configuration.
func WithBottomMariginAdjustment ¶ added in v0.2.0
WithBottomMariginAdjustment sets the bottomMariginAdjustment configuration.
func WithMessageFontFamily ¶ added in v0.2.0
WithMessageFontFamily sets the messageFontFamily configuration.
func WithMessageFontSize ¶ added in v0.2.0
WithMessageFontSize sets the messageFontSize configuration.
func WithMessageFontWeight ¶ added in v0.2.0
WithMessageFontWeight sets the messageFontWeight configuration.
func WithMirrorActors ¶ added in v0.2.0
WithMirrorActors sets the mirrorActors configuration.
func WithNoteAlign ¶ added in v0.2.0
WithNoteAlign sets the noteAlign configuration.
func WithNoteFontFamily ¶ added in v0.2.0
WithNoteFontFamily sets the noteFontFamily configuration.
func WithNoteFontSize ¶ added in v0.2.0
WithNoteFontSize sets the noteFontSize configuration.
func WithNoteFontWeight ¶ added in v0.2.0
WithNoteFontWeight sets the noteFontWeight configuration.