How can I document my code?

Hello. I was wondering if there was any commonly used ways to format the documentation of code in modules and scripts. Specifically, functions.

Commonly, you would use a multi-line comment to satisfy the documenting of a module, usually at the top.

--[[
Module.new()
Blah blah blah

Module:Set(A, B, C)
Blah A, B & C, blah blah blah
]]

In my case, I would include some important information at the very top, including date created and updated to track its version.

4 Likes

It’s down to the preference, I usually go with something like:

--[[
<return_type> function(<parameter_type>, ...)
Description: ...
--]]

-- For example:

--[[
Table<string> getPlayerInventory(<Player> __Player)
Description: Returns a table of __Player's inventory.

<number> getItemPrice(<string> Item)
Description: Returns the cost of Item.
--]]
3 Likes