Skip to content

Commit 20ca91f

Browse files
committed
bind/py2: attach documentation for vars get/set
1 parent 31d6377 commit 20ca91f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bind/gencpy.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,17 @@ func (g *cpyGen) gen() error {
243243

244244
for _, v := range g.pkg.vars {
245245
name := v.Name()
246+
get := v.doc
247+
set := v.doc
248+
if v.doc == "" {
249+
get = "returns " + g.pkg.Name() + "." + name
250+
set = "sets " + g.pkg.Name() + "." + name
251+
}
246252
g.impl.Printf("{%[1]q, %[2]s, METH_VARARGS, %[3]q},\n",
247-
"Get"+name, "cpy_func_"+v.id+"_get", v.doc,
253+
"Get"+name, "cpy_func_"+v.id+"_get", get,
248254
)
249255
g.impl.Printf("{%[1]q, %[2]s, METH_VARARGS, %[3]q},\n",
250-
"Set"+name, "cpy_func_"+v.id+"_set", v.doc,
256+
"Set"+name, "cpy_func_"+v.id+"_set", set,
251257
)
252258
}
253259

main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,9 @@ func TestBindVars(t *testing.T) {
782782
want: []byte(`doc(vars):
783783
''
784784
doc(vars.GetV1()):
785-
''
785+
'returns vars.V1'
786786
doc(vars.SetV1()):
787-
''
787+
'sets vars.V1'
788788
Initial values
789789
v1 = v1
790790
v2 = 42

0 commit comments

Comments
 (0)