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 Name | Description | Example |
---|---|---|
none | Leave it as is | aa_bb_cc => aa_bb_cc |
camel | First split the original name by '_' to get the list of atomic names, and then use Camel style to spell the final name | aa_bb_cc => aaBbCc |
pascal | First split the original name by '_' to get the list of atomic names, and then use Pascal style to spell the final name | aa_bb_cc => AaBbCc |
upper | Just capitalize the original name | aa_bb_cc => AA_BB_CC |
snake | Underline style, equivalent to none style | aa_bb_cc => aa_bb_cc |
Nameing location
Luban can control the naming style of the following locations:
Location | Description |
---|---|
namespace | namespace |
type | Type, including type names of enum, bean, table and manager |
method | Function, function name appearing in bean, table and manager |
property | Attributes mainly refer to the attribute names that appear in beans and tables. Not all languages support the concept of attributes, such as c++ |
field | Field, field name in bean |
enumItem | Enumeration 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.
language | namespace | type | method | property | field | enumItem |
---|---|---|---|---|---|---|
none | none | none | none | none | none | none |
c# | pascal | pascal | pascal | pascal | camel | none |
java | pascal | pascal | pascal | camel | camel | none |
go | snake | pascal | camel | camel | pascal | none |
lua | snake | pascal | camel | camel | snake | none |
typescript | pascal | pascal | camel | camel | camel | none |
c++ | snake | pascal | pascal | pascal | camel | none |
python | snake | pascal | snake | snake | snake | none |
If it is not in these language lists, the none code style is used, that is, the original name is used.
Related command line parameters
For detailed parameter introduction, please see Command Line Tools.
Parameters | Description |
---|---|
codeStyle | |
namingConvention.{codeTarget}.{location} | This parameter is a hierarchical option. If {codeTarget} is not specified, it will take effect on all code targets |