Refactor typedef files to ensure moonwave picks up functions

This commit is contained in:
Filip Tibell 2023-07-22 13:42:29 +02:00
parent 8c14c3cda3
commit 623af1c312
No known key found for this signature in database
7 changed files with 656 additions and 602 deletions

View file

@ -14,7 +14,7 @@ export type MetadataPermissions = {
readOnly: boolean, readOnly: boolean,
} }
-- FIXME: We lose doc comments here because of the union type -- FIXME: We lose doc comments here below in Metadata because of the union type
--[=[ --[=[
@interface Metadata @interface Metadata
@ -87,8 +87,9 @@ export type WriteOptions = {
end end
``` ```
]=] ]=]
return { local fs = {}
--[=[
--[=[
@within FS @within FS
@tag must_use @tag must_use
@ -103,11 +104,12 @@ return {
@param path The path to the file to read @param path The path to the file to read
@return The contents of the file @return The contents of the file
]=] ]=]
readFile = function(path: string): string function fs.readFile(path: string): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within FS @within FS
@tag must_use @tag must_use
@ -121,11 +123,12 @@ return {
@param path The directory path to search in @param path The directory path to search in
@return A list of files & directories found @return A list of files & directories found
]=] ]=]
readDir = function(path: string): { string } function fs.readDir(path: string): { string }
return {} return {}
end, end
--[=[
--[=[
@within FS @within FS
Writes to a file at `path`. Writes to a file at `path`.
@ -138,9 +141,10 @@ return {
@param path The path of the file @param path The path of the file
@param contents The contents of the file @param contents The contents of the file
]=] ]=]
writeFile = function(path: string, contents: string) end, function fs.writeFile(path: string, contents: string) end
--[=[
--[=[
@within FS @within FS
Creates a directory and its parent directories if they are missing. Creates a directory and its parent directories if they are missing.
@ -152,9 +156,10 @@ return {
* Some other I/O error occurred. * Some other I/O error occurred.
@param path The directory to create @param path The directory to create
]=] ]=]
writeDir = function(path: string) end, function fs.writeDir(path: string) end
--[=[
--[=[
@within FS @within FS
Removes a file. Removes a file.
@ -166,9 +171,10 @@ return {
* Some other I/O error occurred. * Some other I/O error occurred.
@param path The file to remove @param path The file to remove
]=] ]=]
removeFile = function(path: string) end, function fs.removeFile(path: string) end
--[=[
--[=[
@within FS @within FS
Removes a directory and all of its contents. Removes a directory and all of its contents.
@ -180,9 +186,10 @@ return {
* Some other I/O error occurred. * Some other I/O error occurred.
@param path The directory to remove @param path The directory to remove
]=] ]=]
removeDir = function(path: string) end, function fs.removeDir(path: string) end
--[=[
--[=[
@within FS @within FS
@tag must_use @tag must_use
@ -195,11 +202,12 @@ return {
@param path The path to get metadata for @param path The path to get metadata for
@return Metadata for the path @return Metadata for the path
]=] ]=]
metadata = function(path: string): Metadata function fs.metadata(path: string): Metadata
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within FS @within FS
@tag must_use @tag must_use
@ -212,11 +220,12 @@ return {
@param path The file path to check @param path The file path to check
@return If the path is a file or not @return If the path is a file or not
]=] ]=]
isFile = function(path: string): boolean function fs.isFile(path: string): boolean
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within FS @within FS
@tag must_use @tag must_use
@ -229,11 +238,12 @@ return {
@param path The directory path to check @param path The directory path to check
@return If the path is a directory or not @return If the path is a directory or not
]=] ]=]
isDir = function(path: string): boolean function fs.isDir(path: string): boolean
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within FS @within FS
Moves a file or directory to a new path. Moves a file or directory to a new path.
@ -251,9 +261,10 @@ return {
@param from The path to move from @param from The path to move from
@param to The path to move to @param to The path to move to
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists @param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
]=] ]=]
move = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end, function fs.move(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
--[=[
--[=[
@within FS @within FS
Copies a file or directory recursively to a new path. Copies a file or directory recursively to a new path.
@ -270,6 +281,7 @@ return {
@param from The path to copy from @param from The path to copy from
@param to The path to copy to @param to The path to copy to
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists @param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
]=] ]=]
copy = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end, function fs.copy(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
}
return fs

View file

@ -196,8 +196,9 @@ export type WebSocket = {
end) end)
``` ```
]=] ]=]
return { local net = {}
--[=[
--[=[
@within Net @within Net
Sends an HTTP request using the given url and / or parameters, and returns a dictionary that describes the response received. Sends an HTTP request using the given url and / or parameters, and returns a dictionary that describes the response received.
@ -206,11 +207,12 @@ return {
@param config The URL or request config to use @param config The URL or request config to use
@return A dictionary representing the response for the request @return A dictionary representing the response for the request
]=] ]=]
request = function(config: string | FetchParams): FetchResponse function net.request(config: string | FetchParams): FetchResponse
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
@tag must_use @tag must_use
@ -221,11 +223,12 @@ return {
@param url The URL to connect to @param url The URL to connect to
@return A web socket handle @return A web socket handle
]=] ]=]
socket = function(url: string): WebSocket function net.socket(url: string): WebSocket
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
Creates an HTTP server that listens on the given `port`. Creates an HTTP server that listens on the given `port`.
@ -235,11 +238,12 @@ return {
@param port The port to use for the server @param port The port to use for the server
@param handlerOrConfig The handler function or config to use for the server @param handlerOrConfig The handler function or config to use for the server
]=] ]=]
serve = function(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle function net.serve(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
@tag must_use @tag must_use
@ -248,11 +252,12 @@ return {
@param value The value to encode as JSON @param value The value to encode as JSON
@param pretty If the encoded JSON string should include newlines and spaces. Defaults to false @param pretty If the encoded JSON string should include newlines and spaces. Defaults to false
@return The encoded JSON string @return The encoded JSON string
]=] ]=]
jsonEncode = function(value: any, pretty: boolean?): string function net.jsonEncode(value: any, pretty: boolean?): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
@tag must_use @tag must_use
@ -260,11 +265,12 @@ return {
@param encoded The JSON string to decode @param encoded The JSON string to decode
@return The decoded lua value @return The decoded lua value
]=] ]=]
jsonDecode = function(encoded: string): any function net.jsonDecode(encoded: string): any
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
@tag must_use @tag must_use
@ -273,11 +279,12 @@ return {
@param s The string to encode @param s The string to encode
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false @param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
@return The encoded string @return The encoded string
]=] ]=]
urlEncode = function(s: string, binary: boolean?): string function net.urlEncode(s: string, binary: boolean?): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Net @within Net
@tag must_use @tag must_use
@ -286,8 +293,9 @@ return {
@param s The string to decode @param s The string to decode
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false @param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
@return The decoded string @return The decoded string
]=] ]=]
urlDecode = function(s: string, binary: boolean?): string function net.urlDecode(s: string, binary: boolean?): string
return nil :: any return nil :: any
end, end
}
return net

