Skip to content

Commit

Permalink
fix docgen for ambiguous fields on nested structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakoth committed May 19, 2020
1 parent ec30886 commit f716d23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ appendix:
}

for name, field := range conf.FieldsFromStruct(t) {
if isPrivate(name) || isProtobuf(name) {
if isPrivate(name) || isProtobuf(name) || field.Ambiguous {
continue
}
a.Fields[Identifier(name)] = c.use(field.Type)
Expand Down
18 changes: 18 additions & 0 deletions docgen/docgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ type A struct {
type B struct {
AmbiguousField string
}

type C struct {
A
B
}
type EnvAmbiguous struct {
A
B
C C
}

func TestCreateDoc_Ambiguous(t *testing.T) {
Expand All @@ -159,6 +165,10 @@ func TestCreateDoc_Ambiguous(t *testing.T) {
"OkField": {
Kind: "int",
},
"C": {
Kind: "struct",
Name: "C",
},
},
Types: map[TypeName]*Type{
"A": {
Expand All @@ -174,6 +184,14 @@ func TestCreateDoc_Ambiguous(t *testing.T) {
"AmbiguousField": {Kind: "string"},
},
},
"C": {
Kind: "struct",
Fields: map[Identifier]*Type{
"A": {Kind: "struct", Name: "A"},
"B": {Kind: "struct", Name: "B"},
"OkField": {Kind: "int"},
},
},
},
}

Expand Down

0 comments on commit f716d23

Please sign in to comment.