Inherit notes from modules?

So, I recently discovered
that what ever note you have above the line of a method/function in a module script, when the module is passed on, the script requiring it will be able to see the note that you have written:


Which is really helpful, cuz sometimes you can just forget what a method does, and when certain types don’t get passed through scripts.

But then i realized something, the notes only shows up for the First-Hand script that requires the module directly, but not the Second-Hand scripts, example:
A Module:

local Module = {}

-- prints 1
Module.Method1 = function()
   print(1)
end

return Module

A First-Hand script ( a script that requires “The Module” directly):

local The_Module = require(TheModule)

local FirstHand = {}
FirstHand.Method1 = The_Module.Method1 -- right here, it shows the note 

return FirstHand 

A Second-Hand script ( another script that requires “The FirstHand” script):

local The_FirstHand = require(The_FirstHand)

local SecondHand = {}
SecondHand.Method1 = The_FirstHand.Method1 -- this time, the note doesn't show up

return SecondHand 

What I’m trying to figure out is, is there anyways for the notes to still show up for Second-Hand scripts?

thx. :grinning:

2 Likes

You could try creating a comment on the firsthand ModuleScript that describes both what the Module and itself does, but I imagine that this could get very tedious several scripts in. In this case, you could include a reference to that script (i.e. -- NOTE: See [ModuleScript] for details on its function).

Really not sure though, there’s probably a way to do what you’re looking for.

1 Like

For the first module try setting up __index method
eg:

local The_Module = require(TheModule)

local FirstHand = {}
FirstHand.__index = The_Module
FirstHand.Method1 = The_Module.Method1 -- right here, it shows the note 

return FirstHand 

It’s a metatable method , hope it works for you.

no, i was thinking about the same thing, sadly it didn’t work

ok, no wait, this works, it was just abit more complicated for my situation, since i have multiple metatables and modules requiring each other

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.