Module:Sandbox/DarthKitty

local p = {}

--[[

local checkType = require("libraryUtil").checkType

local function concatenate(...) for i = 1, select('#', ...) do       checkType("concatenate", i, select(i, ...), "string") end

return table.concat{...} end

concatenate("Hello", ", ", "World", "!") --> "Hello, World!"

--]]

function p.doSomething -- Code goes here... end

-- Call a module that is protected by Module:Non-global/sandbox function p.call_local_module return require('Dev:Sandbox/DarthKitty/Local module') end

-- These properties are probably available to modules that `require` this one, -- but what about other kinds of pages? That is to say, can I any of -- these even though they aren't functions?

p.NIL = nil p.BOOLEAN = false p.STRING = "string" p.NUMBER = 42 p.ARRAY_LIKE = {"A", "B", "C", "D", "E"} p.MAP_LIKE = {one = 1, two = 2, three = 3}

-- Converts a module's name (which can contain spaces, punctuation, etc.) into -- a working Lua identifier. -- -- Created in preparation for writing Template:Module Install. -- -- @TODO `reserved` should be moved to its own submodule, and loaded with --      `mw.loadData`.

function p.title2variable local title = mw.title.getCurrentTitle local rootText = title.rootText

-- Only run on module documentation pages if not title.isSubpage or rootText ~= title.baseText -- not subpage of subpage or rootText ~= 'Global Lua Modules' then error end

local words = mw.text.split(title.subpageText, '[%s-]') local lang = mw.language.getContentLanguage local ustring = mw.ustring local uFind = ustring.find local reserved = { ['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true, ['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true, ['function'] = true, ['if'] = true, ['in'] = true, ['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true, ['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true, ['until'] = true, ['while'] = true,

-- shadowing these might break stuff ['_G'] = true, ['assert'] = true, ['_VERSION'] = true, ['error'] = true, ['getfenv'] = true, ['getmetatable'] = true, ['ipairs'] = true, ['next'] = true, ['pairs'] = true, ['pcall'] = true, ['rawequal'] = true, ['rawget'] = true, ['rawset'] = true, ['select'] = true, ['setmetatable'] = true, ['tonumber'] = true, ['tostring'] = true, ['type'] = true, ['unpack'] = true, ['xpcall'] = true, ['debug'] = true, ['math'] = true, ['os'] = true, ['require'] = true, ['package'] = true, ['string'] = true, ['table'] = true, ['mw'] = true }

for i, word in ipairs(words) do       -- remove everything besides letters, numbers, and spaces word = ustring.gsub(word, '[^%w%s]', '')

-- do not make a word lowercase if it is camelCase if not uFind(word, '%l') or not uFind(word, '%u') then word = lang:lc(word) end

-- lowercase the first letter of the first word -- uppercase the first letter of every remaining word word = i > 1 and lang:ucfirst(word) or lang:lcfirst(word)

if reserved[word] then word = '_' .. word end

words[i] = word end

return table.concat(words) end

return p