Skip to content

Commit de40a8b

Browse files
committed
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 ;)
1 parent 614539a commit de40a8b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/mako/lib/util.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,15 @@ def extract_parts(desc):
244244
# ------------------------------------------------------------------------------
245245
## @{
246246

247+
def capitalize(s):
248+
return s[:1].upper() + s[1:]
249+
247250
# Return transformed string that could make a good type name
248251
def canonical_type_name(s):
249252
# can't use s.capitalize() as it will lower-case the remainder of the string
250-
s = s.replace(' ', '')
251-
return s[:1].upper() + s[1:]
253+
s = ''.join(capitalize(t) for t in s.split(' '))
254+
s = ''.join(capitalize(t) for t in s.split('_'))
255+
return capitalize(s)
252256

253257
def nested_type_name(sn, pn):
254258
return sn + canonical_type_name(pn)

0 commit comments

Comments
 (0)