Author: kclark
Date: Thu Oct 30 17:32:25 2008
New Revision: 709309
URL: http://svn.apache.org/viewvc?rev=709309&view=rev
Log:
rb: Add docstrings to generated ruby code [THRIFT-147]
Author: Bryan Duxbury
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc?rev=709309&r1=709308&r2=709309&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc Thu Oct
30 17:32:25 2008
@@ -136,6 +136,9 @@
t_list* tlist,
std::string iter);
+ void generate_rdoc (std::ofstream& out,
+ t_doc* tdoc);
+
/**
* Helper rendering functions
*/
@@ -443,11 +446,12 @@
* Generates a ruby struct
*/
void t_rb_generator::generate_rb_struct(std::ofstream& out, t_struct* tstruct,
bool is_exception = false) {
+ generate_rdoc(out, tstruct);
indent(out) << "class " << type_name(tstruct);
if (is_exception) {
out << " < StandardError";
}
- out << endl;
+ out << endl;
indent_up();
indent(out) << "include Thrift::Struct" << endl;
@@ -524,6 +528,9 @@
out << "," << endl;
}
+ // generate the field docstrings within the FIELDS constant. no real
better place...
+ generate_rdoc(out, *f_iter);
+
indent(out) <<
upcase_string((*f_iter)->get_name()) << " => ";
@@ -1013,4 +1020,11 @@
}
+void t_rb_generator::generate_rdoc(std::ofstream& out, t_doc* tdoc) {
+ if (tdoc->has_doc()) {
+ generate_docstring_comment(out,
+ "", "# ", tdoc->get_doc(), "");
+ }
+}
+
THRIFT_REGISTER_GENERATOR(rb, "Ruby", "");