Codebase list lua-ldoc / 3053079
Custom display_name handler. Mooffie 10 years ago
3 changed file(s) with 24 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
11091109 'file:///D:/dev/lua/projects/lua-5.1.4/doc/manual.html'
11101110 - `no_summary` suppress the Contents summary
11111111 - `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
11121126 - `not_luadoc` set to `true` if the docs break LuaDoc compatibility
11131127 - `no_space_before_args` set to `true` if you do not want a space between a function's name and its arguments.
11141128 - `template_escape` overrides the usual '#' used for Lua code in templates. This needs to be changed if the output format is Markdown, for instance.
155155 if #ls > 1 then return '<li>','</li>' else return '','' end
156156 end
157157
158 function ldoc.display_name(item)
158 function ldoc.default_display_name(item)
159159 local name = item.display_name or item.name
160160 if item.type == 'function' or item.type == 'lfunction' then
161161 if not ldoc.no_space_before_args then
164164 return name..item.args
165165 else
166166 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)
167175 end
168176 end
169177
199199 'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups',
200200 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
201201 'no_space_before_args','parse_extra','no_lua_ref','sort_modules','use_markdown_titles',
202 'unqualified',
202 'unqualified', 'custom_display_name_handler',
203203 }
204204 ldoc_contents = tablex.makeset(ldoc_contents)
205205