Procházet zdrojové kódy

update left api docs

ruki před 2 měsíci
rodič
revize
1043719d4e

+ 34 - 11
docs/api/scripts/extension-modules/core/base/bytes.md

@@ -11,15 +11,38 @@ To use this module, you need to import it first: `import("core.base.bytes")`
 
 - Create a byte buffer
 
-```lua
-import("core.base.bytes")
+#### Function Prototype
 
-local buff = bytes(size)
+::: tip API
+```lua
+bytes(size: <number>, initval: <number|string>)
+bytes(str: <string>)
+bytes(buffer: <bytes>, offset: <number>, size: <number>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| size | Required. Buffer size in bytes |
+| initval | Optional. Initial value for buffer (number or character) |
+| str | Required. String to convert to bytes object |
+| buffer | Required. Source bytes buffer for slice |
+| offset | Required. Offset position in source buffer |
+| size | Required. Size of the slice |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| bytes | Returns a bytes buffer object |
+
+#### Usage
 
 The bytes constructor supports multiple creation methods, providing flexible buffer creation and management.
 
-### Create a buffer of specified size
+##### Create a buffer of specified size
 
 ```lua
 -- Create a 1024-byte buffer
@@ -32,7 +55,7 @@ local buff = bytes(100, 255) -- Initialize to 255
 local buff = bytes(100, 'A') -- Initialize to character 'A'
 ```
 
-### Create from string
+##### Create from string
 
 Create a bytes object from a string, commonly used to convert strings to binary data:
 
@@ -46,7 +69,7 @@ print(buff:str())   -- Output: hello world
 bytes objects created from strings are read-only and cannot be modified.
 :::
 
-### Create a slice
+##### Create a slice
 
 Create a slice from an existing bytes object, sharing underlying memory without copying data:
 
@@ -56,7 +79,7 @@ local slice = bytes(original, 3, 5)  -- Slice bytes 3-5
 print(slice:str())  -- Output: 345
 ```
 
-### Concatenate multiple buffers
+##### Concatenate multiple buffers
 
 ```lua
 -- Concatenate using parameter list
@@ -68,14 +91,14 @@ local buff = bytes({bytes("123"), bytes("456"), bytes("789")})
 print(buff:str())  -- Output: 123456789
 ```
 
-### Create empty buffer
+##### Create empty buffer
 
 ```lua
 local buff = bytes()   -- Empty buffer
 local buff = bytes({}) -- Empty buffer
 ```
 
-### Index operations
+##### Index operations
 
 bytes objects support accessing and modifying individual bytes through indexing (indices start from 1):
 
@@ -105,7 +128,7 @@ buff[{1, 9}] = bytes("123456789")
 print(buff:str())  -- Output: 123456789
 ```
 
-### Concatenation operation
+##### Concatenation operation
 
 Use the `..` operator to concatenate two bytes objects, creating a new buffer:
 
@@ -492,7 +515,7 @@ bytes:u16le(offset: <number>)
 
 #### Usage
 
-Reads 2 bytes from the specified offset as an unsigned 16-bit integer (little-endian byte order).
+参数Reads 2 bytes from the specified offset as an unsigned 16-bit integer (little-endian byte order).
 
 ## bytes:u16le_set
 

+ 350 - 42
docs/api/scripts/extension-modules/package/tools.md

@@ -10,6 +10,28 @@ This module provides helpers for integrating common build tools in xmake-repo an
 
 Install a package using CMake. Most commonly used for CMake-based packages in xmake-repo.
 
+#### Function Prototype
+
+::: tip API
+```lua
+cmake.install(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. CMake configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `cxflags` - C/C++ compile flags<br>- `cflags` - C compile flags<br>- `packagedeps` - Package dependencies list |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 #### Basic usage
 ```lua
 on_install(function (package)
@@ -39,12 +61,29 @@ end)
 
 Build a package using CMake (without install step).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-cmake.build(package, configs, opt)
+cmake.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. CMake configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
+
+#### Usage
 
-**Example:**
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.cmake").build(package, {"-DCMAKE_BUILD_TYPE=Release"})
@@ -55,6 +94,28 @@ end)
 
 Configure a CMake project (run cmake only, no build/install).
 
