Skip to content

Commit 5c68e42

Browse files
committed
add doc support to nested field types
Adds documentation to the nested field types in `apis/$VERSION/types.go` output for the structs and the fields within those structs. The fields within the structs are modeled with the `pkg/model.Attr` struct, so I added a `Shape` field to that in order to bring in the aws-sdk-go `private/model/api.Shape` that has a `Documentation` field on it... Related: aws-controllers-k8s/community#723
1 parent 71f5331 commit 5c68e42

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

pkg/generate/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ func (g *Generator) GetTypeDefs() ([]*ackmodel.TypeDef, error) {
356356
continue
357357
}
358358
tdefs = append(tdefs, &ackmodel.TypeDef{
359+
Shape: shape,
359360
Names: tdefNames,
360361
Attrs: attrs,
361362
})

pkg/model/type_def.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package model
1515

1616
import (
17+
awssdkmodel "github.com/aws/aws-sdk-go/private/model/api"
18+
1719
"github.com/aws-controllers-k8s/code-generator/pkg/names"
1820
)
1921

@@ -29,4 +31,5 @@ const (
2931
type TypeDef struct {
3032
Names names.Names
3133
Attrs map[string]*Attr
34+
Shape *awssdkmodel.Shape
3235
}

templates/apis/type_def.go.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{{- define "type_def" -}}
2+
{{- if .Shape.Documentation }}
3+
{{ .Shape.Documentation }}
4+
{{- end }}
25
type {{ .Names.Camel }} struct {
36
{{- range $attrName, $attr := .Attrs }}
7+
{{- if $attr.Shape.Documentation }}
8+
{{ $attr.Shape.Documentation }}
9+
{{- end }}
410
{{ $attr.Names.Camel }} {{ $attr.GoType }} `json:"{{ $attr.Names.CamelLower }},omitempty"`
511
{{- end }}
612
}

0 commit comments

Comments
 (0)