require ('strict')local get_args = require ('Module:Arguments').getArgs;local namespace = mw.title.getCurrentTitle.namespace; -- used for categorization
----------------------------< E R R O R _ M A P _ T >--------------------------------------------------------
local error_map_t =
----------------------------< E R R O R _ M S G _ M A K E >--------------------------------------------------
assembles an error message from message text and category in
local function error_msg_make (msg_idx, template, detail, no_cat) local out = ; local category; table.insert (out, '
Error: '); --TODO: simplify? if template then table.insert (out, table.concat); -- TODO: get template names for synonymous parameter errors end table.insert (out, string.format (error_map_t[msg_idx][1], detail)); -- build error message from base +namespace) and not no_cat then -- categorize in article space (and template space to take care of broken usages) table.insert (out, table.concat); end
return table.concat (out); -- make a big string and doneend
--sclass}}
local function sclass (frame) local args_t = get_args (frame); local parent = frame:getParent; local template = parent:getTitle:gsub ('^Template:', ):lower; -- get the name of the template that called this module (includes namespace so strip that) local class_name = args_t[1]; -- names to make it easier to understand local ship_type = args_t[2]; local format = args_t[3]; local ship_type_dab = args_t[4]; local class_name_dab = args_t[5];
if not class_name then -- when omitted, abandon with error message return error_msg_make ('missing', template, 'class name'); end
if not ship_type then -- when omitted, abandon with error message return error_msg_make ('missing', template, 'ship type'); end
if format then if tonumber (format) then -- if if not format or (3template then -- class named for a member of the class table.insert (out_t, '\'\); -- class name is italicized table.insert (out_t, class_name); table.insert (out_t, '\'\); else table.insert (out_t, class_name); -- class name is a common attribute; plain text end
format) then -- when format is omitted, same as format #3 table.insert (out_t, '-class
'); -- dab is not displayed so insert a pipe and end table.insert (out_t, ship_type); -- add ship type table.insert (out_t, ''); -- close ship-type wikilink end
if 0
format then -- no separate ship-type wikilink table.insert (out_t, '-class '); table.insert (out_t, ship_type); table.insert (out_t, ']]'); end if 2
format then -- noun form; no ship type table.insert (out_t, ' class]]'); end if 5
----------------------------< E X P O R T S >----------------------------------------------------------------
return