From 55b303d0beb1b08b5a50488e0bbba075a49d965d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 26 Nov 2020 13:07:47 +0800 Subject: trim tail comment --- script/parser/luadoc.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'script/parser') diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 53f0097d..80c8a732 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -842,6 +842,19 @@ local function convertTokens() end end +local function trimTailComment(text) + if text:sub(1, 1) == '@' then + return text:sub(2) + end + if text:sub(1, 1) == '#' then + return text:sub(2) + end + if text:sub(1, 2) == '--' then + return text:sub(3) + end + return text +end + local function buildLuaDoc(comment) local text = comment.text if text:sub(1, 1) ~= '-' then @@ -868,7 +881,7 @@ local function buildLuaDoc(comment) type = 'doc.tailcomment', start = cstart + comment.start - 1, finish = comment.finish, - text = text:sub(cstart), + text = trimTailComment(text:sub(cstart)), } end end -- cgit v1.2.3