changes to varargs matching
This commit is contained in:
parent
c8f556804e
commit
ecd6b4cfa5
14
ldoc/doc.lua
14
ldoc/doc.lua
|
@ -375,26 +375,34 @@ function Item:finish()
|
||||||
end
|
end
|
||||||
-- not all arguments may be commented: we use the formal arguments
|
-- not all arguments may be commented: we use the formal arguments
|
||||||
-- if available as the authoritative list, and warn if there's an inconsistency.
|
-- if available as the authoritative list, and warn if there's an inconsistency.
|
||||||
-- The _exception_ is if the formal args are just ... !
|
-- A formal argument of ... may match any number of params, however.
|
||||||
if self.formal_args then
|
if self.formal_args then
|
||||||
local fargs = self.formal_args
|
local fargs = self.formal_args
|
||||||
if #fargs ~= 1 or fargs[1] ~= '...' then
|
if #fargs ~= 1 then
|
||||||
local pnames, pcomments = names, comments
|
local pnames, pcomments = names, comments
|
||||||
names, comments = List(),List()
|
names, comments = List(),List()
|
||||||
for i,name in ipairs(fargs) do
|
for i,name in ipairs(fargs) do
|
||||||
if params then -- explicit set of param tags
|
if params then -- explicit set of param tags
|
||||||
if pnames[i] ~= name then
|
local varargs = name == '...'
|
||||||
|
if pnames[i] ~= name and not varargs then
|
||||||
if pnames[i] then
|
if pnames[i] then
|
||||||
self:warning("param and formal argument name mismatch: '"..name.."' '"..pnames[i].."'")
|
self:warning("param and formal argument name mismatch: '"..name.."' '"..pnames[i].."'")
|
||||||
else
|
else
|
||||||
self:warning("undocumented formal argument: '"..name.."'")
|
self:warning("undocumented formal argument: '"..name.."'")
|
||||||
end
|
end
|
||||||
|
elseif varargs then
|
||||||
|
name = pnames[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
names:append(name)
|
names:append(name)
|
||||||
-- ldoc allows comments in the formal arg list to be used
|
-- ldoc allows comments in the formal arg list to be used
|
||||||
comments:append (fargs.comments[name] or pcomments[i] or '')
|
comments:append (fargs.comments[name] or pcomments[i] or '')
|
||||||
end
|
end
|
||||||
|
if #pnames > #fargs and fargs[#fargs] ~= '...' then
|
||||||
|
for i = #fargs+1,#pnames do
|
||||||
|
self:warning("extra param with no formal argument: "..pnames[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue