Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions struct_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func GetDescribeFromComment(doc *ast.CommentGroup, comment *ast.CommentGroup) st
if comment != nil {
res += TrimComment(comment.Text())
}
// skip comments starting with plus sign, known as "markers" and used for example by kubebuilder
if strings.HasPrefix(res, "+") {
res = ""
}

return res
}
5 changes: 1 addition & 4 deletions struct_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ func (p *Parser) parseFileStruct(
structInfo := p.parseStruct(objStructType, typeDocMap[objName])
res[typeKey] = structInfo
for idx, field := range structInfo.Fields {
if field.Reference == "" {
continue
}
subModPath := ""
if field.Reference == "." {
if field.Reference == "" || field.Reference == "." {
subModPath = modPath
} else {
subModPath = namedImportMap[field.Reference]
Expand Down
4 changes: 2 additions & 2 deletions test/ext/hook.go → test/ext/post.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ext

// Hook hook config.
type Hook struct {
// Post hook config.
type Post struct {
Name string `json:"name" require:"" default:"example"` // hook name
Commands []string `json:"commands"` // command list
Envs map[string]string `json:"envs"` // env key map
Expand Down
11 changes: 11 additions & 0 deletions test/post.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package test

import "github.com/eleztian/type2md/test/ext"

// Pre hook config.
type Pre struct {
Name string `json:"name" require:"" default:"example"` // hook name
Commands []string `json:"commands"` // command list
Envs map[string]string `json:"envs"` // env key map
Mode ext.Mode `json:"mode" default:"1"` // run mode
}
12 changes: 6 additions & 6 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "github.com/eleztian/type2md/test/ext"

// Config doc.
type Config struct {
Pre ext.Hook
Post *ext.Hook
Pre Pre
Post *ext.Post
Servers map[string]struct {
Host string `json:"host,omitempty"`
Port int `json:"port" enums:"22,65522" require:"false"`
Expand All @@ -27,8 +27,8 @@ type InlineStruct struct {
// OtherStruct other struct
// this is use for test.
type OtherStruct struct {
A string `json:"a" require:"true" default:"default value"`
B [][2]ext.Mode `json:"b"` // array string
C map[string]interface{} `json:"c"` // map[string]interface{}
D *OtherStruct `json:"d"` // nested struct
A string `json:"a" require:"true" default:"default value"` // +optional
B [][2]ext.Mode `json:"b"` // array string
C map[string]interface{} `json:"c"` // map[string]interface{}
D *OtherStruct `json:"d"` // nested struct
}