Module:Lang/documentor tool/sandbox explained

require('strict')local p =

--lang_xx_settings|template=}}

Reads the content of the template and extracts the parameters from for display on the template'sdocumentation page.

local function lang_xx_settings(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.args[1]) -- get a page object for this page in 'Template:' namespace if not page then return -- TODO: error message? end

local content = page:getContent -- get unparsed content if not page then return -- TODO: error message? end

local out =

local params local style

if content:match('}') or content:match('}') then -- if this template uses params = content:match('}') or content:match('}') -- extract the #invoke:'s parameters if not params then return -- there should be at least one or the template/module won't work TODO: error message? end table.insert(out, '

%s*([^%s=]+)%s*=%s*([^%s|]+)') do -- get the parameter names (k) and values (v) if 'label'

k then -- special case for labels because spaces and pipes v = params:match('label%s*=%s*(%[%[[^%]]+%]%])') or params:match('label%s*=%s*([^|\n]+)') or 'missing label' end table.insert(out, table.concat) -- make rudimentary wikitable entries end

style = content:match('lang_xx_([^|]+)') return table.concat('

) -- add inter-row markup and close the wikitable and done else return -- does not use so abandon quietly endend

--uses_module|template=}}

Reads the content of the template to determine if this template uses Module:Lang.Returns the index of the substring '