Modul:Check for unknown parameters

Seba na module şıma şenê yû pela dokumani vırazê Modul:Check for unknown parameters/dok

-- This module may be used to compare the arguments passed to the parent-- with a list of arguments, returning a specified result if an argument is-- not on the listlocal p = {}local function trim(s)return s:match('^%s*(.-)%s*$')endlocal function isnotempty(s)return s and trim(s) ~= ''endfunction p.check (frame)local args = frame.argslocal pargs = frame:getParent().argslocal ignoreblank = isnotempty(frame.args['ignoreblank'])local checkpos = isnotempty(frame.args['checkpositional'])local knownargs = {}local unknown = 'Found _VALUE_, 'local res = {}local regexps = {}local comments = {}local commentstr = ''-- create the list of known args, regular expressions, and the return stringfor k, v in pairs(args) doif type(k) == 'number' thenv = trim(v)knownargs[v] = 1elseif k == 'unknown' thenunknown = velseif k:find('^regexp[1-9][0-9]*$') thentable.insert(regexps, '^' .. v .. '$')endend-- adds one result to the output tableslocal function addresult(k)if k == '' then-- Fix odd bug for | = which gets stripped to the empty string and-- breaks category linksk = ' 'endlocal r = unknown:gsub('_VALUE_', k)table.insert(res, r)table.insert(comments, '"' .. k .. '"')end-- loop over the parent args, and make sure they are on the listfor k, v in pairs(pargs) doif type(k) == 'string' and knownargs[k] == nil thenlocal knownflag = falsefor i, regexp in ipairs(regexps) doif mw.ustring.match(k, regexp) thenknownflag = truebreakendendif not knownflag and ( not ignoreblank or isnotempty(v) )  thenk = mw.ustring.gsub(k, '[^%w\-_ ]', '?')addresult(k)endelseif checkpos andtype(k) == 'number' and knownargs[tostring(k)] == nil and( not ignoreblank or isnotempty(v) )thenaddresult(k)endendif #comments > 0 thencommentstr = '<!-- Module:Check for unknown parameters results: ' ..table.concat(comments, ', ') .. '-->'endreturn table.concat(res) .. commentstrendreturn p