mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
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:
@@ -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
|
# Return transformed string that could make a good type name
|
||||||
def canonical_type_name(s):
|
def canonical_type_name(s):
|
||||||
# can't use s.capitalize() as it will lower-case the remainder of the string
|
# can't use s.capitalize() as it will lower-case the remainder of the string
|
||||||
s = s.replace(' ', '')
|
s = ''.join(capitalize(t) for t in s.split(' '))
|
||||||
return s[:1].upper() + s[1:]
|
s = ''.join(capitalize(t) for t in s.split('_'))
|
||||||
|
return capitalize(s)
|
||||||
|
|
||||||
def nested_type_name(sn, pn):
|
def nested_type_name(sn, pn):
|
||||||
return sn + canonical_type_name(pn)
|
return sn + canonical_type_name(pn)
|
||||||
|
|||||||
Reference in New Issue
Block a user