Changes

Jump to: navigation, search

Module:Documentation

1,123 bytes added, 22:19, 14 January 2014
split out docpage blurb code
})
-- Get the title.
function envFuncs.title()
-- The title object for the current page, or a test page passed with args.page.
local title
local titleArg = args[message('titleArg', 'string')]
end
-- Get the subject namespace number.
function envFuncs.subjectSpace()
-- The subject namespace number.
return mw.site.namespaces[env.title.namespace].subject.id
end
-- Get the name of the documentation namespace.
function envFuncs.docspace()
-- The name of the documentation namespace.
local subjectSpace = env.subjectSpace
if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
end
-- Get the template page with no namespace or interwiki prefixes.
function envFuncs.templatePage()
-- The template page with no namespace or interwiki prefixes.
local title = env.title
local subpage = title.subpageText
function envFuncs.docTitle()
-- Title object of the /doc subpage.
local title = env.title
local docname = args[1] -- User-specified doc page.
function envFuncs.docpageRoot()
-- The base page of the /doc, /sandbox, and /testcases subpages.
-- For some namespaces this is the talk page, rather than the template page.
local title = env.title
return (env.docspace or title.nsText) .. ':' .. (env.templatePage or title.text)
function envFuncs.sandboxTitle()
-- Title object for the /sandbox subpage.
local titleArg = env.docpageRoot .. '/' .. message('sandboxSubpage', 'string')
local title = mw.title.new(titleArg)
function envFuncs.testcasesTitle()
-- Title object for the /testcases subpage.
local titleArg = env.docpageRoot .. '/' .. message('testcasesSubpage', 'string')
local title = mw.title.new(titleArg)
if not title then
error(message('titleArgError', 'string', {titleArg}))
end
return title
end
function envFuncs.printTitle()
-- Title object for the /Print subpage.
local titleArg = env.templatePage .. '/' .. message('printSubpage', 'string')
local title = mw.title.new(titleArg)
if not title then
text = text .. linkBox
else
if docExist then -- /doc exists; link to it. local docLink = makeWikilink(docpage) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, message('editLinkDisplay', 'string')) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, message('historyLinkDisplay', 'string')) text = text .. message('transcludedFromBlurb', 'string', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif subjectSpace == 828 then -- /doc does not exist; ask to create it. local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = message('modulePreload', 'string')}, message('createLinkDisplay', 'string')) text = text .p. messagemakeDocPageBlurb('createModuleDocBlurb'args, 'string', {createLink}env) .. '<br />' end
-- Add links to /sandbox and /testcases when appropriate.
if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then
-- Return the fmbox output.
return messageBox.main('fmbox', fmargs)
end
 
function p.makeDocPageBlurb(args, env)
-- Get the title object.
local success, docTitle = env:grab('docTitle')
if not success then
-- docTitle is the error message.
return docTitle
end
-- Make the blurb.
local ret
if docTitle.exists then
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local editUrl = docTitle:fullUrl{action = 'edit'}
local editDisplay = message('editLinkDisplay', 'string')
local editLink = makeUrlLink(editUrl, editDisplay)
local historyUrl = docTitle:fullUrl{action = 'history'}
local historyDisplay = message('historyLinkDisplay', 'string')
local historyLink = makeUrlLink(historyUrl, historyDisplay)
ret = message('transcludedFromBlurb', 'string', {docLink})
.. ' '
.. makeToolbar(editLink, historyLink)
.. '<br />'
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createUrl = docTitle:fullUrl{action = 'edit', preload = message('modulePreload', 'string')}
local createDisplay = message('createLinkDisplay', 'string')
local createLink = makeUrlLink(createUrl, createDisplay)
ret = message('createModuleDocBlurb', 'string', {createLink})
.. '<br />'
end
return ret
end
Anonymous user

Navigation menu