diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-12-04 02:57:43 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-12-04 02:57:43 +0800 |
| commit | ec26010fd100bb014584653e0e1370dba816fd1f (patch) | |
| tree | 913b654492370bed305c0e40923643b823a31aa2 /doc | |
| parent | 1fea444b1ae1157a98ac187f58952080a7a63b6e (diff) | |
| download | yuescript-ec26010fd100bb014584653e0e1370dba816fd1f.tar.gz yuescript-ec26010fd100bb014584653e0e1370dba816fd1f.tar.bz2 yuescript-ec26010fd100bb014584653e0e1370dba816fd1f.zip | |
Updated reserved comments function.v0.30.1
Diffstat (limited to 'doc')
| -rwxr-xr-x | doc/docs/doc/README.md | 43 | ||||
| -rwxr-xr-x | doc/docs/zh/doc/README.md | 51 |
2 files changed, 92 insertions, 2 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 07e35e7..11c9427 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
| @@ -4729,7 +4729,7 @@ Converts the code to the AST. | |||
| 4729 | 4729 | ||
| 4730 | **Signature:** | 4730 | **Signature:** |
| 4731 | ```lua | 4731 | ```lua |
| 4732 | to_ast: function(code: string, flattenLevel?: number, astName?: string): | 4732 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 4733 | --[[AST]] AST | nil, | 4733 | --[[AST]] AST | nil, |
| 4734 | --[[error]] nil | string | 4734 | --[[error]] nil | string |
| 4735 | ``` | 4735 | ``` |
| @@ -4741,6 +4741,7 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string): | |||
| 4741 | | code | string | The code. | | 4741 | | code | string | The code. | |
| 4742 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | | 4742 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | |
| 4743 | | astName | string | [Optional] The AST name. Default is "File". | | 4743 | | astName | string | [Optional] The AST name. Default is "File". | |
| 4744 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | | ||
| 4744 | 4745 | ||
| 4745 | **Returns:** | 4746 | **Returns:** |
| 4746 | 4747 | ||
| @@ -4749,6 +4750,33 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string): | |||
| 4749 | | AST \| nil | The AST, or nil if the conversion failed. | | 4750 | | AST \| nil | The AST, or nil if the conversion failed. | |
| 4750 | | string \| nil | The error message, or nil if the conversion succeeded. | | 4751 | | string \| nil | The error message, or nil if the conversion succeeded. | |
| 4751 | 4752 | ||
| 4753 | #### format | ||
| 4754 | |||
| 4755 | **Type:** Function. | ||
| 4756 | |||
| 4757 | **Description:** | ||
| 4758 | |||
| 4759 | Formats the YueScript code. | ||
| 4760 | |||
| 4761 | **Signature:** | ||
| 4762 | ```lua | ||
| 4763 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | ||
| 4764 | ``` | ||
| 4765 | |||
| 4766 | **Parameters:** | ||
| 4767 | |||
| 4768 | | Parameter | Type | Description | | ||
| 4769 | | --- | --- | --- | | ||
| 4770 | | code | string | The code. | | ||
| 4771 | | tabSize | integer | [Optional] The tab size. Default is 4. | | ||
| 4772 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | | ||
| 4773 | |||
| 4774 | **Returns:** | ||
| 4775 | |||
| 4776 | | Return Type | Description | | ||
| 4777 | | --- | --- | | ||
| 4778 | | string | The formatted code. | | ||
| 4779 | |||
| 4752 | #### __call | 4780 | #### __call |
| 4753 | 4781 | ||
| 4754 | **Type:** Metamethod. | 4782 | **Type:** Metamethod. |
| @@ -4820,6 +4848,19 @@ Whether the compiler should reserve the original line number in the compiled cod | |||
| 4820 | reserve_line_number: boolean | 4848 | reserve_line_number: boolean |
| 4821 | ``` | 4849 | ``` |
| 4822 | 4850 | ||
| 4851 | #### reserve_comment | ||
| 4852 | |||
| 4853 | **Type:** Field. | ||
| 4854 | |||
| 4855 | **Description:** | ||
| 4856 | |||
| 4857 | Whether the compiler should reserve the original comments in the compiled code. | ||
| 4858 | |||
| 4859 | **Signature:** | ||
| 4860 | ```lua | ||
| 4861 | reserve_comment: boolean | ||
| 4862 | ``` | ||
| 4863 | |||
| 4823 | #### space_over_tab | 4864 | #### space_over_tab |
| 4824 | 4865 | ||
| 4825 | **Type:** Field. | 4866 | **Type:** Field. |
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 |
| 4689 | to_ast: function(code: string, flattenLevel?: number, astName?: string): | 4689 | to_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 | ||
| 4720 | format: 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 | |||
| 4769 | reserve_line_number: boolean | 4805 | reserve_line_number: boolean |
| 4770 | ``` | 4806 | ``` |
| 4771 | 4807 | ||
| 4808 | #### reserve_comment | ||
| 4809 | |||
| 4810 | **类型:** 成员变量。 | ||
| 4811 | |||
| 4812 | **描述:** | ||
| 4813 | |||
| 4814 | 编译器是否应该在编译后的代码中保留原始注释。 | ||
| 4815 | |||
| 4816 | **签名:** | ||
| 4817 | ```lua | ||
| 4818 | reserve_comment: boolean | ||
| 4819 | ``` | ||
| 4820 | |||
| 4772 | #### space_over_tab | 4821 | #### space_over_tab |
| 4773 | 4822 | ||
| 4774 | **类型:** 成员变量。 | 4823 | **类型:** 成员变量。 |