View file

@ -78,10 +78,11 @@ export type SpawnResult = {
end end
``` ```
]=] ]=]
return { local process = {}
--[=[
--[=[
@within Process @within Process
@read_only @tag read_only
The current operating system being used. The current operating system being used.
@ -90,11 +91,12 @@ return {
* `"linux"` * `"linux"`
* `"macos"` * `"macos"`
* `"windows"` * `"windows"`
]=] ]=]
os = (nil :: any) :: OS, process.os = (nil :: any) :: OS
--[=[
--[=[
@within Process @within Process
@read_only @tag read_only
The architecture of the processor currently being used. The architecture of the processor currently being used.
@ -102,32 +104,36 @@ return {
* `"x86_64"` * `"x86_64"`
* `"aarch64"` * `"aarch64"`
]=] ]=]
arch = (nil :: any) :: Arch, process.arch = (nil :: any) :: Arch
--[=[
--[=[
@within Process @within Process
@read_only @tag read_only
The arguments given when running the Lune script. The arguments given when running the Lune script.
]=] ]=]
args = (nil :: any) :: { string }, process.args = (nil :: any) :: { string }
--[=[
--[=[
@within Process @within Process
@read_only @tag read_only
The current working directory in which the Lune script is running. The current working directory in which the Lune script is running.
]=] ]=]
cwd = (nil :: any) :: string, process.cwd = (nil :: any) :: string
--[=[
--[=[
@within Process @within Process
@read_write @read_write
Current environment variables for this process. Current environment variables for this process.
Setting a value on this table will set the corresponding environment variable. Setting a value on this table will set the corresponding environment variable.
]=] ]=]
env = (nil :: any) :: { [string]: string? }, process.env = (nil :: any) :: { [string]: string? }
--[=[
--[=[
@within Process @within Process
Exits the currently running script as soon as possible with the given exit code. Exits the currently running script as soon as possible with the given exit code.
@ -137,9 +143,10 @@ return {
Setting the exit code using this function will override any otherwise automatic exit code. Setting the exit code using this function will override any otherwise automatic exit code.
@param code The exit code to set @param code The exit code to set
]=] ]=]
exit = function(code: number?) end, function process.exit(code: number?) end
--[=[
--[=[
@within Process @within Process
Spawns a child process that will run the program `program`, and returns a dictionary that describes the final status and ouput of the child process. Spawns a child process that will run the program `program`, and returns a dictionary that describes the final status and ouput of the child process.
@ -153,8 +160,9 @@ return {
@param params Additional parameters to pass to the program @param params Additional parameters to pass to the program
@param options A dictionary of options for the child process @param options A dictionary of options for the child process
@return A dictionary representing the result of the child process @return A dictionary representing the result of the child process
]=] ]=]
spawn = function(program: string, params: { string }?, options: SpawnOptions?): SpawnResult function process.spawn(program: string, params: { string }?, options: SpawnOptions?): SpawnResult
return nil :: any return nil :: any
end, end
}
return process

View file

@ -213,8 +213,9 @@ export type DataModel =
fs.writeFile("myPlaceFile.rbxl", newPlaceFile) fs.writeFile("myPlaceFile.rbxl", newPlaceFile)
``` ```
]=] ]=]
return { local roblox = {}
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -235,11 +236,12 @@ return {
``` ```
@param contents The contents of the place to read @param contents The contents of the place to read
]=] ]=]
deserializePlace = function(contents: string): DataModel function roblox.deserializePlace(contents: string): DataModel
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -260,11 +262,12 @@ return {
``` ```
@param contents The contents of the model to read @param contents The contents of the model to read
]=] ]=]
deserializeModel = function(contents: string): { Instance } function roblox.deserializeModel(contents: string): { Instance }
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -284,11 +287,12 @@ return {
@param dataModel The DataModel for the place to serialize @param dataModel The DataModel for the place to serialize
@param xml If the place should be serialized as xml or not. Defaults to `false`, meaning the place gets serialized using the binary format and not xml. @param xml If the place should be serialized as xml or not. Defaults to `false`, meaning the place gets serialized using the binary format and not xml.
]=] ]=]
serializePlace = function(dataModel: DataModel, xml: boolean?): string function roblox.serializePlace(dataModel: DataModel, xml: boolean?): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -308,11 +312,12 @@ return {
@param instances The array of instances to serialize @param instances The array of instances to serialize
@param xml If the model should be serialized as xml or not. Defaults to `false`, meaning the model gets serialized using the binary format and not xml. @param xml If the model should be serialized as xml or not. Defaults to `false`, meaning the model gets serialized using the binary format and not xml.
]=] ]=]
serializeModel = function(instances: { Instance }, xml: boolean?): string function roblox.serializeModel(instances: { Instance }, xml: boolean?): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -347,11 +352,12 @@ return {
``` ```
@param raw If the cookie should be returned as a pure value or not. Defaults to false @param raw If the cookie should be returned as a pure value or not. Defaults to false
]=] ]=]
getAuthCookie = function(raw: boolean?): string? function roblox.getAuthCookie(raw: boolean?): string?
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Roblox @within Roblox
@tag must_use @tag must_use
@ -380,12 +386,14 @@ return {
)) ))
end end
``` ```
]=] ]=]
getReflectionDatabase = function(): Database function roblox.getReflectionDatabase(): Database
return nil :: any return nil :: any
end, end
-- TODO: Make typedefs for all of the datatypes as well...
Instance = (nil :: any) :: { -- TODO: Make typedefs for all of the datatypes as well...
roblox.Instance = (nil :: any) :: {
new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance), new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance),
},
} }
return roblox

