Discussion:
Documentation on thrift IDL is really parsed?
Gonzalo Aguilar Delgado
2017-03-24 10:44:24 UTC
Permalink
Hello,

I'm trying to make thrift spit documentation with the objects when
generating. Code.

I'm testing the HTML generation that's also quite nice already.

But something like:

/*

Comment line 2
id: test

*/
struct MvcCustomerDTO
{
/* Comment line 1*/
1 : i32 id,
2 : MvcCustomerStatusDTO mvcCustomerStatusDTO,
3 : string firstname,
4 : string lastname,
5 : i64 dateCreated,
6 : i64 dateUpdated,
7 : string fullName,
8 : string customerCode,
}



Doesn't spit anything on output. No comment for the struct and no
comment for the field.

It's nasty cause the generator has the code in to handle everything.

f_out_ << "<table class=\"table-bordered table-striped
table-condensed\">";
f_out_ <<
"<thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</"
"th><th>Default value</th></thead>" << endl;
for (; mem_iter != members.end(); mem_iter++) {
f_out_ << "<tr><td>" << (*mem_iter)->get_key() << "</td><td>";
f_out_ << (*mem_iter)->get_name();
f_out_ << "</td><td>";
print_type((*mem_iter)->get_type());
f_out_ << "</td><td>";
f_out_ << escape_html((*mem_iter)->get_doc());
f_out_ << "</td><td>";
if ((*mem_iter)->get_req() == t_field::T_OPTIONAL) {
f_out_ << "optional";
} else if ((*mem_iter)->get_req() == t_field::T_REQUIRED) {
f_out_ << "required";
} else {
f_out_ << "default";
}
f_out_ << "</td><td>";
t_const_value* default_val = (*mem_iter)->get_value();
if (default_val != NULL) {
f_out_ << "<code>";
print_const_value((*mem_iter)->get_type(), default_val);
f_out_ << "</code>";
}
f_out_ << "</td></tr>" << endl;


And the output has the field to be filled in.



Struct: MvcClientDTO

Key Field Type Description Requiredness Default value
1 id |i32|
default
2 firstname |string|
default
3 lastname |string|
default
4 status |string|
default
5 dateCreated |i64|
default
6 dateUpdated |i64|
default
7 fullName |string|
default
8 clientCode |string|
default


So I suppose it's just a matter of doing the comments right. But what's
the exact format?
Gajanan H
2017-03-24 11:35:19 UTC
Permalink
Hi,

Looks like the comments are not in the right format. You can follow the
below link for generating good looking documentation.

https://github.com/nathanmarz/thrift-dev/blob/master/test/DocTest.thrift

​Cheers
,
Gajanan

On Fri, Mar 24, 2017 at 4:14 PM, Gonzalo Aguilar Delgado <
Post by Gonzalo Aguilar Delgado
Hello,
I'm trying to make thrift spit documentation with the objects when
generating. Code.
I'm testing the HTML generation that's also quite nice already.
/*
Comment line 2
id: test
*/
struct MvcCustomerDTO
{
/* Comment line 1*/
1 : i32 id,
2 : MvcCustomerStatusDTO mvcCustomerStatusDTO,
3 : string firstname,
4 : string lastname,
5 : i64 dateCreated,
6 : i64 dateUpdated,
7 : string fullName,
8 : string customerCode,
}
Doesn't spit anything on output. No comment for the struct and no
comment for the field.
It's nasty cause the generator has the code in to handle everything.
f_out_ << "<table class=\"table-bordered table-striped
table-condensed\">";
f_out_ <<
"<thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>
Requiredness</"
"th><th>Default value</th></thead>" << endl;
for (; mem_iter != members.end(); mem_iter++) {
f_out_ << "<tr><td>" << (*mem_iter)->get_key() << "</td><td>";
f_out_ << (*mem_iter)->get_name();
f_out_ << "</td><td>";
print_type((*mem_iter)->get_type());
f_out_ << "</td><td>";
f_out_ << escape_html((*mem_iter)->get_doc());
f_out_ << "</td><td>";
if ((*mem_iter)->get_req() == t_field::T_OPTIONAL) {
f_out_ << "optional";
} else if ((*mem_iter)->get_req() == t_field::T_REQUIRED) {
f_out_ << "required";
} else {
f_out_ << "default";
}
f_out_ << "</td><td>";
t_const_value* default_val = (*mem_iter)->get_value();
if (default_val != NULL) {
f_out_ << "<code>";
print_const_value((*mem_iter)->get_type(), default_val);
f_out_ << "</code>";
}
f_out_ << "</td></tr>" << endl;
And the output has the field to be filled in.
Struct: MvcClientDTO
Key Field Type Description Requiredness Default value
1 id |i32|
default
2 firstname |string|
default
3 lastname |string|
default
4 status |string|
default
5 dateCreated |i64|
default
6 dateUpdated |i64|
default
7 fullName |string|
default
8 clientCode |string|
default
So I suppose it's just a matter of doing the comments right. But what's
the exact format?
Loading...