Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to represent an argument that's a table? #265

Closed
vadi2 opened this issue Mar 4, 2017 · 6 comments
Closed

How to represent an argument that's a table? #265

vadi2 opened this issue Mar 4, 2017 · 6 comments

Comments

@vadi2
Copy link

vadi2 commented Mar 4, 2017

I have an argument that's a table of values, how can I document it using ldoc? @table seems to be for stand-alone tables.

@keneanung
Copy link

I've been using the following:

---
-- Convenience wrapper around `IOE.Core.echo`. This way we don't need to put the module in
--   front of each echo.
-- @string what The text to echo.
-- @tparam {{highlightText=string,highlightType=IOE.Core.HighlightTypes},...} highlights
--   Highlights in `what`.
local echo = function(what, highlights)

@vadi2
Copy link
Author

vadi2 commented Mar 4, 2017

Don't think that worked right for me:

-- @tparam {{highlightText=string,highlightType=IOE.Core.HighlightTypes},...} cons
function Geyser.Label:addChild(cons, container)
    cons = cons or {}

selection_019

My current and rather contrived workaround is:

--- cons argument for @{Geyser.Label:addChild}
-- @field name a unique name for the label
-- @field height height of the label - specify it as the defaults are huge
-- @field width width of the label - specify it as the defaults are huge
-- @field[opt='LV'] layoutDir specifies in which direction and axis should the labels align, where 2 letters combine into the option: first letter R for right, L for left, T for top, B for bottom, followed by the orientation: V for vertical or H for horizontal. So options are: layoutDir="RV", layoutDir="RH", layoutDir="LV", layoutDir="LH", and so on
-- @field[opt=false] flyOut allows labels to show up when mouse is hovered over
-- @field[opt=''] message initial message to show on the label
-- @field[opt='white'] fgColor optional foreground colour - colour to use for text on the label
-- @field[opt='black'] bgColor optional background colour - colour of the whole label
-- @field[opt=1] fillBg 1 if the background is to be filled, 0 for no background
addChildCons = {
  name = "",
  height = 30,
  width = 70,
  layoutDir = "RV",
  flyOut = true,
  message = "",
  fgColor = "white",
  bgColor = "black",
  fillBig = 1,
}
addChildCons = nil

--- adds a flyout label to an existing label that is marked with nestable=true
--- see http://wiki.mudlet.org/w/Manual:Geyser#Flyout_Labels for examples
-- @tparam table cons see @{addChildCons}
function Geyser.Label:addChild(cons, container)
    cons = cons or {}

selection_020

@stevedonovan
Copy link
Contributor

It is supported, although not well documented. Look at tests/styles/subparams.lua

-------
-- A function with subfield arguments.
-- @param s string
-- @param opts multibyte encoding options
-- @param opts.charset string
-- @param opts.strict bool
-- @param verbose bool
-- @return its length
function with_options (s,opts,verbose)
end

The other alternative of course, is to document that table separately and use a reference to it.

@vadi2
Copy link
Author

vadi2 commented Mar 11, 2017

Thank you, that works great!

@vadi2 vadi2 closed this as completed Mar 11, 2017
vadi2 added a commit to vadi2/mudlet-lua that referenced this issue Mar 11, 2017
lunarmodules/ldoc#265 explained how to document table parameters.
@stevedonovan
Copy link
Contributor

stevedonovan commented Mar 12, 2017 via email

vadi2 added a commit to vadi2/Mudlet that referenced this issue Apr 4, 2017
lunarmodules/ldoc#265 explained how to document table parameters.
@zhanlangorz
Copy link

@stevedonovan But the [opt] flag is not support while use subparams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants