Module:Documentation: Difference between revisions
From Mariopedia, a wiki on Mario, Yoshi, Wario, Donkey Kong, Super Smash Bros., and more!
Jump to navigationJump to search
Content deleted Content added
Southparkfan (talk | contribs) m 16 revisions imported: importing all languages |
m 221 revisions imported from meta:Module:Documentation |
||
(90 intermediate revisions by 48 users not shown) | |||
Line 7:
-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')
local i18n = mw.loadData('Module:Documentation/i18n')
local p = {}
Line 33:
expectType = expectType or 'string'
if type(msg) ~= expectType then
error(require('
end
if not valArray then
Line 41:
local function getMessageVal(match)
match = tonumber(match)
return valArray[match] or error(require('
end
Line 82:
ret[#ret + 1] = select(i, ...)
end
return '<small
end
Line 112:
----------------------------------------------------------------------------
-- Load TemplateStyles
----------------------------------------------------------------------------
p.main =
local parent = frame.getParent(frame)
local output = p._main(parent.args)
return frame:extensionTag{ name='templatestyles', args = { src= message('templatestyles-scr') } } .. output
end
----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------
function p._main(args)
Line 135 ⟶ 143:
:tag('div')
:attr('id', message('main-div-id'))
:addClass(message('main-div-
:wikitext(p._startBox(args, env))
:wikitext(p._content(args, env))
:done()
:wikitext(p._endBox(args, env))
Line 334 ⟶ 337:
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
-- 'sandbox-notice-pagetype-template' --> '[[w:Wikipedia:Template test cases|template sandbox]] page'
-- 'sandbox-notice-pagetype-module' --> '[[w:Wikipedia:Template test cases|module sandbox]] page'
-- 'sandbox-notice-pagetype-other' --> 'sandbox page'
-- 'sandbox-notice-compare-link-display' --> 'diff'
Line 355 ⟶ 358:
-- "This is the template sandbox for [[Template:Foo]] (diff)."
local text = ''
local frame = mw.getCurrentFrame()
local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed.
local pagetype
if subjectSpace == 10 then
Line 365 ⟶ 370:
local templateLink = makeWikilink(templateTitle.prefixedText)
local compareUrl = env.compareUrl
if isPreviewing or not compareUrl then
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
else
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
end
-- Get the test cases page blurb if the page exists. This is something like
Line 376 ⟶ 381:
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
Line 391 ⟶ 396:
text = text .. makeCategoryLink(message('sandbox-category'))
omargs.text = text
omargs.class = message('sandbox-class')
end
Line 402 ⟶ 406:
-- 'protection-template' --> 'pp-template'
-- 'protection-template-args' --> {docusage = 'yes'}
local title = env.title
local protectionLevels
local protectionTemplate = message('protection-template')
local namespace = title.namespace
if not (protectionTemplate and (namespace == 10 or namespace == 828)) then
-- Don't display the protection template if we are not in the template or module namespaces.
return nil
end
protectionLevels = env.protectionLevels
if not protectionLevels then
return nil
end
local
local
if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then
-- The page is
local frame = mw.getCurrentFrame()
else
return nil
Line 483 ⟶ 486:
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
Line 489 ⟶ 495:
data.docTitle = docTitle
-- View, display, edit, and purge links if /doc exists.
data.viewLinkDisplay =
data.editLinkDisplay =
data.historyLinkDisplay =
data.purgeLinkDisplay =
-- Create link if /doc doesn't exist.
local preload = args.preload
Line 505 ⟶ 511:
end
data.preload = preload
data.createLinkDisplay =
return data
end
Line 517 ⟶ 523:
local function escapeBrackets(s)
-- Escapes square brackets with HTML entities.
return s
:gsub('%[', '[') -- Replace square brackets with HTML entities.
:gsub('%]', ']')
end
Line 550 ⟶ 556:
--
-- Messages:
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]'
-- 'template-namespace-heading' --> 'Template documentation'
-- 'module-namespace-heading' --> 'Module documentation'
Line 576 ⟶ 582:
data.heading = heading
elseif subjectSpace == 10 then -- Template namespace
data.heading =
elseif subjectSpace == 828 then -- Module namespace
data.heading =
elseif subjectSpace == 6 then -- File namespace
data.heading =
else
data.heading =
end
Line 612 ⟶ 606:
local sbox = mw.html.create('div')
sbox
:addClass(message('header-div-class'))
:tag('div')
:addClass(message('heading-div-class'))
:wikitext(data.heading)
local links = data.links
if links then
sbox
:
:
:attr('id', data.linksId)
:wikitext(links)
end
return tostring(sbox)
Line 645 ⟶ 635:
local content = args.content
if not content and docTitle and docTitle.exists then
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- of docs are interpreted correctly.
local cbox = mw.html.create('div')
cbox
:addClass(message('content-div-class'))
:wikitext('\n' .. (content or '') .. '\n')
return tostring(cbox)
end
Line 675 ⟶ 669:
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--]=]
Line 707 ⟶ 694:
end
-- Assemble the
local text = ''
if linkBox then
Line 739 ⟶ 719:
end
end
local ebox = mw.html.create('div')
ebox
:addClass(message('footer-div-class'))
:wikitext(text)
return tostring(ebox)
end
Line 754 ⟶ 737:
-- 'history-link-display' --> 'history'
-- 'transcluded-from-blurb' -->
-- 'The above [[w:Wikipedia:Template documentation|documentation]]
-- is [[w:Wikipedia:Transclusion|transcluded]] from $1.'
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'
-- 'create-link-display' --> 'create'
-- 'create-module-doc-blurb' -->
-- 'You might want to $1 a documentation page for this [[w:Wikipedia:Lua|Scribunto module]].'
--]=]
local docTitle = env.docTitle
if not docTitle or args.content then
return nil
end
Line 770 ⟶ 753:
local docLink = makeWikilink(docTitle.prefixedText)
local editUrl = docTitle:fullUrl{action = 'edit'}
local editDisplay =
local editLink = makeUrlLink(editUrl, editDisplay)
local historyUrl = docTitle:fullUrl{action = 'history'}
local historyDisplay =
local historyLink = makeUrlLink(historyUrl, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
Line 782 ⟶ 765:
-- /doc does not exist; ask to create it.
local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
local createDisplay =
local createLink = makeUrlLink(createUrl, createDisplay)
ret = message('create-module-doc-blurb', {createLink})
Line 855 ⟶ 838:
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
local mirrorDisplay = message('mirror-link-display')
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
Line 869 ⟶ 849:
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
else
local testcasesPreload
|