Skip to content

Commit

Permalink
Feat:copy service comment to interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
silves-xiang committed May 21, 2024
1 parent e22436a commit 72c4cbb
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go

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

6 changes: 6 additions & 0 deletions channelz/grpc_channelz_v1/channelz_grpc.pb.go

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

15 changes: 15 additions & 0 deletions cmd/protoc-gen-go-grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
}
}

// Copy comments from proto file to _grpc.pb.go file.
func copyCommentsFromProto(g *protogen.GeneratedFile, service *protogen.Service) {
// Add empty comments line for godoc.
g.P("//")
// Pint comment without '\n', if comment has '\n', godoc considers this annotation to be non-service annotation.
g.P(strings.TrimSpace(service.Comments.Leading.String()))
}

func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
// Full methods constants.
helper.genFullMethods(g, service)
Expand All @@ -198,6 +206,9 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
g.P("//")
g.P("// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.")

// Copy comments from proto file.
copyCommentsFromProto(g, service)

if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
g.P("//")
g.P(deprecationComment)
Expand Down Expand Up @@ -251,6 +262,10 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
g.P("// ", serverType, " is the server API for ", service.GoName, " service.")
g.P("// All implementations ", mustOrShould, " embed Unimplemented", serverType)
g.P("// for forward compatibility")

// Copy comments from proto file.
copyCommentsFromProto(g, service)

if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
g.P("//")
g.P(deprecationComment)
Expand Down

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

4 changes: 4 additions & 0 deletions examples/features/proto/echo/echo_grpc.pb.go

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

4 changes: 4 additions & 0 deletions examples/helloworld/helloworld/helloworld_grpc.pb.go

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

4 changes: 4 additions & 0 deletions examples/route_guide/routeguide/route_guide_grpc.pb.go

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

8 changes: 8 additions & 0 deletions health/grpc_health_v1/health_grpc.pb.go

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

2 changes: 2 additions & 0 deletions internal/proto/grpc_lookup_v1/rls_grpc.pb.go

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

2 changes: 2 additions & 0 deletions interop/grpc_testing/benchmark_service_grpc.pb.go

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

2 changes: 2 additions & 0 deletions interop/grpc_testing/report_qps_scenario_service_grpc.pb.go

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

32 changes: 32 additions & 0 deletions interop/grpc_testing/test_grpc.pb.go

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

2 changes: 2 additions & 0 deletions interop/grpc_testing/worker_service_grpc.pb.go

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

2 changes: 2 additions & 0 deletions interop/stress/grpc_testing/metrics_grpc.pb.go

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

Loading

0 comments on commit 72c4cbb

Please sign in to comment.