aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/zh
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/zh')
-rwxr-xr-xdoc/docs/zh/doc/README.md51
1 files changed, 50 insertions, 1 deletions
diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md
index afef94e..da69e22 100755
--- a/doc/docs/zh/doc/README.md
+++ b/doc/docs/zh/doc/README.md
@@ -4686,7 +4686,7 @@ type AST = {string, integer, integer, any}
4686 4686
4687**签名:** 4687**签名:**
4688```lua 4688```lua
4689to_ast: function(code: string, flattenLevel?: number, astName?: string): 4689to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean):
4690 --[[AST]] AST | nil, 4690 --[[AST]] AST | nil,
4691 --[[error]] nil | string 4691 --[[error]] nil | string
4692``` 4692```
@@ -4697,6 +4697,42 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string):
4697| --- | --- | --- | 4697| --- | --- | --- |
4698| code | string | 代码。 | 4698| code | string | 代码。 |
4699| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | 4699| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 |
4700| astName | string | [可选] AST 名称。默认为 "File"。 |
4701| reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 |
4702
4703**返回值:**
4704
4705| 返回类型 | 描述 |
4706| --- | --- |
4707| AST \| nil | AST,如果转换失败则为 nil。 |
4708| string \| nil | 错误消息,如果转换成功则为 nil。 |
4709
4710#### format
4711
4712**类型:** 函数。
4713
4714**描述:**
4715
4716格式化 YueScript 代码。
4717
4718**签名:**
4719```lua
4720format: function(code: string, tabSize?: number, reserveComment?: boolean): string
4721```
4722
4723**参数:**
4724
4725| 参数名 | 类型 | 描述 |
4726| --- | --- | --- |
4727| code | string | 代码。 |
4728| tabSize | integer | [可选] 制表符大小。默认为 4。 |
4729| reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 |
4730
4731**返回值:**
4732
4733| 返回类型 | 描述 |
4734| --- | --- |
4735| string | 格式化后的代码。 |
4700 4736
4701#### __call 4737#### __call
4702 4738
@@ -4769,6 +4805,19 @@ implicit_return_root: boolean
4769reserve_line_number: boolean 4805reserve_line_number: boolean
4770``` 4806```
4771 4807
4808#### reserve_comment
4809
4810**类型:** 成员变量。
4811
4812**描述:**
4813
4814编译器是否应该在编译后的代码中保留原始注释。
4815
4816**签名:**
4817```lua
4818reserve_comment: boolean
4819```
4820
4772#### space_over_tab 4821#### space_over_tab
4773 4822
4774**类型:** 成员变量。 4823**类型:** 成员变量。