mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
docs(annotations): added ---@generic
support
This commit is contained in:
parent
65b1733405
commit
f9dd682621
24
runtime/doc/builtin.txt
generated
24
runtime/doc/builtin.txt
generated
@ -1305,10 +1305,10 @@ copy({expr}) *copy()*
|
|||||||
Also see |deepcopy()|.
|
Also see |deepcopy()|.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {expr} (`any`)
|
• {expr} (`T`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`T`)
|
||||||
|
|
||||||
cos({expr}) *cos()*
|
cos({expr}) *cos()*
|
||||||
Return the cosine of {expr}, measured in radians, as a |Float|.
|
Return the cosine of {expr}, measured in radians, as a |Float|.
|
||||||
@ -1490,11 +1490,11 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E69
|
|||||||
Also see |copy()|.
|
Also see |copy()|.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {expr} (`any`)
|
• {expr} (`T`)
|
||||||
• {noref} (`boolean?`)
|
• {noref} (`boolean?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`T`)
|
||||||
|
|
||||||
delete({fname} [, {flags}]) *delete()*
|
delete({fname} [, {flags}]) *delete()*
|
||||||
Without {flags} or with {flags} empty: Deletes the file by the
|
Without {flags} or with {flags} empty: Deletes the file by the
|
||||||
@ -5281,7 +5281,7 @@ items({dict}) *items()*
|
|||||||
the index.
|
the index.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {dict} (`any`)
|
• {dict} (`table`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`any`)
|
||||||
@ -6567,7 +6567,7 @@ max({expr}) *max()*
|
|||||||
• {expr} (`any`)
|
• {expr} (`any`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`number`)
|
||||||
|
|
||||||
menu_get({path} [, {modes}]) *menu_get()*
|
menu_get({path} [, {modes}]) *menu_get()*
|
||||||
Returns a |List| of |Dictionaries| describing |menus| (defined
|
Returns a |List| of |Dictionaries| describing |menus| (defined
|
||||||
@ -7733,11 +7733,11 @@ reduce({object}, {func} [, {initial}]) *reduce()* *E99
|
|||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {object} (`any`)
|
• {object} (`any`)
|
||||||
• {func} (`function`)
|
• {func} (`fun(accumulator: T, current: any): any`)
|
||||||
• {initial} (`any?`)
|
• {initial} (`any?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`T`)
|
||||||
|
|
||||||
reg_executing() *reg_executing()*
|
reg_executing() *reg_executing()*
|
||||||
Returns the single letter name of the register being executed.
|
Returns the single letter name of the register being executed.
|
||||||
@ -7951,10 +7951,10 @@ reverse({object}) *reverse()*
|
|||||||
<
|
<
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {object} (`any`)
|
• {object} (`T[]`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`T[]`)
|
||||||
|
|
||||||
round({expr}) *round()*
|
round({expr}) *round()*
|
||||||
Round off {expr} to the nearest integral value and return it
|
Round off {expr} to the nearest integral value and return it
|
||||||
@ -9952,12 +9952,12 @@ sort({list} [, {how} [, {dict}]]) *sort()* *E70
|
|||||||
<
|
<
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {list} (`any`)
|
• {list} (`T[]`)
|
||||||
• {how} (`string|function?`)
|
• {how} (`string|function?`)
|
||||||
• {dict} (`any?`)
|
• {dict} (`any?`)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`any`)
|
(`T[]`)
|
||||||
|
|
||||||
soundfold({word}) *soundfold()*
|
soundfold({word}) *soundfold()*
|
||||||
Return the sound-folded equivalent of {word}. Uses the first
|
Return the sound-folded equivalent of {word}. Uses the first
|
||||||
|
29
runtime/lua/vim/_meta/vimfn.lua
generated
29
runtime/lua/vim/_meta/vimfn.lua
generated
@ -1147,8 +1147,9 @@ function vim.fn.confirm(msg, choices, default, type) end
|
|||||||
--- A |Dictionary| is copied in a similar way as a |List|.
|
--- A |Dictionary| is copied in a similar way as a |List|.
|
||||||
--- Also see |deepcopy()|.
|
--- Also see |deepcopy()|.
|
||||||
---
|
---
|
||||||
--- @param expr any
|
--- @generic T
|
||||||
--- @return any
|
--- @param expr T
|
||||||
|
--- @return T
|
||||||
function vim.fn.copy(expr) end
|
function vim.fn.copy(expr) end
|
||||||
|
|
||||||
--- Return the cosine of {expr}, measured in radians, as a |Float|.
|
--- Return the cosine of {expr}, measured in radians, as a |Float|.
|
||||||
@ -1308,9 +1309,10 @@ function vim.fn.debugbreak(pid) end
|
|||||||
--- {noref} set to 1 will fail.
|
--- {noref} set to 1 will fail.
|
||||||
--- Also see |copy()|.
|
--- Also see |copy()|.
|
||||||
---
|
---
|
||||||
--- @param expr any
|
--- @generic T
|
||||||
|
--- @param expr T
|
||||||
--- @param noref? boolean
|
--- @param noref? boolean
|
||||||
--- @return any
|
--- @return T
|
||||||
function vim.fn.deepcopy(expr, noref) end
|
function vim.fn.deepcopy(expr, noref) end
|
||||||
|
|
||||||
--- Without {flags} or with {flags} empty: Deletes the file by the
|
--- Without {flags} or with {flags} empty: Deletes the file by the
|
||||||
@ -4769,7 +4771,7 @@ function vim.fn.isnan(expr) end
|
|||||||
--- cases, items() returns a List with the index and the value at
|
--- cases, items() returns a List with the index and the value at
|
||||||
--- the index.
|
--- the index.
|
||||||
---
|
---
|
||||||
--- @param dict any
|
--- @param dict table
|
||||||
--- @return any
|
--- @return any
|
||||||
function vim.fn.items(dict) end
|
function vim.fn.items(dict) end
|
||||||
|
|
||||||
@ -5952,7 +5954,7 @@ function vim.fn.matchstrpos(expr, pat, start, count) end
|
|||||||
--- an error. An empty |List| or |Dictionary| results in zero.
|
--- an error. An empty |List| or |Dictionary| results in zero.
|
||||||
---
|
---
|
||||||
--- @param expr any
|
--- @param expr any
|
||||||
--- @return any
|
--- @return number
|
||||||
function vim.fn.max(expr) end
|
function vim.fn.max(expr) end
|
||||||
|
|
||||||
--- Returns a |List| of |Dictionaries| describing |menus| (defined
|
--- Returns a |List| of |Dictionaries| describing |menus| (defined
|
||||||
@ -7016,10 +7018,11 @@ function vim.fn.readfile(fname, type, max) end
|
|||||||
--- echo reduce('xyz', { acc, val -> acc .. ',' .. val })
|
--- echo reduce('xyz', { acc, val -> acc .. ',' .. val })
|
||||||
--- <
|
--- <
|
||||||
---
|
---
|
||||||
|
--- @generic T
|
||||||
--- @param object any
|
--- @param object any
|
||||||
--- @param func function
|
--- @param func fun(accumulator: T, current: any): any
|
||||||
--- @param initial? any
|
--- @param initial? any
|
||||||
--- @return any
|
--- @return T
|
||||||
function vim.fn.reduce(object, func, initial) end
|
function vim.fn.reduce(object, func, initial) end
|
||||||
|
|
||||||
--- Returns the single letter name of the register being executed.
|
--- Returns the single letter name of the register being executed.
|
||||||
@ -7215,8 +7218,9 @@ function vim.fn.resolve(filename) end
|
|||||||
--- let revlist = reverse(copy(mylist))
|
--- let revlist = reverse(copy(mylist))
|
||||||
--- <
|
--- <
|
||||||
---
|
---
|
||||||
--- @param object any
|
--- @generic T
|
||||||
--- @return any
|
--- @param object T[]
|
||||||
|
--- @return T[]
|
||||||
function vim.fn.reverse(object) end
|
function vim.fn.reverse(object) end
|
||||||
|
|
||||||
--- Round off {expr} to the nearest integral value and return it
|
--- Round off {expr} to the nearest integral value and return it
|
||||||
@ -9079,10 +9083,11 @@ function vim.fn.sockconnect(mode, address, opts) end
|
|||||||
--- eval mylist->sort({i1, i2 -> i1 - i2})
|
--- eval mylist->sort({i1, i2 -> i1 - i2})
|
||||||
--- <
|
--- <
|
||||||
---
|
---
|
||||||
--- @param list any
|
--- @generic T
|
||||||
|
--- @param list T[]
|
||||||
--- @param how? string|function
|
--- @param how? string|function
|
||||||
--- @param dict? any
|
--- @param dict? any
|
||||||
--- @return any
|
--- @return T[]
|
||||||
function vim.fn.sort(list, how, dict) end
|
function vim.fn.sort(list, how, dict) end
|
||||||
|
|
||||||
--- Return the sound-folded equivalent of {word}. Uses the first
|
--- Return the sound-folded equivalent of {word}. Uses the first
|
||||||
|
@ -496,6 +496,10 @@ local function render_eval_meta(f, fun, write)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _, text in ipairs(vim.fn.reverse(fun.generics or {})) do
|
||||||
|
write(fmt('--- @generic %s', text))
|
||||||
|
end
|
||||||
|
|
||||||
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
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
--- @field deprecated? true
|
--- @field deprecated? true
|
||||||
--- @field returns? string|false
|
--- @field returns? string|false
|
||||||
--- @field returns_desc? string
|
--- @field returns_desc? string
|
||||||
|
--- @field generics? string[] Used to write `---@generic` annotations over a function.
|
||||||
--- @field signature? string
|
--- @field signature? string
|
||||||
--- @field desc? string
|
--- @field desc? string
|
||||||
--- @field params [string, string, string][]
|
--- @field params [string, string, string][]
|
||||||
@ -1521,9 +1522,10 @@ M.funcs = {
|
|||||||
A |Dictionary| is copied in a similar way as a |List|.
|
A |Dictionary| is copied in a similar way as a |List|.
|
||||||
Also see |deepcopy()|.
|
Also see |deepcopy()|.
|
||||||
]=],
|
]=],
|
||||||
|
generics = { 'T' },
|
||||||
name = 'copy',
|
name = 'copy',
|
||||||
params = { { 'expr', 'any' } },
|
params = { { 'expr', 'T' } },
|
||||||
returns = 'any',
|
returns = 'T',
|
||||||
signature = 'copy({expr})',
|
signature = 'copy({expr})',
|
||||||
},
|
},
|
||||||
cos = {
|
cos = {
|
||||||
@ -1739,8 +1741,10 @@ M.funcs = {
|
|||||||
Also see |copy()|.
|
Also see |copy()|.
|
||||||
|
|
||||||
]=],
|
]=],
|
||||||
|
generics = { 'T' },
|
||||||
name = 'deepcopy',
|
name = 'deepcopy',
|
||||||
params = { { 'expr', 'any' }, { 'noref', 'boolean' } },
|
params = { { 'expr', 'T' }, { 'noref', 'boolean' } },
|
||||||
|
returns = 'T',
|
||||||
signature = 'deepcopy({expr} [, {noref}])',
|
signature = 'deepcopy({expr} [, {noref}])',
|
||||||
},
|
},
|
||||||
delete = {
|
delete = {
|
||||||
@ -5894,7 +5898,7 @@ M.funcs = {
|
|||||||
the index.
|
the index.
|
||||||
]=],
|
]=],
|
||||||
name = 'items',
|
name = 'items',
|
||||||
params = { { 'dict', 'any' } },
|
params = { { 'dict', 'table' } },
|
||||||
signature = 'items({dict})',
|
signature = 'items({dict})',
|
||||||
},
|
},
|
||||||
jobclose = {
|
jobclose = {
|
||||||
@ -7309,6 +7313,7 @@ M.funcs = {
|
|||||||
]=],
|
]=],
|
||||||
name = 'max',
|
name = 'max',
|
||||||
params = { { 'expr', 'any' } },
|
params = { { 'expr', 'any' } },
|
||||||
|
returns = 'number',
|
||||||
signature = 'max({expr})',
|
signature = 'max({expr})',
|
||||||
},
|
},
|
||||||
menu_get = {
|
menu_get = {
|
||||||
@ -8520,7 +8525,13 @@ M.funcs = {
|
|||||||
<
|
<
|
||||||
]=],
|
]=],
|
||||||
name = 'reduce',
|
name = 'reduce',
|
||||||
params = { { 'object', 'any' }, { 'func', 'function' }, { 'initial', 'any' } },
|
generics = { 'T' },
|
||||||
|
params = {
|
||||||
|
{ 'object', 'any' },
|
||||||
|
{ 'func', 'fun(accumulator: T, current: any): any' },
|
||||||
|
{ 'initial', 'any' },
|
||||||
|
},
|
||||||
|
returns = 'T',
|
||||||
signature = 'reduce({object}, {func} [, {initial}])',
|
signature = 'reduce({object}, {func} [, {initial}])',
|
||||||
},
|
},
|
||||||
reg_executing = {
|
reg_executing = {
|
||||||
@ -8785,7 +8796,9 @@ M.funcs = {
|
|||||||
<
|
<
|
||||||
]=],
|
]=],
|
||||||
name = 'reverse',
|
name = 'reverse',
|
||||||
params = { { 'object', 'any' } },
|
generics = { 'T' },
|
||||||
|
params = { { 'object', 'T[]' } },
|
||||||
|
returns = 'T[]',
|
||||||
signature = 'reverse({object})',
|
signature = 'reverse({object})',
|
||||||
},
|
},
|
||||||
round = {
|
round = {
|
||||||
@ -10924,7 +10937,9 @@ M.funcs = {
|
|||||||
<
|
<
|
||||||
]=],
|
]=],
|
||||||
name = 'sort',
|
name = 'sort',
|
||||||
params = { { 'list', 'any' }, { 'how', 'string|function' }, { 'dict', 'any' } },
|
generics = { 'T' },
|
||||||
|
params = { { 'list', 'T[]' }, { 'how', 'string|function' }, { 'dict', 'any' } },
|
||||||
|
returns = 'T[]',
|
||||||
signature = 'sort({list} [, {how} [, {dict}]])',
|
signature = 'sort({list} [, {how} [, {dict}]])',
|
||||||
},
|
},
|
||||||
soundfold = {
|
soundfold = {
|
||||||
|
Loading…
Reference in New Issue
Block a user