d2/d2target/class.go
Alexander Wang 524c089a74 oss
Co-authored-by: Anmol Sethi <hi@nhooyr.io>
2022-11-03 06:54:49 -07:00

44 lines
861 B
Go

package d2target
import (
"fmt"
"oss.terrastruct.com/d2/d2renderers/d2fonts"
)
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() *MText {
return &MText{
Text: fmt.Sprintf("%s%s", cf.Name, cf.Type),
FontSize: d2fonts.FONT_SIZE_L,
IsBold: false,
IsItalic: false,
Shape: "class",
}
}
type ClassMethod struct {
Name string `json:"name"`
Return string `json:"return"`
Visibility string `json:"visibility"`
}
func (cm ClassMethod) Text() *MText {
return &MText{
Text: fmt.Sprintf("%s%s", cm.Name, cm.Return),
FontSize: d2fonts.FONT_SIZE_L,
IsBold: false,
IsItalic: false,
Shape: "class",
}
}