Module:Documentation: Difference between revisions

m
m (Lua error)
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('messageModule: type error in message cfg.TNT' ).. cfgKey .. format('I18n/Documentation', ('cfg-error-msg-type', ..cfgKey, expectType .. ' expected, got ' .. type(msg) .. ')', 2)
end
if not valArray then
Line 41:
local function getMessageVal(match)
match = tonumber(match)
return valArray[match] or error(require('messageModule:TNT').format('I18n/Documentation', no value found for key'cfg-error-msg-empty', '$' .. match .. ' in message cfg.' .., cfgKey), 4)
end
 
Line 112:
 
----------------------------------------------------------------------------
-- Load TemplateStyles
-- Main function
----------------------------------------------------------------------------
 
p.main = makeInvokeFuncfunction('_main'frame)
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-classesclass'))
:css('padding', '12px')
:newline()
:wikitext(p._startBox(args, env))
:wikitext(p._content(args, env))
:tag('div')
:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
:newline()
:done()
:done()
:wikitext(p._endBox(args, env))
Line 379 ⟶ 381:
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
if testcasesTitle.namespacecontentModel == mw.site.namespaces.Module.id"Scribunto" then
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
Line 394 ⟶ 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 485 ⟶ 488:
if not title or not docTitle then
return nil
end
if docTitle.isRedirect then
docTitle = docTitle.redirectTarget
end
 
Line 491 ⟶ 497:
data.docTitle = docTitle
-- View, display, edit, and purge links if /doc exists.
data.viewLinkDisplay = message(i18n['view-link-display')]
data.editLinkDisplay = message(i18n['edit-link-display')]
data.historyLinkDisplay = message(i18n['history-link-display')]
data.purgeLinkDisplay = message(i18n['purge-link-display')]
-- Create link if /doc doesn't exist.
local preload = args.preload
Line 507 ⟶ 513:
end
data.preload = preload
data.createLinkDisplay = message(i18n['create-link-display')]
return data
end
Line 578 ⟶ 584:
data.heading = heading
elseif subjectSpace == 10 then -- Template namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message(i18n['template-namespace-heading')]
elseif subjectSpace == 828 then -- Module namespace
data.heading = message('documentation-icon-wikitext') .. ' ' .. message(i18n['module-namespace-heading')]
elseif subjectSpace == 6 then -- File namespace
data.heading = message(i18n['file-namespace-heading')]
else
data.heading = message(i18n['other-namespaces-heading')]
end
-- Heading CSS
local headingStyle = args['heading-style']
if headingStyle then
data.headingStyleText = headingStyle
elseif subjectSpace == 10 then
-- We are in the template or template talk namespaces.
data.headingFontWeight = 'bold'
data.headingFontSize = '125%'
else
data.headingFontSize = '150%'
end
Line 614 ⟶ 608:
local sbox = mw.html.create('div')
sbox
:addClass(message('header-div-class'))
:css('padding-bottom', '3px')
:css('border-bottom', '1px solid #aaa')
:css('margin-bottom', '1ex')
:newline()
:tag('span')
:cssText(data.headingStyleText)
:css('font-weight', data.headingFontWeight)
:css('font-size', data.headingFontSize)
:wikitext(data.heading)
local links = data.links
if links then
sbox:tag('span')
:addClasstag(data.linksClass'div')
:attraddClass('id', data.linksIdlinksClass)
:attr('id', data.linksId)
:wikitext(links)
end
sbox
:tag('div')
:addClass(message('heading-div-class'))
:wikitext(data.heading)
return tostring(sbox)
end
Line 651 ⟶ 642:
-- 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')
return '\n' .. (content or '') .. '\n'
cbox
:addClass(message('content-div-class'))
return :wikitext('\n' .. (content or '') .. '\n' )
return tostring(cbox)
end
 
Line 677 ⟶ 672:
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'fmbox-id' --> 'documentation-meta-data'
-- 'fmbox-style' --> 'background-color: #ecfcf4'
-- 'fmbox-textstyle' --> 'font-style: italic'
--
-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
--]=]
Line 709 ⟶ 697:
end
 
-- Assemble the argumentsfooter fortext {{fmbox}}field.
local fmargs = {}
fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
fmargs.image = 'none'
fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'
 
-- Assemble the fmbox text field.
local text = ''
if linkBox then
Line 741 ⟶ 722:
end
end
fmargs.text = text
 
local ebox = mw.html.create('div')
return messageBox.main('fmbox', fmargs)
ebox
:addClass(message('footer-div-class'))
:wikitext(text)
return tostring(ebox)
end
 
Line 772 ⟶ 756:
local docLink = makeWikilink(docTitle.prefixedText)
local editUrl = docTitle:fullUrl{action = 'edit'}
local editDisplay = message(i18n['edit-link-display')]
local editLink = makeUrlLink(editUrl, editDisplay)
local historyUrl = docTitle:fullUrl{action = 'history'}
local historyDisplay = message(i18n['history-link-display')]
local historyLink = makeUrlLink(historyUrl, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
Line 784 ⟶ 768:
-- /doc does not exist; ask to create it.
local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
local createDisplay = message(i18n['create-link-display')]
local createLink = makeUrlLink(createUrl, createDisplay)
ret = message('create-module-doc-blurb', {createLink})
Anonymous user