Module:Documentation

--Load loader function local loadLib = require('Module:LoadLib')

--Load Modules loadLib(_G)

--Begin Exports local p = {} local Doc = {} local nowiki = mw.text.nowiki local lb, rb = nowiki('['), nowiki(']') local sep = ' &bull; '

function Doc:linksToList(t) local ret = {} local t2 = {}

local function _parse(t2) local val local title = string.makeTitle(t2[2], t2[3], { disableAbbr=true }) if t2.query then val = string.fullUrl(t2[1], t2.query or {}, title) else val = string.makeLink(t2[1], title) end return t.main and val or table.concat{ lb, val, rb } end

for i, v in ipairs(t) do		table.push(ret, _parse(v)) end ret = table.concat(ret, sep) if t.main then ret = table.concat{ _parse(t.main), ' (', ret, ') ' } end return ret end

function Doc:buildMainBox self.html :css{ ['font-family']='Arial !important'; }		:tag('div') :addClass('color1') :css{ ['padding'] = '2px'; ['border'] = '1.3px solid black'; ['margin'] = '4px'; ['box-shadow'] = '0 0 2px black'; ['border-bottom'] = 'none'; ['margin-bottom'] = 0; }			:tag('span') :css{ ['float'] = 'right'; ['font'] = 'italic small arial'; }				:wikitext('(', string.makeLink('#module-code', string.makeTitle('jump to code', "Jump to the code of this module", { disableAbbr=true })), ')')			:done :tag('span') :css{ float="left"; }				:wikitext(string.makeImage('Template Info Icon.svg', { link='', size=60 })) :done :tag('span') :css{ ['font'] = 'bold x-large arial'; ['margin-left'] = '7px'; ['text-align'] = 'center'; }				:wikitext(self.type, ' Documentation') :done :tag('span') :css{ ['margin-left']='7px'; }				:wikitext(self:linksToList(self.titleExists and self.links.pageTools[1] or self.links.pageTools[2])) :done :tag('hr') :addClass('page-header__separator') :css{ ['background-color'] = '#daa9ad'; ['border'] = 0; ['height'] = '1px'; ['margin-bottom'] = '3px'; ['margin-top'] = 0; ['width'] = '100%'; }			:done :tag('div') :tag('p') :css{ margin=0; }					:wikitext(						string.wrapTag('Page Tools', 'b'), 						self:linksToList(self.titleExists and self.links.sandbox[1] or self.links.sandbox[2])					) :done :done :done local mt = { __tostring = function return tostring(self.html) end, __concat = function(a, b)			if a == self.html then return tostring(a)..b			else return tostring(b)..a			end end }	return setmetatable({ self.html }, mt) end

function Doc:constructor(title, _type) checkType(true, 1, title, 'string', true) checkType(true, 2, _type, 'string', true) self.title = title or 'Sandbox' self.type = string.ucfirst(_type or 'Module') self.title = self.type..':'..self.title:gsub('^'..self.type..':?', '') self.doc = table.concat{ self.title, '/doc' } self.titleExists = mw.title.new(self.title).exists self.sandbox = table.concat{ self.title, '/sandbox' } self.html = mw.html.create('div') local createDocQuery = { action='edit', preload='Template:LuaDocumentation/preload', editintro='Template:LuaDocumentation/editintro', summary=table.format{ "Creating Module Documenation for \"%s\"", self.doc }; }	self.links = { pageTools = { {				{ self.doc, 'view', 'View the Documentation subpage for this module', }, { self.doc, 'edit', 'Edit the Documentation subpage for this module', query={ action='edit' }}, { self.doc, 'latest diff', 'View the diff on the latest Edit to the Documentation subpage for this module', query={ diff='cur' }}, { self.doc, 'hist', 'View the history of this module\'s documentation subpage', query={ action='history' }}, { self.title, 'purge', 'Purge this page', query={ action="purge" }}, },			{				{ self.doc, 'create', 'Create the Documentation for this module', query=createDocQuery }, { self.title, 'purge', 'Purge this page', query={ action="purge" }}, }		},		sandbox = { {				main = { self.sandbox, 'Sandbox', '' }, { self.sandbox, 'edit', '', query={ action="edit" }}, },			{				{},				},		},	}	return self:buildMainBox end

function Doc.main(frame) local args = getArgs(frame) return Doc:constructor(table.unpack(args)) end

Doc.main = { 'static', Doc.main }

--Finish Module/Exports return table.makeClass(Doc, nil, nil, { ignore=true })