Module:Documentation: Difference between revisions

comment tweaks
(don't use title error message)
(comment tweaks)
Line 119:
 
function p._main(args)
--[[
-- This function defines logic flow for the module.
-- @args - table of arguments passed by the user
--
-- Messages:
-- 'main-div-id' --> 'template-documentation'
-- 'main-div-classes' --> 'template-documentation iezoomfix'
--]]
local env = p.getEnvironment(args)
local root = htmlBuilder.create()
Line 151 ⟶ 159:
-- Returns a table with information about the environment, including title objects and other namespace- or
-- path-related data.
-- @args - table of arguments passed by the user
--
-- Title objects include:
Line 202 ⟶ 211:
 
function envFuncs.templateTitle()
--[[
-- The template (or module, etc.) title object.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
-- 'testcases-subpage' --> 'testcases'
--]]
local title = env.title
local subpage = title.subpageText
Line 213 ⟶ 227:
 
function envFuncs.docTitle()
--[[
-- Title object of the /doc subpage.
-- Messages:
-- 'doc-subpage' --> 'doc'
--]]
local title = env.title
local docname = args[1] -- User-specified doc page.
Line 226 ⟶ 244:
function envFuncs.sandboxTitle()
--[[
-- Title object for the /sandbox subpage.
-- Messages:
-- 'sandbox-subpage' --> 'sandbox'
--]]
return mw.title.new(env.docpageRoot .. '/' .. message('sandbox-subpage'))
end
function envFuncs.testcasesTitle()
--[[
-- Title object for the /testcases subpage.
-- Messages:
-- 'testcases-subpage' --> 'testcases'
--]]
return mw.title.new(env.docpageRoot .. '/' .. message('testcases-subpage'))
end
function envFuncs.printTitle()
--[[
-- Title object for the /Print subpage.
-- Messages:
-- 'print-subpage' --> 'Print'
--]]
return env.templateTitle:subPageTitle(message('print-subpage'))
end
Line 286 ⟶ 316:
 
function p.sandboxNotice(args, env)
--[=[
-- Generates a sandbox notice for display above sandbox pages.
-- @args - a table of arguments passed by the user
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
--
-- Messages:
-- 'sandbox-notice-image' --> '[[Image:Sandbox.png|50px|alt=|link=]]'
-- 'sandbox-notice-blurb' --> 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
-- 'sandbox-notice-diff-blurb' --> 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
-- 'sandbox-notice-compare-link-display' --> 'diff'
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
-- 'sandbox-notice-testcases-link-display' --> 'test cases'
-- 'sandbox-category' --> 'Template sandboxes'
--]=]
local title = env.title
local sandboxTitle = env.sandboxTitle
Line 292 ⟶ 336:
return nil
end
-- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text".
local omargs = {} -- Args for {{ombox}}.
-- Get the image wikitext.
omargs.image = message('sandbox-notice-image')
-- Get the text. We start with the opening blurb, which is something like
Line 303 ⟶ 347:
local compareUrl = env.compareUrl
if isPreviewing or not compareUrl then
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1.'
text = text .. message('sandbox-notice-blurb', {templateLink})
else
-- 'This is the [[Wikipedia:Template test cases|template sandbox]] page for $1 ($2).'
local compareDisplay = message('sandbox-notice-compare-link-display')
local compareLink = makeUrlLink(compareUrl, compareDisplay)
text = text .. message('sandbox-notice-diff-blurb', {templateLink, compareLink})
end
-- Get the test cases page blurb if the page exists. This is something like
-- "See also the companion subpage for [[Template:Foo/testcases|test cases]]."
local testcasesTitle = env.testcasesTitle
if testcasesTitle and testcasesTitle.exists then
Line 318 ⟶ 361:
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
end
-- Add the pagesandbox to [[Category:Templatethe sandboxes]]sandbox category.
text = text .. makeCategoryLink(message('sandbox-category'))
omargs.text = text