mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
docs: do not escape Lua keywords #31467
This commit is contained in:
parent
ba7370a902
commit
2550b5e9bd
18
runtime/doc/builtin.txt
generated
18
runtime/doc/builtin.txt
generated
@ -2997,7 +2997,7 @@ getbufline({buf}, {lnum} [, {end}]) *getbufline()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {buf} (`integer|string`)
|
• {buf} (`integer|string`)
|
||||||
• {lnum} (`integer`)
|
• {lnum} (`integer`)
|
||||||
• {end_} (`integer?`)
|
• {end} (`integer?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
@ -3635,7 +3635,7 @@ getline({lnum} [, {end}]) *getline()*
|
|||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {lnum} (`integer|string`)
|
• {lnum} (`integer|string`)
|
||||||
• {end_} (`nil|false?`)
|
• {end} (`nil|false?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`string`)
|
(`string`)
|
||||||
@ -6292,7 +6292,7 @@ matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
|
|||||||
• {buf} (`string|integer`)
|
• {buf} (`string|integer`)
|
||||||
• {pat} (`string`)
|
• {pat} (`string`)
|
||||||
• {lnum} (`string|integer`)
|
• {lnum} (`string|integer`)
|
||||||
• {end_} (`string|integer`)
|
• {end} (`string|integer`)
|
||||||
• {dict} (`table?`)
|
• {dict} (`table?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
@ -7786,7 +7786,7 @@ reltime({start}, {end})
|
|||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {start} (`any?`)
|
• {start} (`any?`)
|
||||||
• {end_} (`any?`)
|
• {end} (`any?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
@ -7847,7 +7847,7 @@ remove({list}, {idx}, {end})
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {list} (`any[]`)
|
• {list} (`any[]`)
|
||||||
• {idx} (`integer`)
|
• {idx} (`integer`)
|
||||||
• {end_} (`integer?`)
|
• {end} (`integer?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
@ -7869,7 +7869,7 @@ remove({blob}, {idx}, {end})
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {blob} (`any`)
|
• {blob} (`any`)
|
||||||
• {idx} (`integer`)
|
• {idx} (`integer`)
|
||||||
• {end_} (`integer?`)
|
• {end} (`integer?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
@ -8500,7 +8500,7 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {start} (`string`)
|
• {start} (`string`)
|
||||||
• {middle} (`string`)
|
• {middle} (`string`)
|
||||||
• {end_} (`string`)
|
• {end} (`string`)
|
||||||
• {flags} (`string?`)
|
• {flags} (`string?`)
|
||||||
• {skip} (`string|function?`)
|
• {skip} (`string|function?`)
|
||||||
• {stopline} (`integer?`)
|
• {stopline} (`integer?`)
|
||||||
@ -8524,7 +8524,7 @@ searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {ti
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {start} (`string`)
|
• {start} (`string`)
|
||||||
• {middle} (`string`)
|
• {middle} (`string`)
|
||||||
• {end_} (`string`)
|
• {end} (`string`)
|
||||||
• {flags} (`string?`)
|
• {flags} (`string?`)
|
||||||
• {skip} (`string|function?`)
|
• {skip} (`string|function?`)
|
||||||
• {stopline} (`integer?`)
|
• {stopline} (`integer?`)
|
||||||
@ -9840,7 +9840,7 @@ slice({expr}, {start} [, {end}]) *slice()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {expr} (`any`)
|
• {expr} (`any`)
|
||||||
• {start} (`integer`)
|
• {start} (`integer`)
|
||||||
• {end_} (`integer?`)
|
• {end} (`integer?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
|
@ -134,6 +134,15 @@ local API_TYPES = {
|
|||||||
void = '',
|
void = '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- @param s string
|
||||||
|
--- @return string
|
||||||
|
local function luaescape(s)
|
||||||
|
if LUA_KEYWORDS[s] then
|
||||||
|
return s .. '_'
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
|
||||||
--- @param x string
|
--- @param x string
|
||||||
--- @param sep? string
|
--- @param sep? string
|
||||||
--- @return string[]
|
--- @return string[]
|
||||||
@ -208,7 +217,7 @@ local function render_fun_sig(f, params)
|
|||||||
--- @param v [string,string]
|
--- @param v [string,string]
|
||||||
--- @return string
|
--- @return string
|
||||||
function(v)
|
function(v)
|
||||||
return v[1]
|
return luaescape(v[1])
|
||||||
end,
|
end,
|
||||||
params
|
params
|
||||||
),
|
),
|
||||||
@ -224,7 +233,6 @@ local function render_fun_sig(f, params)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Uniquify names
|
--- Uniquify names
|
||||||
--- Fix any names that are lua keywords
|
|
||||||
--- @param params [string,string,string][]
|
--- @param params [string,string,string][]
|
||||||
--- @return [string,string,string][]
|
--- @return [string,string,string][]
|
||||||
local function process_params(params)
|
local function process_params(params)
|
||||||
@ -232,9 +240,6 @@ local function process_params(params)
|
|||||||
local sfx = 1
|
local sfx = 1
|
||||||
|
|
||||||
for _, p in ipairs(params) do
|
for _, p in ipairs(params) do
|
||||||
if LUA_KEYWORDS[p[1]] then
|
|
||||||
p[1] = p[1] .. '_'
|
|
||||||
end
|
|
||||||
if seen[p[1]] then
|
if seen[p[1]] then
|
||||||
p[1] = p[1] .. sfx
|
p[1] = p[1] .. sfx
|
||||||
sfx = sfx + 1
|
sfx = sfx + 1
|
||||||
@ -389,10 +394,10 @@ local function render_api_meta(_f, fun, write)
|
|||||||
local param_names = {} --- @type string[]
|
local param_names = {} --- @type string[]
|
||||||
local params = process_params(fun.params)
|
local params = process_params(fun.params)
|
||||||
for _, p in ipairs(params) do
|
for _, p in ipairs(params) do
|
||||||
param_names[#param_names + 1] = p[1]
|
local pname, ptype, pdesc = luaescape(p[1]), p[2], p[3]
|
||||||
local pdesc = p[3]
|
param_names[#param_names + 1] = pname
|
||||||
if pdesc then
|
if pdesc then
|
||||||
local s = '--- @param ' .. p[1] .. ' ' .. p[2] .. ' '
|
local s = '--- @param ' .. pname .. ' ' .. ptype .. ' '
|
||||||
local pdesc_a = split(vim.trim(norm_text(pdesc)))
|
local pdesc_a = split(vim.trim(norm_text(pdesc)))
|
||||||
write(s .. pdesc_a[1])
|
write(s .. pdesc_a[1])
|
||||||
for i = 2, #pdesc_a do
|
for i = 2, #pdesc_a do
|
||||||
@ -402,7 +407,7 @@ local function render_api_meta(_f, fun, write)
|
|||||||
write('--- ' .. pdesc_a[i])
|
write('--- ' .. pdesc_a[i])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
write('--- @param ' .. p[1] .. ' ' .. p[2])
|
write('--- @param ' .. pname .. ' ' .. ptype)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -494,7 +499,7 @@ local function render_eval_meta(f, fun, write)
|
|||||||
local req_args = type(fun.args) == 'table' and fun.args[1] or fun.args or 0
|
local req_args = type(fun.args) == 'table' and fun.args[1] or fun.args or 0
|
||||||
|
|
||||||
for i, param in ipairs(params) do
|
for i, param in ipairs(params) do
|
||||||
local pname, ptype = param[1], param[2]
|
local pname, ptype = luaescape(param[1]), param[2]
|
||||||
local optional = (pname ~= '...' and i > req_args) and '?' or ''
|
local optional = (pname ~= '...' and i > req_args) and '?' or ''
|
||||||
write(fmt('--- @param %s%s %s', pname, optional, ptype))
|
write(fmt('--- @param %s%s %s', pname, optional, ptype))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user