Module:Util: Difference between revisions
PhantomCaleb (talk | contribs) No edit summary |
PhantomCaleb (talk | contribs) No edit summary |
||
Line 9: | Line 9: | ||
}, | }, | ||
} | } | ||
function p.ListLibraries(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) | |||
return list | |||
end | |||
function p.ListFunctions(frame) | function p.ListFunctions(frame) |
Revision as of 20:24, 11 May 2024
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.
local p = {}
local util = {
markup = {
listBulleted = require("Module:Util/markup/listBulleted")
},
pages = {
listSubpages = require("Module:Util/pages/listSubpages"),
},
}
function p.ListLibraries(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)
return list
end
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