issue #78 default parm value now in documentation

This commit is contained in:
Steve Donovan 2013-08-22 10:12:04 +02:00
parent 3c72e9e4d1
commit 7bb95e5e7d
2 changed files with 21 additions and 5 deletions

View File

@ -752,13 +752,25 @@ function build_arg_list (names,pmods)
return '('..table.concat(buffer)..')' return '('..table.concat(buffer)..')'
end end
function Item:type_of_param(p) function Item:param_modifiers (p)
local mods = self.modifiers[self.parameter] local mods = self.modifiers[self.parameter]
if not mods then return '' end if not mods then return '' end
local mparam = rawget(mods,p) return rawget(mods,p)
end
function Item:type_of_param(p)
local mparam = self:param_modifiers(p)
return mparam and mparam.type or '' return mparam and mparam.type or ''
end end
function Item:default_of_param(p)
local m = self:param_modifiers(p)
if not m then return nil end
local opt = m.optchain or m.opt
if opt == true then return nil end
return opt
end
function Item:type_of_ret(idx) function Item:type_of_ret(idx)
local rparam = self.modifiers['return'][idx] local rparam = self.modifiers['return'][idx]
return rparam and rparam.type or '' return rparam and rparam.type or ''

View File

@ -165,12 +165,16 @@ return [==[
<ul> <ul>
# end # end
# for p in iter(param) do # for p in iter(param) do
# local name,tp = item:display_name_of(p), ldoc.typename(item:type_of_param(p)) # local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
<li><span class="parameter">$(name)</span> <li><span class="parameter">$(name)</span>
# if tp ~= '' then # if tp ~= '' then
<span class="types">$(tp)</span> <span class="types">$(tp)</span>
# end # end
$(M(item.params[p],item))</li> $(M(item.params[p],item))
# if def then
(<em>default</em> $(def))
# end
</li>
# end # end
# if sublist then # if sublist then
</li></ul> </li></ul>