Add "---@module"
Closed this issue · 6 comments
Hey,
First of all thank you for this new version of Emmy Lua.
I'm trying to see if I can use it instead of the original version but I really need the ---@module to have the documentation on my projects. Do you think it would be possible for you to add it soon ?
If no can you give me some tips in adding it from the v1, do the codebase differ a lot in the definition of thooses features ?
Regards,
What functionality do you expect from ---@module
? The existing module in EmmyLua2 redirects the required path.
File 1:
---@module Test
local m = Iam("test")
function m.FirstFunction()
print("first function")
end
File 2:
---@module Test
local m = Iam("test")
function m.SecondFunction()
print("first function")
end
File 3:
---@type Test
local testModule = Modules.Get("test")
testModule should have the definition for first and second functions. I want it to work like ---@class
but with adding the definition instead of erasing it when called in another file
you can do
file1 :
---@class (partial) Test
local m = Iam("test")
function m.FirstFunction()
print("first function")
end
file2:
---@class (partial) Test
local m = Iam("test")
function m.SecondFunction()
print("first function")
end
and add module define:
---@generic T
---@param moduleName `T`
---@return T
function Modules.Get(moduleName)
end
use:
--- here is class name
local testMod = Modules.Get("Test")
testMod. -- will get firstFunction/secondFunction
what error
Nevermind it was caused by the optionnal chaining and the backticks.
Thank you for your rapid answer !