Skip to main content
Version: Next

Code Style

Luban generates code for a language that conforms to the recommended style of the language by default, but sometimes developers want to control the generated code style. Luban There is relatively complete support for this.

Naming style

Luban has the following built-in naming styles:

Style NameDescriptionExample
noneLeave it as isaa_bb_cc => aa_bb_cc
camelFirst split the original name by '_' to get the list of atomic names, and then use Camel style to spell the final nameaa_bb_cc => aaBbCc
pascalFirst split the original name by '_' to get the list of atomic names, and then use Pascal style to spell the final nameaa_bb_cc => AaBbCc
upperJust capitalize the original nameaa_bb_cc => AA_BB_CC
snakeUnderline style, equivalent to none styleaa_bb_cc => aa_bb_cc

Nameing location

Luban can control the naming style of the following locations:

LocationDescription
namespacenamespace
typeType, including type names of enum, bean, table and manager
methodFunction, function name appearing in bean, table and manager
propertyAttributes mainly refer to the attribute names that appear in beans and tables. Not all languages support the concept of attributes, such as c++
fieldField, field name in bean
enumItemEnumeration item name, such as WRITE, READ

Code style

Code style provides a set of naming style configurations that indicate the naming style used for each naming location. For common languages, Luban provides default coding styles.

languagenamespacetypemethodpropertyfieldenumItem
nonenonenonenonenonenonenone
c#pascalpascalpascalpascalcamelnone
javapascalpascalpascalcamelcamelnone
gosnakepascalcamelcamelpascalnone
luasnakepascalcamelcamelsnakenone
typescriptpascalpascalcamelcamelcamelnone
c++snakepascalpascalpascalcamelnone
pythonsnakepascalsnakesnakesnakenone

If it is not in these language lists, the none code style is used, that is, the original name is used.

For detailed parameter introduction, please see Command Line Tools.

ParametersDescription
codeStyle
namingConvention.{codeTarget}.{location}This parameter is a hierarchical option. If {codeTarget} is not specified, it will take effect on all code targets