aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/ruby_generator.cc
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-05-20 13:27:33 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-05-20 13:27:33 -0700
commitb39ad701ea5cc215e67c460fbd5cf938431a246e (patch)
tree14754e43a671bb8b474e605a7be279c161b0c1dd /src/compiler/ruby_generator.cc
parent210f3c4b8e3088fc26e674841c7c992ef1c7d609 (diff)
Added comments to ruby code generation
Diffstat (limited to 'src/compiler/ruby_generator.cc')
-rw-r--r--src/compiler/ruby_generator.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index 936a186beb..1501c3f3e0 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -66,7 +66,9 @@ void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
std::map<grpc::string, grpc::string> method_vars =
ListToDict({"mth.name", method->name(), "input.type", input_type,
"output.type", output_type, });
+ out->Print(GetRubyComments(method, true).c_str());
out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n");
+ out->Print(GetRubyComments(method, false).c_str());
}
// Prints out the service using the ruby gRPC DSL.
@@ -82,12 +84,7 @@ void PrintService(const ServiceDescriptor *service, const grpc::string &package,
out->Print(module_vars, "module $module.name$\n");
out->Indent();
- // TODO(temiola): add documentation
- grpc::string doc = "TODO: add proto service documentation here";
- std::map<grpc::string, grpc::string> template_vars =
- ListToDict({"Documentation", doc, });
- out->Print("\n");
- out->Print(template_vars, "# $Documentation$\n");
+ out->Print(GetRubyComments(service, true).c_str());
out->Print("class Service\n");
// Write the indented class body.
@@ -113,6 +110,7 @@ void PrintService(const ServiceDescriptor *service, const grpc::string &package,
// End the service module
out->Outdent();
out->Print("end\n");
+ out->Print(GetRubyComments(service, false).c_str());
}
} // namespace
@@ -138,6 +136,12 @@ grpc::string GetServices(const FileDescriptor *file) {
out.Print(header_comment_vars,
"# Source: $file.name$ for package '$file.package$'\n");
+ grpc::string leading_comments = GetRubyComments(file, true);
+ if (!leading_comments.empty()) {
+ out.Print("# Original file comments:\n");
+ out.Print(leading_comments.c_str());
+ }
+
out.Print("\n");
out.Print("require 'grpc'\n");
// Write out require statemment to import the separately generated file
@@ -164,6 +168,8 @@ grpc::string GetServices(const FileDescriptor *file) {
out.Outdent();
out.Print("end\n");
}
+
+ out.Print(GetRubyComments(file, false).c_str());
}
return output;
}