Merge branch 'master' into namespaced-items

This commit is contained in:
Sebastian Thiel
2021-01-06 21:54:15 +08:00
14 changed files with 52 additions and 43 deletions

View File

@@ -155,7 +155,7 @@ let r = hub.resource().activity(...).${api.terms.action}()
Or specifically ...
```ignore
% for an, a in c.sta_map[fr.id].iteritems():
% for an, a in c.sta_map[fr.id].items():
<% category, resource, activity = activity_split(an) %>\
let r = hub.${mangle_ident(resource)}().${mangle_ident(activity)}(...).${api.terms.action}()
% endfor

View File

@@ -11,7 +11,7 @@
DELEGATE_PROPERTY_NAME, struct_type_bounds_s, scope_url_to_variant,
re_find_replacements, ADD_PARAM_FN, ADD_PARAM_MEDIA_EXAMPLE, upload_action_fn, METHODS_RESOURCE,
method_name_to_variant, size_to_bytes, method_default_scope,
is_repeated_property, setter_fn_name, ADD_SCOPE_FN, rust_doc_sanitize)
is_repeated_property, setter_fn_name, ADD_SCOPE_FN, rust_doc_sanitize, items)
def get_parts(part_prop):
if not part_prop:
@@ -154,7 +154,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
///
/// # Additional Parameters
///
% for opn, op in list((opn, op) for (opn, op) in parameters.iteritems() if opn not in [p.name for p in params]):
% for opn, op in list((opn, op) for (opn, op) in parameters.items() if opn not in [p.name for p in params]):
/// * *${opn}* (${op.location}-${op.type}) - ${op.description}
% endfor
% endif
@@ -336,7 +336,7 @@ ${capture(lib.test_hub, hub_type_name, comments=show_all) | hide_filter}
// into the respective structure. Some of the parts shown here might not be applicable !
// ${random_value_warning}
let mut ${rb_name} = ${request_value_type}::default();
% for spn, sp in request_value.get('properties', dict()).iteritems():
% for spn, sp in items(request_value.get('properties', dict())):
% if parts is not None and spn not in parts:
<% continue %>
% endif
@@ -903,7 +903,7 @@ if enable_resource_parsing \
% for p in media_params:
${p.description | rust_doc_sanitize, rust_doc_comment, indent_all_but_first_by(1)}
///
% for item_name, item in p.info.iteritems():
% for item_name, item in p.info.items():
/// * *${split_camelcase_s(item_name)}*: ${isinstance(item, (list, tuple)) and put_and(enclose_in("'", item)) or str(item)}
% endfor
pub fn ${upload_action_fn(api.terms.upload_action, p.type.suffix)}<${mtype_param}>(self, ${p.type.arg_name}: ${mtype_param}, mime_type: mime::Mime) -> ${rtype}

View File

@@ -119,7 +119,7 @@ impl${rb_params} ${ThisType} {
% for p in optional_props:
${property(p.name)}: Default::default(),
% endfor
% for prop_key, custom_name in api.properties.iteritems():
% for prop_key, custom_name in api.properties.items():
% if prop_key == 'scopes' and not method_default_scope(m):
<% continue %>\
% endif

View File

@@ -3,7 +3,7 @@
IO_TYPES, activity_split, enclose_in, REQUEST_MARKER_TRAIT, mb_type, indent_all_but_first_by,
NESTED_TYPE_SUFFIX, RESPONSE_MARKER_TRAIT, split_camelcase_s, METHODS_RESOURCE,
PART_MARKER_TRAIT, canonical_type_name, TO_PARTS_MARKER, UNUSED_TYPE_MARKER, is_schema_with_optionals,
rust_doc_sanitize)
rust_doc_sanitize, items)
%>\
## Build a schema which must be an object
###################################################################################################################
@@ -12,7 +12,7 @@
<% struct = 'pub struct ' + s.id %>\
% if properties:
${struct} {
% for pn, p in properties.iteritems():
% for pn, p in items(properties):
${p.get('description', 'no description provided') | rust_doc_sanitize, rust_doc_comment, indent_all_but_first_by(1)}
% if pn != mangle_ident(pn):
#[serde(rename="${pn}")]
@@ -111,7 +111,7 @@ impl ${TO_PARTS_MARKER} for ${s_type} {
/// the parts you want to see in the server response.
fn to_parts(&self) -> String {
let mut r = String::new();
% for pn, p in s.properties.iteritems():
% for pn, p in items(s.properties):
<%
mn = 'self.' + mangle_ident(pn)
rt = to_rust_type(schemas, s.id, pn, p, allow_optionals=allow_optionals)
@@ -140,7 +140,7 @@ ${s.get('description', 'There is no detailed description.')}
This type is used in activities, which are methods you may call on this type or where this type is involved in.
The list links the activity name, along with information about where it is used (one of ${put_and(enclose_in('*', IO_TYPES))}).
% for a, iot in c.sta_map[s.id].iteritems():
% for a, iot in c.sta_map[s.id].items():
<%
category, name, method = activity_split(a)
name_suffix = ' ' + split_camelcase_s(name)