diff --git a/ldoc/html.lua b/ldoc/html.lua
index 3e00def..f671ad8 100644
--- a/ldoc/html.lua
+++ b/ldoc/html.lua
@@ -98,15 +98,32 @@ function html.generate_output(ldoc, args, project)
end
function ldoc.typename (tp)
- if not tp then return '' end
- return (tp:gsub('%a[%w_%.]*',function(name)
+ if not tp or tp == '' then return '' end
+ local optional
+ local tp2 = tp:match("%?|?(.*)")
+ if tp2 then
+ optional = true
+ tp = tp2
+ end
+ local types = {}
+ for name in tp:gmatch("[^|]+") do
local ref,err = markup.process_reference(name)
if ref then
- return ('%s '):format(ldoc.href(ref),name)
+ types[#types+1] = ('%s '):format(ldoc.href(ref),name)
else
- return ''..name..' '
+ types[#types+1] = ''..name..' '
end
- end))
+ end
+ local names = table.concat(types, ", ", 1, math.max(#types-1, 1))
+ if #types > 1 then names = names.." or "..types[#types] end
+ if optional then
+ if names ~= '' then
+ names = "optional "..names
+ else
+ names = "optional"
+ end
+ end
+ return names
end
local module_template,err = utils.readfile (path.join(args.template,ldoc.templ))