diff --git a/metaschema/metaschema.go b/metaschema/metaschema.go index e98612b0..5044f023 100644 --- a/metaschema/metaschema.go +++ b/metaschema/metaschema.go @@ -238,6 +238,13 @@ type Flag struct { Def *DefineFlag } +func (f *Flag) GoComment() string { + if f.Description != "" { + return f.Description + } + return f.Def.Description +} + type Choice struct { Field []Field `xml:"field"` Assembly []Assembly `xml:"assembly"` diff --git a/metaschema/template.go b/metaschema/template.go index 5661f95d..34ee606a 100644 --- a/metaschema/template.go +++ b/metaschema/template.go @@ -42,7 +42,6 @@ func GenerateTypes(metaschema *Metaschema) error { "plural": inflection.Plural, "wrapString": wrapString, "parseDatatype": parseDatatype, - "commentFlag": commentFlag, "packageImport": packageImport, "getImports": getImports, "requiresPointer": requiresPointer, @@ -90,14 +89,6 @@ func parseDatatype(datatype string, packageName string) string { return datatypes[Datatype(datatype)] } -func commentFlag(flagName string, metaschema Metaschema) []string { - df, err := metaschema.GetDefineFlag(flagName) - if err == nil { - return wrapString(df.Description) - } - return nil -} - func packageImport(named string, metaschema Metaschema) string { for _, df := range metaschema.DefineFlag { if df.Name == named { diff --git a/metaschema/types.tmpl b/metaschema/types.tmpl index f91f918c..a3f7431a 100644 --- a/metaschema/types.tmpl +++ b/metaschema/types.tmpl @@ -19,10 +19,7 @@ type {{toCamel .Name}} struct { Title string `xml:"title,omitempty" json:"title,omitempty"` {{- end}} {{- range .Flags}} - {{- $cf := commentFlag .Name $m}} - {{- range $cf}} - // {{ . }} - {{- end}} + // {{ .GoComment }} {{- $dt := parseDatatype .Datatype $packageName}} {{- if and (eq "id" .Name) (eq "profile" $packageName)}} Id string `xml:"param-id,attr,omitempty" json:"id,omitempty"` @@ -85,10 +82,7 @@ type {{toCamel .Name}} struct { {{- end}} type {{toCamel .Name}} struct { {{- range .Flags}} - {{- $cf := commentFlag .Name $m -}} - {{range $cf}} - // {{ . }} - {{end -}} + // {{ .GoComment }} {{- $dt := parseDatatype .Datatype $packageName -}} {{toCamel .Name}} {{if eq "" $dt}}string{{else}}{{$dt}}{{end}} `xml:"{{ .Name }},attr,omitempty" json:"{{toLowerCamel .Name}},omitempty"` {{end -}}