ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

document table-returning modules

Open nonchip opened this issue 6 years ago • 2 comments

I have a tableconstructor-returning config file written in moonscript (though this seems to apply to lua as well), in the style:

--- @module myapplication.config
{
  some_variable: 5
  some_section: {
    some_subvariable: 10
    some_section_array: {
      { something: 1 }
      { something: 2 }
    }
}

and it seems kinda impossible to document this table (except by writing everything by hand in some markdown file, but then it still seems impossible to let LDoc handle it as a module description instead of a topic), because it just creates an empty module description file, no matter how many @table or @field tags i add. even the outermost table seems to be ignored if tagged with @table default_config or something like that, maybe because LDoc can't see an assignment there. and @exports is also wrong here because it (rightfully) complains it's just for filtering a module's previously documented locals.

nonchip avatar Jul 28 '17 12:07 nonchip

this seems to kinda work:

--- @module myapplication.config
--- @table default_config
default_config={
--...
}
return default_config

but then LDoc handles it as myapplication.config.default_config which is wrong. using @module myapplication and @table config would fix this naming, but then it would present a module myapplication containing this table, which is also wrong because you have to require 'myapplication.config, not import config from require 'myapplication' as LDoc suggests.

also then it would still not allow for nested tables.

nonchip avatar Jul 28 '17 14:07 nonchip

also in the case of the above example it often ignores the table and parses the fields as global functions with names like default_config\some_variable, i'd guess because in moonscript mode it sees the syntax ...: ... as class members instead of table constructor fields

nonchip avatar Jul 28 '17 14:07 nonchip