2013-01-25 08:09:40 +01:00
|
|
|
----------------------
|
|
|
|
-- Showing off Colon mode.
|
|
|
|
-- If you hate @ tags, you can use colons. However, you need to specify colon
|
|
|
|
-- mode explicitly -C or --colon, or `colon=true` in the config.ld. Be careful
|
|
|
|
-- not to use a colon followed by a space for any other purpose!
|
|
|
|
--
|
|
|
|
-- So the incantation in this case is `ldoc -C colon.lua`.
|
|
|
|
|
|
|
|
-- module: colon
|
|
|
|
|
|
|
|
|
|
|
|
--- first useless function.
|
|
|
|
-- Optional type specifiers are allowed in this format.
|
2013-08-23 15:59:35 +02:00
|
|
|
-- As an extension, '?T' is short for '?nil|T'.
|
2013-01-25 08:09:40 +01:00
|
|
|
-- Note how these types are rendered!
|
|
|
|
-- string: name
|
|
|
|
-- int: age
|
2013-08-23 15:59:35 +02:00
|
|
|
-- ?person3: options
|
2013-01-25 08:09:40 +01:00
|
|
|
-- treturn: ?table|string
|
|
|
|
function one (name,age,options)
|
|
|
|
end
|
|
|
|
|
2013-08-23 15:59:35 +02:00
|
|
|
--- implicit table can always use colon notation.
|
|
|
|
person2 = {
|
|
|
|
id=true, -- string: official ID number
|
|
|
|
sex=true, -- string: one of 'M', 'F' or 'N'
|
|
|
|
spouse=true, -- ?person3: wife or husband
|
|
|
|
}
|
|
|
|
|
2013-01-25 08:09:40 +01:00
|
|
|
--- explicit table in colon format.
|
|
|
|
-- Note how '!' lets you use a type name directly.
|
|
|
|
-- string: surname
|
|
|
|
-- string: birthdate
|
|
|
|
-- !person2: options
|
|
|
|
-- table: person3
|