Get documentation on any Lua object. Includes documentation for several items in the lua stdlibrary.
Note: This requires the PKG protocol to be installed, see lib/pkg

Making a library's types self-documenting is easy:
local G = G or _G
-- My module docs
local M = G.mod and mod'myModName' or {}

--- my fn docs in [$cxt]
M.myFn = function(a, b) --> string
  -- do stuff
end

See Package_pkg and Package_cxt for more details.
Other Resources

Mod doc

Builds on metaty to add the ability to extract and format documentation.
Also offers the Cmd and Cmds types for documenting shell commands.
Types: Doc Main
Functions

Record Doc

Object passed to __doc methods. Aids in writing cxt. Fields: Methods

Record Main

Get cxt documentation for symbol. Fields:

Mod doc.lua

Functions Example: T.eq({98, 99}, {string.byte('abcd', 2, 3)}) * fn string.char(c1, c2, ...) -> string
convert character codes to string and concatenate * fn string.rep
repeat str n times with separator * fn string.pack
pack the values as bytes into the string using the strtys. strtys is a string of the form:
 <  >  = (start only) little / big / native endian
 !#     (start only) max alignment = # bytes
 b B     signed / unsigned byte
 h H l L native short(h) and long(l) + unsigned vers
 i# I#   signed/unsigned int with # bytes
 f d     native float / double
 T       size_t
 c#     fixed-sized string of # bytes (unaligned)
 z       zero-terminated string (unaligned)
 s#     counted string of size # bytes
 x       one byte of padding
 Xo     align to option o, i.e. Xi4
 j J n   lua Integer / Unsigned / Number
Example:
  T.eq(string.pack('>i2i2', 0x1234, 0x5678) == '\x12\x34\x56\x78')]
 
* fn string.unpack
See string.pack for the fmt * fn string.packsize
Get the size which is used by strtys. * fn string.lower
not documented: see string module * fn string.upper
not documented: see string module * fn string.len
not documented: see string module * fn string.dump
not documented: see string module * fn string.reverse
not documented: see string module * fn table.update(to, from) -> to
update to with from, return to. Note: this is an addon from metaty. * fn table.concat(t, sep='') -> string
concatenate a table of strings with optional separator. Examples:
  concat = table.concat
  T.eq(1..' = '..3, concat{1, ' = ', 3})
  T.eq('1, 2, 3',   concat({1, 2, 3}, ', ')
 
* fn table.remove(t, index=#table) -> t[index]
remove an item from a table, returning it. The table is shifted if index < #table which may cost up to O(n) * fn table.sort(list, cmp=lt) -> nil
sort a table in place using a comparison function cmp who's behavior must be: cmp(a, b) --> makeAFirst * fn table.insert
insert or push to table (list-like) Example:
  local push = table.insert
  local t = {}
 
  -- push/append behavior
  push(t, 'd')            -- {'d'
  push(t, 'e')            -- {'d', 'e'}
 
  -- insert behavior
  table.insert(t, 'b', 1) -- {'b', 'd', 'e'}
  table.insert(t, 'c', 2) -- {'b', 'c', 'd', 'e'}
  T.eq({'b', 'c', 'd', 'e'}, t)
 
* fn table.move
Move values from one list to another. Note that si=startIndex and ei=endIndex (inclusive). Equivalent to the following, though done in a way that will properly handle overlapping data:
  ti = siTo
  for fi=siFrom,eiFrom do
    to[ti] = from[fi]; ti = ti + 1
  end
 
* fn io.popen
Execute shell command in separate process. See also: * fn io.input
not documented: see io module * fn io.open
not documented: see io module * fn io.type
not documented: see io module * fn io.tmpfile
not documented: see io module * fn io.close
not documented: see io module * fn io.lines
not documented: see io module * fn io.write
not documented: see io module * fn io.read
not documented: see io module * fn io.output
not documented: see io module * fn io.flush
not documented: see io module * fn os.execute(string) -> (ok, "exit", rc)
Execute shell command via C's `system` API. Returns:
  os.execute'shell command' -> (ok, "exit", rc)
  os.execute()              -> isShellAvailable
Prints whatever was executed. There are no ways to redirect the output besides piping in the command string itself. Recommendation: For all but the simplest cases use io.popen instead * fn os.exit
not documented: see os module * fn os.clock
not documented: see os module * fn os.getenv
not documented: see os module * fn os.tmpname
not documented: see os module * fn os.setlocale
not documented: see os module * fn os.rename
not documented: see os module * fn os.date
not documented: see os module * fn os.remove(path) -> nil
remove file. * fn os.time
not documented: see os module * fn os.difftime
not documented: see os module * fn math.type(v) -> ("float" | "integer" | nil) * fn math.max(x, ...) -> max according to [$<] * fn math.min(x, ...) -> min according to [$<] * fn math.cos(x) -> cos(x) in radians * fn math.sin(x) -> sin(x) in radians * fn math.tan(x) -> tan(x) in radians * fn math.acos(x) -> arccos(x) in radians * fn math.asin(x) -> arcsin(x) in radians * fn math.atan2(n, d) -> arctan(n / d) in radians * fn math.exp(x) -> e^x (where e is the natural log base) * fn math.abs
currently not documented * fn math.ceil
currently not documented * fn math.atan2(n, d) -> arctan(n / d) in radians * fn math.deg
currently not documented * fn math.tanh
currently not documented * fn math.floor
currently not documented * fn math.randomseed
currently not documented * fn math.ldexp
currently not documented * fn math.cosh
currently not documented * fn math.sqrt
currently not documented * fn math.tointeger
currently not documented * fn math.rad
currently not documented * fn math.log10
currently not documented * fn math.log
currently not documented * fn math.modf
currently not documented * fn math.ult
currently not documented * fn math.random
currently not documented * fn math.sinh
currently not documented * fn math.fmod
currently not documented * fn math.frexp
currently not documented * fn math.pow
currently not documented * fn for()
for is a looping construct with two forms: Numeric:
    for i=si,ei,period do -- period=1 by default
      ... do something with i
    end
 
    -- is basically the same as
    local i = si
    while i <= ei do i = i + si
      ... do something with i
    end
 
Generic:
    for i, v, etc in (nextfn, state, _index) do
      .. do something with i, v, ...
    end
 
    -- is almost the same as
    while true do
      local i, v, etc = nextfn(state, _index)
      if i == nil then break end
      _index = i -- note: C internal, _index from lua doesn't change
      ... code using i, v, etc here
    end
 
The goal in writing a stateless iterator function is to match this loop's API as much as possible. Example rewriting ipairs:
    local function rawipairs(t, i)
      i = i + 1
      if i > #t then return nil end
      return i, t[i]
    end
    local function myipairs_(t)
      return rawipairs, t, 0
    end
    for i, v in myipairs{5, 6, 7} do
      iterates through (1, 5) -> (2, 6) -> (3, 7)
    end
 
Example rewriting pairs using next(t, key):
    function mypairs(t)
      return next, t, nil
    end
    for k, v in mypairs{a=1, b=2, c=3} do
      iterates through ('a', 1) -> ('b', 2) -> ('c', 3)
    end
 
See also: metaty.split is a more complex example.