Skip to content

Commit be7d821

Browse files
committed
feat(api): api generation works once again
With the new structure, it should be easy to add CLI programs with proper dependencies accordingly.
1 parent 137ba8c commit be7d821

13 files changed

Lines changed: 77 additions & 16 deletions

File tree

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ MAKO_SRC = src/mako
1313
RUST_SRC = src/rust
1414
API_DEPS_TPL = $(MAKO_SRC)/deps.mako
1515
API_DEPS = .api.deps
16-
API_SHARED_INFO = etc/api/shared.yaml
17-
API_LIST = etc/api/
16+
API_DIR = etc/api
17+
API_SHARED_INFO = $(API_DIR)/shared.yaml
18+
TYPE_API_INFO = $(API_DIR)/type-api.yaml
19+
API_LIST = $(API_DIR)/
1820
ifdef TRAVIS
1921
API_LIST := $(API_LIST)api-list_travis.yaml
2022
else
@@ -56,8 +58,8 @@ $(MAKO_RENDER): $(PYTHON)
5658

5759
# Explicitly NOT depending on $(MAKO_LIB_FILES), as it's quite stable and now takes 'too long' thanks
5860
# to a URL get call to the google discovery service
59-
$(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(API_LIST)
60-
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(API_LIST)
61+
$(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_API_INFO) $(API_LIST)
62+
$(MAKO) -io $(API_DEPS_TPL)=$@ --var TYPE=api --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST)
6163

6264
api-deps: $(API_DEPS)
6365

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ make:
1616
templates:
1717
# all output directories are relative to the one set for the respective API
1818
- source: README.md
19-
- source: LICENSE.md
19+
- source: ../LICENSE.md
2020
- source: ../Cargo.toml
2121
- source: lib.rs
2222
output_dir: src
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
make:
2-
target_suffix: cli
2+
target_suffix: -cli
33
depends_on: api
44
templates:
5+
- source: ../LICENSE.md
6+
- source: ../Cargo.toml
57
- source: main.rs
68
output_dir: src
79
cargo:

etc/bin/mako-render

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def merge(a, b, path=None):
330330
merge(a[key], b[key], path + [str(key)])
331331
else:
332332
# overwrite leafs unconditionally !
333-
a[key] = b[key]
333+
if isinstance(a[key], list) and isinstance(b[key], list):
334+
a[key] = a[key] + b[key]
335+
else:
336+
a[key] = b[key]
334337
else:
335338
a[key] = b[key]
336339
return a

gen/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# DO NOT EDIT !
2+
# This file was generated automatically from 'src/mako/Cargo.toml.mako'
3+
# DO NOT EDIT !
4+
[package]
5+
6+
name = "google-dfareporting2"
7+
version = "0.1.1+20150223"
8+
authors = ["Sebastian Thiel <byronimo@gmail>"]
9+
description = "A complete library to interact with dfareporting (protocol v2.0)"
10+
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2"
11+
homepage = "https://developers.google.com/doubleclick-advertisers/reporting/"
12+
documentation = "http://byron.github.io/google-apis-rs/google-dfareporting2"
13+
license = "MIT"
14+
keywords = ["dfareporting", "google", "protocol", "web", "api"]
15+
16+
[dependencies]
17+
hyper = "*"
18+
mime = "*"
19+
yup-oauth2 = "*"
20+
url = "*"
21+
serde = "*"
22+
serde_macros = "*"

gen/LICENSE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!---
2+
DO NOT EDIT !
3+
This file was generated automatically from 'src/mako/LICENSE.md.mako'
4+
DO NOT EDIT !
5+
-->
6+
The MIT License (MIT)
7+
=====================
8+
9+
Copyright © `2015` `Sebastian Thiel`
10+
11+
Permission is hereby granted, free of charge, to any person
12+
obtaining a copy of this software and associated documentation
13+
files (the “Software”), to deal in the Software without
14+
restriction, including without limitation the rights to use,
15+
copy, modify, merge, publish, distribute, sublicense, and/or sell
16+
copies of the Software, and to permit persons to whom the
17+
Software is furnished to do so, subject to the following
18+
conditions:
19+
20+
The above copyright notice and this permission notice shall be
21+
included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
24+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30+
OTHER DEALINGS IN THE SOFTWARE.

src/mako/Cargo.toml.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ version = "${util.crate_version()}"
1010
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
1111
description = "A complete library to interact with ${util.canonical_name()} (protocol ${version})"
1212
repository = "${util.github_source_root_url()}"
13+
% if documentationLink is not UNDEFINED:
1314
homepage = "${documentationLink}"
15+
% endif
1416
documentation = "${cargo.doc_base_url}/${util.crate_name()}"
1517
license = "${copyright.license_abbrev}"
1618
keywords = ["${name}", ${", ".join(estr(cargo.keywords))}]

src/mako/api/README.md.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
c = new_context(schemas, resources, context.get('methods'))
44
%>\
55
<%namespace name="lib" file="lib/lib.mako"/>\
6-
<%namespace name="util" file="lib/util.mako"/>\
6+
<%namespace name="util" file="../lib/util.mako"/>\
77
<%block filter="markdown_comment">\
88
<%util:gen_info source="${self.uri}" />\
99
</%block>

src/mako/api/lib.rs.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%namespace name="lib" file="lib/lib.mako"/>\
2-
<%namespace name="util" file="lib/util.mako"/>\
2+
<%namespace name="util" file="../lib/util.mako"/>\
33
<%namespace name="rbuild" file="lib/rbuild.mako"/>\
44
<%namespace name="mbuild" file="lib/mbuild.mako"/>\
55
<%namespace name="schema" file="lib/schema.mako"/>\

src/mako/api/lib/lib.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def pretty_name(name):
1212
return ' '.join(split_camelcase_s(name).split('.'))
1313
%>\
14-
<%namespace name="util" file="util.mako"/>\
14+
<%namespace name="util" file="../../lib/util.mako"/>\
1515
<%namespace name="mbuild" file="mbuild.mako"/>\
1616

1717
## If rust-doc is True, examples will be made to work for rust doc tests. Otherwise they are set

0 commit comments

Comments
 (0)