+#### Function Prototype
+
+::: tip API
+```lua
+cmake.configure(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. CMake configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 #### Basic usage
 ```lua
 on_install(function (package)
@@ -73,6 +134,28 @@ end)
 
 Install a package using GNU Autotools (configure/make/make install).
 
+#### Function Prototype
+
+::: tip API
+```lua
+autoconf.install(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `packagedeps` - Package dependencies list |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 #### Basic usage
 ```lua
 on_install(function (package)
@@ -102,12 +185,29 @@ end)
 
 Build a package using Autotools (configure/make).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-autoconf.build(package, configs, opt)
+autoconf.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters |
 
-**Example:**
+#### Return Value
+
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").build(package, {"--enable-static=yes"})
@@ -118,12 +218,29 @@ end)
 
 Run the configure script for an Autotools project.
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-autoconf.configure(package, configs, opt)
+autoconf.configure(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
 
-**Example:**
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").configure(package, {"--prefix=/usr/local"})
@@ -134,12 +251,29 @@ end)
 
 Run make with custom arguments.
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-autoconf.make(package, argv, opt)
+autoconf.make(package: <package>, argv: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| argv | Required. make argument list |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
 
-**Example:**
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").make(package, {"install"})
@@ -154,12 +288,29 @@ end)
 
 Install a package using Meson (setup/compile/install).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-meson.install(package, configs, opt)
+meson.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Meson configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `packagedeps` - Package dependencies list |
+
+#### Return Value
+
+No return value
+
+#### Usage
 
-**Typical usage:**
+Typical usage:
 ```lua
 add_deps("meson", "ninja")
 on_install(function (package)
@@ -182,12 +333,29 @@ end)
 
 Build a package using Meson (setup/compile).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-meson.build(package, configs, opt)
+meson.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Meson configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
 
-**Example:**
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.meson").build(package, {"-Ddefault_library=static"})
@@ -196,14 +364,31 @@ end)
 
 ### meson.generate
 
-Generate build files for Meson (setup only).
+Generate Meson build files only (setup).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-meson.generate(package, configs, opt)
+meson.generate(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
 
-**Example:**
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Meson configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.meson").generate(package, {"-Dbuildtype=release"})
@@ -216,14 +401,31 @@ end)
 
 ### make.install
 
-Install a package using Make (build then install target).
+Build and install a package using Make (build + install).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-make.install(package, configs, opt)
+make.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `packagedeps` - Package dependencies list |
 
-**Typical usage:**
+#### Return Value
+
+No return value
+
+#### Usage
+
+Typical usage:
 ```lua
 add_deps("make")
 on_install(function (package)
@@ -240,12 +442,29 @@ end)
 
 Build a package using Make.
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-make.build(package, configs, opt)
+make.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
 
-**Example:**
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.make").build(package, {"CC=gcc"})
@@ -256,12 +475,29 @@ end)
 
 Run make with custom arguments.
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-make.make(package, argv, opt)
+make.make(package: <package>, argv: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| argv | Required. make argument list |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
 
-**Example:**
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.make").make(package, {"install"})
@@ -274,14 +510,31 @@ end)
 
 ### ninja.install
 
-Install a package using Ninja (build then install target).
+Build and install a package using Ninja (build + install).
+
+#### Function Prototype
 
-**Signature:**
+::: tip API
 ```lua
-ninja.install(package, configs, opt)
+ninja.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `packagedeps` - Package dependencies list |
+
+#### Return Value
+
+No return value
+
+#### Usage
 
-**Typical usage:**
+Typical usage:
 ```lua
 add_deps("ninja")
 on_install(function (package)
@@ -298,12 +551,29 @@ end)
 
 Build a package using Ninja.
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-ninja.build(package, configs, opt)
+ninja.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. Configuration parameter list |
+| opt | Optional. Option parameters |
+
+#### Return Value
 
