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

+ 153 - 23
docs/api/scripts/extension-modules/core/base/hashset.md

@@ -11,11 +11,19 @@ To use this module, you need to import it first: `import("core.base.hashset")`
 
 - Create an empty hash set
 
-```lua
-import("core.base.hashset")
+#### Function Prototype
 
-local set = hashset.new()
+::: tip API
+```lua
+hashset.new()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates an empty hash set object.
 
@@ -29,11 +37,21 @@ print(set:empty())  -- Output: true
 
 - Create hash set from parameter list
 
-```lua
-import("core.base.hashset")
+#### Function Prototype
 
-local set = hashset.of(1, 2, 3, 5, 5, 7, 1, 9)
+::: tip API
+```lua
+hashset.of(...)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| ... | Variable number of values to initialize the set |
+
+#### Usage
 
 Creates a hash set from a parameter list, automatically removing duplicate elements.
 
@@ -53,11 +71,21 @@ assert(not set:has(10))
 
 - Create hash set from array
 
-```lua
-import("core.base.hashset")
+#### Function Prototype
 
-local set = hashset.from(array)
+::: tip API
+```lua
+hashset.from(array: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| array | Required. Array to create the set from |
+
+#### Usage
 
 Creates a hash set from an array, automatically removing duplicate elements.
 
@@ -76,9 +104,21 @@ local unique_array = set:to_array()
 
 - Insert an element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local inserted = set:insert(value)
+hashset:insert(value: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| value | Required. Element to insert |
+
+#### Usage
 
 Inserts an element into the hash set. If the element already exists, it will not be inserted.
 
@@ -112,9 +152,21 @@ set:insert(nil)  -- Can also insert nil value
 
 - Remove an element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local removed = set:remove(value)
+hashset:remove(value: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| value | Required. Element to remove |
+
+#### Usage
 
 Removes an element from the hash set.
 
@@ -137,9 +189,21 @@ print(result)  -- Output: false (element doesn't exist)
 
 - Check if element exists
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local exists = set:has(value)
+hashset:has(value: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| value | Required. Element to check |
+
+#### Usage
 
 Checks if the specified element is in the hash set.
 
@@ -165,9 +229,19 @@ end
 
 - Get set size
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local count = set:size()
+hashset:size()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the number of elements in the hash set.
 
@@ -186,9 +260,19 @@ print(set:size())  -- Output: 5
 
 - Check if set is empty
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local is_empty = set:empty()
+hashset:empty()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns true if the set is empty (contains no elements).
 
@@ -204,9 +288,19 @@ print(set:empty())  -- Output: false
 
 - Clear the set
 
+#### Function Prototype
+
+::: tip API
 ```lua
-set:clear()
+hashset:clear()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes all elements from the set, resetting it to an empty set.
 
@@ -223,9 +317,19 @@ print(set:empty()) -- Output: true
 
 - Clone the set
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local new_set = set:clone()
+hashset:clone()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates a complete copy of the hash set, with the new set being independent of the original.
 
@@ -249,9 +353,19 @@ assert(set1 == set2)  -- Equal
 
 - Convert to array
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local array = set:to_array()
+hashset:to_array()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Converts the hash set to an array, returning a table containing all elements. nil values are ignored.
 
@@ -271,11 +385,19 @@ print("Deduplicated size:", #unique_array)    -- 5
 
 - Iterate over set elements
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in set:items() do
-    -- Process item
-end
+hashset:items()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the set (unordered).
 
@@ -310,11 +432,19 @@ print("Sum:", sum)  -- Output: 15
 
 - Iterate over set elements in order
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in set:orderitems() do
-    -- Process item
-end
+hashset:orderitems()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the set in ascending order.
 

+ 78 - 19
docs/api/scripts/extension-modules/core/base/heap.md

@@ -11,17 +11,27 @@ To use this module, you need to import it first: `import("core.base.heap")`
 
 - Create a value heap
 
-```lua
-import("core.base.heap")
+#### Function Prototype
 
-local h = heap.valueheap(options)
+::: tip API
+```lua
+heap.valueheap(options: <table>)
 ```
+:::
 
-Creates a new value heap using a Lua table. The heap is a min-heap by default, but can be customized with a comparison function.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| options | Optional. Lua table with options |
 
 Parameters in `options`:
 - `cmp` - Optional comparison function. Should return true if the first argument has higher priority than the second
 
+#### Usage
+
+Creates a new value heap using a Lua table. The heap is a min-heap by default, but can be customized with a comparison function.
+
 ```lua
 -- Create a min-heap (default)
 local h = heap.valueheap()
@@ -52,9 +62,21 @@ local h = heap.valueheap{1, 5, 3, 7, 2}
 
 - Push a value onto the heap
 
+#### Function Prototype
+
+::: tip API
 ```lua
-heap:push(value)
+heap:push(value: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| value | Required. Value to push onto the heap |
+
+#### Usage
 
 Adds a value to the heap and maintains the heap property. The value will be placed in the correct position according to the comparison function.
 
@@ -92,14 +114,23 @@ The value cannot be nil.
 
 - Pop a value from the heap
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local value = heap:pop(index)
+heap:pop(index: <number>)
 ```
+:::
 
-Removes and returns a value from the heap. If no index is provided, removes the top element (highest priority). After removal, the heap property is maintained.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| index | Optional. The position to pop from (1-based). Defaults to 1 (top of heap) |
+
+#### Usage
 
-Parameters:
-- `index` - Optional. The position to pop from (1-based). Defaults to 1 (top of heap)
+Removes and returns a value from the heap. If no index is provided, removes the top element (highest priority). After removal, the heap property is maintained.
 
 ```lua
 local h = heap.valueheap()
@@ -133,14 +164,23 @@ print(item.data)      -- Output: foo
 
 - Peek at a value without removing it
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local value = heap:peek(index)
+heap:peek(index: <number>)
 ```
+:::
 
-Returns a value from the heap without removing it. If no index is provided, returns the top element (highest priority).
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| index | Optional. The position to peek at (1-based). Defaults to 1 (top of heap) |
 
-Parameters:
-- `index` - Optional. The position to peek at (1-based). Defaults to 1 (top of heap)
+#### Usage
+
+Returns a value from the heap without removing it. If no index is provided, returns the top element (highest priority).
 
 ```lua
 local h = heap.valueheap()
@@ -177,15 +217,24 @@ end
 
 - Replace a value at a given index
 
+#### Function Prototype
+
+::: tip API
 ```lua
-heap:replace(index, value)
+heap:replace(index: <number>, value: <any>)
 ```
+:::
 
-Replaces the value at the specified index with a new value and rebalances the heap to maintain the heap property.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| index | Required. The position to replace (1-based) |
+| value | Required. The new value |
 
-Parameters:
-- `index` - Required. The position to replace (1-based)
-- `value` - Required. The new value
+#### Usage
+
+Replaces the value at the specified index with a new value and rebalances the heap to maintain the heap property.
 
 ```lua
 local h = heap.valueheap()
@@ -228,9 +277,19 @@ Use `replace` when you need to update an element's priority without removing and
 
 - Get the number of elements in the heap
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local count = heap.length()
+heap:length()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the current number of elements in the heap. This is a function, not a method.
 

+ 73 - 0
docs/api/scripts/extension-modules/core/base/json.md

@@ -11,6 +11,24 @@ There are also some examples here: [Json Examples](https://github.com/xmake-io/x
 
 - Get the lua table directly from the string decoding json
 
+#### Function Prototype
+
+::: tip API
+```lua
+json.decode(jsonstr: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| jsonstr | Required. JSON string to decode |
+
+#### Usage
+
+Decodes a JSON string into a Lua table.
+
 ```lua
 import("core.base.json")
 local luatable = json.decode('[1,"2", {"a":1, "b":true}]')
@@ -36,6 +54,24 @@ If there is null in it, you can use `json.null` to judge
 
 - Encode a lua table
 
+#### Function Prototype
+
+::: tip API
+```lua
+json.encode(t: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| t | Required. Lua table to encode |
+
+#### Usage
+
+Encodes a Lua table into a JSON string.
+
 ```lua
 local jsonstr = json.encode({1, "2", {a = 1}})
 ```
@@ -50,6 +86,24 @@ local jsonstr = json.encode({json.null, 1, "2", false, true})
 
 - Load the json file directly and parse it into a lua table
 
+#### Function Prototype
+
+::: tip API
+```lua
+json.loadfile(filepath: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| filepath | Required. Path to the JSON file to load |
+
+#### Usage
+
+Loads a JSON file and parses it into a Lua table.
+
 ```lua
 local luatable = json.loadfile("/tmp/xxx.json")
 ```
@@ -58,6 +112,25 @@ local luatable = json.loadfile("/tmp/xxx.json")
 
 - Save the lua table to the specified json file
 
+#### Function Prototype
+
+::: tip API
+```lua
+json.savefile(filepath: <string>, data: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| filepath | Required. Path to save the JSON file |
+| data | Required. Lua table to save |
+
+#### Usage
+
+Saves a Lua table to a JSON file.
+
 ```lua
 json.savefile("/tmp/xxx.json", {1, {a = 1}})
 ```

+ 234 - 27
docs/api/scripts/extension-modules/core/base/list.md

@@ -11,11 +11,19 @@ To use this module, you need to import it first: `import("core.base.list")`
 
 - Create an empty linked list
 
-```lua
-import("core.base.list")
+#### Function Prototype
 
-local l = list.new()
+::: tip API
+```lua
+list.new()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates a new empty doubly linked list object.
 
@@ -29,9 +37,21 @@ print(l:empty())  -- Output: true
 
 - Add element to the end of the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
-list:push(item)
+list:push(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to add |
+
+#### Usage
 
 Adds an element to the end of the list. Equivalent to `list:insert_last(item)`.
 
@@ -56,9 +76,19 @@ The list stores references to elements, not copies. You can store values of any
 
 - Remove element from the end of the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
 list:pop()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes an element from the end of the list. Equivalent to `list:remove_last()`.
 
@@ -76,9 +106,21 @@ print(l:last().value)  -- Output: 2
 
 - Add element to the beginning of the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
-list:unshift(item)
+list:unshift(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to add |
+
+#### Usage
 
 Adds an element to the beginning of the list. Equivalent to `list:insert_first(item)`.
 
@@ -97,9 +139,19 @@ end
 
 - Remove element from the beginning of the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
 list:shift()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes an element from the beginning of the list. Equivalent to `list:remove_first()`.
 
@@ -117,15 +169,24 @@ print(l:first().value)  -- Output: 2
 
 - Insert an element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-list:insert(item, after)
+list:insert(item: <any>, after: <any>)
 ```
+:::
 
-Inserts a new element after the specified element. If the `after` parameter is not provided, inserts at the end of the list.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to insert |
+| after | Optional. Insert after this element; if nil, inserts at the end |
 
-Parameters:
-- `item`: The element to insert
-- `after`: Optional, insert after this element; if nil, inserts at the end
+#### Usage
+
+Inserts a new element after the specified element. If the `after` parameter is not provided, inserts at the end of the list.
 
 ```lua
 local l = list.new()
@@ -147,9 +208,21 @@ end
 
 - Insert element at the beginning
 
+#### Function Prototype
+
+::: tip API
 ```lua
-list:insert_first(item)
+list:insert_first(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to insert |
+
+#### Usage
 
 Inserts an element at the beginning of the list.
 
@@ -168,9 +241,21 @@ print(l:first().value)  -- Output: 1
 
 - Insert element at the end
 
+#### Function Prototype
+
+::: tip API
 ```lua
-list:insert_last(item)
+list:insert_last(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to insert |
+
+#### Usage
 
 Inserts an element at the end of the list.
 
@@ -187,9 +272,21 @@ print(l:last().value)  -- Output: 3
 
 - Remove specified element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local removed_item = list:remove(item)
+list:remove(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. The element to remove |
+
+#### Usage
 
 Removes the specified element from the list and returns the removed element.
 
@@ -228,9 +325,19 @@ print(l:empty())  -- Output: true
 
 - Remove element from the beginning
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local removed_item = list:remove_first()
+list:remove_first()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes an element from the beginning of the list and returns the removed element. Returns nil if the list is empty.
 
@@ -248,9 +355,19 @@ print(l:first().value)  -- Output: 2
 
 - Remove element from the end
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local removed_item = list:remove_last()
+list:remove_last()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes an element from the end of the list and returns the removed element. Returns nil if the list is empty.
 
@@ -268,9 +385,19 @@ print(l:last().value)  -- Output: 2
 
 - Get the first element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local item = list:first()
+list:first()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the first element of the list without removing it. Returns nil if the list is empty.
 
@@ -287,9 +414,19 @@ print(l:first().value)  -- Output: 1
 
 - Get the last element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local item = list:last()
+list:last()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the last element of the list without removing it. Returns nil if the list is empty.
 
@@ -306,9 +443,21 @@ print(l:last().value)  -- Output: 3
 
 - Get the next element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local next_item = list:next(current)
+list:next(current: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| current | Optional. The current element; if nil, returns the first element |
+
+#### Usage
 
 Gets the next element after the specified element. If `current` is nil, returns the first element.
 
@@ -342,9 +491,21 @@ end
 
 - Get the previous element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local prev_item = list:prev(current)
+list:prev(current: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| current | Optional. The current element; if nil, returns the last element |
+
+#### Usage
 
 Gets the previous element before the specified element. If `current` is nil, returns the last element.
 
@@ -378,9 +539,19 @@ end
 
 - Get list size
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local count = list:size()
+list:size()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the number of elements in the list.
 
@@ -397,9 +568,19 @@ print(l:size())  -- Output: 3
 
 - Check if list is empty
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local is_empty = list:empty()
+list:empty()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns true if the list is empty (contains no elements).
 
@@ -415,9 +596,19 @@ print(l:empty())  -- Output: false
 
 - Clear the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
 list:clear()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes all elements from the list, resetting it to an empty list.
 
@@ -436,11 +627,19 @@ print(l:size())   -- Output: 0
 
 - Iterate forward through the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in list:items() do
-    -- Process item
-end
+list:items()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the list from head to tail.
 
@@ -476,11 +675,19 @@ end
 
 - Iterate backward through the list
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in list:ritems() do
-    -- Process item
-end
+list:ritems()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the list from tail to head.
 

+ 17 - 1
docs/api/scripts/extension-modules/core/base/option.md

@@ -7,6 +7,22 @@ Commonly used to get the value of the xmake command parameter option, often used
 
 - Get parameter option values
 
+#### Function Prototype
+
+::: tip API
+```lua
+option.get(name: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Option name |
+
+#### Usage
+
 Used to get parameter option values in plugin development, for example:
 
 ```lua
@@ -29,4 +45,4 @@ task("hello")
         import("core.base.option")
         print(option.get("info"))
     end)
-```
+```

+ 138 - 56
docs/api/scripts/extension-modules/core/base/pipe.md

@@ -11,24 +11,33 @@ To use this module, you need to import it first: `import("core.base.pipe")`
 
 - Create an anonymous pipe pair
 
-```lua
-import("core.base.pipe")
+#### Function Prototype
 
-local rpipe, wpipe = pipe.openpair()
+::: tip API
+```lua
+pipe.openpair(mode: <string>, buffsize: <number>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| mode | Optional. Pipe mode, default is "AA" |
+| buffsize | Optional. Buffer size, default is 0 (system default) |
+
+Available modes:
+- `"BB"`: Both read and write in blocking mode
+- `"BA"`: Read blocking, write non-blocking
+- `"AB"`: Read non-blocking, write blocking
+- `"AA"`: Both read and write in non-blocking mode (default)
+
+#### Usage
 
 Creates a pair of anonymous pipes, returning read and write pipe objects.
 
 Anonymous pipes are mainly used for communication between related processes (such as parent-child processes). A common scenario is redirecting subprocess input/output.
 
-Parameters:
-- `mode` (optional): Pipe mode, default is `"AA"`
-  - `"BB"`: Both read and write in blocking mode
-  - `"BA"`: Read blocking, write non-blocking
-  - `"AB"`: Read non-blocking, write blocking
-  - `"AA"`: Both read and write in non-blocking mode (default)
-- `buffsize` (optional): Buffer size, default is 0 (system default)
-
 Basic usage example:
 
 ```lua
@@ -78,25 +87,34 @@ rpipe:close()
 
 - Open a named pipe
 
-```lua
-import("core.base.pipe")
+#### Function Prototype
 
-local pipefile = pipe.open(name, mode, buffsize)
+::: tip API
+```lua
+pipe.open(name: <string>, mode: <string>, buffsize: <number>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Pipe name |
+| mode | Required. Open mode |
+| buffsize | Optional. Buffer size, default is 0 |
+
+Available modes:
+- `"r"` or `"rA"`: Read-only, non-blocking (client-side)
+- `"w"` or `"wA"`: Write-only, non-blocking (server-side)
+- `"rB"`: Read-only, blocking
+- `"wB"`: Write-only, blocking
+
+#### Usage
 
 Opens or creates a named pipe.
 
 Named pipes can be used for communication between completely independent processes without any relationship. Similar to local sockets but more lightweight. Suitable for scenarios where data needs to be passed between different applications.
 
-Parameters:
-- `name`: Pipe name
-- `mode`: Open mode
-  - `"r"` or `"rA"`: Read-only, non-blocking (client-side)
-  - `"w"` or `"wA"`: Write-only, non-blocking (server-side)
-  - `"rB"`: Read-only, blocking
-  - `"wB"`: Write-only, blocking
-- `buffsize` (optional): Buffer size, default is 0
-
 ### Server-side Example
 
 ```lua
@@ -148,19 +166,30 @@ pipefile:close()
 
 - Read data from pipe
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local read, data = pipefile:read(buff, size, opt)
+pipe:read(buff: <bytes>, size: <number>, opt: <table>)
 ```
+:::
 
-Reads data from the pipe into the specified buffer.
+#### Parameter Description
 
-Parameters:
-- `buff`: bytes buffer object to store the read data
-- `size`: Number of bytes to read
-- `opt` (optional): Option parameters
-  - `block`: Whether to block reading, default false
-  - `start`: Buffer start position, default 1
-  - `timeout`: Timeout in milliseconds, default -1 (infinite wait)
+| Parameter | Description |
+|-----------|-------------|
+| buff | Required. bytes buffer object to store the read data |
+| size | Required. Number of bytes to read |
+| opt | Optional. Option parameters |
+
+Options:
+- `block`: Whether to block reading, default false
+- `start`: Buffer start position, default 1
+- `timeout`: Timeout in milliseconds, default -1 (infinite wait)
+
+#### Usage
+
+Reads data from the pipe into the specified buffer.
 
 Return values:
 - `read`: Actual number of bytes read, returns -1 on failure
@@ -183,19 +212,30 @@ end
 
 - Write data to pipe
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local write = pipefile:write(data, opt)
+pipe:write(data: <string|bytes>, opt: <table>)
 ```
+:::
 
-Writes data to the pipe.
+#### Parameter Description
 
-Parameters:
-- `data`: Data to write, can be string or bytes object
-- `opt` (optional): Option parameters
-  - `block`: Whether to block writing, default false
-  - `start`: Data start position, default 1
-  - `last`: Data end position, default is data size
-  - `timeout`: Timeout in milliseconds, default -1
+| Parameter | Description |
+|-----------|-------------|
+| data | Required. Data to write, can be string or bytes object |
+| opt | Optional. Option parameters |
+
+Options:
+- `block`: Whether to block writing, default false
+- `start`: Data start position, default 1
+- `last`: Data end position, default is data size
+- `timeout`: Timeout in milliseconds, default -1
+
+#### Usage
+
+Writes data to the pipe.
 
 Return values:
 - `write`: Actual number of bytes written, returns -1 on failure
@@ -214,15 +254,26 @@ end
 
 - Connect to named pipe (server-side)
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok = pipefile:connect(opt)
+pipe:connect(opt: <table>)
 ```
+:::
 
-Connects to a named pipe, only used on the server-side of named pipes. After creating a named pipe on the server, call this method to wait for client connection.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| opt | Optional. Option parameters |
 
-Parameters:
-- `opt` (optional): Option parameters
-  - `timeout`: Timeout in milliseconds, default -1
+Options:
+- `timeout`: Timeout in milliseconds, default -1
+
+#### Usage
+
+Connects to a named pipe, only used on the server-side of named pipes. After creating a named pipe on the server, call this method to wait for client connection.
 
 Return values:
 - Returns a positive number on success, -1 on failure
@@ -241,18 +292,29 @@ end
 
 - Wait for pipe events
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local events = pipefile:wait(events, timeout)
+pipe:wait(events: <number>, timeout: <number>)
 ```
+:::
 
-Waits for specified pipe events to occur. In non-blocking mode, this method can be used to implement event-driven I/O.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| events | Required. Events to wait for |
+| timeout | Required. Timeout in milliseconds, -1 means wait indefinitely |
 
-Parameters:
-- `events`: Events to wait for, supports the following event constants:
-  - `pipe.EV_READ` (1): Readable event, indicates pipe has data to read
-  - `pipe.EV_WRITE` (2): Writable event, indicates pipe can accept data
-  - `pipe.EV_CONN` (2): Connection event, used for named pipes to wait for client connection
-- `timeout`: Timeout in milliseconds, -1 means wait indefinitely
+Event constants:
+- `pipe.EV_READ` (1): Readable event, indicates pipe has data to read
+- `pipe.EV_WRITE` (2): Writable event, indicates pipe can accept data
+- `pipe.EV_CONN` (2): Connection event, used for named pipes to wait for client connection
+
+#### Usage
+
+Waits for specified pipe events to occur. In non-blocking mode, this method can be used to implement event-driven I/O.
 
 Return values:
 - Returns the actual event constant value that occurred
@@ -279,9 +341,19 @@ end
 
 - Close the pipe
 
+#### Function Prototype
+
+::: tip API
 ```lua
-pipefile:close()
+pipe:close()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Closes the pipe and releases resources. Pipes should be closed promptly after use.
 
@@ -289,9 +361,19 @@ Closes the pipe and releases resources. Pipes should be closed promptly after us
 
 - Get pipe name
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local name = pipefile:name()
+pipe:name()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Gets the name of a named pipe. Returns nil for anonymous pipes.
 

+ 108 - 25
docs/api/scripts/extension-modules/core/base/process.md

@@ -11,17 +11,20 @@ To use this module, you need to import it first: `import("core.base.process")`
 
 - Open a subprocess with command string
 
-```lua
-import("core.base.process")
+#### Function Prototype
 
-local proc = process.open(command, opt)
+::: tip API
+```lua
+process.open(command: <string>, opt: <table>)
 ```
+:::
 
-Creates a new subprocess by executing a command string. Returns a subprocess object that can be used to control and communicate with the process.
+#### Parameter Description
 
-Parameters:
-- `command` - Required. The command string to execute
-- `opt` - Optional. Process options table
+| Parameter | Description |
+|-----------|-------------|
+| command | Required. The command string to execute |
+| opt | Optional. Process options table |
 
 Options in `opt`:
 - `stdin` - Input source (file path, file object, or pipe object)
@@ -29,6 +32,10 @@ Options in `opt`:
 - `stderr` - Error output destination (file path, file object, or pipe object)
 - `envs` - Environment variables array (e.g., `{"PATH=xxx", "XXX=yyy"}`)
 
+#### Usage
+
+Creates a new subprocess by executing a command string. Returns a subprocess object that can be used to control and communicate with the process.
+
 ```lua
 -- Basic process execution
 local proc = process.open("echo hello world")
@@ -64,18 +71,25 @@ proc:close()
 
 - Open a subprocess with program and arguments list
 
-```lua
-import("core.base.process")
+#### Function Prototype
 
-local proc = process.openv(program, argv, opt)
+::: tip API
+```lua
+process.openv(program: <string>, argv: <table>, opt: <table>)
 ```
+:::
 
-Creates a new subprocess by executing a program with a list of arguments. This is safer than `process.open` as it avoids shell interpretation issues.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| program | Required. The program to execute |
+| argv | Required. Array of arguments to pass to the program |
+| opt | Optional. Process options table (same as `process.open`) |
 
-Parameters:
-- `program` - Required. The program to execute
-- `argv` - Required. Array of arguments to pass to the program
-- `opt` - Optional. Process options table (same as `process.open`)
+#### Usage
+
+Creates a new subprocess by executing a program with a list of arguments. This is safer than `process.open` as it avoids shell interpretation issues.
 
 ```lua
 -- Execute program with arguments
@@ -111,14 +125,23 @@ proc:close()
 
 - Wait for subprocess to complete
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok, status = process:wait(timeout)
+process:wait(timeout: <number>)
 ```
+:::
 
-Waits for the subprocess to complete and returns the exit status. Can be used with or without timeout.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| timeout | Optional. Timeout in milliseconds. Use -1 for infinite wait, 0 for non-blocking |
+
+#### Usage
 
-Parameters:
-- `timeout` - Optional. Timeout in milliseconds. Use -1 for infinite wait, 0 for non-blocking
+Waits for the subprocess to complete and returns the exit status. Can be used with or without timeout.
 
 Returns:
 - `ok` - Exit code (0 for success, negative for error)
@@ -160,9 +183,19 @@ proc:close()
 
 - Kill the subprocess
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local success, error = process:kill()
+process:kill()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Terminates the subprocess immediately. Returns true if successful, false with error message if failed.
 
@@ -197,9 +230,19 @@ proc:close()
 
 - Close the subprocess
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local success = process:close()
+process:close()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Closes the subprocess and releases associated resources. Should be called when done with the process.
 
@@ -223,9 +266,19 @@ proc:close()
 
 - Get the process name
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local name = process:name()
+process:name()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the name of the process (filename without path).
 
@@ -239,9 +292,19 @@ proc:close()
 
 - Get the process program path
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local program = process:program()
+process:program()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the full program path that was used to start the process.
 
@@ -255,9 +318,19 @@ proc:close()
 
 - Get the process cdata
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local cdata = process:cdata()
+process:cdata()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the underlying cdata object for the process. Used internally by the scheduler and other low-level operations.
 
@@ -272,9 +345,19 @@ proc:close()
 
 - Get the object type
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local type = process:otype()
+process:otype()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the object type identifier. For subprocess objects, this returns 3 (poller.OT_PROC).
 

+ 122 - 16
docs/api/scripts/extension-modules/core/base/queue.md

@@ -11,11 +11,19 @@ To use this module, you need to import it first: `import("core.base.queue")`
 
 - Create an empty queue
 
-```lua
-import("core.base.queue")
+#### Function Prototype
 
-local q = queue.new()
+::: tip API
+```lua
+queue.new()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates a new empty queue object.
 
@@ -29,9 +37,21 @@ print(q:empty())  -- Output: true
 
 - Enqueue (add element to the end)
 
+#### Function Prototype
+
+::: tip API
 ```lua
-queue:push(item)
+queue:push(item: <any>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| item | Required. Element to add to the queue |
+
+#### Usage
 
 Adds an element to the end of the queue. This is a fundamental queue operation.
 
@@ -60,9 +80,19 @@ q:push(true)
 
 - Dequeue (remove and return element from the front)
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local item = queue:pop()
+queue:pop()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes and returns an element from the front of the queue. Returns nil if the queue is empty. This is a fundamental queue operation.
 
@@ -96,9 +126,19 @@ end
 
 - Peek at the front element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local item = queue:first()
+queue:first()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the first element (front) of the queue without removing it. Returns nil if the queue is empty.
 
@@ -129,9 +169,19 @@ end
 
 - Peek at the rear element
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local item = queue:last()
+queue:last()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the last element (rear) of the queue without removing it. Returns nil if the queue is empty.
 
@@ -149,9 +199,19 @@ print(q:size())   -- Output: 3 (element not removed)
 
 - Get queue size
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local count = queue:size()
+queue:size()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns the number of elements in the queue.
 
@@ -171,9 +231,19 @@ print(q:size())  -- Output: 2
 
 - Check if queue is empty
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local is_empty = queue:empty()
+queue:empty()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns true if the queue is empty (contains no elements).
 
@@ -203,9 +273,19 @@ end
 
 - Clear the queue
 
+#### Function Prototype
+
+::: tip API
 ```lua
 queue:clear()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Removes all elements from the queue, resetting it to an empty queue.
 
@@ -226,9 +306,19 @@ print(q:empty()) -- Output: true
 
 - Clone the queue
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local new_queue = queue:clone()
+queue:clone()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates a complete copy of the queue, with the new queue being independent of the original.
 
@@ -252,11 +342,19 @@ print(q2:size())  -- Output: 2 (copy modified)
 
 - Iterate forward through the queue
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in queue:items() do
-    -- Process item
-end
+queue:items()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the queue from front to rear.
 
@@ -297,11 +395,19 @@ Iteration does not modify the queue content; elements remain in the queue after
 
 - Iterate backward through the queue
 
+#### Function Prototype
+
+::: tip API
 ```lua
-for item in queue:ritems() do
-    -- Process item
-end
+queue:ritems()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Returns an iterator function for traversing all elements in the queue from rear to front.
 

+ 219 - 159
docs/api/scripts/extension-modules/core/base/scheduler.md

@@ -10,19 +10,24 @@ To use this module, you need to import it first: `import("core.base.scheduler")`
 
 - Start a new coroutine task
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local co = scheduler.co_start(function()
-    print("Hello from coroutine!")
-end)
+::: tip API
+```lua
+scheduler.co_start(cotask: <function>, ...)
 ```
+:::
 
-Start a new coroutine and execute the specified task function. The coroutine will start executing immediately unless the scheduler is not yet started.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| cotask | Required. The coroutine task function to execute |
+| ... | Optional. Arguments to pass to the task function |
 
-Parameters:
-- `cotask` - Required. The coroutine task function to execute
-- `...` - Optional. Arguments to pass to the task function
+#### Usage
+
+Start a new coroutine and execute the specified task function. The coroutine will start executing immediately unless the scheduler is not yet started.
 
 Return value:
 - Returns coroutine object on success, nil and error message on failure
@@ -50,20 +55,25 @@ print("Completed", count, "tasks")
 
 - Start a named coroutine task
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local co = scheduler.co_start_named("worker", function()
-    print("Named coroutine started")
-end)
+::: tip API
+```lua
+scheduler.co_start_named(coname: <string>, cotask: <function>, ...)
 ```
+:::
 
-Start a coroutine task with a specified name for easier debugging and monitoring.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| coname | Required. Coroutine name |
+| cotask | Required. The coroutine task function to execute |
+| ... | Optional. Arguments to pass to the task function |
 
-Parameters:
-- `coname` - Required. Coroutine name
-- `cotask` - Required. The coroutine task function to execute
-- `...` - Optional. Arguments to pass to the task function
+#### Usage
+
+Start a coroutine task with a specified name for easier debugging and monitoring.
 
 ```lua
 -- Start multiple named coroutines
@@ -80,23 +90,25 @@ end
 
 - Start a coroutine task with options
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local co = scheduler.co_start_withopt({
-    name = "isolated-worker",
-    isolate = true
-}, function()
-    print("Isolated coroutine started")
-end)
+::: tip API
+```lua
+scheduler.co_start_withopt(opt: <table>, cotask: <function>, ...)
 ```
+:::
 
-Start a coroutine task with specific options.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| opt | Required. Coroutine options table |
+| cotask | Required. The coroutine task function to execute |
+| ... | Optional. Arguments to pass to the task function |
 
-Parameters:
-- `opt` - Required. Coroutine options table
-- `cotask` - Required. The coroutine task function to execute
-- `...` - Optional. Arguments to pass to the task function
+#### Usage
+
+Start a coroutine task with specific options.
 
 `opt` options:
 - `name` - Coroutine name
@@ -118,15 +130,19 @@ end)
 
 - Suspend the current coroutine
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function task()
-    print("Task started")
-    scheduler.co_suspend()  -- Suspend coroutine
-    print("Task resumed")
-end
+::: tip API
+```lua
+scheduler.co_suspend()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Suspend the currently executing coroutine and yield execution to other coroutines.
 
@@ -148,23 +164,24 @@ end)
 
 - Resume a suspended coroutine
 
+#### Function Prototype
+
+::: tip API
 ```lua
-import("core.base.scheduler")
+scheduler.co_resume(co: <coroutine>, ...)
+```
+:::
 
-local co = scheduler.co_start(function()
-    local value = scheduler.co_suspend()
-    print("Resumed with value:", value)
-end)
+#### Parameter Description
 
--- Resume coroutine and pass arguments
-scheduler.co_resume(co, "hello")
-```
+| Parameter | Description |
+|-----------|-------------|
+| co | Required. The coroutine object to resume |
+| ... | Optional. Arguments to pass to the coroutine |
 
-Resume the specified suspended coroutine and optionally pass arguments to it.
+#### Usage
 
-Parameters:
-- `co` - Required. The coroutine object to resume
-- `...` - Optional. Arguments to pass to the coroutine
+Resume the specified suspended coroutine and optionally pass arguments to it.
 
 ```lua
 -- Coroutine communication example
@@ -185,16 +202,19 @@ print("Got result:", result)
 
 - Yield execution of the current coroutine
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function task()
-    for i = 1, 5 do
-        print("Task step", i)
-        scheduler.co_yield()  -- Yield execution
-    end
-end
+::: tip API
+```lua
+scheduler.co_yield()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Yield execution of the current coroutine to allow other coroutines to run. This is a key function for cooperative multitasking.
 
@@ -217,20 +237,23 @@ scheduler.co_group_wait("cooperative")
 
 - Sleep the coroutine for specified time
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function delayed_task()
-    print("Task started")
-    scheduler.co_sleep(1000)  -- Sleep for 1 second
-    print("Task resumed after sleep")
-end
+::: tip API
+```lua
+scheduler.co_sleep(ms: <number>)
 ```
+:::
 
-Make the current coroutine sleep for the specified number of milliseconds, during which other coroutines can continue executing.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| ms | Required. Sleep time in milliseconds, 0 means no sleep |
 
-Parameters:
-- `ms` - Required. Sleep time in milliseconds, 0 means no sleep
+#### Usage
+
+Make the current coroutine sleep for the specified number of milliseconds, during which other coroutines can continue executing.
 
 ```lua
 -- Timed task example
@@ -247,22 +270,23 @@ end
 
 - Lock the specified lock
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function critical_section()
-    scheduler.co_lock("shared_resource")
-    print("Entering critical section")
-    -- Critical section code
-    scheduler.co_unlock("shared_resource")
-    print("Leaving critical section")
-end
+::: tip API
+```lua
+scheduler.co_lock(lockname: <string>)
 ```
+:::
 
-Acquire the lock with the specified name. If the lock is already held by another coroutine, the current coroutine will wait until the lock becomes available.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| lockname | Required. The name of the lock |
 
-Parameters:
-- `lockname` - Required. The name of the lock
+#### Usage
+
+Acquire the lock with the specified name. If the lock is already held by another coroutine, the current coroutine will wait until the lock becomes available.
 
 ```lua
 -- Mutex lock example
@@ -284,43 +308,46 @@ end
 
 - Release the specified lock
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function critical_section()
-    scheduler.co_lock("my_lock")
-    -- Critical section code
-    scheduler.co_unlock("my_lock")
-end
+::: tip API
+```lua
+scheduler.co_unlock(lockname: <string>)
 ```
+:::
 
-Release the lock with the specified name, allowing other waiting coroutines to acquire the lock.
+#### Parameter Description
 
-Parameters:
-- `lockname` - Required. The name of the lock to release
+| Parameter | Description |
+|-----------|-------------|
+| lockname | Required. The name of the lock to release |
+
+#### Usage
+
+Release the lock with the specified name, allowing other waiting coroutines to acquire the lock.
 
 ## scheduler.co_group_begin
 
 - Begin a coroutine group
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-scheduler.co_group_begin("workers", function(group)
-    -- All coroutines started in this scope will join the group
-    for i = 1, 5 do
-        scheduler.co_start(function()
-            print("Worker", i, "started")
-        end)
-    end
-end)
+::: tip API
+```lua
+scheduler.co_group_begin(name: <string>, scopefunc: <function>)
 ```
+:::
 
-Begin a new coroutine group. All coroutines started within the specified function will join this group.
+#### Parameter Description
 
-Parameters:
-- `name` - Required. The coroutine group name
-- `scopefunc` - Required. The scope function
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. The coroutine group name |
+| scopefunc | Required. The scope function |
+
+#### Usage
+
+Begin a new coroutine group. All coroutines started within the specified function will join this group.
 
 ```lua
 -- Batch job processing example
@@ -340,31 +367,28 @@ end)
 
 - Wait for coroutine group completion
 
-```lua
-import("core.base.scheduler")
-
-scheduler.co_group_begin("test", function()
-    for i = 1, 10 do
-        scheduler.co_start(function()
-            print("Task", i, "completed")
-        end)
-    end
-end)
+#### Function Prototype
 
--- Wait for all coroutines to complete
-scheduler.co_group_wait("test")
-print("All tasks completed")
+::: tip API
+```lua
+scheduler.co_group_wait(name: <string>, opt: <table>)
 ```
+:::
 
-Wait for all coroutines in the specified group to complete execution.
+#### Parameter Description
 
-Parameters:
-- `name` - Required. The coroutine group name
-- `opt` - Optional. Wait options
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. The coroutine group name |
+| opt | Optional. Wait options |
 
 `opt` options:
 - `limit` - Maximum number of coroutines to wait for completion (default wait for all coroutines)
 
+#### Usage
+
+Wait for all coroutines in the specified group to complete execution.
+
 ```lua
 -- Limited wait example
 scheduler.co_group_begin("limited", function()
@@ -386,17 +410,19 @@ print("First 3 tasks completed")
 
 - Get the currently running coroutine
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-function task()
-    local co = scheduler.co_running()
-    if co then
-        print("Current coroutine name:", co:name())
-        print("Current coroutine status:", co:status())
-    end
-end
+::: tip API
+```lua
+scheduler.co_running()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Get the currently running coroutine object.
 
@@ -419,11 +445,19 @@ end)
 
 - Get the total number of coroutines
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-print("Total coroutines:", scheduler.co_count())
+::: tip API
+```lua
+scheduler.co_count()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Get the total number of active coroutines in the current scheduler.
 
@@ -449,17 +483,24 @@ print("After starting tasks:", scheduler.co_count())
 
 - Create a coroutine semaphore
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local semaphore = scheduler.co_semaphore("test", 2)  -- Initial value is 2
+::: tip API
+```lua
+scheduler.co_semaphore(name: <string>, value: <number>)
 ```
+:::
 
-Create a new coroutine semaphore for synchronization and resource control between coroutines.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Semaphore name |
+| value | Optional. Initial semaphore value (default 0) |
 
-Parameters:
-- `name` - Required. Semaphore name
-- `value` - Optional. Initial semaphore value (default 0)
+#### Usage
+
+Create a new coroutine semaphore for synchronization and resource control between coroutines.
 
 Return value:
 - Semaphore object
@@ -484,17 +525,23 @@ end
 
 - Wait for semaphore
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local semaphore = scheduler.co_semaphore("test", 1)
-local value = semaphore:wait(5000)  -- Wait for 5 seconds
+::: tip API
+```lua
+co_semaphore:wait(timeout: <number>)
 ```
+:::
 
-Wait for the semaphore. If the semaphore value is greater than 0, return immediately; otherwise, suspend the current coroutine until the semaphore becomes available.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| timeout | Optional. Timeout in milliseconds, -1 means wait indefinitely, 0 means don't wait |
 
-Parameters:
-- `timeout` - Optional. Timeout in milliseconds, -1 means wait indefinitely, 0 means don't wait
+#### Usage
+
+Wait for the semaphore. If the semaphore value is greater than 0, return immediately; otherwise, suspend the current coroutine until the semaphore becomes available.
 
 Return value:
 - Returns semaphore value on success, 0 on timeout, -1 on error
@@ -525,17 +572,23 @@ end)
 
 - Release semaphore
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local semaphore = scheduler.co_semaphore("test", 0)
-local new_value = semaphore:post(2)  -- Increase by 2
+::: tip API
+```lua
+co_semaphore:post(value: <number>)
 ```
+:::
 
-Release the semaphore by increasing its value and wake up waiting coroutines.
+#### Parameter Description
 
-Parameters:
-- `value` - Required. The value to increase by
+| Parameter | Description |
+|-----------|-------------|
+| value | Required. The value to increase by |
+
+#### Usage
+
+Release the semaphore by increasing its value and wake up waiting coroutines.
 
 Return value:
 - The new semaphore value after release
@@ -563,12 +616,19 @@ end
 
 - Get semaphore name
 
-```lua
-import("core.base.scheduler")
+#### Function Prototype
 
-local semaphore = scheduler.co_semaphore("my_semaphore", 1)
-print("Semaphore name:", semaphore:name())
+::: tip API
+```lua
+co_semaphore:name()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Get the semaphore name.
 

+ 281 - 0
docs/api/scripts/extension-modules/core/base/semver.md

@@ -9,6 +9,24 @@ We can use `import("core.base.semver")` for direct import and use.
 
 - Create a new semver instance from a version string. Raise an error if the parsing failed
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.new(version: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| version | Required. Version string |
+
+#### Usage
+
+Creates a new semver instance from a version string. Raises an error if parsing fails.
+
 ```lua
 local version = semver.new("v2.1.0")
 ```
@@ -17,6 +35,24 @@ local version = semver.new("v2.1.0")
 
 - Same as new, but return a nil value if the parsing failed
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.try_parse(version: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| version | Required. Version string |
+
+#### Usage
+
+Same as new, but returns nil value if parsing failed.
+
 ```lua
 local version = semver.try_parse("v2.1.0")
 ```
@@ -25,6 +61,26 @@ local version = semver.try_parse("v2.1.0")
 
 - Match a valid version from the string
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.match(str: <string>, pos: <number>, pattern: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| str | Required. String to match from |
+| pos | Required. Start position |
+| pattern | Optional. Pattern to match |
+
+#### Usage
+
+Matches a valid version from the string.
+
 ```lua
 print(semver.match("v2.1.0", 1)) -- start from position 1
 print(semver.match("v2.1.0", 0, "%d+%.%d+"))
@@ -39,6 +95,24 @@ print(semver.match("v2.1.0", 0, "%d+%.%d+"))
 
 - Get if a given string version is valid, by testing if the version can be parsed
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.is_valid(version: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| version | Required. Version string to validate |
+
+#### Usage
+
+Tests if the version can be parsed.
+
 ```lua
 print(semver.is_valid("536f2bd6a092eba91315b7d1e120dff63392a11d"))
 print(semver.is_valid("v2.1.0-pre"))
@@ -53,6 +127,24 @@ true
 
 - Test if the given range is a valid one
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.is_valid_range(range: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| range | Required. Range string to validate |
+
+#### Usage
+
+Tests if the given range is a valid one.
+
 ```lua
 print(semver.is_valid_range(">2.1.0"))
 print(semver.is_valid_range(">v2.1.0"))
@@ -70,6 +162,25 @@ true
 
 - Compare two versions, return a number between 1 and -1
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.compare(v1: <string>, v2: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| v1 | Required. First version string |
+| v2 | Required. Second version string |
+
+#### Usage
+
+Compares two versions and returns a number between -1 and 1.
+
 ```lua
 print(semver.compare("v2.2", "v2.2.0"))
 print(semver.compare("v2.2.0", "v2.1.0"))
@@ -88,6 +199,25 @@ print(semver.compare("v2.1.0", "v2.2.0"))
 
 - Check if a version satisfies a range version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.satisfies(version: <string>, range: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| version | Required. Version string |
+| range | Required. Range string |
+
+#### Usage
+
+Checks if a version satisfies a range version.
+
 ```lua
 print(semver.satisfies("v2.1.0", ">= 2.1"))
 print(semver.satisfies("v2.1.0", ">1.0 <2.1"))
@@ -106,6 +236,27 @@ true
 
 - Select required version from versions, tags and branches
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver.select(range: <string>, versions: <table>, tags: <table>, branches: <table>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| range | Required. Range string |
+| versions | Required. Array of versions |
+| tags | Required. Array of tags |
+| branches | Required. Array of branches |
+
+#### Usage
+
+Selects required version from versions, tags and branches.
+
 ```lua
 local version, source = semver.select(">=1.5.0 <1.6", {"1.5.0", "1.5.1"}, {"v1.5.0"}, {"master", "dev"})
 print(semver.select(">=1.5.0 <1.6", {"1.5.0", "1.5.1"}, {"v1.5.0"}, {"master", "dev"}))
@@ -123,6 +274,24 @@ master branch
 
 - Get a value from the informations table
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:get(key: <string>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| key | Required. Information key |
+
+#### Usage
+
+Gets a value from the informations table.
+
 ```lua
 local version = semver.new("v2.1.0+build")
 print(version["_INFO"])
@@ -149,6 +318,22 @@ print(version:get("major"))
 
 - Get the major version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:major()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the major version number.
+
 ```lua
 semver.new("v2.1.0"):major() -- return 2
 ```
@@ -157,6 +342,22 @@ semver.new("v2.1.0"):major() -- return 2
 
 - Get the minor version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:minor()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the minor version number.
+
 ```lua
 semver.new("v2.1.0"):minor() -- return 1
 ```
@@ -165,6 +366,22 @@ semver.new("v2.1.0"):minor() -- return 1
 
 - Get the patch version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:patch()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the patch version number.
+
 ```lua
 semver.new("v2.1.0"):patch() -- return 0
 ```
@@ -173,6 +390,22 @@ semver.new("v2.1.0"):patch() -- return 0
 
 - Get the build version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:build()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the build version.
+
 ```lua
 semver.new("v2.1.0+build"):build() -- return {"build"}
 ```
@@ -181,6 +414,22 @@ semver.new("v2.1.0+build"):build() -- return {"build"}
 
 - Get the prerelease version
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:prerelease()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the prerelease version.
+
 ```lua
 semver.new("v2.1.0-prerelease"):prerelease() -- return {"prerelease"}
 ```
@@ -189,6 +438,22 @@ semver.new("v2.1.0-prerelease"):prerelease() -- return {"prerelease"}
 
 - Get the raw string
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:rawstr()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the raw version string.
+
 ```lua
 semver.new("v2.1.0+build"):rawstr() -- return v2.1.0+build
 ```
@@ -197,6 +462,22 @@ semver.new("v2.1.0+build"):rawstr() -- return v2.1.0+build
 
 - Get the short version string
 
+#### Function Prototype
+
+::: tip API
+```lua
+semver:shortstr()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Returns the short version string.
+
 ```lua
 semver.new("v2.1.0+build"):shortstr() -- return 2.1.0
 ```

+ 293 - 113
docs/api/scripts/extension-modules/core/base/socket.md

@@ -11,22 +11,31 @@ To use this module, you need to import it first: `import("core.base.socket")`
 
 - Create a TCP socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.tcp()
+::: tip API
+```lua
+socket.tcp(opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| opt | Optional. Option parameters |
+
+Options:
+- `family`: Address family, options:
+  - `socket.IPV4` (1) - IPv4 address family (default)
+  - `socket.IPV6` (2) - IPv6 address family
+
+#### Usage
 
 Creates a TCP socket object (`socket.TCP`), using IPv4 by default.
 
 TCP is a connection-oriented, reliable stream protocol that guarantees data arrives in order, suitable for most network communication scenarios.
 
-Parameters:
-- `opt` (optional): Option parameters
-  - `family`: Address family, options:
-    - `socket.IPV4` (1) - IPv4 address family (default)
-    - `socket.IPV6` (2) - IPv6 address family
-
 ```lua
 -- Create IPv4 TCP socket
 local sock = socket.tcp()
@@ -39,20 +48,29 @@ local sock = socket.tcp({family = socket.IPV6})
 
 - Create a UDP socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.udp()
+::: tip API
+```lua
+socket.udp(opt: <table>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| opt | Optional. Option parameters |
+
+Options:
+- `family`: Address family, can be `socket.IPV4` (default) or `socket.IPV6`
+
+#### Usage
 
 Creates a UDP socket object (`socket.UDP`) for connectionless datagram communication.
 
 UDP is a connectionless, unreliable datagram protocol that doesn't guarantee data arrival or order, but has low latency, suitable for real-time communication, broadcasting, etc.
 
-Parameters:
-- `opt` (optional): Option parameters
-  - `family`: Address family, can be `socket.IPV4` (default) or `socket.IPV6`
-
 UDP is suitable for scenarios requiring low latency and can tolerate some packet loss:
 
 ```lua
@@ -75,11 +93,19 @@ sock:close()
 
 - Create a Unix domain socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.unix()
+::: tip API
+```lua
+socket.unix()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Creates a Unix domain socket (address family `socket.UNIX`) for inter-process communication on the same machine.
 
@@ -91,18 +117,25 @@ Only available on Unix/Linux/macOS systems. Suitable for high-performance local
 
 - Create and bind a TCP socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.bind(addr, port, opt)
+::: tip API
+```lua
+socket.bind(addr: <string>, port: <number>, opt: <table>)
 ```
+:::
 
-Creates a TCP socket and binds it to the specified address and port, typically used for servers.
+#### Parameter Description
 
-Parameters:
-- `addr`: IP address, such as `"127.0.0.1"` or `"0.0.0.0"`
-- `port`: Port number
-- `opt` (optional): Option parameters, same as [socket.tcp](#socket-tcp)
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. IP address, such as "127.0.0.1" or "0.0.0.0" |
+| port | Required. Port number |
+| opt | Optional. Option parameters, same as socket.tcp |
+
+#### Usage
+
+Creates a TCP socket and binds it to the specified address and port, typically used for servers.
 
 Complete TCP echo server example:
 
@@ -145,18 +178,27 @@ end
 
 - Create and bind a Unix domain socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.bind_unix(addr, opt)
+::: tip API
+```lua
+socket.bind_unix(addr: <string>, opt: <table>)
 ```
+:::
 
-Creates a Unix domain socket and binds it to the specified path.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. Unix domain socket path |
+| opt | Optional. Option parameters |
 
-Parameters:
-- `addr`: Unix domain socket path
-- `opt` (optional): Option parameters
-  - `is_abstract`: Whether to use abstract namespace (Linux only)
+Options:
+- `is_abstract`: Whether to use abstract namespace (Linux only)
+
+#### Usage
+
+Creates a Unix domain socket and binds it to the specified path.
 
 ```lua
 import("core.base.socket")
@@ -170,20 +212,29 @@ server:listen(10)
 
 - Create and connect a TCP socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.connect(addr, port, opt)
+::: tip API
+```lua
+socket.connect(addr: <string>, port: <number>, opt: <table>)
 ```
+:::
 
-Creates a TCP socket and connects to the specified address and port, used for clients.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. Server IP address |
+| port | Required. Server port number |
+| opt | Optional. Option parameters |
+
+Options:
+- `family`: Address family
+- `timeout`: Connection timeout (milliseconds)
 
-Parameters:
-- `addr`: Server IP address
-- `port`: Server port number
-- `opt` (optional): Option parameters
-  - `family`: Address family
-  - `timeout`: Connection timeout (milliseconds)
+#### Usage
+
+Creates a TCP socket and connects to the specified address and port, used for clients.
 
 Complete TCP client example:
 
@@ -220,27 +271,49 @@ end
 
 - Create and connect a Unix domain socket
 
-```lua
-import("core.base.socket")
+#### Function Prototype
 
-local sock = socket.connect_unix(addr, opt)
+::: tip API
+```lua
+socket.connect_unix(addr: <string>, opt: <table>)
 ```
+:::
 
-Creates a Unix domain socket and connects to the specified path.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. Unix domain socket path |
+| opt | Optional. Option parameters |
 
-Parameters:
-- `addr`: Unix domain socket path
-- `opt` (optional): Option parameters
-  - `is_abstract`: Whether to use abstract namespace (Linux only)
-  - `timeout`: Connection timeout
+Options:
+- `is_abstract`: Whether to use abstract namespace (Linux only)
+- `timeout`: Connection timeout
+
+#### Usage
+
+Creates a Unix domain socket and connects to the specified path.
 
 ## socket:bind
 
 - Bind socket to address
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok = sock:bind(addr, port)
+socket:bind(addr: <string>, port: <number>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. IP address |
+| port | Required. Port number |
+
+#### Usage
 
 Binds the socket to the specified IP address and port.
 
@@ -250,14 +323,23 @@ Return value: Returns a positive number on success, -1 and error message on fail
 
 - Start listening for connections
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok = sock:listen(backlog)
+socket:listen(backlog: <number>)
 ```
+:::
 
-Makes the socket start listening for client connections, used for servers.
+#### Parameter Description
 
-Parameters:
-- `backlog`: Maximum length of the pending connection queue, default 10
+| Parameter | Description |
+|-----------|-------------|
+| backlog | Optional. Maximum length of the pending connection queue, default 10 |
+
+#### Usage
+
+Makes the socket start listening for client connections, used for servers.
 
 Must be called after `bind` and before `accept`.
 
@@ -265,15 +347,26 @@ Must be called after `bind` and before `accept`.
 
 - Accept client connection
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local client_sock = sock:accept(opt)
+socket:accept(opt: <table>)
 ```
+:::
 
-Accepts a client connection, returns a new socket object for communicating with the client.
+#### Parameter Description
 
-Parameters:
-- `opt` (optional): Option parameters
-  - `timeout`: Timeout (milliseconds), default -1 (infinite wait)
+| Parameter | Description |
+|-----------|-------------|
+| opt | Optional. Option parameters |
+
+Options:
+- `timeout`: Timeout (milliseconds), default -1 (infinite wait)
+
+#### Usage
+
+Accepts a client connection, returns a new socket object for communicating with the client.
 
 Return value: Returns client socket object on success, nil and error message on failure.
 
@@ -291,17 +384,28 @@ end
 
 - Connect to remote address
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok = sock:connect(addr, port, opt)
+socket:connect(addr: <string>, port: <number>, opt: <table>)
 ```
+:::
 
-Connects to the specified remote address and port.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| addr | Required. Target IP address |
+| port | Required. Target port number |
+| opt | Optional. Option parameters |
 
-Parameters:
-- `addr`: Target IP address
-- `port`: Target port number
-- `opt` (optional): Option parameters
-  - `timeout`: Connection timeout (milliseconds)
+Options:
+- `timeout`: Connection timeout (milliseconds)
+
+#### Usage
+
+Connects to the specified remote address and port.
 
 Return value: Returns a positive number on success, -1 and error message on failure.
 
@@ -309,18 +413,29 @@ Return value: Returns a positive number on success, -1 and error message on fail
 
 - Send data
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local sent = sock:send(data, opt)
+socket:send(data: <string|bytes>, opt: <table>)
 ```
+:::
 
-Sends data through the socket.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| data | Required. Data to send, can be string or bytes object |
+| opt | Optional. Option parameters |
 
-Parameters:
-- `data`: Data to send, can be string or bytes object
-- `opt` (optional): Option parameters
-  - `block`: Whether to block sending, default false
-  - `start`: Data start position, default 1
-  - `last`: Data end position, default is data size
+Options:
+- `block`: Whether to block sending, default false
+- `start`: Data start position, default 1
+- `last`: Data end position, default is data size
+
+#### Usage
+
+Sends data through the socket.
 
 Return value: Actual number of bytes sent, returns -1 on failure.
 
@@ -341,18 +456,29 @@ end
 
 - Receive data
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local recv, data = sock:recv(buff, size, opt)
+socket:recv(buff: <bytes>, size: <number>, opt: <table>)
 ```
+:::
 
-Receives data from the socket.
+#### Parameter Description
 
-Parameters:
-- `buff`: bytes buffer object
-- `size`: Number of bytes to receive
-- `opt` (optional): Option parameters
-  - `block`: Whether to block receiving, default false
-  - `timeout`: Timeout (milliseconds)
+| Parameter | Description |
+|-----------|-------------|
+| buff | Required. bytes buffer object |
+| size | Required. Number of bytes to receive |
+| opt | Optional. Option parameters |
+
+Options:
+- `block`: Whether to block receiving, default false
+- `timeout`: Timeout (milliseconds)
+
+#### Usage
+
+Receives data from the socket.
 
 Return values:
 - `recv`: Actual number of bytes received, returns -1 on failure
@@ -377,17 +503,26 @@ end
 
 - Send datagram (UDP)
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local sent = sock:sendto(data, addr, port, opt)
+socket:sendto(data: <string|bytes>, addr: <string>, port: <number>, opt: <table>)
 ```
+:::
 
-Sends a datagram to the specified address via UDP socket.
+#### Parameter Description
 
-Parameters:
-- `data`: Data to send, can be string or bytes object
-- `addr`: Target IP address
-- `port`: Target port number
-- `opt` (optional): Option parameters
+| Parameter | Description |
+|-----------|-------------|
+| data | Required. Data to send, can be string or bytes object |
+| addr | Required. Target IP address |
+| port | Required. Target port number |
+| opt | Optional. Option parameters |
+
+#### Usage
+
+Sends a datagram to the specified address via UDP socket.
 
 Return value: Actual number of bytes sent, returns -1 on failure.
 
@@ -403,17 +538,28 @@ sock:close()
 
 - Receive datagram (UDP)
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local recv, data, peer_addr, peer_port = sock:recvfrom(buff, size, opt)
+socket:recvfrom(buff: <bytes>, size: <number>, opt: <table>)
 ```
+:::
 
-Receives a datagram from the UDP socket and gets the sender's address information.
+#### Parameter Description
 
-Parameters:
-- `buff`: bytes buffer object
-- `size`: Number of bytes to receive
-- `opt` (optional): Option parameters
-  - `block`: Whether to block receiving
+| Parameter | Description |
+|-----------|-------------|
+| buff | Required. bytes buffer object |
+| size | Required. Number of bytes to receive |
+| opt | Optional. Option parameters |
+
+Options:
+- `block`: Whether to block receiving
+
+#### Usage
+
+Receives a datagram from the UDP socket and gets the sender's address information.
 
 Return values:
 - `recv`: Actual number of bytes received
@@ -450,19 +596,30 @@ end
 
 - Wait for socket events
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local events = sock:wait(events, timeout)
+socket:wait(events: <number>, timeout: <number>)
 ```
+:::
 
-Waits for specified socket events to occur.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| events | Required. Events to wait for, supports the following event constants |
+| timeout | Required. Timeout (milliseconds), -1 means infinite wait |
 
-Parameters:
-- `events`: Events to wait for, supports the following event constants:
-  - `socket.EV_RECV` (1): Receivable event
-  - `socket.EV_SEND` (2): Sendable event
-  - `socket.EV_CONN` (2): Connection event (equivalent to EV_SEND)
-  - `socket.EV_ACPT` (1): Accept connection event (equivalent to EV_RECV)
-- `timeout`: Timeout (milliseconds), -1 means infinite wait
+Supported event constants:
+- `socket.EV_RECV` (1): Receivable event
+- `socket.EV_SEND` (2): Sendable event
+- `socket.EV_CONN` (2): Connection event (equivalent to EV_SEND)
+- `socket.EV_ACPT` (1): Accept connection event (equivalent to EV_RECV)
+
+#### Usage
+
+Waits for specified socket events to occur.
 
 Return value: Returns the actual event constant value that occurred.
 
@@ -486,9 +643,19 @@ end
 
 - Close socket
 
+#### Function Prototype
+
+::: tip API
 ```lua
-sock:close()
+socket:close()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
 
 Closes the socket and releases resources. Sockets should be closed promptly after use.
 
@@ -496,16 +663,29 @@ Closes the socket and releases resources. Sockets should be closed promptly afte
 
 - Control socket options
 
+#### Function Prototype
+
+::: tip API
 ```lua
-local ok = sock:ctrl(code, value)
+socket:ctrl(code: <number>, value: <number>)
 ```
+:::
 
-Sets socket control options to adjust socket parameters such as buffer sizes.
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| code | Required. Control code constant |
+| value | Required. Control value |
 
 Supported control code constants:
 - `socket.CTRL_SET_RECVBUFF` (2): Set receive buffer size (bytes)
 - `socket.CTRL_SET_SENDBUFF` (4): Set send buffer size (bytes)
 
+#### Usage
+
+Sets socket control options to adjust socket parameters such as buffer sizes.
+
 Increasing buffer sizes can improve performance in high-throughput scenarios:
 
 ```lua

+ 18 - 0
docs/api/scripts/extension-modules/core/base/task.md

@@ -7,6 +7,24 @@ Used for task operations, generally used to call other task tasks in custom scri
 
 - Run the specified task
 
+#### Function Prototype
+
+::: tip API
+```lua
+task.run(name: <string>, opt: <table>, ...)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Task name |
+| opt | Optional. Task options table |
+| ... | Optional. Arguments passed to the task function |
+
+#### Usage
+
 Used to run tasks or plugins defined by [task](/api/description/plugin-and-task.html#task) in custom scripts, plugin tasks, for example:
 
 ```lua

+ 114 - 24
docs/api/scripts/extension-modules/core/base/thread.md

@@ -6,13 +6,24 @@ Provides native thread support for concurrent programming, including thread crea
 
 - Start a thread
 
-Creates and starts a thread to execute a callback function.
+#### Function Prototype
 
+::: tip API
 ```lua
-local t = thread.start(callback_function, ...)
+thread.start(callback: <function>, ...)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| callback | Required. Callback function to execute in the thread |
+| ... | Optional. Additional arguments passed to the callback function |
 
-Parameters: `callback` callback function to execute in the thread, `...` additional arguments passed to the callback function
+#### Usage
+
+Creates and starts a thread to execute a callback function.
 
 Return Value: Returns a thread object that can be used to wait for thread completion
 
@@ -24,13 +35,25 @@ Each thread is a separate Lua VM instance, their Lua variable states are complet
 
 - Start a named thread
 
-Creates and starts a new thread with the specified name and callback function.
+#### Function Prototype
 
+::: tip API
 ```lua
-local t = thread.start_named("thread_name", callback_function, ...)
+thread.start_named(name: <string>, callback: <function>, ...)
 ```
+:::
 
-Parameters: `name` thread name, `callback` callback function to execute in the thread, `...` additional arguments passed to the callback function
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Thread name |
+| callback | Required. Callback function to execute in the thread |
+| ... | Optional. Additional arguments passed to the callback function |
+
+#### Usage
+
+Creates and starts a new thread with the specified name and callback function.
 
 Return Value: Returns a thread object that can be used to wait for thread completion
 
@@ -65,13 +88,21 @@ end
 
 - Get the current thread name
 
-Returns the name of the currently running thread.
+#### Function Prototype
 
+::: tip API
 ```lua
-local name = thread.running()
+thread.running()
 ```
+:::
+
+#### Parameter Description
 
-### Return Value
+No parameters required for this function.
+
+#### Usage
+
+Returns the name of the currently running thread.
 
 Returns the name of the current thread as a string.
 
@@ -79,11 +110,21 @@ Returns the name of the current thread as a string.
 
 - Create a mutex object
 
-Creates a new mutex for thread synchronization.
+#### Function Prototype
 
+::: tip API
 ```lua
-local mutex = thread.mutex()
+thread.mutex()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Creates a new mutex for thread synchronization.
 
 Return Value: Returns a mutex object with the following methods: `mutex:lock()` lock the mutex, `mutex:unlock()` unlock the mutex
 
@@ -121,13 +162,21 @@ end
 
 - Create an event object
 
-Creates a new event for thread signaling and synchronization.
+#### Function Prototype
 
+::: tip API
 ```lua
-local event = thread.event()
+thread.event()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
 
-Parameters: `timeout` timeout in milliseconds (-1 for infinite wait)
+#### Usage
+
+Creates a new event for thread signaling and synchronization.
 
 Return Value: Returns an event object with the following methods: `event:wait(timeout)` wait for the event to be signaled, `event:post()` signal the event
 
@@ -168,13 +217,24 @@ end
 
 - Create a semaphore object
 
-Creates a new semaphore for thread synchronization and resource counting.
+#### Function Prototype
 
+::: tip API
 ```lua
-local semaphore = thread.semaphore(name, initial_count)
+thread.semaphore(name: <string>, initial_count: <number>)
 ```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| name | Required. Semaphore name |
+| initial_count | Required. Initial count value |
+
+#### Usage
 
-Parameters: `name` semaphore name, `initial_count` initial count value
+Creates a new semaphore for thread synchronization and resource counting.
 
 Return Value: Returns a semaphore object with the following methods: `semaphore:wait(timeout)` wait for semaphore (decrement count), `semaphore:post(count)` post to semaphore (increment count)
 
@@ -215,11 +275,21 @@ end
 
 - Create a thread-safe queue object
 
-Creates a new thread-safe queue for inter-thread data communication.
+#### Function Prototype
 
+::: tip API
 ```lua
-local queue = thread.queue()
+thread.queue()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Creates a new thread-safe queue for inter-thread data communication.
 
 Return Value: Returns a queue object with the following methods: `queue:push(value)` push a value to the queue, `queue:pop()` pop a value from the queue, `queue:empty()` check if the queue is empty
 
@@ -263,11 +333,21 @@ end
 
 - Create a shared data object
 
-Creates a new shared data object for inter-thread data sharing.
+#### Function Prototype
 
+::: tip API
 ```lua
-local sharedata = thread.sharedata()
+thread.sharedata()
 ```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Usage
+
+Creates a new shared data object for inter-thread data sharing.
 
 Return Value: Returns a shared data object with the following methods: `sharedata:set(value)` set the shared data value, `sharedata:get()` get the shared data value
 
@@ -309,13 +389,23 @@ end
 
 - Wait for thread completion (thread instance method)
 
-Waits for the thread to complete execution. This method supports mixed scheduling with coroutines, allowing you to wait for thread completion within a coroutine.
+#### Function Prototype
 
+::: tip API
 ```lua
-thread:wait(timeout)
+thread:wait(timeout: <number>)
 ```
+:::
+
+#### Parameter Description
 
-Parameters: `timeout` timeout in milliseconds (-1 for infinite wait)
+| Parameter | Description |
+|-----------|-------------|
+| timeout | Required. Timeout in milliseconds (-1 for infinite wait) |
+
+#### Usage
+
+Waits for the thread to complete execution. This method supports mixed scheduling with coroutines, allowing you to wait for thread completion within a coroutine.
 
 Return Value: Returns a status code indicating the wait result