fix(typename): improved camelCasing

Previously, it was possible to get types like Foo_bar, which is not
desireable.
Now it is totally impossible to see such blasphemy ;)
This commit is contained in:
Sebastian Thiel
2015-03-11 15:41:49 +01:00
parent 614539a925
commit de40a8bd1e

View File

@@ -244,11 +244,15 @@ def extract_parts(desc):
# ------------------------------------------------------------------------------
## @{
def capitalize(s):
return s[:1].upper() + s[1:]
# Return transformed string that could make a good type name
def canonical_type_name(s):
# can't use s.capitalize() as it will lower-case the remainder of the string
s = s.replace(' ', '')
return s[:1].upper() + s[1:]
s = ''.join(capitalize(t) for t in s.split(' '))
s = ''.join(capitalize(t) for t in s.split('_'))
return capitalize(s)
def nested_type_name(sn, pn):
return sn + canonical_type_name(pn)