diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-08-03 13:41:47 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2023-08-03 14:01:53 +0200 |
commit | b1fb04475e6fa0c44895cb6fe97b75816d74c297 (patch) | |
tree | 31873cf0a47cec025155d0b52d72a3ab5ea5bd12 /scripts/lua2dox.lua | |
parent | d2f81330247ee060d557330b2716ccea8f789a50 (diff) | |
download | rneovim-b1fb04475e6fa0c44895cb6fe97b75816d74c297.tar.gz rneovim-b1fb04475e6fa0c44895cb6fe97b75816d74c297.tar.bz2 rneovim-b1fb04475e6fa0c44895cb6fe97b75816d74c297.zip |
docs: remove "#" comment char in @return
Everything after a "#" char is a "description" comment, i.e. luals won't
treat it as a type, name, etc. But "#" should not be present in the
generated docs (such as :help docs).
https://github.com/LuaLS/lua-language-server/wiki/Annotations#return
Diffstat (limited to 'scripts/lua2dox.lua')
-rw-r--r-- | scripts/lua2dox.lua | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 9a666ea629..01bb8ab57a 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -154,6 +154,8 @@ local function removeCommentFromLine(line) return line:sub(1, pos_comment - 1), line:sub(pos_comment) end +--- Processes "@…" directives in a docstring line. +--- --- @param line string --- @param generics table<string,string> --- @return string? @@ -206,6 +208,8 @@ local function process_magic(line, generics) magic = magic:gsub('^return%s+.*%((' .. type .. ')%)', 'return %1') magic = magic:gsub('^return%s+.*%((' .. type .. '|nil)%)', 'return %1') end + -- Remove first "#" comment char, if any. https://github.com/LuaLS/lua-language-server/wiki/Annotations#return + magic = magic:gsub('# ', '', 1) -- handle the return of vim.spell.check magic = magic:gsub('({.*}%[%])', '`%1`') magic_split = vim.split(magic, ' ', { plain = true }) |