Skip to content

Commit 692afd2

Browse files
committed
Improve docgen
1 parent 3bf0f26 commit 692afd2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

docgen/docgen.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/antonmedv/expr/internal/conf"
55
"reflect"
66
"regexp"
7+
"strings"
78
)
89

910
// Kind can be any of array, map, struct, func, string, int, float, bool or any.
@@ -68,6 +69,10 @@ func (c *Context) use(t reflect.Type, ops ...option) *Type {
6869
// all embedded structs methods as well, no need to recursion.
6970
for i := 0; i < t.NumMethod(); i++ {
7071
m := t.Method(i)
72+
// Skip all protobuf generated methods as well.
73+
if strings.HasPrefix(m.Name, "XXX_") {
74+
continue
75+
}
7176
if isPrivate(m.Name) {
7277
continue
7378
}
@@ -123,19 +128,19 @@ func (c *Context) use(t reflect.Type, ops ...option) *Type {
123128

124129
case reflect.Func:
125130
arguments := make([]*Type, 0)
126-
127131
start := 0
128132
if config.method {
129133
start = 1
130134
}
131-
132135
for i := start; i < t.NumIn(); i++ {
133136
arguments = append(arguments, c.use(t.In(i)))
134137
}
135-
return &Type{
138+
f := &Type{
136139
Kind: "func",
137140
Arguments: arguments,
138-
Return: c.use(t.Out(0)),
141+
}
142+
if t.NumOut() > 0 {
143+
f.Return = c.use(t.Out(0))
139144
}
140145
}
141146

0 commit comments

Comments
 (0)