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

View File

@ -36,7 +36,7 @@ local function parse_at_tags(text)
modifiers = { } modifiers = { }
for x in mod_string :gmatch "[^,]+" do for x in mod_string :gmatch "[^,]+" do
local k, v = x :match "^([^=]+)=(.*)$" 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 modifiers[k] = v
end end
end end

View File

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