diff --git a/Makefile b/Makefile index f1e22452ded..b2cf58591aa 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ LICENSE.md: $(MAKO_SRC)/LICENSE.md.mako $(API_SHARED_INFO) license: LICENSE.md -rebuild-apis: clean-apis apis +rebuild-apis: clean-apis apis license clean: clean-apis -rm -Rf $(VENV_DIR) diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index e82eb9e6387..6c45081ad4a 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -31,6 +31,7 @@ cargo: repository_url: https://github.com/Byron/google-apis-rs copyright: + license_abbrev: "MIT" # should at some point be 2015-2016 ... years: '2015' authors: diff --git a/src/mako/LICENSE.md.mako b/src/mako/LICENSE.md.mako index 85eee7a8812..cd85776bb8f 100644 --- a/src/mako/LICENSE.md.mako +++ b/src/mako/LICENSE.md.mako @@ -1,8 +1,9 @@ ## -*- coding: utf-8 -*- +<%! import util %>\ The MIT License (MIT) ===================== -Copyright © `${copyright.years}` ${', '.join("`%s`" % a for a in copyright.authors)} +Copyright © `${copyright.years}` ${util.put_and(["`%s`" % a for a in copyright.authors])} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/src/mako/README.md.mako b/src/mako/README.md.mako index 81758ca48a7..4b4fe66bcf6 100644 --- a/src/mako/README.md.mako +++ b/src/mako/README.md.mako @@ -2,4 +2,5 @@ <%namespace name="lib" file="lib/lib.mako"/>\ The `${util.library_name(name, version)}` library allows access to all features of *${canonicalName}*. -<%lib:docs /> \ No newline at end of file +<%lib:docs /> +<%lib:license /> \ No newline at end of file diff --git a/src/mako/cargo.toml.mako b/src/mako/cargo.toml.mako index 0e0f11587f0..055d73f033d 100644 --- a/src/mako/cargo.toml.mako +++ b/src/mako/cargo.toml.mako @@ -1,4 +1,5 @@ <%! import util %>\ +<%namespace name="mutil" file="lib/util.mako"/>\ # DO NOT EDIT ! # This file was generated automatically by '${self.uri}' # DO NOT EDIT ! @@ -8,10 +9,10 @@ name = "${name}${util.to_api_version(version)}" version = "${cargo.build_version}" authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}] description = "A complete library to interact with ${canonicalName} (protocol ${version})" -repository = "${cargo.repo_base_url}/${OUTPUT_DIR}" +repository = "${mutil.repository_url()}" homepage = "${documentationLink}" documentation = "${cargo.doc_base_url}" -license = "MIT" +license = "${copyright.license_abbrev}" keywords = ["${name}", ${", ".join('"%s"' % k for k in cargo.keywords)}] [dependencies] diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index 788120fea4e..b0860afdd26 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -1,3 +1,13 @@ +<%! import util %>\ <%def name="docs()">\ TODO: Library level fully fledged documentation, incuding **summary** and **usage**. + + +<%def name="license()">\ +# License +The **${util.library_name(name, version)}** library was generated by ${util.put_and(copyright.authors)}, and is placed +under the *${copyright.license_abbrev}* license. +You can read the full text at the repository's [license file][repo-license]. + +[repo-license]: ${cargo.repo_base_url + 'LICENSE.md'} \ No newline at end of file diff --git a/src/mako/lib/util.mako b/src/mako/lib/util.mako index be499f38c5c..8b0d22c2070 100644 --- a/src/mako/lib/util.mako +++ b/src/mako/lib/util.mako @@ -6,4 +6,8 @@ <% assert len(v) >= 2 and v[0] == 'v'%>\ ## convert it once to int, just to be sure it is an int ${v[1:]}\ + + +<%def name="repository_url()">\ +${cargo.repo_base_url}/${OUTPUT_DIR}\ \ No newline at end of file diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index a069146c982..70090c40825 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -12,6 +12,14 @@ def to_api_version(v): assert len(v) >= 2 and v[0] == 'v' return v[1:] +# l must be a list, if it is more than one, 'and' will before last item +# l will also be coma-separtated +# Returns string +def put_and(l): + if len(l) < 2: + return l[0] + return ', '.join(l[:-1]) + ' and ' + l[-1] + # build a full library name (non-canonical) def library_name(name, version): return name + to_api_version(version)