fix(cosmetics): nicer code and identifiers

This commit is contained in:
Sebastian Thiel
2015-03-11 11:26:22 +01:00
parent 54540e695a
commit 9b308bb6dd
3 changed files with 7 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ Handle the following *Resources* with ease ...
md_methods = list()
for method in sorted(c.rta_map[r]):
if rust_doc:
md_methods.append("[*%s*](struct.%s.html)" % (method, mb_type(r, method)))
md_methods.append("[*%s*](struct.%s.html)" % (' '.join(n.lower() for n in reversed(method.split('.'))), mb_type(r, method)))
else:
# TODO: link to final destination, possibly just have one for all ...
md_methods.append("*%s*" % method)

View File

@@ -67,6 +67,10 @@ impl${rb_params} ${ThisType} {
# we would could have information about data requirements for each property in it's dict.
# for now, we just hardcode it, and treat the entries as way to easily change param names
assert len(api.properties) == 2, "Hardcoded for now, thanks to scope requirements"
type_params = ''
if mb_additional_type_params(m):
type_params = '<%s>' % ', '.join(mb_additional_type_params(m))
%>\
% if 'description' in m:
@@ -74,7 +78,7 @@ impl${rb_params} ${ThisType} {
///
${m.description | rust_doc_comment, indent_all_but_first_by(1)}
% endif
pub fn ${mangle_ident(a)}<${', '.join(mb_additional_type_params(m))}>(&self${method_args}) -> ${RType}${mb_tparams} {
pub fn ${mangle_ident(a)}${type_params}(&self${method_args}) -> ${RType}${mb_tparams} {
${RType} {
hub: self.hub,
% for p in required_props:

View File

@@ -254,7 +254,7 @@ def nested_type_name(sn, pn):
# Make properties which are reserved keywords usable
def mangle_ident(n):
n = camel_to_under(n).replace('-', '.').replace('.', '').replace('$', '')
n = camel_to_under(n).replace('-', '.').replace('.', '_').replace('$', '')
if n in RESERVED_WORDS:
return n + '_'
return n