Module:Documentation

local p = {}

local utilsTable = require("Module:UtilsTable") local wikitable = require("Module:Wikitable")

function p.module(moduleExamples) local output = '' for fn, fnExamples in pairs(moduleExamples) do output = output .. ("=== ===\n"):format(fn) output = output .. p.fn(fn, fnExamples) .. "\n" end return output end

function p.fn(fn, fnExamples) local tableData = { rows = { {				header = true, cells = { "Input", "Output" }, }		},	}	for _, example in ipairs(fnExamples) do		local input = mw.getCurrentFrame:extensionTag({			name = "syntaxhighlight",			args = { lang = "lua" },			content = ("%s(%s)"):format(fn, utilsTable.inspect(example.args))		}) local output = wikitable[fn](unpack(example.args)) if example.description then table.insert(tableData.rows, {				header = true,				cells = 			}) end table.insert(tableData.rows, {cells = {input, output} }) end return wikitable.createTable(tableData) end

return p