compiler/cpp/src/generate/t_go_generator.cc
/**
 * Generates the docstring for a struct or function.
 */
Generates the docstring for a struct or function.
Generates the docstring for a struct or function .
void t_go_generator::generate_go_docstring(ofstream& out,
                                               t_doc*    tdoc,
                                               t_struct* tstruct,
                                               const char* subheader) {
  bool has_doc = false;
  stringstream ss;
  if (tdoc->has_doc()) {
    has_doc = true;
    ss << tdoc->get_doc();
  }
  const vector<t_field*>& fields = tstruct->get_members();
  if (fields.size() > 0) {
    if (has_doc) {
      ss << endl;
    }
    has_doc = true;
    ss << subheader << ":\n";
    vector<t_field*>::const_iterator p_iter;
    for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter) {
      t_field* p = *p_iter;
      ss << " - " << publicize(variable_name_to_go_name(p->get_name()));
      if (p->has_doc()) {
        ss << ": " << p->get_doc();
      } else {
        ss << endl;
      }
    }
  }
  if (has_doc) {
    generate_docstring_comment(out,
      "/**\n",
      " * ", ss.str(),
      " */\n");
  }
}
void t_go_generator :: generate_go_docstring ( ofstream & out , t_doc * tdoc , t_struct * tstruct , const char * subheader ) { bool has_doc = false ; stringstream ss ; if ( tdoc -> has_doc ( ) ) { has_doc = true ; ss << tdoc -> get_doc ( ) ; } const vector < t_field * > & fields = tstruct -> get_members ( ) ; if ( fields . size ( ) > 0 ) { if ( has_doc ) { ss << endl ; } has_doc = true ; ss << subheader << " \n " ; vector < t_field * > :: const_iterator p_iter ; for ( p_iter = fields . begin ( ) ; p_iter != fields . end ( ) ; ++ p_iter ) { t_field * p = * p_iter ; ss << " " << publicize ( variable_name_to_go_name ( p -> get_name ( ) ) ) ; if ( p -> has_doc ( ) ) { ss << " " << p -> get_doc ( ) ; } else { ss << endl ; } } } if ( has_doc ) { generate_docstring_comment ( out , " \n " , " " , ss . str ( ) , " \n " ) ; } }
Generates the docstring for a struct or function.
Generates the docstring for a struct or function .