Editing
Module:Protection banner/documentation
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module generates documentation for [[Module:Protection banner]]. -------------------------------------------------------------------------------- -- Documentation class -------------------------------------------------------------------------------- local Documentation = {} Documentation.__index = Documentation function Documentation:new(mainCfg, docCfg) return setmetatable({ _mainCfg = mainCfg, _docCfg = docCfg }, self) end function Documentation:makeReasonTable() -- Get the data from the cfg.banners table. local rowData = {} for action, reasonTables in pairs(self._mainCfg.banners) do for reason, t in pairs(reasonTables) do rowData[#rowData + 1] = { reason = reason, action = action, description = t.description } end end -- Sort the table into alphabetical order, first by action and then by -- reason. table.sort(rowData, function (t1, t2) if t1.action == t2.action then return t1.reason < t2.reason else return t1.action < t2.action end end) -- Assemble a wikitable of the data. local ret = {} ret[#ret + 1] = '{| class="wikitable"' if #rowData < 1 then ret[#ret + 1] = '|-' ret[#ret + 1] = string.format( '| colspan="3" | %s', self._docCfg['documentation-blurb-noreasons'] ) else -- Header ret[#ret + 1] = '|-' ret[#ret + 1] = string.format( '! %s\n! %s\n! %s', self._docCfg['documentation-heading-reason'], self._docCfg['documentation-heading-action'], self._docCfg['documentation-heading-description'] ) -- Rows for _, t in ipairs(rowData) do ret[#ret + 1] = '|-' ret[#ret + 1] = string.format( '| %s\n| %s\n| %s', t.reason, t.action, t.description or '' ) end end ret[#ret + 1] = '|}' return table.concat(ret, '\n') end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p.reasonTable() local mainCfg = require('Module:Protection banner/config') local docCfg = require('Module:Protection banner/documentation/config') local documentationObj = Documentation:new(mainCfg, docCfg) return documentationObj:makeReasonTable() end return p
Summary:
Please note that all contributions to Mirrorplay: Fae are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
MPFae:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information