Skip to content

Commit

Permalink
feat(license): improved license information
Browse files Browse the repository at this point in the history
... and readme, and looks of author listing.
Slowly getting into the flow, possibilities seem thrilling.
  • Loading branch information
Byron committed Mar 2, 2015
1 parent 3670e4f commit fc15a70
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/mako/LICENSE.md.mako
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/mako/README.md.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
<%lib:docs />
<%lib:license />
5 changes: 3 additions & 2 deletions src/mako/cargo.toml.mako
Original file line number Diff line number Diff line change
@@ -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 !
Expand All @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions src/mako/lib/lib.mako
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<%! import util %>\
<%def name="docs()">\
TODO: Library level fully fledged documentation, incuding **summary** and **usage**.
</%def>
<%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'}
</%def>
4 changes: 4 additions & 0 deletions src/mako/lib/util.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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>

<%def name="repository_url()">\
${cargo.repo_base_url}/${OUTPUT_DIR}\
</%def>
8 changes: 8 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit fc15a70

Please sign in to comment.