Custom display_name handler.
Mooffie
10 years ago
1109 | 1109 |
'file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'
|
1110 | 1110 |
- `no_summary` suppress the Contents summary
|
1111 | 1111 |
- `custom_see_handler` function that filters see-references
|
|
1112 |
- `custom_display_name_handler` function that formats an item's name. The arguments are the item
|
|
1113 |
and the default function used to format the name. For example, to show an icon or label beside any
|
|
1114 |
function tagged with a certain tag:
|
|
1115 |
-- define a @callback tag:
|
|
1116 |
custom_tags = { { 'callback', hidden = true } }
|
|
1117 |
|
|
1118 |
-- show a label beside functions tagged with @callback.
|
|
1119 |
custom_display_name_handler = function(item, default_handler)
|
|
1120 |
if item.type == 'function' and item.tags.callback then
|
|
1121 |
return item.name .. ' [callback]'
|
|
1122 |
end
|
|
1123 |
return default_handler(item)
|
|
1124 |
end
|
|
1125 |
|
1112 | 1126 |
- `not_luadoc` set to `true` if the docs break LuaDoc compatibility
|
1113 | 1127 |
- `no_space_before_args` set to `true` if you do not want a space between a function's name and its arguments.
|
1114 | 1128 |
- `template_escape` overrides the usual '#' used for Lua code in templates. This needs to be changed if the output format is Markdown, for instance.
|
155 | 155 |
if #ls > 1 then return '<li>','</li>' else return '','' end
|
156 | 156 |
end
|
157 | 157 |
|
158 | |
function ldoc.display_name(item)
|
|
158 |
function ldoc.default_display_name(item)
|
159 | 159 |
local name = item.display_name or item.name
|
160 | 160 |
if item.type == 'function' or item.type == 'lfunction' then
|
161 | 161 |
if not ldoc.no_space_before_args then
|
|
164 | 164 |
return name..item.args
|
165 | 165 |
else
|
166 | 166 |
return name
|
|
167 |
end
|
|
168 |
end
|
|
169 |
|
|
170 |
function ldoc.display_name(item)
|
|
171 |
if ldoc.custom_display_name_handler then
|
|
172 |
return ldoc.custom_display_name_handler(item, ldoc.default_display_name)
|
|
173 |
else
|
|
174 |
return ldoc.default_display_name(item)
|
167 | 175 |
end
|
168 | 176 |
end
|
169 | 177 |
|
199 | 199 |
'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups',
|
200 | 200 |
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
|
201 | 201 |
'no_space_before_args','parse_extra','no_lua_ref','sort_modules','use_markdown_titles',
|
202 | |
'unqualified',
|
|
202 |
'unqualified', 'custom_display_name_handler',
|
203 | 203 |
}
|
204 | 204 |
ldoc_contents = tablex.makeset(ldoc_contents)
|
205 | 205 |
|