pico8lib
pico8lib copied to clipboard
Update function documentation to use luadoc format
This will permit us to automatically generate documentation to include in the project's wiki from the source.
Documentation for the format is here: https://keplerproject.github.io/luadoc/manual.html#introduction
It's not much different than what the lib already does. Here is an example:
--- Call the function fn and assert that an exception is thrown with
--- the given `expected message`
-- See `test/test_test.p8` for examples of how to use this assertion
-- @param fn A function to be called
-- @param expected_message The exact text of the expected exception
-- @return nil
function TestCase:assert_throws(fn, expected_message)
local threw = false
if (expected_message == nil) expected_message = ""
try(
fn,
function (e)
threw = true
local err_msg = self:_parse_error_message(e)
if err_msg ~= expected_message then
assert(nil, "expected exception '"
.. expected_message .. "' but received '" .. err_msg .. "'")
end
end,
nil
)
if not threw then
assert(nil, "expected exception '" .. expected_message .. "' but none was thrown")
end
end
I would suggest adding "help wanted" and "newbie friendly" tags to this
-- @tparam string text this parameter is named 'text' and has the fixed type 'string'
-- @treturn {string,...} a table of substrings
I've pushed changes to some comments to this format. Still a lot of existing comments that need updating. If anyone decides to tackle this, please comment before you start so we don't step on each others' toes.
Thanks for doing this. I've done some research on getting ldoc working. I'd like to discuss my findings with you. Are you on any of the discord servers?
I'm on the one linked from the README in this repo ;)
Done in #9 and https://github.com/sparr/pico8lib/commit/678c714f8518c79f77322a05fc53e23014eefc3d