ruki 2 месяцев назад
Родитель
Сommit
1fbf07ea28

+ 176 - 0
docs/api/scripts/extension-modules/core/language/language.md

@@ -7,6 +7,28 @@ Used to obtain information about the compiled language, generally used for the o
 
 - Get a list of code suffixes for all languages
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.extensions()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| table | Returns a table with file extensions as keys and language source types as values |
+
+#### Usage
+
+Get a list of code suffixes for all languages.
+
 The results are as follows:
 
 ```lua
@@ -25,6 +47,28 @@ The results are as follows:
 
 - Get a list of target types in all languages
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.targetkinds()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| table | Returns a table with target types as keys and lists of supported linkers as values |
+
+#### Usage
+
+Get a list of target types in all languages.
+
 The results are as follows:
 
 ```lua
@@ -39,6 +83,28 @@ The results are as follows:
 
 - Get a list of source file types in all languages
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.sourcekinds()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| table | Returns a table with source file types as keys and file extensions or extension lists as values |
+
+#### Usage
+
+Get a list of source file types in all languages.
+
 The results are as follows:
 
 ```lua
@@ -59,6 +125,28 @@ The results are as follows:
 
 - Load a list of source file compilation option names for all languages
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.sourceflags()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| table | Returns a table with source file types as keys and compilation option name lists as values |
+
+#### Usage
+
+Load a list of source file compilation option names for all languages.
+
 The results are as follows:
 
 ```lua
@@ -73,6 +161,28 @@ The results are as follows:
 
 - Load the specified language
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.load(name: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Language name, e.g., "c++", "c" |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| language | Returns a language object, or nil if it doesn't exist |
+
+#### Usage
+
 Load a specific language object from the language name, for example:
 
 ```lua
@@ -86,6 +196,28 @@ end
 
 - Load the specified language from the source file type
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.load_sk(sourcekind: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| sourcekind | Required. Source file type, e.g., "cc", "cxx", "mm" |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| language | Returns a language object, or nil if it doesn't exist |
+
+#### Usage
+
 Load specific language objects from the source file type: `cc, cxx, mm, mxx, sc, gc, as ..`, for example:
 
 ```lua
@@ -99,6 +231,28 @@ end
 
 - Load the specified language from the source file suffix name
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.load_ex(extension: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| extension | Required. Source file extension, e.g., ".cpp", ".c" |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| language | Returns a language object, or nil if it doesn't exist |
+
+#### Usage
+
 Load specific language objects from the source file extension: `.cc, .c, .cpp, .mm, .swift, .go ..`, for example:
 
 ```lua
@@ -112,6 +266,28 @@ end
 
 - Get the source file type of the specified source file
 
+#### Function Prototype
+
+::: tip API
+```lua
+language.sourcekind_of(filepath: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| filepath | Required. Source file path |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| string | Returns the source file type, e.g., "cxx", "cc" |
+
+#### Usage
+
 That is, from a given source file path, get the type of source file it belongs to, for example:
 
 ```lua

+ 177 - 1
docs/zh/api/scripts/extension-modules/core/language/language.md

@@ -6,6 +6,28 @@
 
 - 获取所有语言的代码后缀名列表
 
+#### 函数原型
+
+::: tip API
+```lua
+language.extensions()
+```
+:::
+
+#### 参数说明
+
+此函数不需要参数。
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| table | 返回一个表,键为文件后缀名,值为语言源类型 |
+
+#### 用法说明
+
+获取所有语言的代码后缀名列表。
+
 获取结果如下:
 
 ```lua
@@ -24,6 +46,28 @@
 
 - 获取所有语言的目标类型列表
 
+#### 函数原型
+
+::: tip API
+```lua
+language.targetkinds()
+```
+:::
+
+#### 参数说明
+
+此函数不需要参数。
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| table | 返回一个表,键为目标类型,值为该类型支持的链接器列表 |
+
+#### 用法说明
+
+获取所有语言的目标类型列表。
+
 获取结果如下:
 
 ```lua
@@ -38,6 +82,28 @@
 
 - 获取所有语言的源文件类型列表
 
+#### 函数原型
+
+::: tip API
+```lua
+language.sourcekinds()
+```
+:::
+
+#### 参数说明
+
+此函数不需要参数。
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| table | 返回一个表,键为源文件类型,值为文件后缀名或后缀名列表 |
+
+#### 用法说明
+
+获取所有语言的源文件类型列表。
+
 获取结果如下:
 
 ```lua
@@ -58,6 +124,28 @@
 
 - 加载所有语言的源文件编译选项名列表
 
+#### 函数原型
+
+::: tip API
+```lua
+language.sourceflags()
+```
+:::
+
+#### 参数说明
+
+此函数不需要参数。
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| table | 返回一个表,键为源文件类型,值为编译选项名列表 |
+
+#### 用法说明
+
+加载所有语言的源文件编译选项名列表。
+
 获取结果如下:
 
 ```lua
@@ -72,6 +160,28 @@
 
 - 加载指定语言
 
+#### 函数原型
+
+::: tip API
+```lua
+language.load(name: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| name | 必需。语言名称,例如 "c++", "c" |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| language | 返回语言对象,如果不存在则返回 nil |
+
+#### 用法说明
+
 从语言名称加载具体语言对象,例如:
 
 ```lua
@@ -85,6 +195,28 @@ end
 
 - 从源文件类型加载指定语言
 
+#### 函数原型
+
+::: tip API
+```lua
+language.load_sk(sourcekind: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| sourcekind | 必需。源文件类型,例如 "cc", "cxx", "mm" |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| language | 返回语言对象,如果不存在则返回 nil |
+
+#### 用法说明
+
 从源文件类型:`cc, cxx, mm, mxx, sc, gc, as ..`加载具体语言对象,例如:
 
 ```lua
@@ -98,10 +230,32 @@ end
 
 - 从源文件后缀名加载指定语言
 
+#### 函数原型
+
+::: tip API
+```lua
+language.load_ex(extension: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| extension | 必需。源文件后缀名,例如 ".cpp", ".c" |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| language | 返回语言对象,如果不存在则返回 nil |
+
+#### 用法说明
+
 从源文件后缀名:`.cc, .c, .cpp, .mm, .swift, .go  ..`加载具体语言对象,例如:
 
 ```lua
-local lang = language.load_sk(".cpp")
+local lang = language.load_ex(".cpp")
 if lang then
     print(lang:name())
 end
@@ -111,6 +265,28 @@ end
 
 - 获取指定源文件的源文件类型
 
+#### 函数原型
+
+::: tip API
+```lua
+language.sourcekind_of(filepath: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| filepath | 必需。源文件路径 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| string | 返回源文件类型,例如 "cxx", "cc" |
+
+#### 用法说明
+
 也就是从给定的一个源文件路径,获取它是属于那种源文件类型,例如:
 
 ```lua