Skip to content

Commit be93825

Browse files
committed
feat(mako): cargo.toml template
It's quite final, and super easy to change and to read. It seems we want to use namespaces/shared implementations soon to allow using defs. In our case, we transform the version in a particular way, which is easy enough, yet I'd like to use it to make the system more powerful.
1 parent 2d77857 commit be93825

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

etc/api/shared.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Contains values shared among all API implementations
22
directories:
33
# directory under which all generated sources should reside
4-
output: ./generated
4+
output: generated
55
# how to get from `output` back to common library
66
common: ../
77
# where are all the API meta files
8-
api_base: ./etc/api
8+
api_base: etc/api
99
# all mako source files
10-
mako_src: ./src/mako
10+
mako_src: src/mako
1111
api:
1212
list:
1313
- name: youtube
@@ -19,8 +19,10 @@ api:
1919
# output_dir: optional - not there if unset
2020
cargo:
2121
build_version: "0.0.1"
22+
repo_base_url: https://github.com/Byron/youtube-rs
23+
doc_base_url: http://byron.github.io/youtube-rs
2224
authors:
2325
- Sebastian Thiel <byronimo@gmail>
24-
keywords: [google, protocol]
26+
keywords: [google, protocol, web, api]
2527
# All APIs should live in the same repository
2628
repository_url: https://github.com/Byron/youtube-rs

src/mako/cargo.toml.mako

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[package]
22

3-
name = "youtube3-dev"
4-
version = "0.0.1"
5-
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
6-
description = "A library to facilitate interacting with your youtube account"
7-
repository = "https://github.com/Byron/youtube-rs"
3+
name = "${name}${version[1:]}"
4+
version = "${cargo.build_version}"
5+
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
6+
description = "A library to interact with ${canonicalName} (protocol ${version})"
7+
repository = "${cargo.repo_base_url}/${OUTPUT_DIR}"
8+
homepage = "${documentationLink}"
9+
documentation = "${cargo.doc_base_url}"
810
license = "MIT"
9-
keywords = ["youtube", "google", "protocol"]
11+
keywords = ["${name}", ${", ".join('"%s"' % k for k in cargo.keywords)}]
1012

1113
[dependencies]
1214
# Just to get hyper to work !

src/mako/deps.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<%api_info=[]%>\
66
% for a in api.list:
77
<%
8-
gen_root = directories.output + '/' + a.name + '_' + a.version
8+
gen_root = directories.output + '/' + a.name + a.version[1:]
99
api_name = a.name + a.version
1010
api_clean = api_name + '-clean'
1111
# source, destination
@@ -17,7 +17,7 @@
1717
%>\
1818
${gen_root}: ${' '.join(i[0] for i in sds)} ${api_json_inputs}
1919
@mkdir -p $@
20-
$(TPL) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
20+
$(TPL) --var OUTPUT_DIR=$@ -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
2121
2222
${api_name}: ${gen_root}
2323

0 commit comments

Comments
 (0)