Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix serviceBag init and other documentation errors #508

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--[=[
Generic command definition template which we can use to
@class CmdrCommandDefinitionTemplate
@class CmdrExecutionTemplate
]=]

local function waitForValue(objectValue)
Expand Down
36 changes: 18 additions & 18 deletions src/loader/src/Maid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
local Maid = {}
Maid.ClassName = "Maid"

--[=[
--[[
Constructs a new Maid object

```lua
Expand All @@ -35,14 +35,14 @@ Maid.ClassName = "Maid"

@ignore
@return Maid
]=]
]]
function Maid.new()
return setmetatable({
_tasks = {}
}, Maid)
end

--[=[
--[[
Returns true if the class is a maid, and false otherwise.

```lua
Expand All @@ -53,12 +53,12 @@ end
@ignore
@param value any
@return boolean
]=]
]]
function Maid.isMaid(value)
return type(value) == "table" and value.ClassName == "Maid"
end

--[=[
--[[
Returns Maid[key] if not part of Maid metatable

```lua
Expand All @@ -73,7 +73,7 @@ end
@ignore
@param index any
@return MaidTask
]=]
]]
function Maid:__index(index)
if Maid[index] then
return Maid[index]
Expand All @@ -82,7 +82,7 @@ function Maid:__index(index)
end
end

--[=[
--[[
Add a task to clean up. Tasks given to a maid will be cleaned when
maid[index] is set to a different value.

Expand All @@ -101,7 +101,7 @@ end
@ignore
@param index any
@param newTask MaidTask
]=]
]]
function Maid:__newindex(index, newTask)
if Maid[index] ~= nil then
error(string.format("Cannot use '%s' as a Maid key", tostring(index)), 2)
Expand Down Expand Up @@ -145,13 +145,13 @@ function Maid:__newindex(index, newTask)
end
end

--[=[
--[[
Gives a task to the maid for cleanup and returns the resulting value

@ignore
@param task MaidTask -- An item to clean
@return MaidTask
]=]
]]
function Maid:Add(task)
if not task then
error("Task cannot be false or nil", 2)
Expand All @@ -166,13 +166,13 @@ function Maid:Add(task)
return task
end

--[=[
--[[
Gives a task to the maid for cleanup, but uses an incremented number as a key.

@ignore
@param task MaidTask -- An item to clean
@return number -- taskId
]=]
]]
function Maid:GiveTask(task)
if not task then
error("Task cannot be false or nil", 2)
Expand All @@ -188,13 +188,13 @@ function Maid:GiveTask(task)
return taskId
end

--[=[
--[[
Gives a promise to the maid for clean.

@ignore
@param promise Promise<T>
@return Promise<T>
]=]
]]
function Maid:GivePromise(promise)
if not promise:IsPending() then
return promise
Expand All @@ -211,7 +211,7 @@ function Maid:GivePromise(promise)
return newPromise
end

--[=[
--[[
Cleans up all tasks and removes them as entries from the Maid.

:::note
Expand All @@ -228,7 +228,7 @@ end
:::

@ignore
]=]
]]
function Maid:DoCleaning()
local tasks = self._tasks

Expand Down Expand Up @@ -272,13 +272,13 @@ function Maid:DoCleaning()
end
end

--[=[
--[[
Alias for [Maid.DoCleaning()](/api/Maid#DoCleaning)

@ignore
@function Destroy
@within Maid
]=]
]]
Maid.Destroy = Maid.DoCleaning

return Maid
2 changes: 1 addition & 1 deletion src/quaternion/src/Shared/QuaternionObject.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Author: xXxMoNkEyMaNxXx

@class Quaternion
@class QuaternionObject
]=]

local require = require(script.Parent.loader).load(script)
Expand Down
8 changes: 7 additions & 1 deletion src/servicebag/src/Shared/ServiceBag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
serviceBag:Start()
```

:::tip
ServiceBag does not allow services to yield on :Init() or :Start(), nor
does it allow you to add services after :Init() or :Start()
:::

@class ServiceBag
]=]

Expand Down Expand Up @@ -241,7 +246,8 @@ function ServiceBag:_addServiceType(serviceType)
end

if self:IsStarted() then
error(string.format("Already started, cannot add %q", self:_getServiceName(serviceType)))
local hint = "HINT: Be sure to call serviceBag:GetService(require(\"MyService\")) either before calling serviceBag:Init() or during serviceBag:Init() (within another service:Init)"
error(string.format("Already started, cannot add %q. \n%s", self:_getServiceName(serviceType), hint))
return
end

Expand Down
2 changes: 1 addition & 1 deletion src/signal/src/Shared/GoodSignal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
stravant - July 31st, 2021 - Created the file.
Quenty - Auguest 21st, 2023 - Modified to fit Nevermore contract, with Moonwave docs

@class Signal
@class GoodSignal
]=]

-- The currently idle thread to run the next handler on
Expand Down
4 changes: 2 additions & 2 deletions src/tie/src/Shared/TieDefinition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ end
invoking interface methods, or querying the interface will result
in errors.

```tip
:::tip
Probably use :Find() instead of Get, since this always returns an interface.
```
:::

@param adornee Instance -- Adornee to get interface on
@param tieRealm TieRealm?
Expand Down
Loading