compiler/cpp/src/generate/t_html_generator.cc
/**
 * Generates the HTML block for a Thrift service.
 *
 * @param tservice The service definition
 */
Generates the HTML block for a Thrift service.
@param tservice The service definition
Generates the HTML block for a Thrift service . @param tservice The service definition
void t_html_generator::generate_service(t_service* tservice) {
  f_out_ << "<h3 id=\"Svc_" << service_name_ << "\">Service: "
    << service_name_ << "</h3>" << endl;
  if (tservice->get_extends()) {
    f_out_ << "<div class=\"extends\"><em>extends</em> ";
    print_type(tservice->get_extends());
    f_out_ << "</div>\n";
  }
  print_doc(tservice);
  vector<t_function*> functions = tservice->get_functions();
  vector<t_function*>::iterator fn_iter = functions.begin();
  for ( ; fn_iter != functions.end(); fn_iter++) {
    string fn_name = (*fn_iter)->get_name();
    f_out_ << "<div class=\"definition\">";
    f_out_ << "<h4 id=\"Fn_" << service_name_ << "_" << fn_name
      << "\">Function: " << service_name_ << "." << fn_name
      << "</h4>" << endl;
    f_out_ << "<pre>";
    int offset = print_type((*fn_iter)->get_returntype());
    bool first = true;
    f_out_ << " " << fn_name << "(";
    offset += fn_name.size() + 2;
    vector<t_field*> args = (*fn_iter)->get_arglist()->get_members();
    vector<t_field*>::iterator arg_iter = args.begin();
    for ( ; arg_iter != args.end(); arg_iter++) {
      if (!first) {
        f_out_ << "," << endl;
        for (int i = 0; i < offset; ++i) {
          f_out_ << " ";
        }
      }
      first = false;
      print_type((*arg_iter)->get_type());
      f_out_ << " " << (*arg_iter)->get_name();
      if ((*arg_iter)->get_value() != NULL) {
        f_out_ << " = ";
        print_const_value((*arg_iter)->get_value());
      }
    }
    f_out_ << ")" << endl;
    first = true;
    vector<t_field*> excepts = (*fn_iter)->get_xceptions()->get_members();
    vector<t_field*>::iterator ex_iter = excepts.begin();
    if (ex_iter != excepts.end()) {
      f_out_ << "    throws ";
      for ( ; ex_iter != excepts.end(); ex_iter++) {
        if (!first) {
          f_out_ << ", ";
        }
        first = false;
        print_type((*ex_iter)->get_type());
      }
      f_out_ << endl;
    }
    f_out_ << "</pre>";
    print_doc(*fn_iter);
    print_fn_args_doc(*fn_iter);
    f_out_ << "</div>";
  }
}
void t_html_generator :: generate_service ( t_service * tservice ) { f_out_ << " \" " << service_name_ << " \" " << service_name_ << " " << endl ; if ( tservice -> get_extends ( ) ) { f_out_ << " \" \" " ; print_type ( tservice -> get_extends ( ) ) ; f_out_ << " \n " ; } print_doc ( tservice ) ; vector < t_function * > functions = tservice -> get_functions ( ) ; vector < t_function * > :: iterator fn_iter = functions . begin ( ) ; for ( ; fn_iter != functions . end ( ) ; fn_iter ++ ) { string fn_name = ( * fn_iter ) -> get_name ( ) ; f_out_ << " \" \" " ; f_out_ << " \" " << service_name_ << " " << fn_name << " \" " << service_name_ << " " << fn_name << " " << endl ; f_out_ << " " ; int offset = print_type ( ( * fn_iter ) -> get_returntype ( ) ) ; bool first = true ; f_out_ << " " << fn_name << " " ; offset += fn_name . size ( ) + 2 ; vector < t_field * > args = ( * fn_iter ) -> get_arglist ( ) -> get_members ( ) ; vector < t_field * > :: iterator arg_iter = args . begin ( ) ; for ( ; arg_iter != args . end ( ) ; arg_iter ++ ) { if ( ! first ) { f_out_ << " " << endl ; for ( int i = 0 ; i < offset ; ++ i ) { f_out_ << " " ; } } first = false ; print_type ( ( * arg_iter ) -> get_type ( ) ) ; f_out_ << " " << ( * arg_iter ) -> get_name ( ) ; if ( ( * arg_iter ) -> get_value ( ) != NULL ) { f_out_ << " " ; print_const_value ( ( * arg_iter ) -> get_value ( ) ) ; } } f_out_ << " " << endl ; first = true ; vector < t_field * > excepts = ( * fn_iter ) -> get_xceptions ( ) -> get_members ( ) ; vector < t_field * > :: iterator ex_iter = excepts . begin ( ) ; if ( ex_iter != excepts . end ( ) ) { f_out_ << " " ; for ( ; ex_iter != excepts . end ( ) ; ex_iter ++ ) { if ( ! first ) { f_out_ << " " ; } first = false ; print_type ( ( * ex_iter ) -> get_type ( ) ) ; } f_out_ << endl ; } f_out_ << " " ; print_doc ( * fn_iter ) ; print_fn_args_doc ( * fn_iter ) ; f_out_ << " " ; } }
Generates the HTML block for a Thrift service.
Generates the HTML block for a Thrift service .