doc: Disable the ldoc optional function parameter mangling.

It no longer does `foo(bar[,bar=42])` and will rather do `(foo, bar)`.

This is easier to read and some new user are no familiar with the
optional parameter convention. They copy/paste the mangled value in
their config and end up with invalid Lua.
This commit is contained in:
Emmanuel Lepage Vallee 2021-12-16 09:50:52 -08:00
parent 16f84ec87a
commit 292b657aea
1 changed files with 19 additions and 0 deletions

View File

@ -956,6 +956,25 @@ custom_display_name_handler = function(item, default_handler)
init_custom_types(item)
-- Do not use the default handler. It encodes the parameters using
-- the optchain convention. Not everybody is confortable with this.
-- It is also unreadable.
item.args = ""
if item.params then
item.args = "("
for key, line in ipairs(item.params) do
local name, comment = item:split_param(line)
local def = item:default_of_param(line)
if def then
item.args = item.args .. '<span class="optional_param">' .. name .. "</span>" .. (key < #item.params and ", " or "")
else
item.args = item.args .. name .. (key < #item.params and ", " or "")
end
end
item.args = item.args .. ")"
end
local ret = default_handler(item)
-- Edit the input so the template is notified.