issue #57: [opt=default] support - see tests/styles/four.lua

This commit is contained in:
steve donovan 2013-03-19 15:00:57 +02:00
parent 4bc48dafc3
commit 65723a9dc4
3 changed files with 10 additions and 4 deletions

View File

@ -665,15 +665,21 @@ function build_arg_list (names,pmods)
local function acc(x) table.insert(buffer, x) end
for i = 1, #names do
local m = pmods and pmods[i]
local opt
if m then
if not m.optchain then
acc ((']'):rep(npending))
npending=0
end
if m.opt or m.optchain then acc(' ['); npending=npending+1 end
opt = m.opt or m.optchain
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
end
acc ((']'):rep(npending))
return '('..table.concat(buffer)..')'

View File

@ -36,7 +36,7 @@ local function parse_at_tags(text)
modifiers = { }
for x in mod_string :gmatch "[^,]+" do
local k, v = x :match "^([^=]+)=(.*)$"
if not k then k, v = x, x end
if not k then k, v = x, true end -- wuz x, x
modifiers[k] = v
end
end

View File

@ -13,8 +13,8 @@
-- you may document an indefinite number of extra arguments!
-- @string name person's name
-- @int age
-- @string[opt] calender optional calendar
-- @int[optchain] offset optional offset
-- @string[opt='gregorian'] calender optional calendar
-- @int[optchain=0] offset optional offset
-- @treturn string
function one (name,age,...)
end