View file

@ -27,8 +27,9 @@ export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml)) fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml))
``` ```
]=] ]=]
return { local serde = {}
--[=[
--[=[
@within Serde @within Serde
@tag must_use @tag must_use
@ -46,11 +47,12 @@ return {
@param value The value to encode @param value The value to encode
@param pretty If the encoded string should be human-readable, including things such as newlines and spaces. Only supported for json and toml formats, and defaults to false @param pretty If the encoded string should be human-readable, including things such as newlines and spaces. Only supported for json and toml formats, and defaults to false
@return The encoded string @return The encoded string
]=] ]=]
encode = function(format: EncodeDecodeFormat, value: any, pretty: boolean?): string function serde.encode(format: EncodeDecodeFormat, value: any, pretty: boolean?): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Serde @within Serde
@tag must_use @tag must_use
@ -67,11 +69,12 @@ return {
@param format The format to use @param format The format to use
@param encoded The string to decode @param encoded The string to decode
@return The decoded lua value @return The decoded lua value
]=] ]=]
decode = function(format: EncodeDecodeFormat, encoded: string): any function serde.decode(format: EncodeDecodeFormat, encoded: string): any
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Serde @within Serde
@tag must_use @tag must_use
@ -89,11 +92,12 @@ return {
@param format The format to use @param format The format to use
@param encoded The string to compress @param encoded The string to compress
@return The compressed string @return The compressed string
]=] ]=]
compress = function(format: CompressDecompressFormat, s: string): string function serde.compress(format: CompressDecompressFormat, s: string): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Serde @within Serde
@tag must_use @tag must_use
@ -111,8 +115,9 @@ return {
@param format The format to use @param format The format to use
@param encoded The string to decompress @param encoded The string to decompress
@return The decompressed string @return The decompressed string
]=] ]=]
decompress = function(format: CompressDecompressFormat, s: string): string function serde.decompress(format: CompressDecompressFormat, s: string): string
return nil :: any return nil :: any
end, end
}
return serde

