11<%! from util import (activity_split, put_and, md_italic, split_camelcase_s, canonical_type_name,
2- rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, markdown_rust_block) % > \
2+ rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, markdown_rust_block,
3+ unindent, indent) % > \
34< % namespace name=" util" file =" util.mako" / > \
45
56# # If rust-doc is True, examples will be made to work for rust doc tests. Otherwise they are set
67# # for github markdown.
7- < % def name= " docs(c, rust_doc=True)" > \
8+ < % def name= " docs(c, rust_doc=True)" filter = " unindent " > \
89< %
910 # fr == fattest resource, the fatter, the more important, right ?
1011 fr = None
1617 resource, activity = activity_split(an)
1718 amap.setdefault(resource, list ()).append(activity)
1819%> \
19- # Features
20+ # Features
2021
21- Handle the following *Resources* with ease ...
22+ Handle the following *Resources* with ease ...
2223
23- % for r in sorted (amap.keys()):
24- * ${ split_camelcase_s(r)} (${ put_and(md_italic(sorted (amap[r])))} )
25- % endfor
24+ % for r in sorted (amap.keys()):
25+ * ${ split_camelcase_s(r)} (${ put_and(md_italic(sorted (amap[r])))} )
26+ % endfor
2627
27- # Structure of this Library
28+ # Structure of this Library
2829
29- The API is structured into the following primary items:
30+ The API is structured into the following primary items:
3031
31- * **Hub**
32- * a central object to maintain state and allow accessing all *Activities*
33- * **Resources**
34- * primary types that you can apply *Activities* to
35- * a collection of properties and *Parts*
36- * **Parts**
37- * a collection of properties
38- * never directly used in *Activities*
39- * **Activities**
40- * operations to apply to *Resources*
32+ * **Hub**
33+ * a central object to maintain state and allow accessing all *Activities*
34+ * **Resources**
35+ * primary types that you can apply *Activities* to
36+ * a collection of properties and *Parts*
37+ * **Parts**
38+ * a collection of properties
39+ * never directly used in *Activities*
40+ * **Activities**
41+ * operations to apply to *Resources*
4142
42- Generally speaking, you can invoke *Activities* like this:
43+ Generally speaking, you can invoke *Activities* like this:
4344
44- ```Rust,ignore
45- let r = hub.resource().activity(...).${ api.terms.action} ()
46- ```
45+ ```Rust,ignore
46+ let r = hub.resource().activity(...).${ api.terms.action} ()
47+ ```
4748
48- Or specifically ...
49+ Or specifically ...
4950
50- ```ignore
51+ ```ignore
5152% for an, a in c.sta_map[fr.id].iteritems():
52- <%
53- resource, activity = activity_split(an)
54- %> \
55- let r = hub.${ resource} ().${ activity} (...).${ api.terms.action} ()
53+ <% resource, activity = activity_split(an) %> \
54+ let r = hub.${ resource} ().${ activity} (...).${ api.terms.action} ()
5655% endfor
57- ```
58-
59- The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
60- supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
61- specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
62- The `${ api.terms.action} ()` method performs the actual communication with the server and returns the respective result.
56+ ```
6357
64- # Usage (*TODO*)
58+ The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
59+ supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
60+ specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
61+ The `${ api.terms.action} ()` method performs the actual communication with the server and returns the respective result.
6562
66- ${ ' ## ' } Instantiating the Hub
63+ # Usage (*TODO*)
6764
68- ${ self .hub_usage_example(rust_doc) } \
65+ ${ ' ## ' } Instantiating the Hub
6966
70- **TODO** Example calls - there should soon be a generator able to do that with proper inputs
71- ${ ' ##' } About error handling
67+ ${ self .hub_usage_example(rust_doc) | indent} \
7268
73- ${ ' ##' } About Customization/Callbacks
69+ **TODO** Example calls - there should soon be a generator able to do that with proper inputs
70+ ${ ' ##' } About error handling
7471
75- [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
76- [google-go-api]: https://github.com/google/google-api-go-client
72+ ${ ' ##' } About Customization/Callbacks
7773
74+ [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
75+ [google-go-api]: https://github.com/google/google-api-go-client
7876</%def>
7977
8078## Sets up a hub ready for use. You must wrap it into a test function for it to work
8179## Needs test_prelude.
82- <%def name = "test_hub(hub_type ) "> \
83- use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
84- use std::default::Default;
85-
86- use ${ util.library_name()} ::${ hub_type} ;
87-
88- // Get an ApplicationSecret instance by some means. It contains the `client_id` and `client_secret`,
89- // among other things.
90- let secret: ApplicationSecret = Default::default();
91- // Instantiate the authenticator. It will choose a suitable authentication flow for you,
92- // unless you replace `None` with the desired Flow
93- // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about what's going on
94- // You probably want to bring in your own `TokenStorage` to persist tokens and retrieve them from storage.
95- let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
96- hyper::Client::new(),
97- <MemoryStorage as Default >::default(), None);
98- let mut hub = ${ hub_type} ::new(hyper::Client::new(), auth);\
80+ <%def name = "test_hub(hub_type ) " filter = " unindent " > \
81+ use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
82+ use std::default::Default;
83+
84+ use ${ util.library_name()} ::${ hub_type} ;
85+
86+ // Get an ApplicationSecret instance by some means. It contains the `client_id` and `client_secret`,
87+ // among other things.
88+ let secret: ApplicationSecret = Default::default();
89+ // Instantiate the authenticator. It will choose a suitable authentication flow for you,
90+ // unless you replace `None` with the desired Flow
91+ // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about what's going on
92+ // You probably want to bring in your own `TokenStorage` to persist tokens and retrieve them from storage.
93+ let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
94+ hyper::Client::new(),
95+ <MemoryStorage as Default >::default(), None);
96+ let mut hub = ${ hub_type} ::new(hyper::Client::new(), auth);\
9997</%def >
10098
10199## You will still have to set the filter for your comment type - either nothing, or rust_doc_comment !
@@ -116,11 +114,11 @@ ${self.test_hub(canonical_type_name(canonicalName))}\
116114</%block >
117115</%def >
118116
119- <%def name = "license() "> \
120- # License
121- The **${ util.library_name()} ** library was generated by ${ put_and(copyright .authors)} , and is placed
122- under the *${ copyright .license_abbrev} * license.
123- You can read the full text at the repository's [license file][repo-license].
117+ <%def name = "license() " filter = " unindent " > \
118+ # License
119+ The **${ util.library_name()} ** library was generated by ${ put_and(copyright .authors)} , and is placed
120+ under the *${ copyright .license_abbrev} * license.
121+ You can read the full text at the repository's [license file][repo-license].
124122
125- [repo-license]: ${ cargo.repo_base_url + ' LICENSE.md' }
123+ [repo-license]: ${ cargo.repo_base_url + ' LICENSE.md' }
126124</%def >
0 commit comments