ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

Bug in the name for `new` method in class module (colon instead of dot generated)

Open deepakjois opened this issue 9 years ago • 4 comments
trafficstars

Code


---
-- A Class Module
-- @classmod ClassModule


local ClassModule = {}

--- Create a new ClassModule
-- @return a new ClassModule object
function ClassModule.new()
  return nil
end

--- Do something with ClassModule object.
function ClassModule:doSomething()
end

Running ldoc

ldoc ClassModule.lua

Result

See screenshot below. Note how ClassModule.new is documented as ClassModule:new

screenshot 2016-09-14 19 37 20

Expected Result

The ClassModule.new function should be documented with the single dot, but instead it is documented with a colon.

Other info

I see this behavior, even if I document the module with the @module directive, and include a @type directive somewhere below the @module directive. The only way it works is if I use a different module name and a different type name. For example:


---
-- A Class Module
-- @module Module

--- ClassModule
-- @type ClassModule
local ClassModule = {}

--- Create a new ClassModule
-- @return a new ClassModule object
function ClassModule.new()
  return nil
end

--- Do something with ClassModule object.
function ClassModule:doSomething()
end

See screenshot below:

screenshot 2016-09-14 19 45 17

Is this a bug? If not, please suggest a workaround, if you can think of any.

deepakjois avatar Sep 14 '16 14:09 deepakjois

-- @function ClassModule.new

RyanSquared avatar Nov 24 '16 01:11 RyanSquared

I just had a look at this and it seems it is still not fixed. @RyanSquared your tip doesn't seem to fix it either, was that something you expected to generate the expected output or a suggestion for how it could be fixed?

alerque avatar May 04 '23 20:05 alerque

I believe this was something that worked at the time. Something like:

--- Create a new ClassModule
-- @function ClassModule.new()
-- @return ClassModule
function ClassModule.new()
  return nil
end

~~it's been a few years, pls forgive if i don't remember exactly~~

RyanSquared avatar May 04 '23 22:05 RyanSquared

Hmm, interesting, that does actually work and gives the expected output with the caveat that you have to use --not_luadoc for that exact MWE (one could possibly rearrange it to avoid that).

alerque avatar May 04 '23 22:05 alerque