package d2target
import (
"fmt"
)
const (
PrefixPadding = 10
PrefixWidth = 20
CenterPadding = 50
VerticalPadding = 20
)
type Class struct {
Fields []ClassField `json:"fields"`
Methods []ClassMethod `json:"methods"`
}
type ClassField struct {
Name string `json:"name"`
Type string `json:"type"`
Visibility string `json:"visibility"`
}
func (cf ClassField ) Text (fontSize int ) *MText {
return &MText {
Text : fmt .Sprintf ("%s%s" , cf .Name , cf .Type ),
FontSize : fontSize ,
IsBold : false ,
IsItalic : false ,
Shape : "class" ,
}
}
func (cf ClassField ) VisibilityToken () string {
switch cf .Visibility {
case "protected" :
return "#"
case "private" :
return "-"
default :
return "+"
}
}
type ClassMethod struct {
Name string `json:"name"`
Return string `json:"return"`
Visibility string `json:"visibility"`
}
func (cm ClassMethod ) Text (fontSize int ) *MText {
return &MText {
Text : fmt .Sprintf ("%s%s" , cm .Name , cm .Return ),
FontSize : fontSize ,
IsBold : false ,
IsItalic : false ,
Shape : "class" ,
}
}
func (cm ClassMethod ) VisibilityToken () string {
switch cm .Visibility {
case "protected" :
return "#"
case "private" :
return "-"
default :
return "+"
}
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .