fix(mako): unify generated constants

like library-name. That way, they are always the same, even if I
change my mind.

Good coding style is easy, using the current setup.
This commit is contained in:
Sebastian Thiel
2015-03-02 15:31:53 +01:00
parent fc15a7030f
commit 317554aff3
4 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
<%! import util %>\
<%namespace name="lib" file="lib/lib.mako"/>\
The `${util.library_name(name, version)}` library allows access to all features of *${canonicalName}*.
<%namespace name="util" file="lib/util.mako"/>\
The `${util.library_name()}` library allows access to all features of *${canonicalName}*.
<%lib:docs />
<%lib:license />

View File

@@ -5,7 +5,7 @@
# DO NOT EDIT !
[package]
name = "${name}${util.to_api_version(version)}"
name = "${mutil.library_name()}"
version = "${cargo.build_version}"
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
description = "A complete library to interact with ${canonicalName} (protocol ${version})"
@@ -13,7 +13,7 @@ repository = "${mutil.repository_url()}"
homepage = "${documentationLink}"
documentation = "${cargo.doc_base_url}"
license = "${copyright.license_abbrev}"
keywords = ["${name}", ${", ".join('"%s"' % k for k in cargo.keywords)}]
keywords = ["${name}", ${", ".join(util.estr(cargo.keywords))}]
[dependencies]
# Just to get hyper to work !

View File

@@ -1,4 +1,4 @@
<%! import util %>\
## This will only work within a substitution, not within python code
@@ -10,4 +10,8 @@ ${v[1:]}\
<%def name="repository_url()">\
${cargo.repo_base_url}/${OUTPUT_DIR}\
</%def>
<%def name="library_name()">\
${util.library_name(name, version)}\
</%def>

View File

@@ -20,6 +20,10 @@ def put_and(l):
return l[0]
return ', '.join(l[:-1]) + ' and ' + l[-1]
# escape each string in l with "s" and return the new list
def estr(l):
return ["%s" % i for i in l]
# build a full library name (non-canonical)
def library_name(name, version):
return name + to_api_version(version)