Skip to content

Commit

Permalink
Do not ignore basic type comments (elastic#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
charith-elastic committed Feb 15, 2021
1 parent 851eb91 commit 1f0ce7b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
11 changes: 6 additions & 5 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
5 changes: 5 additions & 0 deletions test/api/v1/guestbook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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{})
}
15 changes: 14 additions & 1 deletion test/expected.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
****
Expand Down Expand Up @@ -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$$]
****



0 comments on commit 1f0ce7b

Please sign in to comment.