ldoc
ldoc copied to clipboard
Strict mode which disables inferring information
I am having a bit of an issue here where I have a Lua module that has a basic plugin system that simply loads the plugin into a local variable and then aliases the plugin's data into the main module.
-- Basic module
local module = {
init = function(self) end
}
-- Plugin
local plugin = {
plugin_init = function(module) end
}
-- After loading plugin
local module = {
init = function(self) end,
plugin_init = function(self) end -- note how the plugin's init was actually referencing the module!
}
The issue here is that my main module uses : syntax so self is omitted from the parameters. The plugin cannot do this since it needs to reference module instead of itself, therefore each of the plugin's argument lists must begin with module. In functions where there is only one argument, module, I don't have LDoc listing any @param tags. Since there are no tags, it infers whatever the function actually displays, in this case module. This may end up confusing my users since it looks like they should be passing the module into this particular function when in fact, it gets sent already as self.
So I propose adding a strict or disable_inferring flag to the config file that disables inferring function arguments, table fields, etc. Perhaps an infer flag that is defaulted to true could work too.
Cool, I've pushed a commit that adds a no_args_infer flag, which is also accepted by the config file. Try it out - it should completely stop LDoc from guessing things from source code. Should have a 1.4.4 candidate in a day or so.
Fixed in 1bcd76e.