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 = {}

for i, v in ipairs(t) do		local val local title = string.makeTitle(v[2], v[3], { disableAbbr=true }) if v.query then val = string.fullUrl(v[1], v.query or {}, title) else val = string.makeLink(v[1], title) end table.push(ret, table.concat{ lb, val, rb }) end return table.concat(ret, sep) 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 :done :done return self.html 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.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" }}, }		},	}	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 })