diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-10-18 11:33:12 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-10-21 11:32:06 +0100 |
commit | 3572319b4cb1a4163624a5fe328886f1928dbc4a (patch) | |
tree | 5e190a6d9ca8a2e0f998ef578f895efee9450fb4 /scripts/gen_help_html.lua | |
parent | 6fd13eeddaf5db89c1b81cc7d3d3f1a7da5401a7 (diff) | |
download | rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.gz rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.bz2 rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.zip |
feat(vim.validate): improve fast form and deprecate spec form
Problem:
`vim.validate()` takes two forms when it only needs one.
Solution:
- Teach the fast form all the features of the spec form.
- Deprecate the spec form.
- General optimizations for both forms.
- Add a `message` argument which can be used alongside or in place
of the `optional` argument.
Diffstat (limited to 'scripts/gen_help_html.lua')
-rw-r--r-- | scripts/gen_help_html.lua | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua index b5dbce38f6..21d865309d 100644 --- a/scripts/gen_help_html.lua +++ b/scripts/gen_help_html.lua @@ -1289,25 +1289,15 @@ end --- --- @return nvim.gen_help_html.gen_result result function M.gen(help_dir, to_dir, include, commit, parser_path) - vim.validate { - help_dir = { - help_dir, - function(d) - return vim.fn.isdirectory(vim.fs.normalize(d)) == 1 - end, - 'valid directory', - }, - to_dir = { to_dir, 's' }, - include = { include, 't', true }, - commit = { commit, 's', true }, - parser_path = { - parser_path, - function(f) - return f == nil or vim.fn.filereadable(vim.fs.normalize(f)) == 1 - end, - 'valid vimdoc.{so,dll} filepath', - }, - } + vim.validate('help_dir', help_dir, function(d) + return vim.fn.isdirectory(vim.fs.normalize(d)) == 1 + end, 'valid directory') + vim.validate('to_dir', to_dir, 'string') + vim.validate('include', include, 'table', true) + vim.validate('commit', commit, 'sring', true) + vim.validate('parser_path', parser_path, function(f) + return vim.fn.filereadable(vim.fs.normalize(f)) == 1 + end, true, 'valid vimdoc.{so,dll} filepath') local err_count = 0 local redirects_count = 0 @@ -1410,23 +1400,13 @@ end --- --- @return nvim.gen_help_html.validate_result result function M.validate(help_dir, include, parser_path) - vim.validate { - help_dir = { - help_dir, - function(d) - return vim.fn.isdirectory(vim.fs.normalize(d)) == 1 - end, - 'valid directory', - }, - include = { include, 't', true }, - parser_path = { - parser_path, - function(f) - return f == nil or vim.fn.filereadable(vim.fs.normalize(f)) == 1 - end, - 'valid vimdoc.{so,dll} filepath', - }, - } + vim.validate('help_dir', help_dir, function(d) + return vim.fn.isdirectory(vim.fs.normalize(d)) == 1 + end, 'valid directory') + vim.validate('include', include, 'table', true) + vim.validate('parser_path', parser_path, function(f) + return vim.fn.filereadable(vim.fs.normalize(f)) == 1 + end, true, 'valid vimdoc.{so,dll} filepath') local err_count = 0 ---@type integer local files_to_errors = {} ---@type table<string, string[]> ensure_runtimepath() |