Custom display_name handler.

This commit is contained in:
Mooffie 2013-12-09 12:13:06 +02:00
parent 94433da88f
commit 3053079fee
3 changed files with 24 additions and 2 deletions

View File

@ -1110,6 +1110,20 @@ when using Markdown. When explicit will expand non-references in backticks into
'file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'
- `no_summary` suppress the Contents summary
- `custom_see_handler` function that filters see-references
- `custom_display_name_handler` function that formats an item's name. The arguments are the item
and the default function used to format the name. For example, to show an icon or label beside any
function tagged with a certain tag:
-- define a @callback tag:
custom_tags = { { 'callback', hidden = true } }
-- show a label beside functions tagged with @callback.
custom_display_name_handler = function(item, default_handler)
if item.type == 'function' and item.tags.callback then
return item.name .. ' [callback]'
end
return default_handler(item)
end
- `not_luadoc` set to `true` if the docs break LuaDoc compatibility
- `no_space_before_args` set to `true` if you do not want a space between a function's name and its arguments.
- `template_escape` overrides the usual '#' used for Lua code in templates. This needs to be changed if the output format is Markdown, for instance.

View File

@ -200,7 +200,7 @@ local ldoc_contents = {
'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups',
'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',
'unqualified', 'custom_display_name_handler',
}
ldoc_contents = tablex.makeset(ldoc_contents)

View File

@ -156,7 +156,7 @@ function html.generate_output(ldoc, args, project)
if #ls > 1 then return '<li>','</li>' else return '','' end
end
function ldoc.display_name(item)
function ldoc.default_display_name(item)
local name = item.display_name or item.name
if item.type == 'function' or item.type == 'lfunction' then
if not ldoc.no_space_before_args then
@ -168,6 +168,14 @@ function html.generate_output(ldoc, args, project)
end
end
function ldoc.display_name(item)
if ldoc.custom_display_name_handler then
return ldoc.custom_display_name_handler(item, ldoc.default_display_name)
else
return ldoc.default_display_name(item)
end
end
function ldoc.no_spaces(s)
s = s:gsub('%s*$','')
return (s:gsub('%W','_'))