Tweaks to opt/optchain: (optional) is emitted after optional arguments without defaults. convert_opts (counter-intuitively) disables automatic opt->optchain promotion

This commit is contained in:
steve donovan 2014-10-12 16:45:09 +02:00
parent cfdc6f8f53
commit 56ac2601c0
3 changed files with 9 additions and 6 deletions

View File

@ -233,7 +233,7 @@ local ldoc_contents = {
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
'no_space_before_args','parse_extra','no_lua_ref','sort_modules','use_markdown_titles',
'unqualified', 'custom_display_name_handler', 'kind_names', 'custom_references',
'dont_escape_underscore','global_lookup','prettify_files'
'dont_escape_underscore','global_lookup','prettify_files','convert_opt'
}
ldoc_contents = tablex.makeset(ldoc_contents)

View File

@ -807,8 +807,9 @@ function build_arg_list (names,pmods)
-- with @param[opt] b
local buffer, npending = { }, 0
local function acc(x) table.insert(buffer, x) end
-- a number of trailing [opt]s can be safely converted to [opt],[optchain],...
if pmods then
-- a number of trailing [opt]s will be usually converted to [opt],[optchain],...
-- *unless* a person uses convert_opt.
if pmods and not doc.ldoc.convert_opt then
local m = pmods[#names]
if m and m.opt then
m.optchain = m.opt
@ -855,11 +856,11 @@ function Item:type_of_param(p)
return mparam and mparam.type or ''
end
-- default value for param; if optional but no default, it's just `true`.
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

View File

@ -186,7 +186,9 @@ return [==[
<span class="types">$(tp)</span>
# end
$(M(item.params.map[p],item))
# if def then
# if def == true then
(<em>optional</em>)
# elseif def then
(<em>default</em> $(def))
# end
# if item:readonly(p) then