Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add links in comments #240

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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