v0.0.335 added DescriptionMeta to enum codegen
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 58s

This commit is contained in:
Mike Schwörer 2023-12-05 19:38:03 +01:00
parent 2fad6340c7
commit af38b06d22
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 24 additions and 3 deletions

View File

@ -75,6 +75,12 @@ func (e {{.EnumTypeName}}) Meta() enums.EnumMetaValue {
{{if $hasDescr}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: langext.Ptr(e.Description())} {{else}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil} {{end}} {{if $hasDescr}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: langext.Ptr(e.Description())} {{else}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil} {{end}}
} }
{{if $hasDescr}}
func (e {{.EnumTypeName}}) DescriptionMeta() enums.EnumDescriptionMetaValue {
return enums.EnumDescriptionMetaValue{VarName: e.VarName(), Value: e.String(), Description: e.Description()}
}
{{end}}
func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) { func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) {
for _, ev := range __{{.EnumTypeName}}Values { for _, ev := range __{{.EnumTypeName}}Values {
if string(ev) == vv { if string(ev) == vv {
@ -94,4 +100,12 @@ func {{.EnumTypeName}}ValuesMeta() []enums.EnumMetaValue {
} }
} }
{{if $hasDescr}}
func (e {{.EnumTypeName}}) ValuesDescriptionMeta() []enums.EnumDescriptionMetaValue {
return []enums.EnumMetaValue{ {{range .Values}}
{{.VarName}}.DescriptionMeta(), {{end}}
}
}
{{end}}
{{end}} {{end}}

View File

@ -15,10 +15,17 @@ type StringEnum interface {
type DescriptionEnum interface { type DescriptionEnum interface {
Enum Enum
Description() string Description() string
DescriptionMeta() EnumDescriptionMetaValue
} }
type EnumMetaValue struct { type EnumMetaValue struct {
VarName string `json:"varName"` VarName string `json:"varName"`
Value any `json:"value"` Value Enum `json:"value"`
Description *string `json:"description"` Description *string `json:"description"`
} }
type EnumDescriptionMetaValue struct {
VarName string `json:"varName"`
Value Enum `json:"value"`
Description string `json:"description"`
}

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.334" const GoextVersion = "0.0.335"
const GoextVersionTimestamp = "2023-12-05T19:23:27+0100" const GoextVersionTimestamp = "2023-12-05T19:38:03+0100"