Skip to content

Commit 3670e4f

Browse files
committed
feat(mako): LICENSE + README.md
Readme is very initial, but the architecture is set to evolve it to something no less than beatiful.
1 parent 4e5f2c0 commit 3670e4f

8 files changed

Lines changed: 64 additions & 13 deletions

File tree

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: json-to-xml clean help api-deps rebuild-apis
1+
.PHONY: json-to-xml clean help api-deps rebuild-apis license
22
.SUFFIXES:
33

44
include Makefile.helpers
@@ -7,14 +7,14 @@ VENV := virtualenv
77
VENV_DIR := .pyenv
88
PYTHON := $(VENV_DIR)/bin/python
99
PIP := $(VENV_DIR)/bin/pip
10-
MAKO_RENDER := ./etc/bin/mako-render
10+
MAKO_RENDER := etc/bin/mako-render
1111
TPL := $(PYTHON) $(MAKO_RENDER)
1212

1313
MAKO_SRC = src/mako
1414
API_DEPS_TPL = $(MAKO_SRC)/deps.mako
1515
API_DEPS = .api.deps
16-
API_SHARED_INFO = ./etc/api/shared.yaml
17-
API_JSON_FILES = $(shell find ./etc -type f -name '*-api.json')
16+
API_SHARED_INFO = etc/api/shared.yaml
17+
API_JSON_FILES = $(shell find etc -type f -name '*-api.json')
1818
MAKO_LIB_DIR = $(MAKO_SRC)/lib
1919
MAKO_LIB_FILES = $(shell find $(MAKO_LIB_DIR) -type f -name '*.mako' -or -name '*.py')
2020

@@ -26,6 +26,7 @@ help:
2626
$(info api-deps - generate a file to tell make what API file dependencies will be)
2727
$(info rebuild-apis - clear out all generated apis, and regenerate them)
2828
$(info help-api - show all api targets to build individually)
29+
$(info license - regenerate the main license file)
2930

3031
$(PYTHON):
3132
virtualenv $(VENV_DIR)
@@ -40,6 +41,11 @@ api-deps: $(API_DEPS)
4041

4142
include $(API_DEPS)
4243

44+
LICENSE.md: $(MAKO_SRC)/LICENSE.md.mako $(API_SHARED_INFO)
45+
$(TPL) -io $<=$@ --data-files $(API_SHARED_INFO)
46+
47+
license: LICENSE.md
48+
4349
rebuild-apis: clean-apis apis
4450

4551
clean: clean-apis

etc/api/shared.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ api:
1616
templates:
1717
# all output directories are relative to the one set for the respective API
1818
- source: README.md
19+
- source: LICENSE.md
1920
- source: cargo.toml
2021
# output_dir: optional - not there if unset
2122
cargo:
2223
build_version: "0.0.1"
2324
repo_base_url: https://github.com/Byron/google-apis-rs
2425
doc_base_url: http://byron.github.io/google-apis-rs
2526
authors:
27+
# don't forget to possibly add them to copyright authors
2628
- Sebastian Thiel <byronimo@gmail>
2729
keywords: [google, protocol, web, api]
2830
# All APIs should live in the same repository
2931
repository_url: https://github.com/Byron/google-apis-rs
32+
33+
copyright:
34+
# should at some point be 2015-2016 ...
35+
years: '2015'
36+
authors:
37+
- 'Sebastian Thiel'

etc/bin/mako-render

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,14 @@ def cmdline(argv=None):
308308
try:
309309
result = template.render(**data_converted)
310310
if output_file:
311-
if not os.path.isdir(dirname(output_file)):
312-
os.makedirs(dirname(output_file))
311+
dir = dirname(output_file)
312+
if dir and not os.path.isdir(dir):
313+
os.makedirs(dir)
313314
fh = open(output_file, "wb")
314-
fh.write(result)
315+
fh.write(result.encode('utf-8'))
315316
fh.close()
316317
else:
317-
print(result)
318+
print(result.encode('utf-8'))
318319
except:
319320
_exit()
320321
# end for each input file

src/mako/LICENSE.md.mako

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

src/mako/README.md.mako

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%! import util %>\
2+
<%namespace name="lib" file="lib/lib.mako"/>\
3+
The `${util.library_name(name, version)}` library allows access to all features of *${canonicalName}*.
4+
5+
<%lib:docs />

src/mako/deps.mako

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# DO NOT EDIT !
22
# This file was generated automatically by '${self.uri}'
33
# DO NOT EDIT !
4-
## ${util.to_api_version('v3')}
5-
## here <%util:to_api_version v="v3"/>
4+
65
<%api_info=[]%>\
76
% for a in api.list:
87
<%
98
import util
10-
version = util.to_api_version(a.version)
11-
gen_root = directories.output + '/' + a.name + version
12-
api_name = a.name + version
9+
gen_root = directories.output + '/' + a.name + util.to_api_version(a.version)
10+
api_name = util.library_name(a.name, a.version)
1311
api_clean = api_name + '-clean'
1412
# source, destination of individual output files
1513
sds = [(directories.mako_src + '/' + i.source + '.mako', gen_root + i.get('output_dir', '') + '/' + i.source)

src/mako/lib/lib.mako

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%def name="docs()">\
2+
TODO: Library level fully fledged documentation, incuding **summary** and **usage**.
3+
</%def>

src/mako/lib/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ def rdc(s):
1111
def to_api_version(v):
1212
assert len(v) >= 2 and v[0] == 'v'
1313
return v[1:]
14+
15+
# build a full library name (non-canonical)
16+
def library_name(name, version):
17+
return name + to_api_version(version)

0 commit comments

Comments
 (0)