diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-25 02:34:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 02:34:13 -0700 |
commit | ce7017b850e0f62b3ebe6ea0d7010ba0291624e5 (patch) | |
tree | f0fb2185dfbc0dc95eba5a5f4c75bc5d25c7a7bf /scripts | |
parent | 6c77e840aee998640e7d4d623f1ec475ced51e39 (diff) | |
download | rneovim-ce7017b850e0f62b3ebe6ea0d7010ba0291624e5.tar.gz rneovim-ce7017b850e0f62b3ebe6ea0d7010ba0291624e5.tar.bz2 rneovim-ce7017b850e0f62b3ebe6ea0d7010ba0291624e5.zip |
docs: render @see, @note items in _meta/api.lua #30494
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen_eval_files.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index 35af84ae28..6c97893a4a 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -245,6 +245,16 @@ local function get_api_meta() for _, fun in pairs(functions) do local deprecated = fun.deprecated_since ~= nil + local notes = {} --- @type string[] + for _, note in ipairs(fun.notes or {}) do + notes[#notes + 1] = note.desc + end + + local sees = {} --- @type string[] + for _, see in ipairs(fun.see or {}) do + sees[#sees + 1] = see.desc + end + local params = {} --- @type [string,string][] for _, p in ipairs(fun.params) do params[#params + 1] = { @@ -258,6 +268,8 @@ local function get_api_meta() signature = 'NA', name = fun.name, params = params, + notes = notes, + see = sees, returns = api_type(fun.returns[1].type), deprecated = deprecated, } @@ -315,6 +327,26 @@ local function render_api_meta(_f, fun, write) end end + -- LuaLS doesn't support @note. Render @note items as a markdown list. + if fun.notes and #fun.notes > 0 then + write('--- Note:') + for _, note in ipairs(fun.notes) do + -- XXX: abuse md_to_vimdoc() to force-fit the markdown list. Need norm_md()? + note = text_utils.md_to_vimdoc(' - ' .. note, 0, 0, 74) + for _, l in ipairs(split(vim.trim(norm_text(note)))) do + write('--- ' .. l:gsub('\n*$', '')) + end + end + write('---') + end + + for _, see in ipairs(fun.see or {}) do + see = text_utils.md_to_vimdoc('@see ' .. see, 0, 0, 74) + for _, l in ipairs(split(vim.trim(norm_text(see)))) do + write('--- ' .. l:gsub([[\s*$]], '')) + end + end + local param_names = {} --- @type string[] local params = process_params(fun.params) for _, p in ipairs(params) do @@ -336,6 +368,7 @@ local function render_api_meta(_f, fun, write) write('--- @param ' .. p[1] .. ' ' .. p[2]) end end + if fun.returns ~= '' then local ret_desc = fun.returns_desc and ' : ' .. fun.returns_desc or '' ret_desc = text_utils.md_to_vimdoc(ret_desc, 0, 0, 74) |