From 1f0ce7b2457f62dce6414b4715453d6aa92d41b1 Mon Sep 17 00:00:00 2001 From: Charith Ellawala <52399125+charith-elastic@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:28:43 +0000 Subject: [PATCH] Do not ignore basic type comments (#8) --- processor/processor.go | 11 ++++++----- test/api/v1/guestbook_types.go | 5 +++++ test/expected.asciidoc | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/processor/processor.go b/processor/processor.go index 2da3a71..b7daff6 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -440,11 +440,6 @@ func mkType(pkg *loader.Package, t gotypes.Type) *types.Type { } func (p *processor) loadAliasType(typeDef *types.Type, pkg *loader.Package, underlying gotypes.Type, depth int) *types.Type { - if bt, ok := underlying.(*gotypes.Basic); ok { - typeDef.UnderlyingType = &types.Type{Name: bt.String(), Kind: types.BasicKind} - return typeDef - } - tPkg := pkg // check whether this type is imported @@ -467,6 +462,12 @@ func (p *processor) loadAliasType(typeDef *types.Type, pkg *loader.Package, unde return typeDef } + if bt, ok := underlying.(*gotypes.Basic); ok { + typeDef.UnderlyingType = &types.Type{Name: bt.String(), Kind: types.BasicKind} + typeDef.Doc = tInfo.Doc + return typeDef + } + return p.processType(tPkg, tInfo, depth+1) } diff --git a/test/api/v1/guestbook_types.go b/test/api/v1/guestbook_types.go index c24df25..b8a8279 100644 --- a/test/api/v1/guestbook_types.go +++ b/test/api/v1/guestbook_types.go @@ -41,6 +41,8 @@ type GuestbookEntry struct { Time metav1.Time `json:"time,omitempty"` // Comment by guest Comment string `json:"comment,omitempty"` + // Rating provided by the guest + Rating Rating `json:"rating,omitempty"` } // GuestbookStatus defines the observed state of Guestbook. @@ -71,6 +73,9 @@ type GuestbookList struct { Items []Guestbook `json:"items"` } +// Rating is the rating provided by a guest. +type Rating string + func init() { SchemeBuilder.Register(&Guestbook{}, &GuestbookList{}) } diff --git a/test/expected.asciidoc b/test/expected.asciidoc index 571a98f..d5b7a9e 100644 --- a/test/expected.asciidoc +++ b/test/expected.asciidoc @@ -56,13 +56,14 @@ GuestbookEntry defines an entry in a guest book. | *`name`* __string__ | Name of the guest | *`time`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#time-v1-meta[$$Time$$]__ | Time of entry | *`comment`* __string__ | Comment by guest +| *`rating`* __xref:{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-rating[$$Rating$$]__ | Rating provided by the guest |=== [id="{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookheader"] ==== GuestbookHeader (string) - +GuestbookHeaders are strings to include at the top of a page. .Appears In: **** @@ -111,3 +112,15 @@ GuestbookSpec defines the desired state of Guestbook. +[id="{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-rating"] +==== Rating (string) + +Rating is the rating provided by a guest. + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookentry[$$GuestbookEntry$$] +**** + + +