Skip to content

Commit f125403

Browse files
committed
更新文档
1 parent fffd0ad commit f125403

File tree

6 files changed

+1149
-41
lines changed

6 files changed

+1149
-41
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
## 文档
2626

2727
* [格式化行为介绍](docs/format_action.md)
28-
* [如何配置格式化](docs/old_version_doc/format_config.md)
29-
* [代码诊断配置](docs/old_version_doc/diagnosis_config.md)
28+
* [如何配置格式化](docs/format_config.md)
3029

3130
# Contribute
3231

README_EN.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@ In addition to providing language service examples, the project also provides an
1919
* Can be used as a lua library/cli tool/C++ parsing lua library/language server
2020

2121
## RoadMap
22-
* reimplement range formatting[0%]
23-
* reimplement type formatting[0%]
2422
* plugin[0%]
2523

2624
## Document
27-
* [Usage](docs/usage_EN.md)
28-
* [Introduction to formatting behavior](docs/old_version_doc/format_action_EN.md)
29-
* [How to configure formatting](docs/old_version_doc/format_config_EN.md)
30-
* [Code diagnosis configuration](docs/old_version_doc/diagnosis_config_EN.md)
31-
* [Disable format](docs/old_version_doc/disable_format_EN.md)
32-
* [auto import configuration](docs/old_version_doc/auto_import_config_EN.md)
25+
26+
* [Introduction to formatting behavior](docs/format_action_EN.md)
27+
* [How to configure formatting](docs/format_config_EN.md)
3328
## Contribute
3429
Any pr or issue are welcome
3530

@@ -53,6 +48,9 @@ cmake --build .
5348

5449
**Contributors**
5550

51+
[**@obszczymucha**](https://github.com/obszczymucha)
52+
53+
[**@Rainer Poisel**](https://github.com/rpoisel)
5654

5755
## License
5856

docs/format_action.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
该格式化工具具有高度可配置,可支持简单扩展语法,风格多样,性能卓绝等特点。适用于格式化配置文件, 格式化大型代码库等。适合项目内统一代码风格,或者具有特别的喜好个人开发者。
44

5-
格式化结果符合基本审美,格式化效果出众,格式化速度一骑绝尘。
6-
75
## 基本格式化
86

9-
代码的基本格式化主要是为符号两边增设基本的空白,为语句块实现正确的缩进,为不同语句之间设定合适的间距。
7+
代码的基本格式化原则主要是为符号两边增设基本的空白,为语句块实现正确的缩进,为不同语句之间设定合适的间距,保持token在顺序位置上不会改变,清理行尾多余的空白
108

119
```lua
1210
local t=123 --local
@@ -48,7 +46,7 @@ end
4846

4947
## 对齐
5048

51-
代码对齐也是很重要的需求,连续赋值语句,连续的键值对表项,连续的数组类表都可以对齐
49+
在基本需求之上格式化工具提供对进阶的审美需求的满足,代码对齐是很重要的组成部分。
5250

5351
```lua
5452
local ttt = 123 --first
@@ -85,30 +83,3 @@ local c = {
8583
{ 1, 2, 3 }
8684
}
8785
```
88-
89-
## if语句对齐
90-
91-
lua没有switch语句,一般都是通过if/elseif做一个匹配列表,如果喜欢的话可以设置类似于switch-case的对齐方式。
92-
93-
```lua
94-
if aa.isDDDD()
95-
and bb == fwfwfw
96-
or hi == 123 then
97-
print(1313)
98-
elseif cc == 123
99-
or dd == 13131 and ddd == 123 then
100-
local ccc = 123
101-
end
102-
```
103-
104-
会被格式化为:
105-
```lua
106-
if aa.isDDDD()
107-
and bb == fwfwfw
108-
or hi == 123 then
109-
print(1313)
110-
elseif cc == 123
111-
or dd == 13131 and ddd == 123 then
112-
local ccc = 123
113-
end
114-
```

docs/format_action_EN.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Introduction to formatting behavior
2+
3+
The formatter is highly configurable, supports simple extended syntax, has a variety of styles, and is extremely performant. Suitable for formatting configuration files, formatting large code bases, etc. Suitable for a unified code style within the project, or individual developers with special preferences.
4+
5+
## Basic formatting
6+
7+
The basic formatting principle of the code is mainly to add basic whitespace on both sides of the symbol, achieve correct indentation for the statement block, set the appropriate spacing between different statements, keep the token in the sequential position will not change, and clean up the excess space at the end of the line.
8+
9+
```lua
10+
local t=123 --local
11+
aaa,bbbb = 1123, 2342
12+
local f =function() end
13+
local d = {
14+
-- comment
15+
aa = 213, --comment
16+
};
17+
local e = a+b+c+d
18+
function fff(a,b,c) end
19+
function ff2()
20+
--[[
21+
long comment
22+
]]
23+
end
24+
```
25+
26+
will be formatted as:
27+
```lua
28+
local t = 123 --local
29+
aaa, bbbb = 1123, 2342
30+
local f = function()
31+
end
32+
local d = {
33+
-- comment
34+
aa = 213, --comment
35+
};
36+
local e = a + b + c + d
37+
function fff(a, b, c)
38+
end
39+
40+
function ff2()
41+
--[[
42+
long comment
43+
]]
44+
end
45+
```
46+
47+
## Alignment
48+
49+
On top of basic requirements, formatting tools provide satisfaction for advanced aesthetic needs, and code alignment is an important component.
50+
51+
52+
```lua
53+
local ttt = 123 --first
54+
cd = 345 --second
55+
56+
57+
local d = {
58+
aa =123,
59+
bbbb = 4353,
60+
eee = 131231,
61+
}
62+
63+
local c = {
64+
{ aaaaa, bbbb, ccc },
65+
{ 1, 2, 3 }
66+
}
67+
```
68+
69+
will be formatted as:
70+
71+
```lua
72+
local ttt = 123 --first
73+
cd = 345 --second
74+
75+
76+
local d = {
77+
aa = 123,
78+
bbbb = 4353,
79+
eee = 131231,
80+
}
81+
82+
local c = {
83+
{ aaaaa, bbbb, ccc },
84+
{ 1, 2, 3 }
85+
}
86+
```

0 commit comments

Comments
 (0)