Change LDoc to properly format optional arguments and defaults

This commit is contained in:
Lwmte 2025-04-12 17:27:06 +02:00
parent 218299193f
commit 0128660f07
3 changed files with 13 additions and 14 deletions

View file

@ -868,20 +868,19 @@ function build_arg_list (names,pmods)
local opt
if m then
if not m.optchain then
acc ((']'):rep(npending))
npending=0
end
opt = m.optchain or m.opt
if opt then
acc('[')
npending=npending+1
end
end
if i>1 then acc (', ') end
acc(names[i])
if opt and opt ~= true then acc('='..opt) end
if opt then
acc('[' .. names[i])
if opt ~= true then acc('='..opt) end
acc(']')
else
acc(names[i])
end
end
acc ((']'):rep(npending))
return '('..table.concat(buffer)..')'
end

View file

@ -215,12 +215,12 @@ return [==[
# end
$(M(item.params.map[p],item))
# if def == true then
(<em>optional</em>)
(<em>Optional.</em>)
# elseif def then
(<em>default</em> $(def))
(<em>Default.</em> $(def))
# end
# if item:readonly(p) then
<em>readonly</em>
<em>Read-only.</em>
# end
</li>
# end

View file

@ -216,12 +216,12 @@
# end
$(M(item.params.map[p],item))
# if def == true then
(<em>optional</em>)
<em>Optional.</em>
# elseif def then
(<em>default</em> $(def))
<em>Default: $(def).</em>
# end
# if item:readonly(p) then
<em>readonly</em>
<em>Read-only.</em>
# end
</li>
# end