doc: Shape the methods and functions arguments in the summary.

Given the full prototype can be quite long with all the optional
argument definition, better help the eyes focus on the important
part.
This commit is contained in:
Emmanuel Lepage Vallee 2019-06-08 00:35:02 -04:00
parent 90a29f92eb
commit 3e3a298a33
2 changed files with 27 additions and 4 deletions

View File

@ -165,6 +165,21 @@ file = {
} }
} }
-- Wrap the module name for the CSS highlight.
local function wrap_modname(str, item)
if (not item.module) or str:sub(1, #item.module.name+1) ~= item.module.name.."." then return str end
return "<span class='function_modname'>"..item.module.name..".</span>"
.. str:sub(#item.module.name+2, 9999)
end
-- Wrap the arguments for the CSS highlight.
local function wrap_args(item)
if not item.args then return "" end
return "<span class='function_args'>"..item.args.."</span>"
end
-- Mimics the ldoc built-in method style, but better. -- Mimics the ldoc built-in method style, but better.
-- --
-- This custom renderer exists because using ldoc built-in method detection -- This custom renderer exists because using ldoc built-in method detection
@ -177,7 +192,7 @@ local function render_methods(item)
ret = ":"..ret ret = ":"..ret
end end
return ret .. (item.args and " "..item.args or "") return ret .. " " .. wrap_args(item)
end end
-- Parse the magic parameters to type concention in something the template eats. -- Parse the magic parameters to type concention in something the template eats.
@ -210,7 +225,6 @@ local function sanitize_type(item, ldoc)
-- It has to be set, otherwise the table will have different col count. -- It has to be set, otherwise the table will have different col count.
item.display_type = "<span class='summary_type'>N/A</span>" item.display_type = "<span class='summary_type'>N/A</span>"
end end
local no_prefix = { local no_prefix = {
property = true, signal = true, clientruleproperty = true, property = true, signal = true, clientruleproperty = true,
deprecatedproperty = true, deprecatedproperty = true,
@ -284,7 +298,7 @@ custom_display_name_handler = function(item, default_handler)
end end
if item.type == "method" then if item.type == "method" then
return render_methods(item) ret = render_methods(item)
end end
@ -300,9 +314,12 @@ custom_display_name_handler = function(item, default_handler)
-- It isn't there by default. -- It isn't there by default.
if add_args[item.type] then if add_args[item.type] then
ret = ret .. " " .. item.args ret = ret .. " " .. wrap_args(item)
end end
-- Beautify.
ret = wrap_modname(ret, item)
return ret return ret
end end

View File

@ -309,6 +309,12 @@ td.summarytype {
text-align: right; text-align: right;
} }
table.function_list .function_args /*.function_modname*/ {
color: #94b1ff;
text-decoration: underline;
text-decoration-color: #bbd3ff;
}
dl.function { dl.function {
margin-right: 15px; margin-right: 15px;
margin-left: 15px; margin-left: 15px;