Yuescript
Yuescript copied to clipboard
Preserve comments preceding global declarations
Existing issues, such as #58 and #57, have requested support for static type annotations. A less extreme solution would be to preserve comments containing Sumneko's annotations for use with their Lua language server. This way, the resulting Lua code will be identical but still support type-checking. It could also improve interoperability with other documentation generators.
The Yuescript tool could expose an option to preserve comments directly before global declarations, e.g. those displayed by yue -g
added option yue -c
to reserve some comments before statements, like
---@param a any
---@param b any
---@param c any
f = (a, b, c)->
But not sure if this works for the Lua LSP functions.
I have custom script that use yue module to compile to lua. Can you make 'reserve_comment' support in yue module!
Thanks and regards!
'reserve_comment' was added in module. Should be available as
local yue = require("yue")
print yue.to_lua([[
-- a comment
f = ->
]], {reserve_comment = true})
Shouldn't it be preserve_comment
(with a p
in the beginning)?
"preserve" and "reserve" both have the meaning of keeping something, while "reserve" is just for keeping something for future use, the "preserve" word has more meaning of keeping something from harm (protect). So I think using the "reserve" word could be better.