issue #57: [opt=default] support - see tests/styles/four.lua
steve donovan
11 years ago
664 | 664 |
local function acc(x) table.insert(buffer, x) end
|
665 | 665 |
for i = 1, #names do
|
666 | 666 |
local m = pmods and pmods[i]
|
|
667 |
local opt
|
667 | 668 |
if m then
|
668 | 669 |
if not m.optchain then
|
669 | 670 |
acc ((']'):rep(npending))
|
670 | 671 |
npending=0
|
671 | 672 |
end
|
672 | |
if m.opt or m.optchain then acc(' ['); npending=npending+1 end
|
|
673 |
opt = m.opt or m.optchain
|
|
674 |
if opt then
|
|
675 |
acc(' [')
|
|
676 |
npending=npending+1
|
|
677 |
end
|
673 | 678 |
end
|
674 | 679 |
if i>1 then acc (', ') end
|
675 | 680 |
acc(names[i])
|
|
681 |
if opt and opt ~= true then acc('='..opt) end
|
676 | 682 |
end
|
677 | 683 |
acc ((']'):rep(npending))
|
678 | 684 |
return '('..table.concat(buffer)..')'
|
35 | 35 |
modifiers = { }
|
36 | 36 |
for x in mod_string :gmatch "[^,]+" do
|
37 | 37 |
local k, v = x :match "^([^=]+)=(.*)$"
|
38 | |
if not k then k, v = x, x end
|
|
38 |
if not k then k, v = x, true end -- wuz x, x
|
39 | 39 |
modifiers[k] = v
|
40 | 40 |
end
|
41 | 41 |
end
|
12 | 12 |
-- you may document an indefinite number of extra arguments!
|
13 | 13 |
-- @string name person's name
|
14 | 14 |
-- @int age
|
15 | |
-- @string[opt] calender optional calendar
|
16 | |
-- @int[optchain] offset optional offset
|
|
15 |
-- @string[opt='gregorian'] calender optional calendar
|
|
16 |
-- @int[optchain=0] offset optional offset
|
17 | 17 |
-- @treturn string
|
18 | 18 |
function one (name,age,...)
|
19 | 19 |
end
|