Skip to content

Commit

Permalink
feat: add links in comments (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq authored Sep 9, 2024
1 parent b2d7fee commit 404c76b
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 32 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 @@ -740,13 +740,14 @@ func (g *generator) generateLocalStubs(p printFn) {
p(``)
p(``)
p(`// Local stub implementations.`)
p(``)
g.tset.importPackage("context", "context")

var b strings.Builder
for _, comp := range g.components {

stub := notExported(comp.intfName()) + "_local_stub"
p(``)
p(`// %s is a local stub implementation of [%s].`, stub, g.tset.genTypeString(comp.intf))
p(`type %s struct{`, stub)
p(` impl %s`, g.componentRef(comp))
p(` name string`)
Expand Down
7 changes: 5 additions & 2 deletions cmd/kod/internal/struct2interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ func makeFile(file string) (*makeInterfaceFile, error) {
}
}

for _, structName := range structInfo.structs {
typeDoc[structName] = fmt.Sprintf("%s is a component interface implemented by [%s].\n%s",
structInfo.struct2Interfaces[structName], structName, structInfo.typeDoc[structName])
}

for structName, methods := range structInfo.methods {
typeDoc[structName] = fmt.Sprintf("%s is a component that implements %s.\n%s",
structName, structInfo.struct2Interfaces[structName], structInfo.typeDoc[structName])
for _, m := range methods {
allMethods[structName] = append(allMethods[structName], m.Lines()...)
}
Expand Down
4 changes: 4 additions & 0 deletions examples/helloworld/kod_gen.go

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

6 changes: 3 additions & 3 deletions examples/helloworld/kod_gen_interface.go

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

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

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

27 changes: 14 additions & 13 deletions tests/case1/kod_gen_interface.go

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

3 changes: 3 additions & 0 deletions tests/case2/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/case2/kod_gen_interface.go

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

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

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

6 changes: 3 additions & 3 deletions tests/case3/kod_gen_interface.go

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

Loading

0 comments on commit 404c76b

Please sign in to comment.