From d3b4017218824d53ac82a963cae8d8d18ea19601 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 14 Mar 2024 14:44:52 +0100 Subject: [PATCH] Update api reference pages --- pages/api-reference/fs.md | 9 ++++++--- pages/api-reference/luau.md | 37 ++++++++++++++++++++----------------- pages/api-reference/net.md | 18 +++++++++++++++++- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/pages/api-reference/fs.md b/pages/api-reference/fs.md index 8c3e82c..598038e 100644 --- a/pages/api-reference/fs.md +++ b/pages/api-reference/fs.md @@ -254,9 +254,12 @@ This is a dictionary that will contain the following values: - `kind` - If the target path is a `file`, `dir` or `symlink` - `exists` - If the target path exists -- `createdAt` - The timestamp at which the file or directory was created -- `modifiedAt` - The timestamp at which the file or directory was last modified -- `accessedAt` - The timestamp at which the file or directory was last accessed +- `createdAt` - The timestamp represented as a `DateTime` object at which the file or directory + was created +- `modifiedAt` - The timestamp represented as a `DateTime` object at which the file or directory + was last modified +- `accessedAt` - The timestamp represented as a `DateTime` object at which the file or directory + was last accessed - `permissions` - Current permissions for the file or directory Note that timestamps are relative to the unix epoch, and may not be accurate if the system clock is diff --git a/pages/api-reference/luau.md b/pages/api-reference/luau.md index aa2dcbe..6f20596 100644 --- a/pages/api-reference/luau.md +++ b/pages/api-reference/luau.md @@ -16,6 +16,9 @@ local callableFn = luau.load(bytecode) callableFn() ``` +Since luau bytecode is highly compressible, it may also make sense to compress it using the `serde` +library while transmitting large amounts of it. + ## Functions ### compile @@ -29,18 +32,19 @@ An error will be thrown if the sourcecode given isn't valid Luau code. ```lua local luau = require("@lune/luau") +-- Compile the source to some highly optimized bytecode local bytecode = luau.compile("print('Hello, World!')", { - optimizationLevel: 1, - coverageLevel: 0, - debugLevel: 1, + optimizationLevel = 2, + coverageLevel = 0, + debugLevel = 1, }) ``` #### Parameters -- `source` The string that'll be compiled into bytecode +- `source` The string that will be compiled into bytecode -- `compileOptions` The luau compiler options used when compiling the source string +- `compileOptions` The options passed to the luau compiler that will output the bytecode #### Returns @@ -69,13 +73,13 @@ callableFn() #### Parameters -- `source` Either bytecode or sourcecode +- `source` Either luau bytecode or string source code -- `loadOptions` The load options used when creating a callbable function +- `loadOptions` The options passed to luau for loading the chunk #### Returns -- luau function +- luau chunk --- @@ -83,27 +87,26 @@ callableFn() ### CompileOptions -The Luau compiler options used in generating luau bytecode +The options passed to the luau compiler while compiling bytecode. This is a dictionary that may contain one or more of the following values: -- `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1` -- `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0` -- `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1` - -Documentation regarding what these values represent can be found here; +- `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1`. +- `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0`. +- `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1`. -- https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13 +Documentation regarding what these values represent can be found +[here](https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13-L39). --- ### LoadOptions -The Luau load options are used for generating a lua function from either bytecode or sourcecode +The options passed while loading a luau chunk from an arbitrary string, or bytecode. This is a dictionary that may contain one or more of the following values: -- `debugName` - The debug name of the closure. Defaults to `luau.load(...)` +- `debugName` - The debug name of the closure. Defaults to `luau.load(...)`. - `environment` - Environment values to set and/or override. Includes default globals unless overwritten. diff --git a/pages/api-reference/net.md b/pages/api-reference/net.md index 88d7964..3c5f285 100644 --- a/pages/api-reference/net.md +++ b/pages/api-reference/net.md @@ -230,13 +230,29 @@ This is a dictionary that may contain one or more of the following values: Configuration for `net.serve`. -This may contain one of, or both of the following callbacks: +This may contain one of or more of the following values: +- `address` for setting the IP address to serve from. Defaults to the loopback interface + (`http://localhost`). - `handleRequest` for handling normal http requests, equivalent to just passing a function to `net.serve` - `handleWebSocket` for handling web socket requests, which will receive a `WebSocket` object as its first and only parameter +When setting `address`, the `handleRequest` callback must also be defined. + +```lua + net.serve(8080, { + address = "http://0.0.0.0", + handleRequest = function(request) + return { + status = 200, + body = "Echo:\n" .. request.body, + } + end + }) +``` + --- ### ServeHandle