Fri, 01 Feb 2019 11:22:20 +0000
docs: Add initial documentation
local it = require "scansion.iterators"; local script_methods = {}; local excluded_fields = { name = true, defined_line = true, type = true, annotation = true }; function script_methods:client(data) self:_append("["..data.name.."]"); for k, v in pairs(data) do if not excluded_fields[k] then self:_append("", k..": "..v); end end self:_append(""); end function script_methods:action(name, verb, data) if self.in_header then self.in_header = false; self:_append("----------"); self:_append(""); end self:_append(name.." "..verb..(data and ":" or "")); if data then for s in tostring(data):gmatch("[^\n]+") do self:_append("", s); end end self:_append(""); end function script_methods:_append(...) local fields = { ... }; for i = 1, select("#", ...) do fields[i] = tostring(fields[i]); end table.insert(self.lines, table.concat(fields, "\t")); end function script_methods:lines() return it.values(self.lines); end function script_methods:render() return table.concat(self.lines, "\n"); end local script_mt = { __index = script_methods }; return { new_script = function () return setmetatable({ in_header = true, n_clients = 0, clients = {} }, script_mt); end; }