jtackaberry / luadox

Lua API documentation generator
Apache License 2.0
15 stars 2 forks source link

Feature request: Support for LuaCATS annotations #12

Open Mange opened 1 month ago

Mange commented 1 month ago

I'm trying my best to auto-generate documentation for my own project that uses LuaCATS, through Lua LSP to give me a good experience inside of my editor. I would like to be able to also publish documentation on the web, so I'm trying to integrate luadox.

Right now it works fairly well, but I get a lot of warnings because of unsupported annotations. I also need to duplicate all @param and convert them to the luadox @tparam, but the duplicated @param still emits a warning forever.

For example:

--- Rounds a number to the nearest integer.
---
--- @param n number The number to round.
--- @tparam number n The number to round.
function math.round(n)
  if n >= 0 then return math.floor(n + 0.5) end
  return math.ceil(n - 0.5)
end

I think it would be great to support the LuaCATS annotations in addition to our own ones.

Some suggestions

  1. @param <name> <type> <description> as an alternative to @tparam <type> <name> <description>.
  2. @return <type> [<name> [comment]] as an alternative to @treturn <type> [comment].
  3. Supporting Markdown links a-la Returns a [MyThing](lua://MyThing) as an alternative to Returns a @{MyThing}.
jtackaberry commented 1 month ago

I actually started work along these lines a while back (in ee8f640 plus a bunch of uncommitted code), but got pulled in another direction and couldn't finish. I definitely understand the use case, and intend to better support LuaCATS too, by providing a LuaCATS mode for LuaDox, and the ability to explicitly namespace Luadox-specific annotations, e.g. @luadox:section.

I anticipate work will resume in a month or two, because I want to overhaul one of my larger Lua projects with LuaCATS annotations because I can't deal with not having LSP support anymore. :)