Module:Lang/documentor tool explained

require('strict')local p =

--private_tags}}

Reads the override table in Module:Lang/data and renders a wiki table of private tags and their associated languages

local function private_tags (frame) local override_t = mw.loadData ('Module:Lang/data').override; -- get the override table local private_t = ;

for tag, lang in pairs (override_t) do if tag:find ('%-x%-') then table.insert (private_t, table.concat) end end table.sort (private_t)

table.insert (private_t, 1, '

';-- return '
' .. table.concat (private_t) .. '\n|}' .. '
'--error (mw.dumpObject (private_t))end

--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_([^|]+)'); if not style or ('italic' ~= mw.text.trim (style) and 'inherit' ~= mw.text.trim (style)) then return '

Error: template #invoke calls unknown function'; end 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 '