Lua table 的 Ldoc 文档

Lua Ldoc documentation of a table

我想使用 Ldoc 记录 table。 documentation 表示

好的,这看起来不错,但是当我将格式应用于 table:

--- A table of mappings between NodOn remote scene codes and a text description.
nodonSceneTableVerbose = {
    [10]="Button 1 Single Press",   -- Button 1 Single Press
    [20]="Button 2 Single Press",   -- Button 2 Single Press
    [30]="Button 3 Single Press",   -- Button 3 Single Press
    [40]="Button 4 Single Press",   -- Button 4 Single Press
    [13]="Button 1 Double Press",   -- Button 1 Double Press
    [23]="Button 2 Double Press",   -- Button 2 Double Press
    [33]="Button 3 Double Press",   -- Button 3 Double Press
    [43]="Button 4 Double Press",   -- Button 4 Double Press
    [12]="Button 1 Hold Press",     -- Button 1 Hold Press
    [22]="Button 2 Hold Press",     -- Button 2 Hold Press
    [32]="Button 3 Hold Press",     -- Button 3 Hold Press
    [42]="Button 4 Hold Press",     -- Button 4 Hold Press
    [11]="Button 1 Hold Released",  -- Button 1 Hold Released
    [21]="Button 2 Hold Released",  -- Button 2 Hold Released
    [31]="Button 3 Hold Released",  -- Button 3 Hold Released
    [41]="Button 4 Hold Released"   -- Button 4 Hold Released
}

我得到这个结果

这不是我所期望的。 ldoc 命令没有产生任何错误。怎么了?

所以事实证明你不能在将元素设置为 [10] 等的表格上使用 inferring more from code 等等。相反,您可以像这样手动定义字段:

--- A table of mappings between NodOn remote scene codes and a text description.
-- @table nodonSceneTableVerbose
-- @field 10 Button 1 Single Press
-- @field 20 Button 2 Single Press
-- @field 30 Button 3 Single Press
-- @field 40 Button 4 Single Press
-- @field 13 Button 1 Double Press
-- @field 23 Button 2 Double Press
-- @field 33 Button 3 Double Press
-- @field 43 Button 4 Double Press
-- @field 12 Button 1 Hold Press
-- @field 22 Button 2 Hold Press
-- @field 32 Button 3 Hold Press
-- @field 42 Button 4 Hold Press
-- @field 11 Button 1 Hold Released
-- @field 21 Button 2 Hold Released
-- @field 31 Button 3 Hold Released
-- @field 41 Button 4 Hold Released
nodonSceneTableVerbose = {
    [10]="Button 1 Single Press",
    [20]="Button 2 Single Press",
    [30]="Button 3 Single Press",
    [40]="Button 4 Single Press",
    [13]="Button 1 Double Press",
    [23]="Button 2 Double Press",
    [33]="Button 3 Double Press",
    [43]="Button 4 Double Press",
    [12]="Button 1 Hold Press",
    [22]="Button 2 Hold Press",
    [32]="Button 3 Hold Press",
    [42]="Button 4 Hold Press",
    [11]="Button 1 Hold Released",
    [21]="Button 2 Hold Released",
    [31]="Button 3 Hold Released",
    [41]="Button 4 Hold Released" 
}