Anonymous user
Module:Documentation: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
don’t show “The above documentation is transcluded from…” when it’s not transcluded, but rather explicitly specified in the {{{content}}} parameter
m (1 revision imported) |
(don’t show “The above documentation is transcluded from…” when it’s not transcluded, but rather explicitly specified in the {{{content}}} parameter) |
||
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 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') } } .. frame:preprocess(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 391 ⟶ 396:
text = text .. makeCategoryLink(message('sandbox-category'))
omargs.text = text
omargs.class = message('sandbox-class')
local ret = '<div style="clear: both;"></div>'
ret = ret .. messageBox.main('ombox', omargs)
Line 402 ⟶ 408:
-- '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 445 ⟶ 450:
local links
local content = args.content
if not content
-- No need to include the links if the documentation is on the template page itself.
local linksData = p.makeStartBoxLinksData(args, env)
Line 492 ⟶ 497:
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 508 ⟶ 513:
end
data.preload = preload
data.createLinkDisplay =
return data
end
Line 553 ⟶ 558:
--
-- 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 579 ⟶ 584:
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 615 ⟶ 608:
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 652 ⟶ 641:
-- 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 678 ⟶ 671:
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--]=]
Line 710 ⟶ 696:
end
-- Assemble the
local text = ''
if linkBox then
Line 742 ⟶ 721:
end
end
local ebox = mw.html.create('div')
ebox
:addClass(message('footer-div-class'))
:wikitext(text)
return tostring(ebox)
end
Line 765 ⟶ 747:
--]=]
local docTitle = env.docTitle
if not docTitle or args.content then
return nil
end
Line 773 ⟶ 755:
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 785 ⟶ 767:
-- /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 858 ⟶ 840:
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 872 ⟶ 851:
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
else
local testcasesPreload
|