View file

@ -60,8 +60,11 @@ end
stdio.ewrite("\nAnd some error text, too") stdio.ewrite("\nAnd some error text, too")
``` ```
]=] ]=]
return { local stdio = {}
--[=[
stdio.prompt = prompt
--[=[
@within Stdio @within Stdio
@tag must_use @tag must_use
@ -80,11 +83,12 @@ return {
@param color The color to use @param color The color to use
@return A printable ANSI string @return A printable ANSI string
]=] ]=]
color = function(color: Color): string function stdio.color(color: Color): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Stdio @within Stdio
@tag must_use @tag must_use
@ -103,11 +107,12 @@ return {
@param style The style to use @param style The style to use
@return A printable ANSI string @return A printable ANSI string
]=] ]=]
style = function(style: Style): string function stdio.style(style: Style): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Stdio @within Stdio
@tag must_use @tag must_use
@ -115,25 +120,27 @@ return {
@param ... The values to format @param ... The values to format
@return The formatted string @return The formatted string
]=] ]=]
format = function(...: any): string function stdio.format(...: any): string
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Stdio @within Stdio
Writes a string directly to stdout, without any newline. Writes a string directly to stdout, without any newline.
@param s The string to write to stdout @param s The string to write to stdout
]=] ]=]
write = function(s: string) end, function stdio.write(s: string) end
--[=[
--[=[
@within Stdio @within Stdio
Writes a string directly to stderr, without any newline. Writes a string directly to stderr, without any newline.
@param s The string to write to stderr @param s The string to write to stderr
]=] ]=]
ewrite = function(s: string) end, function stdio.ewrite(s: string) end
prompt = prompt,
} return stdio

View file

@ -27,27 +27,30 @@
print("Running after task.spawn yields") print("Running after task.spawn yields")
``` ```
]=] ]=]
return { local task = {}
--[=[
--[=[
@within Task @within Task
Stops a currently scheduled thread from resuming. Stops a currently scheduled thread from resuming.
@param thread The thread to cancel @param thread The thread to cancel
]=] ]=]
cancel = function(thread: thread) end, function task.cancel(thread: thread) end
--[=[
--[=[
@within Task @within Task
Defers a thread or function to run at the end of the current task queue. Defers a thread or function to run at the end of the current task queue.
@param functionOrThread The function or thread to defer @param functionOrThread The function or thread to defer
@return The thread that will be deferred @return The thread that will be deferred
]=] ]=]
defer = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread function task.defer<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Task @within Task
Delays a thread or function to run after `duration` seconds. Delays a thread or function to run after `duration` seconds.
@ -56,15 +59,16 @@ return {
@param functionOrThread The function or thread to delay @param functionOrThread The function or thread to delay
@return The thread that will be delayed @return The thread that will be delayed
]=] ]=]
delay = function<T...>( function task.delay<T...>(
duration: number?, duration: number?,
functionOrThread: thread | (T...) -> ...any, functionOrThread: thread | (T...) -> ...any,
...: T... ...: T...
): thread ): thread
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Task @within Task
Instantly runs a thread or function. Instantly runs a thread or function.
@ -74,11 +78,12 @@ return {
@param functionOrThread The function or thread to spawn @param functionOrThread The function or thread to spawn
@return The thread that was spawned @return The thread that was spawned
]=] ]=]
spawn = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread function task.spawn<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
return nil :: any return nil :: any
end, end
--[=[
--[=[
@within Task @within Task
Waits for *at least* the given amount of time. Waits for *at least* the given amount of time.
@ -88,8 +93,9 @@ return {
@param duration The amount of time to wait @param duration The amount of time to wait
@return The exact amount of time waited @return The exact amount of time waited
]=] ]=]
wait = function(duration: number?): number function task.wait(duration: number?): number
return nil :: any return nil :: any
end, end
}
return task