pico8lib icon indicating copy to clipboard operation
pico8lib copied to clipboard

Update function documentation to use luadoc format

Open mindfilleter opened this issue 2 years ago • 5 comments

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

mindfilleter avatar May 11 '23 22:05 mindfilleter

I would suggest adding "help wanted" and "newbie friendly" tags to this

mindfilleter avatar May 11 '23 22:05 mindfilleter

-- @tparam string text this parameter is named 'text' and has the fixed type 'string'
-- @treturn {string,...} a table of substrings

sparr avatar May 15 '23 03:05 sparr

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.

sparr avatar May 16 '23 02:05 sparr

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?

mindfilleter avatar May 16 '23 02:05 mindfilleter

I'm on the one linked from the README in this repo ;)

sparr avatar May 18 '23 13:05 sparr

Done in #9 and https://github.com/sparr/pico8lib/commit/678c714f8518c79f77322a05fc53e23014eefc3d

sparr avatar Sep 08 '24 08:09 sparr