Module:Util

From Zelda Wiki, the Zelda encyclopedia
Revision as of 20:09, 11 May 2024 by PhantomCaleb (talk | contribs)
Jump to navigation Jump to search

This is the root module for Zelda Wiki's libraries or utility functions. These are functions that are not directly invoked by any template—they are used only by other modules that share a common need for subroutines that can parse template arguments, manipulate tables, compare strings, and so on.

Each function is located on its own subpage. These are inteded to eventually replace the existing utility modules, such as Module:UtilsTable, which cause large job queues due to the fact that high-usage functions are packaged together. The hope is that by separating each of these functions into their own module, each individual module will be stable and unlikely to change, and new utility functions can be added without triggering any job queue at all.

Libaries

Utility functions are grouped together under the following base pages (or "libaries") according to their functionality. Script error: The function "ListLibraries" does not exist.


local p = {}

local util = {
	markup = {
		listBulleted = require("Module:Util/markup/listBulleted")	
	},
	pages = {
		listSubpages = require("Module:Util/pages/listSubpages"),
	},
}

function p.ListFunctions(frame)
	local title = mw.title.getCurrentTitle()
	local modulePage = string.gsub(title.prefixedText, "/Documentation$", "")
	local subpages = util.pages.listSubpages(modulePage, { depth = 1, noDocumentation = true })
	for i in ipairs(subpages) do
		subpageName = string.match(subpages[i], "[^/]+$")
		subpages[i] = string.format("[[%s|<kbd>%s</kbd>]]", subpages[i], subpageName)
	end
	local list = util.markup.listBulleted(subpages)
	local listSection = "==Functions==\n"..list
	return listSection
end

return p