Skip to content

Commit 24dce2d

Browse files
committed
修改文档
1 parent d8c82d8 commit 24dce2d

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* [格式化行为介绍](docs/format_action.md)
2929
* [如何配置格式化](docs/format_config.md)
3030
* [代码诊断配置](docs/diagnosis_config.md)
31+
* [部分屏蔽格式化](docs/disable_format.md)
3132
* [auto import配置](docs/auto_import_config.md)
3233
# Contribute
3334

README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ In addition to providing language service examples, the project also provides an
2828
* [Introduction to formatting behavior](docs/format_action_EN.md)
2929
* [How to configure formatting](docs/format_config_EN.md)
3030
* [Code diagnosis configuration](docs/diagnosis_config_EN.md)
31+
* [Disable format](docs/disable_format_EN.md)
3132
* [auto import configuration](docs/auto_import_config_EN.md)
3233
## Contribute
3334
Any pr or issue are welcome

docs/disable_format.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 格式化屏蔽
2+
3+
通常项目中存在一些不宜格式化的文件,或者在一个文件中一些语句的格式化需要例外的手动处理,对于这样的情况,该算法库依然提供一定的支持
4+
5+
## 使用---@format
6+
7+
遵循emmylua doc的方式,我实现了通过分析注释屏蔽格式化的方式。
8+
9+
在需要屏蔽的语句上方加上`---@format disable-next`即可屏蔽该语句内的格式化。
10+
11+
例如:
12+
```lua
13+
---@format disable-next
14+
local t =123
15+
16+
```
17+
18+
如果某语句块需要屏蔽则加上`---@format disable`即可屏蔽该语句块内的格式化.
19+
20+
例如:
21+
```lua
22+
---@format disable
23+
24+
local d = 123
25+
local cc=2313
26+
local ccc =13
27+
28+
```
29+
30+
## 注意
31+
32+
1. 无论是否屏蔽格式化,被format注解屏蔽格式化的语句的缩进依然会被格式化,
33+
2. 屏蔽格式化的单位是语句,不是表达式,如果format注解写为内联注释,则屏蔽不会生效

docs/disable_format_EN.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# format disable
2+
3+
Usually there are some files that are not suitable for formatting in the project, or the formatting of some statements in a file requires exceptional manual processing. For such cases, the algorithm library still provides certain support.
4+
5+
## use ---@format
6+
7+
Following the way of emmylua doc, I implemented the way of disable formatting by analyzing comments.
8+
9+
Add `---@format disable-next` above the statement to be disable the formatting in the statement.
10+
11+
E.g:
12+
````lua
13+
---@format disable-next
14+
local t=123
15+
16+
````
17+
18+
If a statement block needs to be disable-format, add `---@format disable` to header of block for disabled formatting.
19+
20+
E.g:
21+
````lua
22+
---@format disable
23+
24+
local d = 123
25+
local cc=2313
26+
local ccc =13
27+
28+
````
29+
30+
## Notice
31+
32+
1. Regardless of whether the formatting is disable or not, the indentation of the statement masked by the format annotation will still be formatted.
33+
2. The unit of masking and formatting is a statement, not an expression. If the format annotation is written as an inline comment, the masking will not take effect.

0 commit comments

Comments
 (0)