-**Example:**
+No return value
+
+#### Usage
+
+Example:
 ```lua
 on_install(function (package)
     import("package.tools.ninja").build(package)
@@ -318,12 +588,29 @@ end)
 
 Build a package using MSBuild (Visual Studio projects).
 
-**Signature:**
+#### Function Prototype
+
+::: tip API
 ```lua
-msbuild.build(package, configs, opt)
+msbuild.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
 
-**Typical usage:**
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| configs | Required. MSBuild configuration parameter list |
+| opt | Optional. Option parameters, supports the following:<br>- `packagedeps` - Package dependencies list |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
+Typical usage:
 ```lua
 on_install(function (package)
     local configs = {}
@@ -349,6 +636,27 @@ Install a package using xmake itself. This is suitable for:
 - Porting third-party libraries that cannot be built directly, by writing a `xmake.lua` to adapt the build.
 - Building and installing projects that already maintain their own `xmake.lua` build script.
 
+#### Function Prototype
+
+::: tip API
+```lua
+xmake.install(package: <package>, opt: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| package | Required. Package instance object |
+| opt | Optional. Option parameters |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 #### Usage for projects with their own xmake.lua
 If the source already contains a proper `xmake.lua`, you can simply:
 ```lua

+ 152 - 0
docs/api/scripts/extension-modules/privilege/sudo.md

@@ -11,6 +11,26 @@ In order to ensure security, unless you must use it, try not to use this interfa
 
 - Determine if sudo supports
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.has()
+```
+:::
+
+#### Parameter Description
+
+No parameters
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| boolean | Returns true if sudo is supported, false otherwise |
+
+#### Usage
+
 At present, sudo is supported only under `macosx/linux`. The administrator privilege running on Windows is not supported yet. Therefore, it is recommended to use the interface to judge the support situation before use.
 
 ```lua
@@ -25,6 +45,28 @@ end
 
 - Quietly running native shell commands
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.run(cmd: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| cmd | Required. Shell command to execute |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| boolean | Returns true on success, false on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.run](/api/scripts/builtin-modules/os#os-run).
 
 ```lua
@@ -37,28 +79,138 @@ sudo.run("rm /system/file")
 
 - Quietly running native shell commands with parameter list
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.runv(argv: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| argv | Required. Command argument list |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| boolean | Returns true on success, false on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.runv](/api/scripts/builtin-modules/os#os-runv).
 
 ## sudo.exec
 
 - Echo running native shell commands
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.exec(cmd: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| cmd | Required. Shell command to execute |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| boolean | Returns true on success, false on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.exec](/api/scripts/builtin-modules/os#os-exec).
 
 ## sudo.execv
 
 - Echo running native shell commands with parameter list
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.execv(argv: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| argv | Required. Command argument list |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| boolean | Returns true on success, false on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.execv](/api/scripts/builtin-modules/os#os-execv).
 
 ## sudo.iorun
 
 - Quietly running native shell commands and getting output
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.iorun(cmd: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| cmd | Required. Shell command to execute |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| string | Returns output content on success, nil on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.iorun](/api/scripts/builtin-modules/os#os-iorun).
 
 ## sudo.iorunv
 
 - Run the native shell command quietly and get the output with a list of parameters
 
+#### Function Prototype
+
+::: tip API
+```lua
+sudo.iorunv(argv: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| argv | Required. Command argument list |
+
+#### Return Value
+
+| Type | Description |
+|------|-------------|
+| string | Returns output content on success, nil on failure |
+
+#### Usage
+
 For specific usage, please refer to: [os.iorunv](/api/scripts/builtin-modules/os#os-iorunv).

+ 43 - 0
docs/api/scripts/extension-modules/utils/archive.md

@@ -7,6 +7,28 @@ This module is used to compress and decompress files. It supports decompression
 
 - zip files
 
+#### Function Prototype
+
+::: tip API
+```lua
+archive.archive(archivefile: <string>, outputdir: <string>, options: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| archivefile | Required. Archive file path |
+| outputdir | Required. Output directory path |
+| options | Optional. Configuration options, supports the following:<br>- `curdir` - Current working directory<br>- `recurse` - Whether to recurse directories<br>- `compress` - Compression quality (fastest|faster|default|better|best)<br>- `excludes` - Exclude files list |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 ```lua
 import("utils.archive")
 
@@ -33,6 +55,27 @@ archive.archive("/tmp/a.zip", "/tmp/outputdir", options)
 
 - unzip files
 
+#### Function Prototype
+
+::: tip API
+```lua
+archive.extract(archivefile: <string>, outputdir: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| archivefile | Required. Archive file path |
+| outputdir | Required. Output directory path |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 ```lua
 import("utils.archive")
 

+ 22 - 0
docs/api/scripts/extension-modules/utils/platform.md

@@ -7,6 +7,28 @@ This module is used for some platform-related auxiliary operation interfaces
 
 - Convert mingw's libxxxdll.a to msvc's xxx.lib library
 
+#### Function Prototype
+
+::: tip API
+```lua
+gnu2mslib(outputlib: <string>, inputfile: <string>, options: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| outputlib | Required. Output .lib file path |
+| inputfile | Required. Input .dll.a or .def file path |
+| options | Optional. Option parameters, supports the following:<br>- `dllname` - DLL file name<br>- `arch` - Architecture (e.g. "x64") |
+
+#### Return Value
+
+No return value
+
+#### Usage
+
 This feature is particularly helpful for Fortran & C++ mixed projects, because VS does not provide the fortran compiler. You can only use MinGW's gfortran to compile the fortran part, and then link with the VS project.
 Often such projects also have some other libraries provided in the vs format, so pure MinGW compilation is not possible, you can only use this function to mix compilation.
 

+ 33 - 10
docs/zh/api/scripts/extension-modules/core/base/bytes.md

@@ -11,15 +11,38 @@ bytes 模块提供了二进制数据缓冲区的操作功能,用于处理原
 
 - 创建字节缓冲区
 
-```lua
-import("core.base.bytes")
+#### 函数原型
 
-local buff = bytes(size)
+::: tip API
+```lua
+bytes(size: <number>, initval: <number|string>)
+bytes(str: <string>)
+bytes(buffer: <bytes>, offset: <number>, size: <number>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| size | 必需。缓冲区大小(字节数) |
+| initval | 可选。缓冲区的初始值(数字或字符) |
+| str | 必需。要转换为 bytes 对象的字符串 |
+| buffer | 必需。源 bytes 缓冲区(用于切片) |
+| offset | 必需。在源缓冲区中的偏移位置 |
+| size | 必需。切片的大小 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| bytes | 返回一个 bytes 缓冲区对象 |
+
+#### 用法说明
 
 bytes 构造函数支持多种创建方式,提供灵活的缓冲区创建和管理。
 
-### 创建指定大小的缓冲区
+##### 创建指定大小的缓冲区
 
 ```lua
 -- 创建 1024 字节的缓冲区
@@ -32,7 +55,7 @@ local buff = bytes(100, 255)  -- 初始化为 255
 local buff = bytes(100, 'A')  -- 初始化为字符 'A'
 ```
 
-### 从字符串创建
+##### 从字符串创建
 
 从字符串创建 bytes 对象,常用于将字符串转换为二进制数据处理:
 
@@ -46,7 +69,7 @@ print(buff:str())   -- 输出: hello world
 从字符串创建的 bytes 对象是只读的,不能修改。
 :::
 
-### 创建切片
+##### 创建切片
 
 从现有 bytes 对象创建切片,共享底层内存,不复制数据:
 
@@ -56,7 +79,7 @@ local slice = bytes(original, 3, 5)  -- 切片字节 3-5
 print(slice:str())  -- 输出: 345
 ```
 
-### 连接多个缓冲区
+##### 连接多个缓冲区
 
 ```lua
 -- 使用参数列表连接
@@ -68,14 +91,14 @@ local buff = bytes({bytes("123"), bytes("456"), bytes("789")})
 print(buff:str())  -- 输出: 123456789
 ```
 
-### 创建空缓冲区
+##### 创建空缓冲区
 
 ```lua
 local buff = bytes()  -- 空缓冲区
 local buff = bytes({})  -- 空缓冲区
 ```
 
-### 索引操作
+##### 索引操作
 
 bytes 对象支持通过索引访问和修改单个字节(下标从 1 开始):
 
@@ -105,7 +128,7 @@ buff[{1, 9}] = bytes("123456789")
 print(buff:str())  -- 输出: 123456789
 ```
 
-### 连接操作
+##### 连接操作
 
 使用 `..` 操作符连接两个 bytes 对象,创建新的缓冲区:
 

+ 347 - 39
docs/zh/api/scripts/extension-modules/package/tools.md

@@ -10,6 +10,28 @@
 
 通过 CMake 安装包,适用于大多数 CMake 类包。
 
+#### 函数原型
+
+::: tip API
+```lua
+cmake.install(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。CMake 配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `cxflags` - C/C++ 编译参数<br>- `cflags` - C 编译参数<br>- `packagedeps` - 包依赖列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 #### 基础用法
 ```lua
 on_install(function (package)
@@ -39,12 +61,29 @@ end)
 
 仅用 CMake 构建包(不安装)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-cmake.build(package, configs, opt)
+cmake.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。CMake 配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
 
-**示例:**
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.cmake").build(package, {"-DCMAKE_BUILD_TYPE=Release"})
@@ -55,6 +94,28 @@ end)
 
 仅配置 CMake 项目(只运行 cmake,不编译/安装)。
 
+#### 函数原型
+
+::: tip API
+```lua
+cmake.configure(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。CMake 配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 #### 基础用法
 ```lua
 on_install(function (package)
@@ -73,6 +134,28 @@ end)
 
 通过 GNU Autotools(configure/make/make install)安装包。
 
+#### 函数原型
+
+::: tip API
+```lua
+autoconf.install(package: <package>, configs: <table>, opt: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `packagedeps` - 包依赖列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 #### 基础用法
 ```lua
 on_install(function (package)
@@ -102,12 +185,29 @@ end)
 
 通过 Autotools 构建包(configure/make)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-autoconf.build(package, configs, opt)
+autoconf.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数 |
 
-**示例:**
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").build(package, {"--enable-static=yes"})
@@ -118,12 +218,29 @@ end)
 
 运行 Autotools 项目的 configure 脚本。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-autoconf.configure(package, configs, opt)
+autoconf.configure(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
 
-**示例:**
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").configure(package, {"--prefix=/usr/local"})
@@ -134,12 +251,29 @@ end)
 
 自定义参数调用 make。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-autoconf.make(package, argv, opt)
+autoconf.make(package: <package>, argv: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| argv | 必需。make 参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
 
-**示例:**
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.autoconf").make(package, {"install"})
@@ -154,12 +288,29 @@ end)
 
 通过 Meson(setup/compile/install)安装包。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-meson.install(package, configs, opt)
+meson.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。Meson 配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `packagedeps` - 包依赖列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
 
-**典型用法:**
+典型用法:
 ```lua
 add_deps("meson", "ninja")
 on_install(function (package)
@@ -182,12 +333,29 @@ end)
 
 通过 Meson 构建包(setup/compile)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-meson.build(package, configs, opt)
+meson.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。Meson 配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
 
-**示例:**
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.meson").build(package, {"-Ddefault_library=static"})
@@ -198,12 +366,29 @@ end)
 
 仅生成 Meson 构建文件(setup)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-meson.generate(package, configs, opt)
+meson.generate(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
 
-**示例:**
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。Meson 配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.meson").generate(package, {"-Dbuildtype=release"})
@@ -218,12 +403,29 @@ end)
 
 通过 Make 构建并安装包(build + install)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-make.install(package, configs, opt)
+make.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `packagedeps` - 包依赖列表 |
 
-**典型用法:**
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
+典型用法:
 ```lua
 add_deps("make")
 on_install(function (package)
@@ -240,12 +442,29 @@ end)
 
 通过 Make 构建包。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-make.build(package, configs, opt)
+make.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
 
-**示例:**
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.make").build(package, {"CC=gcc"})
@@ -256,12 +475,29 @@ end)
 
 自定义参数调用 make。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-make.make(package, argv, opt)
+make.make(package: <package>, argv: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| argv | 必需。make 参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
 
-**示例:**
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.make").make(package, {"install"})
@@ -276,12 +512,29 @@ end)
 
 通过 Ninja 构建并安装包(build + install)。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-ninja.install(package, configs, opt)
+ninja.install(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `packagedeps` - 包依赖列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
 
-**典型用法:**
+典型用法:
 ```lua
 add_deps("ninja")
 on_install(function (package)
@@ -298,12 +551,29 @@ end)
 
 通过 Ninja 构建包。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-ninja.build(package, configs, opt)
+ninja.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。配置参数列表 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
 
-**示例:**
+无返回值
+
+#### 用法说明
+
+示例:
 ```lua
 on_install(function (package)
     import("package.tools.ninja").build(package)
@@ -318,12 +588,29 @@ end)
 
 通过 MSBuild(Visual Studio 工程)构建包。
 
-**签名:**
+#### 函数原型
+
+::: tip API
 ```lua
-msbuild.build(package, configs, opt)
+msbuild.build(package: <package>, configs: <table>, opt: <table>)
 ```
+:::
 
-**典型用法:**
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| configs | 必需。MSBuild 配置参数列表 |
+| opt | 可选。选项参数,支持以下选项:<br>- `packagedeps` - 包依赖列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
+典型用法:
 ```lua
 on_install(function (package)
     local configs = {}
@@ -349,6 +636,27 @@ end)
 - 移植一些三方库(原生编译不过时),可通过自定义 xmake.lua 适配后再用 xmake.install 安装。
 - 源码本身就维护有 xmake.lua 的项目包构建,无需额外配置,直接用 xmake.install 即可。
 
+#### 函数原型
+
+::: tip API
+```lua
+xmake.install(package: <package>, opt: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| package | 必需。包实例对象 |
+| opt | 可选。选项参数 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 #### 针对已有 xmake.lua 的项目
 如果源码目录下已有标准的 xmake.lua,直接:
 ```lua

+ 152 - 0
docs/zh/api/scripts/extension-modules/privilege/sudo.md

@@ -11,6 +11,26 @@
 
 -  判断sudo是否支持
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.has()
+```
+:::
+
+#### 参数说明
+
+无参数
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| boolean | 支持 sudo 返回 true,不支持返回 false |
+
+#### 用法说明
+
 目前仅在`macosx/linux`下支持sudo,windows上的管理员权限运行暂时还不支持,因此建议使用前可以通过此接口判断支持情况后,针对性处理。
 
 ```lua
@@ -25,6 +45,28 @@ end
 
 - 安静运行原生shell命令
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.run(cmd: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| cmd | 必需。要执行的 shell 命令 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| boolean | 命令执行成功返回 true,失败返回 false |
+
+#### 用法说明
+
 具体用法可参考:[os.run](/zh/api/scripts/builtin-modules/os#os-run)。
 
 ```lua
@@ -37,28 +79,138 @@ sudo.run("rm /system/file")
 
 - 安静运行原生shell命令,带参数列表
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.runv(argv: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| argv | 必需。命令参数列表 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| boolean | 命令执行成功返回 true,失败返回 false |
+
+#### 用法说明
+
 具体用法可参考:[os.runv](/zh/api/scripts/builtin-modules/os#os-runv)。
 
 ## sudo.exec
 
 - 回显运行原生shell命令
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.exec(cmd: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| cmd | 必需。要执行的 shell 命令 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| boolean | 命令执行成功返回 true,失败返回 false |
+
+#### 用法说明
+
 具体用法可参考:[os.exec](/zh/api/scripts/builtin-modules/os#os-exec)。
 
 ## sudo.execv
 
 - 回显运行原生shell命令,带参数列表
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.execv(argv: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| argv | 必需。命令参数列表 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| boolean | 命令执行成功返回 true,失败返回 false |
+
+#### 用法说明
+
 具体用法可参考:[os.execv](/zh/api/scripts/builtin-modules/os#os-execv)。
 
 ## sudo.iorun
 
 - 安静运行原生shell命令并获取输出内容
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.iorun(cmd: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| cmd | 必需。要执行的 shell 命令 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| string | 命令执行成功返回输出内容,失败返回 nil |
+
+#### 用法说明
+
 具体用法可参考:[os.iorun](/zh/api/scripts/builtin-modules/os#os-iorun)。
 
 ## sudo.iorunv
 
 - 安静运行原生shell命令并获取输出内容,带参数列表
 
+#### 函数原型
+
+::: tip API
+```lua
+sudo.iorunv(argv: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| argv | 必需。命令参数列表 |
+
+#### 返回值说明
+
+| 类型 | 描述 |
+|------|------|
+| string | 命令执行成功返回输出内容,失败返回 nil |
+
+#### 用法说明
+
 具体用法可参考:[os.iorunv](/zh/api/scripts/builtin-modules/os#os-iorunv)。

+ 43 - 0
docs/zh/api/scripts/extension-modules/utils/archive.md

@@ -7,6 +7,28 @@
 
 - 压缩文件
 
+#### 函数原型
+
+::: tip API
+```lua
+archive.archive(archivefile: <string>, outputdir: <string>, options: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| archivefile | 必需。压缩文件路径 |
+| outputdir | 必需。输出目录路径 |
+| options | 可选。配置选项,支持以下选项:<br>- `curdir` - 当前工作目录<br>- `recurse` - 是否递归目录<br>- `compress` - 压缩质量(fastest|faster|default|better|best)<br>- `excludes` - 排除文件列表 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 ```lua
 import("utils.archive")
 
@@ -33,6 +55,27 @@ archive.archive("/tmp/a.zip", "/tmp/outputdir", options)
 
 - 解压文件
 
+#### 函数原型
+
+::: tip API
+```lua
+archive.extract(archivefile: <string>, outputdir: <string>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| archivefile | 必需。压缩文件路径 |
+| outputdir | 必需。输出目录路径 |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 ```lua
 import("utils.archive")
 

+ 22 - 0
docs/zh/api/scripts/extension-modules/utils/platform.md

@@ -7,6 +7,28 @@
 
 - 将 mingw 的 libxxxdll.a 转换成 msvc 的 xxx.lib 库
 
+#### 函数原型
+
+::: tip API
+```lua
+gnu2mslib(outputlib: <string>, inputfile: <string>, options: <table>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| outputlib | 必需。输出的 .lib 文件路径 |
+| inputfile | 必需。输入的 .dll.a 或 .def 文件路径 |
+| options | 可选。选项参数,支持以下选项:<br>- `dllname` - DLL 文件名<br>- `arch` - 架构(如 "x64") |
+
+#### 返回值说明
+
+无返回值
+
+#### 用法说明
+
 这个功能对 Fortran & C++ 混合项目特别有帮助,因为 VS 不提供fortran编译器,只能用MinGW的gfortran来编译fortran部分,然后和VS的项目链接。
 往往这样的项目同时有一些其他的库以vs格式提供,因此纯用MinGW编译也不行,只能使用这个功能来混合编译。