fix(test): method builder examples work now

It was easier than expected, but in the end needs quite some custom
code and handling. Good to have mako (and python !!!)
This commit is contained in:
Sebastian Thiel
2015-03-05 16:10:59 +01:00
parent 9cbb2adc5a
commit a3206abc92
5 changed files with 569 additions and 462 deletions

View File

@@ -97,6 +97,8 @@ let mut hub = YouTube::new(hyper::Client::new(), auth);
## About Customization/Callbacks
## About Optionals in parts (needed for Json, otherwise I'd happily drop them)
[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
[google-go-api]: https://github.com/google/google-api-go-client

File diff suppressed because it is too large Load Diff

View File

@@ -68,6 +68,8 @@ ${'##'} About error handling
${'##'} About Customization/Callbacks
${'##'} About Optionals in parts (needed for Json, otherwise I'd happily drop them)
[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
[google-go-api]: https://github.com/google/google-api-go-client
</%def>

View File

@@ -63,9 +63,13 @@ ${capture(lib.test_hub, hub_type_name, comments=False) | hide_rust_doc_test}
let mut ${rb_name}: ${request_value.id} = Default::default();
% for spn, sp in request_value.get('properties', dict()).iteritems():
<%
assignment = rvfrt(spn, sp)
assignment = rvfrt(spn, sp, request_value.id)
if is_string_value(assignment):
assignment = assignment + '.to_string()'
if assignment.endswith('default()'):
assignment = assignment[1:] # cut & - it's not ok in this case :)!
else:
assignment = 'Some(%s)' % assignment
%>\
## ${to_rust_type(request_value.id, spn, sp, allow_optionals=False)}
${rb_name}.${mangle_ident(spn)} = ${assignment};

View File

@@ -489,6 +489,4 @@ def rnd_arg_val_for_type(tn):
try:
return str(RUST_TYPE_RND_MAP[tn]())
except KeyError:
# be verbose to show actual type ! It's for documentation, after all, people should see what's going on
# right away without another lookup
return '&<%s as Default>::default()' % tn
return '&Default::default()'