mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
build(lua2dox): add parenthesis around parameter types in documentation (#18532)
This will check if the string after the variable in a @param is either "number", "string", "table", "boolean" and "function" and if so add a parenthesis around it. This will help separate the variable type with the following text. Had all our functions been annotated with emmylua then a more robust solution might have been preferable (such as always assuming the third string is parameter type without making any checks). I believe however this is a clear improvement over the current situation and will suffice for now.
This commit is contained in:
@@ -403,6 +403,29 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
||||
if string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment
|
||||
state = 'in_magic_comment'
|
||||
local magic = string.sub(line, 4 + offset)
|
||||
|
||||
local magic_split = string_split(magic, ' ')
|
||||
|
||||
local type_index = 2
|
||||
if magic_split[1] == 'param' then
|
||||
type_index = type_index + 1
|
||||
end
|
||||
|
||||
if magic_split[type_index] == 'number' or
|
||||
magic_split[type_index] == 'number|nil' or
|
||||
magic_split[type_index] == 'string' or
|
||||
magic_split[type_index] == 'string|nil' or
|
||||
magic_split[type_index] == 'table' or
|
||||
magic_split[type_index] == 'table|nil' or
|
||||
magic_split[type_index] == 'boolean' or
|
||||
magic_split[type_index] == 'boolean|nil' or
|
||||
magic_split[type_index] == 'function' or
|
||||
magic_split[type_index] == 'function|nil'
|
||||
then
|
||||
magic_split[type_index] = '(' .. magic_split[type_index] .. ')'
|
||||
end
|
||||
magic = table.concat(magic_split, ' ')
|
||||
|
||||
outStream:writeln('/// @' .. magic)
|
||||
fn_magic = checkComment4fn(fn_magic,magic)
|
||||
elseif string.sub(line,3,3)=='-' then -- it's a nonmagic doc comment
|
||||
|
Reference in New Issue
Block a user