Skip to content

Commit 317554a

Browse files
committed
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.
1 parent fc15a70 commit 317554a

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/mako/README.md.mako

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

55
<%lib:docs />
66
<%lib:license />

src/mako/cargo.toml.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# DO NOT EDIT !
66
[package]
77
8-
name = "${name}${util.to_api_version(version)}"
8+
name = "${mutil.library_name()}"
99
version = "${cargo.build_version}"
1010
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
1111
description = "A complete library to interact with ${canonicalName} (protocol ${version})"
1212
repository = "${mutil.repository_url()}"
1313
homepage = "${documentationLink}"
1414
documentation = "${cargo.doc_base_url}"
1515
license = "${copyright.license_abbrev}"
16-
keywords = ["${name}", ${", ".join('"%s"' % k for k in cargo.keywords)}]
16+
keywords = ["${name}", ${", ".join(util.estr(cargo.keywords))}]
1717
1818
[dependencies]
1919
# Just to get hyper to work !

src/mako/lib/util.mako

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
<%! import util %>\
22
33
44
## This will only work within a substitution, not within python code
@@ -10,4 +10,8 @@ ${v[1:]}\
1010

1111
<%def name="repository_url()">\
1212
${cargo.repo_base_url}/${OUTPUT_DIR}\
13+
</%def>
14+
15+
<%def name="library_name()">\
16+
${util.library_name(name, version)}\
1317
</%def>

src/mako/lib/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def put_and(l):
2020
return l[0]
2121
return ', '.join(l[:-1]) + ' and ' + l[-1]
2222

23+
# escape each string in l with "s" and return the new list
24+
def estr(l):
25+
return ["%s" % i for i in l]
26+
2327
# build a full library name (non-canonical)
2428
def library_name(name, version):
2529
return name + to_api_version(version)

0 commit comments

Comments
 (0)