From aadf37004ee609d940674f6f30ae4c942ba522c8 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 19 Mar 2015 11:56:18 +0100 Subject: [PATCH] docs(methods):deal with 'virtual' methods resource We assure to know about it, instead of writing nonsense about that 'methods' resources which does not actually exist. I am relatively sure to have found all the spots. Fixes #22 --- src/mako/lib/lib.mako | 20 ++++++++++++++++++++ src/mako/lib/mbuild.mako | 6 +++++- src/mako/lib/rbuild.mako | 6 +++++- src/mako/lib/schema.mako | 8 +++++--- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index 5592a0cbae..44d6cec7a2 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -57,9 +57,19 @@ The original source code can be found [on github](${cargo.repo_base_url}/tree/ma % endif # Features +% if len(c.rta_map) > 1: Handle the following *Resources* with ease from the central ${link('hub', hub_url)} ... +% elif METHODS_RESOURCE in c.rta_map: +Use the following functionality with ease from the central ${link('hub', hub_url)} ... +% else: +<% assert False, "Shouldn't be here" %> +It seems there is nothing you can do here ... . +% endif % for r in sorted(c.rta_map.keys()): +% if r == METHODS_RESOURCE: +<% continue %> +% endif ## skip method resource <% md_methods = list() for method in sorted(c.rta_map[r]): @@ -72,7 +82,17 @@ Handle the following *Resources* with ease from the central ${link('hub', hub_ur md_resource = link(md_resource, 'struct.%s.html' % singular(canonical_type_name(r))) %>\ * ${md_resource} (${put_and(md_methods)}) +% endfor ## each resource activity + +% if METHODS_RESOURCE in c.rta_map: +% if len(c.rta_map) > 1: +Other activities are ... + +% endif +% for method in sorted(c.rta_map[METHODS_RESOURCE]): +* ${link(split_camelcase_s(method), 'struct.%s.html' % mb_type(METHODS_RESOURCE, method))} % endfor +% endif % for method_type, methods in header_methods: % if methods: diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index 2040bfef15..5ac344a4de 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -9,7 +9,7 @@ hub_type_params_s, method_media_params, enclose_in, mb_type_bounds, method_response, METHOD_BUILDER_MARKERT_TRAIT, pass_through, markdown_rust_block, parts_from_params, DELEGATE_PROPERTY_NAME, struct_type_bounds_s, supports_scopes, scope_url_to_variant, - re_find_replacements, ADD_PARAM_FN, ADD_PARAM_MEDIA_EXAMPLE, upload_action_fn) + re_find_replacements, ADD_PARAM_FN, ADD_PARAM_MEDIA_EXAMPLE, upload_action_fn, METHODS_RESOURCE) def get_parts(part_prop): if not part_prop: @@ -70,7 +70,11 @@ ${m.description | rust_doc_comment} % endif /// % endif ## supports media download +% if resource == METHODS_RESOURCE: +/// A builder for the *${method}* method. +% else: /// A builder for the *${method}* method supported by a *${singular(resource)}* resource. +% endif /// It is not used directly, but through a `${rb_type(resource)}`. /// % if part_desc: diff --git a/src/mako/lib/rbuild.mako b/src/mako/lib/rbuild.mako index a5ab6a2064..8e3cefb0a7 100644 --- a/src/mako/lib/rbuild.mako +++ b/src/mako/lib/rbuild.mako @@ -5,7 +5,7 @@ activity_input_type, TREF, IO_REQUEST, schema_to_required_property, rust_copy_value_s, is_required_property, organize_params, REQUEST_VALUE_PROPERTY_NAME, build_all_params, rb_type_params_s, hub_type_params_s, mb_type_params_s, mb_additional_type_params, - struct_type_bounds_s) + struct_type_bounds_s, METHODS_RESOURCE) %>\ <%namespace name="util" file="util.mako"/>\ <%namespace name="lib" file="lib.mako"/>\ @@ -19,7 +19,11 @@ rb_params = rb_type_params_s(resource, c) ThisType = rb_type(resource) + rb_params %>\ +% if resource == METHODS_RESOURCE: +/// A builder providing access to all free methods, which are not associated with a particular resource. +% else: /// A builder providing access to all methods supported on *${singular(resource)}* resources. +% endif /// It is not used directly, but through the `${hub_type_name}` hub. /// /// # Example diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index 00a0f50582..b7b4319efc 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -1,7 +1,7 @@ <%! from util import (schema_markers, rust_doc_comment, mangle_ident, to_rust_type, put_and, 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) + NESTED_TYPE_SUFFIX, RESPONSE_MARKER_TRAIT, split_camelcase_s, METHODS_RESOURCE) default_traits = ('RustcEncodable', 'Clone', 'Default') %>\ @@ -110,9 +110,11 @@ The list links the activity name, along with information about where it is used % for a, iot in c.sta_map[s.id].iteritems(): <% category, name, method = activity_split(a) - name = name or category + name_suffix = ' ' + split_camelcase_s(name) + if name == METHODS_RESOURCE: + name_suffix = '' struct_url = 'struct.' + mb_type(name, method) + '.html' - method_name = split_camelcase_s(method) + ' ' + split_camelcase_s(name) + method_name = ' '.join(split_camelcase_s(method).split('.')) + name_suffix value_type = '|'.join(iot) or 'none' %>\ * [${method_name}](${struct_url}) (${value_type})