ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

first `---` comment after module comment is ignored if there is any non-comment before it

Open GinjaNinja32 opened this issue 1 year ago • 0 comments
trafficstars

bisected, caused by #396.

search_for_token searches through the file, stopping if it encounters the target token or a --- comment. if it advances the position, finds a comment, but then find_module doesn't return the t,v that SFT returns, then parse_file never actually processes the comment that was found.

a slight modification of the example from #396 that shows the issue; DoNothing is entirely absent from the generated docs:

--- my module

local v = 42

--- my function
-- takes nothing and returns nothing
-- @return nothing
function DoNothing()
end

--- my thing
Thing = {
}

the "contains no items" warning only triggers if there is no module() call and no --- comments other than the module comment in the entire file, which is potentially a reasonable case to warn about - the reason it triggered on the example in #396 is that the doc on DoNothing() was actually parsed as the module comment, and then there were no documented items beyond that (i.e. there actually were no items, as the warning said!). Adding an actual module comment to it (as in my example above) makes the warning go away even with the pre-#396 code.

I would still like a way to turn the warning off or ignore it - maybe a pragma? The reason I'm even looking at this code in the first place is that I have modules that actually don't have any items, because they just register themselves with other modules and don't expose any functions/etc themselves, and I'd like to use --fatalwarnings but can't because of the "no items" warning :slightly_smiling_face:

GinjaNinja32 avatar Oct 21 '24 22:10 GinjaNinja32