diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 9e4f430..46b381c 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -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)..')' diff --git a/ldoc/parse.lua b/ldoc/parse.lua index 176dc41..dded82c 100644 --- a/ldoc/parse.lua +++ b/ldoc/parse.lua @@ -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 diff --git a/tests/styles/four.lua b/tests/styles/four.lua index f2bcc31..91093c9 100644 --- a/tests/styles/four.lua +++ b/tests/styles/four.lua @@ -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