Skip to content

Commit

Permalink
Update api reference pages
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Mar 14, 2024
1 parent d81c16e commit d3b4017
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
9 changes: 6 additions & 3 deletions pages/api-reference/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 20 additions & 17 deletions pages/api-reference/luau.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -69,41 +73,40 @@ 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

---

## Types

### 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.

Expand Down
18 changes: 17 additions & 1 deletion pages/api-reference/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d3b4017

Please sign in to comment.