Skip to content

Commit

Permalink
chore: improve comments for generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Oct 22, 2024
1 parent c0a0c9e commit 44fdda7
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 39 deletions.
3 changes: 2 additions & 1 deletion cmd/kod/internal/generate_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ func (g *generator) generateLocalStubs(p printFn) {
p(`}`)

p(``)
p(`// Check that %s implements the %s interface.`, stub, g.tset.genTypeString(comp.intf))
p(`// Check that [%s] implements the [%s] interface.`, stub, g.tset.genTypeString(comp.intf))
p(`var _ %s = (*%s)(nil)`, g.tset.genTypeString(comp.intf), stub)
p(``)

Expand All @@ -788,6 +788,7 @@ func (g *generator) generateLocalStubs(p printFn) {
}

p(``)
p(`// %s wraps the method [%s.%s].`, m.Name(), comp.implName(), m.Name())
p(`func (s %s) %s(%s) (%s) {`, stub, m.Name(), g.args(mt), g.returns(mt))

// If the first argument is not context.Context, then we don't support interceptors.
Expand Down
11 changes: 7 additions & 4 deletions examples/helloworld/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions tests/case1/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions tests/case2/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions tests/case3/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions tests/case4/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/case5/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 44fdda7

Please sign in to comment.