11<%! from util import (activity_split, put_and, md_italic, split_camelcase_s, canonical_type_name,
22 rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, markdown_rust_block,
3- unindent, indent ) % > \
3+ unindent_first_by ) % > \
44< % namespace name=" util" file =" util.mako" / > \
55
66# # If rust-doc is True, examples will be made to work for rust doc tests. Otherwise they are set
77# # for github markdown.
8- < % def name= " docs(c, rust_doc=True)" filter = " unindent" > \
8+ # ##############################################################################################
9+ # ##############################################################################################
10+ < % def name= " docs(c, rust_doc=True)" > \
911< %
1012 # fr == fattest resource, the fatter, the more important, right ?
1113 fr = None
1719 resource, activity = activity_split(an)
1820 amap.setdefault(resource, list ()).append(activity)
1921%> \
20- # Features
22+ # Features
2123
22- Handle the following *Resources* with ease ...
24+ Handle the following *Resources* with ease ...
2325
24- % for r in sorted (amap.keys()):
25- * ${ split_camelcase_s(r)} (${ put_and(md_italic(sorted (amap[r])))} )
26- % endfor
26+ % for r in sorted (amap.keys()):
27+ * ${ split_camelcase_s(r)} (${ put_and(md_italic(sorted (amap[r])))} )
28+ % endfor
2729
28- # Structure of this Library
30+ # Structure of this Library
2931
30- The API is structured into the following primary items:
32+ The API is structured into the following primary items:
3133
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*
34+ * **Hub**
35+ * a central object to maintain state and allow accessing all *Activities*
36+ * **Resources**
37+ * primary types that you can apply *Activities* to
38+ * a collection of properties and *Parts*
39+ * **Parts**
40+ * a collection of properties
41+ * never directly used in *Activities*
42+ * **Activities**
43+ * operations to apply to *Resources*
4244
43- Generally speaking, you can invoke *Activities* like this:
45+ Generally speaking, you can invoke *Activities* like this:
4446
45- ```Rust,ignore
46- let r = hub.resource().activity(...).${ api.terms.action} ()
47- ```
47+ ```Rust,ignore
48+ let r = hub.resource().activity(...).${ api.terms.action} ()
49+ ```
4850
49- Or specifically ...
51+ Or specifically ...
5052
51- ```ignore
53+ ```ignore
5254% for an, a in c.sta_map[fr.id].iteritems():
5355<% resource, activity = activity_split(an) %> \
54- let r = hub.${ resource} ().${ activity} (...).${ api.terms.action} ()
56+ let r = hub.${ resource} ().${ activity} (...).${ api.terms.action} ()
5557% endfor
56- ```
58+ ```
59+
60+ The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
61+ supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
62+ specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
63+ The `${ api.terms.action} ()` method performs the actual communication with the server and returns the respective result.
5764
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.
65+ # Usage (*TODO*)
6266
63- # Usage (*TODO*)
67+ ${ ' ## ' } Instantiating the Hub
6468
65- ${ ' ## ' } Instantiating the Hub
69+ ${ self .hub_usage_example(rust_doc) } \
6670
67- ${ self .hub_usage_example(rust_doc) | indent } \
71+ **TODO** Example calls - there should soon be a generator able to do that with proper inputs
6872
69- **TODO** Example calls - there should soon be a generator able to do that with proper inputs
70- ${ ' ##' } About error handling
73+ ${ ' ##' } About error handling
7174
72- ${ ' ##' } About Customization/Callbacks
75+ ${ ' ##' } About Customization/Callbacks
7376
74- [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
75- [google-go-api]: https://github.com/google/google-api-go-client
77+ [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
78+ [google-go-api]: https://github.com/google/google-api-go-client
7679</%def>
7780
7881## Sets up a hub ready for use. You must wrap it into a test function for it to work
7982## Needs test_prelude.
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);\
83+ ###############################################################################################
84+ ###############################################################################################
85+ <%def name = "test_hub(hub_type ) "> \
86+ use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
87+ use std::default::Default;
88+
89+ use ${ util.library_name()} ::${ hub_type} ;
90+
91+ // Get an ApplicationSecret instance by some means. It contains the `client_id` and `client_secret`,
92+ // among other things.
93+ let secret: ApplicationSecret = Default::default();
94+ // Instantiate the authenticator. It will choose a suitable authentication flow for you,
95+ // unless you replace `None` with the desired Flow
96+ // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about what's going on
97+ // You probably want to bring in your own `TokenStorage` to persist tokens and retrieve them from storage.
98+ let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
99+ hyper::Client::new(),
100+ <MemoryStorage as Default >::default(), None);
101+ let mut hub = ${ hub_type} ::new(hyper::Client::new(), auth);\
97102</%def >
98103
99104## You will still have to set the filter for your comment type - either nothing, or rust_doc_comment !
105+ ###############################################################################################
106+ ###############################################################################################
100107<%def name = "hub_usage_example(rust_doc = True) "> \
101108<%
102109 test_filter = rust_test_fn_invisible
@@ -114,11 +121,13 @@ ${self.test_hub(canonical_type_name(canonicalName))}\
114121</%block >
115122</%def >
116123
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].
124+ ###############################################################################################
125+ ###############################################################################################
126+ <%def name = "license() "> \
127+ # License
128+ The **${ util.library_name()} ** library was generated by ${ put_and(copyright .authors)} , and is placed
129+ under the *${ copyright .license_abbrev} * license.
130+ You can read the full text at the repository's [license file][repo-license].
122131
123- [repo-license]: ${ cargo.repo_base_url + ' LICENSE.md' }
132+ [repo-license]: ${ cargo.repo_base_url + ' LICENSE.md' }
124133</%def >
0 commit comments