From b1fb04475e6fa0c44895cb6fe97b75816d74c297 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 3 Aug 2023 13:41:47 +0200 Subject: 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 --- scripts/lua2dox.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts/lua2dox.lua') 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 --- @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 }) -- cgit