Module:Constants

local p = {}

local utilsLayout = require("Module:UtilsLayout") local utilsPage = require("Module:UtilsPage") local utilsTable = require("Module:UtilsTable")

function p.Documentation(frame) local templateName = frame.args[1] local categories if mw.title.getCurrentTitle.subpageText == "Documentation" then categories = "" else categories = "" end local msg = string.format("This module allows other modules to import the constant.", templateName) msg = frame:preprocess(msg) return msg, categories end

function p.List(frame) local subpages = utilsPage.getSubpages("Module:Constants") subpages = utilsTable.filter(subpages, function(subpage)		return string.find(subpage, "/Documentation") == nil	end) local tableData = {} for i, subpage in ipairs(subpages) do		local input = frame:extensionTag({			name = "syntaxhighlight",			args = { lang = "lua" },			content = string.format('require("%s")', subpage),		}) local output = frame:extensionTag({			name = "syntaxhighlight",			args = { lang = "lua" },			content = mw.dumpObject(require(subpage))		}) table.insert(tableData, {input, output}) end local wikitable = utilsLayout.table({		headers = {"Input", "Output"},		rows = tableData,	}) return wikitable end

return p