Title: Module:Documentation - freem
URL Source: https://freemwiki.com/wiki/Module:Documentation/
Markdown Content:
[Jump to content](https://freemwiki.com/wiki/Module:Documentation/#bodyContent)
- [x] Main menu
Main menu
move to sidebar hide
Navigation
* [Main page](https://freemwiki.com/wiki/Main_Page "Visit the main page [alt-shift-z]")
* [Recent changes](https://freemwiki.com/wiki/Special:RecentChanges "A list of recent changes in the wiki [alt-shift-r]")
* [Random page](https://freemwiki.com/wiki/Special:Random "Load a random page [alt-shift-x]")
* [Help about MediaWiki](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents)
Legal
* [Terms](https://freemwiki.com/wiki/Terms_of_Service)
* [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy)
* [About](https://freemwiki.com/wiki/About)
* [Contact](https://freemwiki.com/wiki/Contact)
[**freem**](https://freemwiki.com/wiki/Main_Page)
[Search](https://freemwiki.com/wiki/Special:Search "Search freem [alt-shift-f]")
Search
- [x] Appearance
* [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3ADocumentation "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3ADocumentation "You are encouraged to log in; however, it is not mandatory [alt-shift-o]")
- [x] Personal tools
* [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3ADocumentation "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3ADocumentation "You are encouraged to log in; however, it is not mandatory [alt-shift-o]")
Pages for logged out editors [learn more](https://freemwiki.com/wiki/Help:Introduction)
* [Contributions](https://freemwiki.com/wiki/Special:MyContributions "A list of edits made from this IP address [alt-shift-y]")
* [Talk](https://freemwiki.com/wiki/Special:MyTalk "Discussion about edits from this IP address [alt-shift-n]")
# Module:Documentation
- [x] Add languages
* [Module](https://freemwiki.com/wiki/Module:Documentation "View the module page [alt-shift-c]")
* [Discussion](https://freemwiki.com/index.php?title=Module_talk:Documentation&action=edit&redlink=1 "Discussion about the content page (page does not exist) [alt-shift-t]")
- [x] English
* [Read](https://freemwiki.com/wiki/Module:Documentation)
* [Edit source](https://freemwiki.com/index.php?title=Module:Documentation&action=edit "Edit the source code of this page [alt-shift-e]")
* [View history](https://freemwiki.com/index.php?title=Module:Documentation&action=history "Past revisions of this page [alt-shift-h]")
- [x] Tools
Tools
move to sidebar hide
Actions
* [Read](https://freemwiki.com/wiki/Module:Documentation)
* [Edit source](https://freemwiki.com/index.php?title=Module:Documentation&action=edit "Edit the source code of this page [alt-shift-e]")
* [View history](https://freemwiki.com/index.php?title=Module:Documentation&action=history)
General
* [What links here](https://freemwiki.com/wiki/Special:WhatLinksHere/Module:Documentation "A list of all wiki pages that link here [alt-shift-j]")
* [Related changes](https://freemwiki.com/wiki/Special:RecentChangesLinked/Module:Documentation "Recent changes in pages linked from this page [alt-shift-k]")
* [Special pages](https://freemwiki.com/wiki/Special:SpecialPages "A list of all special pages [alt-shift-q]")
* [Printable version](javascript:print(); "Printable version of this page [alt-shift-p]")
* [Permanent link](https://freemwiki.com/index.php?title=Module:Documentation&oldid=579600 "Permanent link to this revision of this page")
* [Page information](https://freemwiki.com/index.php?title=Module:Documentation&action=info "More information about this page")
Appearance
move to sidebar hide
From freem
(Redirected from [Module:Documentation/](https://freemwiki.com/index.php?title=Module:Documentation/&redirect=no "Module:Documentation/"))
_Documentation for this module may be created at [Module:Documentation/doc](https://freemwiki.com/index.php?title=Module:Documentation/doc&action=edit&redlink=1 "Module:Documentation/doc (page does not exist)")_
[](https://freemwiki.com/wiki/Module:Documentation/#L-1)-- This module implements {{[documentation](https://freemwiki.com/wiki/Template:Documentation "Template:Documentation")}}.[](https://freemwiki.com/wiki/Module:Documentation/#L-2)[](https://freemwiki.com/wiki/Module:Documentation/#L-3)-- Get required modules.[](https://freemwiki.com/wiki/Module:Documentation/#L-4)local getArgs = require(['Module:Arguments'](https://freemwiki.com/wiki/Module:Arguments)).getArgs[](https://freemwiki.com/wiki/Module:Documentation/#L-5)[](https://freemwiki.com/wiki/Module:Documentation/#L-6)-- Get the config table.[](https://freemwiki.com/wiki/Module:Documentation/#L-7)local cfg = mw.loadData(['Module:Documentation/config'](https://freemwiki.com/wiki/Module:Documentation/config))[](https://freemwiki.com/wiki/Module:Documentation/#L-8)[](https://freemwiki.com/wiki/Module:Documentation/#L-9)local p = {}[](https://freemwiki.com/wiki/Module:Documentation/#L-10)[](https://freemwiki.com/wiki/Module:Documentation/#L-11)-- Often-used functions.[](https://freemwiki.com/wiki/Module:Documentation/#L-12)local ugsub = mw.ustring.gsub[](https://freemwiki.com/wiki/Module:Documentation/#L-13)local format = mw.ustring.format[](https://freemwiki.com/wiki/Module:Documentation/#L-14)[](https://freemwiki.com/wiki/Module:Documentation/#L-15)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-16)-- Helper functions[](https://freemwiki.com/wiki/Module:Documentation/#L-17)--[](https://freemwiki.com/wiki/Module:Documentation/#L-18)-- These are defined as local functions, but are made available in the p[](https://freemwiki.com/wiki/Module:Documentation/#L-19)-- table for testing purposes.[](https://freemwiki.com/wiki/Module:Documentation/#L-20)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-21)[](https://freemwiki.com/wiki/Module:Documentation/#L-22)local function message(cfgKey, valArray, expectType)[](https://freemwiki.com/wiki/Module:Documentation/#L-23)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-24) -- Gets a message from the cfg table and formats it if appropriate.[](https://freemwiki.com/wiki/Module:Documentation/#L-25) -- The function raises an error if the value from the cfg table is not[](https://freemwiki.com/wiki/Module:Documentation/#L-26) -- of the type expectType. The default type for expectType is 'string'.[](https://freemwiki.com/wiki/Module:Documentation/#L-27) -- If the table valArray is present, strings such as $1, $2 etc. in the[](https://freemwiki.com/wiki/Module:Documentation/#L-28) -- message are substituted with values from the table keys [1], [2] etc.[](https://freemwiki.com/wiki/Module:Documentation/#L-29) -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.',[](https://freemwiki.com/wiki/Module:Documentation/#L-30) -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."[](https://freemwiki.com/wiki/Module:Documentation/#L-31) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-32)local msg = cfg[cfgKey][](https://freemwiki.com/wiki/Module:Documentation/#L-33)expectType = expectType or 'string'[](https://freemwiki.com/wiki/Module:Documentation/#L-34)if type(msg) ~= expectType then[](https://freemwiki.com/wiki/Module:Documentation/#L-35)error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)[](https://freemwiki.com/wiki/Module:Documentation/#L-36)end[](https://freemwiki.com/wiki/Module:Documentation/#L-37)if not valArray then[](https://freemwiki.com/wiki/Module:Documentation/#L-38)return msg[](https://freemwiki.com/wiki/Module:Documentation/#L-39)end[](https://freemwiki.com/wiki/Module:Documentation/#L-40)[](https://freemwiki.com/wiki/Module:Documentation/#L-41)local function getMessageVal(match)[](https://freemwiki.com/wiki/Module:Documentation/#L-42)match = tonumber(match)[](https://freemwiki.com/wiki/Module:Documentation/#L-43)return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)[](https://freemwiki.com/wiki/Module:Documentation/#L-44)end[](https://freemwiki.com/wiki/Module:Documentation/#L-45)[](https://freemwiki.com/wiki/Module:Documentation/#L-46)return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)[](https://freemwiki.com/wiki/Module:Documentation/#L-47)end[](https://freemwiki.com/wiki/Module:Documentation/#L-48)[](https://freemwiki.com/wiki/Module:Documentation/#L-49)p.message = message[](https://freemwiki.com/wiki/Module:Documentation/#L-50)[](https://freemwiki.com/wiki/Module:Documentation/#L-51)local function makeWikilink(page, display)[](https://freemwiki.com/wiki/Module:Documentation/#L-52)if display then[](https://freemwiki.com/wiki/Module:Documentation/#L-53)return format('[[%s|%s]]', page, display)[](https://freemwiki.com/wiki/Module:Documentation/#L-54)else[](https://freemwiki.com/wiki/Module:Documentation/#L-55)return format('[[%s]]', page)[](https://freemwiki.com/wiki/Module:Documentation/#L-56)end[](https://freemwiki.com/wiki/Module:Documentation/#L-57)end[](https://freemwiki.com/wiki/Module:Documentation/#L-58)[](https://freemwiki.com/wiki/Module:Documentation/#L-59)p.makeWikilink = makeWikilink[](https://freemwiki.com/wiki/Module:Documentation/#L-60)[](https://freemwiki.com/wiki/Module:Documentation/#L-61)local function makeCategoryLink(cat, sort)[](https://freemwiki.com/wiki/Module:Documentation/#L-62)local catns = mw.site.namespaces[14].name[](https://freemwiki.com/wiki/Module:Documentation/#L-63)return makeWikilink(catns .. ':' .. cat, sort)[](https://freemwiki.com/wiki/Module:Documentation/#L-64)end[](https://freemwiki.com/wiki/Module:Documentation/#L-65)[](https://freemwiki.com/wiki/Module:Documentation/#L-66)p.makeCategoryLink = makeCategoryLink[](https://freemwiki.com/wiki/Module:Documentation/#L-67)[](https://freemwiki.com/wiki/Module:Documentation/#L-68)local function makeUrlLink(url, display)[](https://freemwiki.com/wiki/Module:Documentation/#L-69)return format('[%s %s]', url, display)[](https://freemwiki.com/wiki/Module:Documentation/#L-70)end[](https://freemwiki.com/wiki/Module:Documentation/#L-71)[](https://freemwiki.com/wiki/Module:Documentation/#L-72)p.makeUrlLink = makeUrlLink[](https://freemwiki.com/wiki/Module:Documentation/#L-73)[](https://freemwiki.com/wiki/Module:Documentation/#L-74)local function makeToolbar(...)[](https://freemwiki.com/wiki/Module:Documentation/#L-75)local ret = {}[](https://freemwiki.com/wiki/Module:Documentation/#L-76)local lim = select('#', ...)[](https://freemwiki.com/wiki/Module:Documentation/#L-77)if lim < 1 then[](https://freemwiki.com/wiki/Module:Documentation/#L-78)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-79)end[](https://freemwiki.com/wiki/Module:Documentation/#L-80)for i = 1, lim do[](https://freemwiki.com/wiki/Module:Documentation/#L-81)ret[#ret + 1] = select(i, ...)[](https://freemwiki.com/wiki/Module:Documentation/#L-82)end[](https://freemwiki.com/wiki/Module:Documentation/#L-83)-- 'documentation-toolbar'[](https://freemwiki.com/wiki/Module:Documentation/#L-84)return format([](https://freemwiki.com/wiki/Module:Documentation/#L-85)'(%s)',[](https://freemwiki.com/wiki/Module:Documentation/#L-86)message('toolbar-class'),[](https://freemwiki.com/wiki/Module:Documentation/#L-87)table.concat(ret, ' | ')[](https://freemwiki.com/wiki/Module:Documentation/#L-88))[](https://freemwiki.com/wiki/Module:Documentation/#L-89)end[](https://freemwiki.com/wiki/Module:Documentation/#L-90)[](https://freemwiki.com/wiki/Module:Documentation/#L-91)p.makeToolbar = makeToolbar[](https://freemwiki.com/wiki/Module:Documentation/#L-92)[](https://freemwiki.com/wiki/Module:Documentation/#L-93)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-94)-- Argument processing[](https://freemwiki.com/wiki/Module:Documentation/#L-95)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-96)[](https://freemwiki.com/wiki/Module:Documentation/#L-97)local function makeInvokeFunc(funcName)[](https://freemwiki.com/wiki/Module:Documentation/#L-98)return function (frame)[](https://freemwiki.com/wiki/Module:Documentation/#L-99)local args = getArgs(frame, {[](https://freemwiki.com/wiki/Module:Documentation/#L-100)valueFunc = function (key, value)[](https://freemwiki.com/wiki/Module:Documentation/#L-101)if type(value) == 'string' then[](https://freemwiki.com/wiki/Module:Documentation/#L-102)value = value:match('^%s*(.-)%s*$') -- Remove whitespace.[](https://freemwiki.com/wiki/Module:Documentation/#L-103)if key == 'heading' or value ~= '' then[](https://freemwiki.com/wiki/Module:Documentation/#L-104)return value[](https://freemwiki.com/wiki/Module:Documentation/#L-105)else[](https://freemwiki.com/wiki/Module:Documentation/#L-106)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-107)end[](https://freemwiki.com/wiki/Module:Documentation/#L-108)else[](https://freemwiki.com/wiki/Module:Documentation/#L-109)return value[](https://freemwiki.com/wiki/Module:Documentation/#L-110)end[](https://freemwiki.com/wiki/Module:Documentation/#L-111)end[](https://freemwiki.com/wiki/Module:Documentation/#L-112)})[](https://freemwiki.com/wiki/Module:Documentation/#L-113)return p[funcName](args)[](https://freemwiki.com/wiki/Module:Documentation/#L-114)end[](https://freemwiki.com/wiki/Module:Documentation/#L-115)end[](https://freemwiki.com/wiki/Module:Documentation/#L-116)[](https://freemwiki.com/wiki/Module:Documentation/#L-117)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-118)-- Entry points[](https://freemwiki.com/wiki/Module:Documentation/#L-119)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-120)[](https://freemwiki.com/wiki/Module:Documentation/#L-121)function p.nonexistent(frame)[](https://freemwiki.com/wiki/Module:Documentation/#L-122)if mw.title.getCurrentTitle().subpageText == 'testcases' then[](https://freemwiki.com/wiki/Module:Documentation/#L-123)return frame:expandTemplate{title = 'module test cases notice'}[](https://freemwiki.com/wiki/Module:Documentation/#L-124)else[](https://freemwiki.com/wiki/Module:Documentation/#L-125)return p.main(frame)[](https://freemwiki.com/wiki/Module:Documentation/#L-126)end[](https://freemwiki.com/wiki/Module:Documentation/#L-127)end[](https://freemwiki.com/wiki/Module:Documentation/#L-128)[](https://freemwiki.com/wiki/Module:Documentation/#L-129)p.main = makeInvokeFunc('_main')[](https://freemwiki.com/wiki/Module:Documentation/#L-130)[](https://freemwiki.com/wiki/Module:Documentation/#L-131)function p._main(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-132)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-133) -- This function defines logic flow for the module.[](https://freemwiki.com/wiki/Module:Documentation/#L-134) -- @args - table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-135) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-136)local env = p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-137)local root = mw.html.create()[](https://freemwiki.com/wiki/Module:Documentation/#L-138)root[](https://freemwiki.com/wiki/Module:Documentation/#L-139):wikitext(p._getModuleWikitext(args, env))[](https://freemwiki.com/wiki/Module:Documentation/#L-140):wikitext(p.protectionTemplate(env))[](https://freemwiki.com/wiki/Module:Documentation/#L-141):wikitext(p.sandboxNotice(args, env))[](https://freemwiki.com/wiki/Module:Documentation/#L-142):tag('div')[](https://freemwiki.com/wiki/Module:Documentation/#L-143)-- 'documentation-container'[](https://freemwiki.com/wiki/Module:Documentation/#L-144):addClass(message('container'))[](https://freemwiki.com/wiki/Module:Documentation/#L-145):attr('role', 'complementary')[](https://freemwiki.com/wiki/Module:Documentation/#L-146):attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)[](https://freemwiki.com/wiki/Module:Documentation/#L-147):attr('aria-label', args.heading == '' and 'Documentation' or nil)[](https://freemwiki.com/wiki/Module:Documentation/#L-148):newline()[](https://freemwiki.com/wiki/Module:Documentation/#L-149):tag('div')[](https://freemwiki.com/wiki/Module:Documentation/#L-150)-- 'documentation'[](https://freemwiki.com/wiki/Module:Documentation/#L-151):addClass(message('main-div-classes'))[](https://freemwiki.com/wiki/Module:Documentation/#L-152):newline()[](https://freemwiki.com/wiki/Module:Documentation/#L-153):wikitext(p._startBox(args, env))[](https://freemwiki.com/wiki/Module:Documentation/#L-154):wikitext(p._content(args, env))[](https://freemwiki.com/wiki/Module:Documentation/#L-155):tag('div')[](https://freemwiki.com/wiki/Module:Documentation/#L-156)-- 'documentation-clear'[](https://freemwiki.com/wiki/Module:Documentation/#L-157):addClass(message('clear'))[](https://freemwiki.com/wiki/Module:Documentation/#L-158):done()[](https://freemwiki.com/wiki/Module:Documentation/#L-159):newline()[](https://freemwiki.com/wiki/Module:Documentation/#L-160):done()[](https://freemwiki.com/wiki/Module:Documentation/#L-161):wikitext(p._endBox(args, env))[](https://freemwiki.com/wiki/Module:Documentation/#L-162):done()[](https://freemwiki.com/wiki/Module:Documentation/#L-163):wikitext(p.addTrackingCategories(env))[](https://freemwiki.com/wiki/Module:Documentation/#L-164)-- 'Module:Documentation/styles.css'[](https://freemwiki.com/wiki/Module:Documentation/#L-165)return mw.getCurrentFrame():extensionTag ([](https://freemwiki.com/wiki/Module:Documentation/#L-166)'templatestyles', '', {src=cfg['templatestyles'][](https://freemwiki.com/wiki/Module:Documentation/#L-167)}) .. tostring(root)[](https://freemwiki.com/wiki/Module:Documentation/#L-168)end[](https://freemwiki.com/wiki/Module:Documentation/#L-169)[](https://freemwiki.com/wiki/Module:Documentation/#L-170)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-171)-- Environment settings[](https://freemwiki.com/wiki/Module:Documentation/#L-172)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-173)[](https://freemwiki.com/wiki/Module:Documentation/#L-174)function p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-175)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-176) -- Returns a table with information about the environment, including title[](https://freemwiki.com/wiki/Module:Documentation/#L-177) -- objects and other namespace- or path-related data.[](https://freemwiki.com/wiki/Module:Documentation/#L-178) -- @args - table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-179) --[](https://freemwiki.com/wiki/Module:Documentation/#L-180) -- Title objects include:[](https://freemwiki.com/wiki/Module:Documentation/#L-181) -- env.title - the page we are making documentation for (usually the current title)[](https://freemwiki.com/wiki/Module:Documentation/#L-182) -- env.templateTitle - the template (or module, file, etc.)[](https://freemwiki.com/wiki/Module:Documentation/#L-183) -- env.docTitle - the /doc subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-184) -- env.sandboxTitle - the /sandbox subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-185) -- env.testcasesTitle - the /testcases subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-186) --[](https://freemwiki.com/wiki/Module:Documentation/#L-187) -- Data includes:[](https://freemwiki.com/wiki/Module:Documentation/#L-188) -- env.protectionLevels - the protection levels table of the title object.[](https://freemwiki.com/wiki/Module:Documentation/#L-189) -- env.subjectSpace - the number of the title's subject namespace.[](https://freemwiki.com/wiki/Module:Documentation/#L-190) -- env.docSpace - the number of the namespace the title puts its documentation in.[](https://freemwiki.com/wiki/Module:Documentation/#L-191) -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.[](https://freemwiki.com/wiki/Module:Documentation/#L-192) -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.[](https://freemwiki.com/wiki/Module:Documentation/#L-193) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-194) -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value[](https://freemwiki.com/wiki/Module:Documentation/#L-195) -- returned will be nil.[](https://freemwiki.com/wiki/Module:Documentation/#L-196) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-197)[](https://freemwiki.com/wiki/Module:Documentation/#L-198)local env, envFuncs = {}, {}[](https://freemwiki.com/wiki/Module:Documentation/#L-199)[](https://freemwiki.com/wiki/Module:Documentation/#L-200)-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value[](https://freemwiki.com/wiki/Module:Documentation/#L-201)-- returned by that function is memoized in the env table so that we don't call any of the functions[](https://freemwiki.com/wiki/Module:Documentation/#L-202)-- more than once. (Nils won't be memoized.)[](https://freemwiki.com/wiki/Module:Documentation/#L-203)setmetatable(env, {[](https://freemwiki.com/wiki/Module:Documentation/#L-204)__index = function (t, key)[](https://freemwiki.com/wiki/Module:Documentation/#L-205)local envFunc = envFuncs[key][](https://freemwiki.com/wiki/Module:Documentation/#L-206)if envFunc then[](https://freemwiki.com/wiki/Module:Documentation/#L-207)local success, val = pcall(envFunc)[](https://freemwiki.com/wiki/Module:Documentation/#L-208)if success then[](https://freemwiki.com/wiki/Module:Documentation/#L-209)env[key] = val -- Memoise the value.[](https://freemwiki.com/wiki/Module:Documentation/#L-210)return val[](https://freemwiki.com/wiki/Module:Documentation/#L-211)end[](https://freemwiki.com/wiki/Module:Documentation/#L-212)end[](https://freemwiki.com/wiki/Module:Documentation/#L-213)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-214)end[](https://freemwiki.com/wiki/Module:Documentation/#L-215)})[](https://freemwiki.com/wiki/Module:Documentation/#L-216)[](https://freemwiki.com/wiki/Module:Documentation/#L-217)function envFuncs.title()[](https://freemwiki.com/wiki/Module:Documentation/#L-218)-- The title object for the current page, or a test page passed with args.page.[](https://freemwiki.com/wiki/Module:Documentation/#L-219)local title[](https://freemwiki.com/wiki/Module:Documentation/#L-220)local titleArg = args.page[](https://freemwiki.com/wiki/Module:Documentation/#L-221)if titleArg then[](https://freemwiki.com/wiki/Module:Documentation/#L-222)title = mw.title.new(titleArg)[](https://freemwiki.com/wiki/Module:Documentation/#L-223)else[](https://freemwiki.com/wiki/Module:Documentation/#L-224)title = mw.title.getCurrentTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-225)end[](https://freemwiki.com/wiki/Module:Documentation/#L-226)return title[](https://freemwiki.com/wiki/Module:Documentation/#L-227)end[](https://freemwiki.com/wiki/Module:Documentation/#L-228)[](https://freemwiki.com/wiki/Module:Documentation/#L-229)function envFuncs.templateTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-230)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-231) -- The template (or module, etc.) title object.[](https://freemwiki.com/wiki/Module:Documentation/#L-232) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-233) -- 'sandbox-subpage' --> 'sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-234) -- 'testcases-subpage' --> 'testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-235) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-236)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-237)local title = env.title[](https://freemwiki.com/wiki/Module:Documentation/#L-238)local subpage = title.subpageText[](https://freemwiki.com/wiki/Module:Documentation/#L-239)if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') or (subpage == message('doc-subpage') and mw.title.getCurrentTitle().namespace == env.docSpace) then[](https://freemwiki.com/wiki/Module:Documentation/#L-240)return mw.title.makeTitle(subjectSpace, title.baseText)[](https://freemwiki.com/wiki/Module:Documentation/#L-241)else[](https://freemwiki.com/wiki/Module:Documentation/#L-242)return mw.title.makeTitle(subjectSpace, title.text)[](https://freemwiki.com/wiki/Module:Documentation/#L-243)end[](https://freemwiki.com/wiki/Module:Documentation/#L-244)end[](https://freemwiki.com/wiki/Module:Documentation/#L-245)[](https://freemwiki.com/wiki/Module:Documentation/#L-246)function envFuncs.docTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-247)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-248) -- Title object of the /doc subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-249) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-250) -- 'doc-subpage' --> 'doc'[](https://freemwiki.com/wiki/Module:Documentation/#L-251) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-252)local title = env.title[](https://freemwiki.com/wiki/Module:Documentation/#L-253)local docname = args[1] -- User-specified doc page.[](https://freemwiki.com/wiki/Module:Documentation/#L-254)local docpage[](https://freemwiki.com/wiki/Module:Documentation/#L-255)if docname then[](https://freemwiki.com/wiki/Module:Documentation/#L-256)docpage = docname[](https://freemwiki.com/wiki/Module:Documentation/#L-257)else[](https://freemwiki.com/wiki/Module:Documentation/#L-258)docpage = env.docpageBase .. '/' .. message('doc-subpage')[](https://freemwiki.com/wiki/Module:Documentation/#L-259)end[](https://freemwiki.com/wiki/Module:Documentation/#L-260)return mw.title.new(docpage)[](https://freemwiki.com/wiki/Module:Documentation/#L-261)end[](https://freemwiki.com/wiki/Module:Documentation/#L-262)[](https://freemwiki.com/wiki/Module:Documentation/#L-263)function envFuncs.sandboxTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-264)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-265) -- Title object for the /sandbox subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-266) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-267) -- 'sandbox-subpage' --> 'sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-268) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-269)return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))[](https://freemwiki.com/wiki/Module:Documentation/#L-270)end[](https://freemwiki.com/wiki/Module:Documentation/#L-271)[](https://freemwiki.com/wiki/Module:Documentation/#L-272)function envFuncs.testcasesTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-273)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-274) -- Title object for the /testcases subpage.[](https://freemwiki.com/wiki/Module:Documentation/#L-275) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-276) -- 'testcases-subpage' --> 'testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-277) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-278)return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))[](https://freemwiki.com/wiki/Module:Documentation/#L-279)end[](https://freemwiki.com/wiki/Module:Documentation/#L-280)[](https://freemwiki.com/wiki/Module:Documentation/#L-281)function envFuncs.protectionLevels()[](https://freemwiki.com/wiki/Module:Documentation/#L-282)-- The protection levels table of the title object.[](https://freemwiki.com/wiki/Module:Documentation/#L-283)return env.title.protectionLevels[](https://freemwiki.com/wiki/Module:Documentation/#L-284)end[](https://freemwiki.com/wiki/Module:Documentation/#L-285)[](https://freemwiki.com/wiki/Module:Documentation/#L-286)function envFuncs.subjectSpace()[](https://freemwiki.com/wiki/Module:Documentation/#L-287)-- The subject namespace number.[](https://freemwiki.com/wiki/Module:Documentation/#L-288)return mw.site.namespaces[env.title.namespace].subject.id[](https://freemwiki.com/wiki/Module:Documentation/#L-289)end[](https://freemwiki.com/wiki/Module:Documentation/#L-290)[](https://freemwiki.com/wiki/Module:Documentation/#L-291)function envFuncs.docSpace()[](https://freemwiki.com/wiki/Module:Documentation/#L-292)-- The documentation namespace number. For most namespaces this is the[](https://freemwiki.com/wiki/Module:Documentation/#L-293)-- same as the subject namespace. However, pages in the Article, File,[](https://freemwiki.com/wiki/Module:Documentation/#L-294)-- MediaWiki or Category namespaces must have their /doc, /sandbox and[](https://freemwiki.com/wiki/Module:Documentation/#L-295)-- /testcases pages in talk space.[](https://freemwiki.com/wiki/Module:Documentation/#L-296)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-297)if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then[](https://freemwiki.com/wiki/Module:Documentation/#L-298)return subjectSpace + 1[](https://freemwiki.com/wiki/Module:Documentation/#L-299)else[](https://freemwiki.com/wiki/Module:Documentation/#L-300)return subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-301)end[](https://freemwiki.com/wiki/Module:Documentation/#L-302)end[](https://freemwiki.com/wiki/Module:Documentation/#L-303)[](https://freemwiki.com/wiki/Module:Documentation/#L-304)function envFuncs.docpageBase()[](https://freemwiki.com/wiki/Module:Documentation/#L-305)-- The base page of the /doc, /sandbox, and /testcases subpages.[](https://freemwiki.com/wiki/Module:Documentation/#L-306)-- For some namespaces this is the talk page, rather than the template page.[](https://freemwiki.com/wiki/Module:Documentation/#L-307)local templateTitle = env.templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-308)local docSpace = env.docSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-309)local docSpaceText = mw.site.namespaces[docSpace].name[](https://freemwiki.com/wiki/Module:Documentation/#L-310)-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.[](https://freemwiki.com/wiki/Module:Documentation/#L-311)return docSpaceText .. ':' .. templateTitle.text[](https://freemwiki.com/wiki/Module:Documentation/#L-312)end[](https://freemwiki.com/wiki/Module:Documentation/#L-313)[](https://freemwiki.com/wiki/Module:Documentation/#L-314)function envFuncs.compareUrl()[](https://freemwiki.com/wiki/Module:Documentation/#L-315)-- Diff link between the sandbox and the main template using [[[Special:ComparePages]]](https://freemwiki.com/wiki/Special:ComparePages "Special:ComparePages").[](https://freemwiki.com/wiki/Module:Documentation/#L-316)local templateTitle = env.templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-317)local sandboxTitle = env.sandboxTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-318)if templateTitle.exists and sandboxTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-319)local compareUrl = mw.uri.canonicalUrl([](https://freemwiki.com/wiki/Module:Documentation/#L-320)'Special:ComparePages',[](https://freemwiki.com/wiki/Module:Documentation/#L-321){ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}[](https://freemwiki.com/wiki/Module:Documentation/#L-322))[](https://freemwiki.com/wiki/Module:Documentation/#L-323)return tostring(compareUrl)[](https://freemwiki.com/wiki/Module:Documentation/#L-324)else[](https://freemwiki.com/wiki/Module:Documentation/#L-325)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-326)end[](https://freemwiki.com/wiki/Module:Documentation/#L-327)end[](https://freemwiki.com/wiki/Module:Documentation/#L-328)[](https://freemwiki.com/wiki/Module:Documentation/#L-329)return env[](https://freemwiki.com/wiki/Module:Documentation/#L-330)end[](https://freemwiki.com/wiki/Module:Documentation/#L-331)[](https://freemwiki.com/wiki/Module:Documentation/#L-332)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-333)-- Auxiliary templates[](https://freemwiki.com/wiki/Module:Documentation/#L-334)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-335)[](https://freemwiki.com/wiki/Module:Documentation/#L-336)p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')[](https://freemwiki.com/wiki/Module:Documentation/#L-337)[](https://freemwiki.com/wiki/Module:Documentation/#L-338)function p._getModuleWikitext(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-339)local currentTitle = mw.title.getCurrentTitle()[](https://freemwiki.com/wiki/Module:Documentation/#L-340)if currentTitle.contentModel ~= 'Scribunto' then return end[](https://freemwiki.com/wiki/Module:Documentation/#L-341)pcall(require, currentTitle.prefixedText) -- if it fails, we don't care[](https://freemwiki.com/wiki/Module:Documentation/#L-342)local moduleWikitext = package.loaded["Module:Module wikitext"][](https://freemwiki.com/wiki/Module:Documentation/#L-343)if moduleWikitext then[](https://freemwiki.com/wiki/Module:Documentation/#L-344)return moduleWikitext.main()[](https://freemwiki.com/wiki/Module:Documentation/#L-345)end[](https://freemwiki.com/wiki/Module:Documentation/#L-346)end[](https://freemwiki.com/wiki/Module:Documentation/#L-347)[](https://freemwiki.com/wiki/Module:Documentation/#L-348)function p.sandboxNotice(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-349)--[=[[](https://freemwiki.com/wiki/Module:Documentation/#L-350) -- Generates a sandbox notice for display above sandbox pages.[](https://freemwiki.com/wiki/Module:Documentation/#L-351) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-352) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-353) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-354) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-355) -- 'sandbox-notice-image' --> '[[[File:Sandbox.svg|50px|alt=|link=]]](https://freemwiki.com/wiki/File:Sandbox.svg "File:Sandbox.svg")'[](https://freemwiki.com/wiki/Module:Documentation/#L-356) -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'[](https://freemwiki.com/wiki/Module:Documentation/#L-357) -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'[](https://freemwiki.com/wiki/Module:Documentation/#L-358) -- 'sandbox-notice-pagetype-template' --> '[[[Wikipedia:Template test cases|template sandbox]]](https://freemwiki.com/wiki/Wikipedia:Template_test_cases "Wikipedia:Template test cases") page'[](https://freemwiki.com/wiki/Module:Documentation/#L-359) -- 'sandbox-notice-pagetype-module' --> '[[[Wikipedia:Template test cases|module sandbox]]](https://freemwiki.com/wiki/Wikipedia:Template_test_cases "Wikipedia:Template test cases") page'[](https://freemwiki.com/wiki/Module:Documentation/#L-360) -- 'sandbox-notice-pagetype-other' --> 'sandbox page'[](https://freemwiki.com/wiki/Module:Documentation/#L-361) -- 'sandbox-notice-compare-link-display' --> 'diff'[](https://freemwiki.com/wiki/Module:Documentation/#L-362) -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'[](https://freemwiki.com/wiki/Module:Documentation/#L-363) -- 'sandbox-notice-testcases-link-display' --> 'test cases'[](https://freemwiki.com/wiki/Module:Documentation/#L-364) -- 'sandbox-category' --> 'Template sandboxes'[](https://freemwiki.com/wiki/Module:Documentation/#L-365) -- 'module-sandbox-category' --> 'Module sandboxes'[](https://freemwiki.com/wiki/Module:Documentation/#L-366) -- 'other-sandbox-category' --> 'Sandboxes outside of template or module namespace'[](https://freemwiki.com/wiki/Module:Documentation/#L-367) --]=][](https://freemwiki.com/wiki/Module:Documentation/#L-368)local title = env.title[](https://freemwiki.com/wiki/Module:Documentation/#L-369)local sandboxTitle = env.sandboxTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-370)local templateTitle = env.templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-371)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-372)if not (subjectSpace and title and sandboxTitle and templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-373)and mw.title.equals(title, sandboxTitle)) then[](https://freemwiki.com/wiki/Module:Documentation/#L-374)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-375)end[](https://freemwiki.com/wiki/Module:Documentation/#L-376)-- Build the table of arguments to pass to {{[ombox](https://freemwiki.com/wiki/Template:Ombox "Template:Ombox")}}. We need just two fields, "image" and "text".[](https://freemwiki.com/wiki/Module:Documentation/#L-377)local omargs = {}[](https://freemwiki.com/wiki/Module:Documentation/#L-378)omargs.image = message('sandbox-notice-image')[](https://freemwiki.com/wiki/Module:Documentation/#L-379)-- Get the text. We start with the opening blurb, which is something like[](https://freemwiki.com/wiki/Module:Documentation/#L-380)-- "This is the template sandbox for [[[Template:Foo]]](https://freemwiki.com/wiki/Template:Foo "Template:Foo") (diff)."[](https://freemwiki.com/wiki/Module:Documentation/#L-381)local text = '__EXPECTUNUSEDTEMPLATE__'[](https://freemwiki.com/wiki/Module:Documentation/#L-382)local pagetype, sandboxCat[](https://freemwiki.com/wiki/Module:Documentation/#L-383)if subjectSpace == 10 then[](https://freemwiki.com/wiki/Module:Documentation/#L-384)pagetype = message('sandbox-notice-pagetype-template')[](https://freemwiki.com/wiki/Module:Documentation/#L-385)sandboxCat = message('sandbox-category')[](https://freemwiki.com/wiki/Module:Documentation/#L-386)elseif subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-387)pagetype = message('sandbox-notice-pagetype-module')[](https://freemwiki.com/wiki/Module:Documentation/#L-388)sandboxCat = message('module-sandbox-category')[](https://freemwiki.com/wiki/Module:Documentation/#L-389)else[](https://freemwiki.com/wiki/Module:Documentation/#L-390)pagetype = message('sandbox-notice-pagetype-other')[](https://freemwiki.com/wiki/Module:Documentation/#L-391)sandboxCat = message('other-sandbox-category')[](https://freemwiki.com/wiki/Module:Documentation/#L-392)end[](https://freemwiki.com/wiki/Module:Documentation/#L-393)local templateLink = makeWikilink(templateTitle.prefixedText)[](https://freemwiki.com/wiki/Module:Documentation/#L-394)local compareUrl = env.compareUrl[](https://freemwiki.com/wiki/Module:Documentation/#L-395)if compareUrl then[](https://freemwiki.com/wiki/Module:Documentation/#L-396)local compareDisplay = message('sandbox-notice-compare-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-397)local compareLink = makeUrlLink(compareUrl, compareDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-398)text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-399)else[](https://freemwiki.com/wiki/Module:Documentation/#L-400)text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-401)end[](https://freemwiki.com/wiki/Module:Documentation/#L-402)-- Get the test cases page blurb if the page exists. This is something like[](https://freemwiki.com/wiki/Module:Documentation/#L-403)-- "See also the companion subpage for [[[Template:Foo/testcases|test cases]]](https://freemwiki.com/wiki/Template:Foo/testcases "Template:Foo/testcases")."[](https://freemwiki.com/wiki/Module:Documentation/#L-404)local testcasesTitle = env.testcasesTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-405)if testcasesTitle and testcasesTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-406)if testcasesTitle.contentModel == "Scribunto" then[](https://freemwiki.com/wiki/Module:Documentation/#L-407)local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-408)local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-409)local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-410)local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-411)text = text .. '
' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-412)else[](https://freemwiki.com/wiki/Module:Documentation/#L-413)local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-414)local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-415)text = text .. '
' .. message('sandbox-notice-testcases-blurb', {testcasesLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-416)end[](https://freemwiki.com/wiki/Module:Documentation/#L-417)end[](https://freemwiki.com/wiki/Module:Documentation/#L-418)[](https://freemwiki.com/wiki/Module:Documentation/#L-419)-- Add the sandbox to the sandbox category.[](https://freemwiki.com/wiki/Module:Documentation/#L-420)omargs.text = text .. makeCategoryLink(sandboxCat)[](https://freemwiki.com/wiki/Module:Documentation/#L-421)[](https://freemwiki.com/wiki/Module:Documentation/#L-422)-- 'documentation-clear'[](https://freemwiki.com/wiki/Module:Documentation/#L-423)return '
'[](https://freemwiki.com/wiki/Module:Documentation/#L-424).. require(['Module:Message box'](https://freemwiki.com/wiki/Module:Message_box)).main('ombox', omargs)[](https://freemwiki.com/wiki/Module:Documentation/#L-425)end[](https://freemwiki.com/wiki/Module:Documentation/#L-426)[](https://freemwiki.com/wiki/Module:Documentation/#L-427)function p.protectionTemplate(env)[](https://freemwiki.com/wiki/Module:Documentation/#L-428)-- Generates the padlock icon in the top right.[](https://freemwiki.com/wiki/Module:Documentation/#L-429)-- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-430)-- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-431)-- 'protection-template' --> 'pp-template'[](https://freemwiki.com/wiki/Module:Documentation/#L-432)-- 'protection-template-args' --> {docusage = 'yes'}[](https://freemwiki.com/wiki/Module:Documentation/#L-433)local protectionLevels = env.protectionLevels[](https://freemwiki.com/wiki/Module:Documentation/#L-434)if not protectionLevels then[](https://freemwiki.com/wiki/Module:Documentation/#L-435)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-436)end[](https://freemwiki.com/wiki/Module:Documentation/#L-437)local editProt = protectionLevels.edit and protectionLevels.edit[1][](https://freemwiki.com/wiki/Module:Documentation/#L-438)local moveProt = protectionLevels.move and protectionLevels.move[1][](https://freemwiki.com/wiki/Module:Documentation/#L-439)if editProt then[](https://freemwiki.com/wiki/Module:Documentation/#L-440)-- The page is edit-protected.[](https://freemwiki.com/wiki/Module:Documentation/#L-441)return require(['Module:Protection banner'](https://freemwiki.com/wiki/Module:Protection_banner))._main{[](https://freemwiki.com/wiki/Module:Documentation/#L-442)message('protection-reason-edit'), small = true[](https://freemwiki.com/wiki/Module:Documentation/#L-443)}[](https://freemwiki.com/wiki/Module:Documentation/#L-444)elseif moveProt and moveProt ~= 'autoconfirmed' then[](https://freemwiki.com/wiki/Module:Documentation/#L-445)-- The page is move-protected but not edit-protected. Exclude move[](https://freemwiki.com/wiki/Module:Documentation/#L-446)-- protection with the level "autoconfirmed", as this is equivalent to[](https://freemwiki.com/wiki/Module:Documentation/#L-447)-- no move protection at all.[](https://freemwiki.com/wiki/Module:Documentation/#L-448)return require(['Module:Protection banner'](https://freemwiki.com/wiki/Module:Protection_banner))._main{[](https://freemwiki.com/wiki/Module:Documentation/#L-449)action = 'move', small = true[](https://freemwiki.com/wiki/Module:Documentation/#L-450)}[](https://freemwiki.com/wiki/Module:Documentation/#L-451)else[](https://freemwiki.com/wiki/Module:Documentation/#L-452)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-453)end[](https://freemwiki.com/wiki/Module:Documentation/#L-454)end[](https://freemwiki.com/wiki/Module:Documentation/#L-455)[](https://freemwiki.com/wiki/Module:Documentation/#L-456)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-457)-- Start box[](https://freemwiki.com/wiki/Module:Documentation/#L-458)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-459)[](https://freemwiki.com/wiki/Module:Documentation/#L-460)p.startBox = makeInvokeFunc('_startBox')[](https://freemwiki.com/wiki/Module:Documentation/#L-461)[](https://freemwiki.com/wiki/Module:Documentation/#L-462)function p._startBox(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-463)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-464) -- This function generates the start box.[](https://freemwiki.com/wiki/Module:Documentation/#L-465) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-466) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-467) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-468) -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make[](https://freemwiki.com/wiki/Module:Documentation/#L-469) -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox[](https://freemwiki.com/wiki/Module:Documentation/#L-470) -- which generate the box HTML.[](https://freemwiki.com/wiki/Module:Documentation/#L-471) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-472)env = env or p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-473)local links[](https://freemwiki.com/wiki/Module:Documentation/#L-474)local content = args.content[](https://freemwiki.com/wiki/Module:Documentation/#L-475)if not content or args[1] then[](https://freemwiki.com/wiki/Module:Documentation/#L-476)-- No need to include the links if the documentation is on the template page itself.[](https://freemwiki.com/wiki/Module:Documentation/#L-477)local linksData = p.makeStartBoxLinksData(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-478)if linksData then[](https://freemwiki.com/wiki/Module:Documentation/#L-479)links = p.renderStartBoxLinks(linksData)[](https://freemwiki.com/wiki/Module:Documentation/#L-480)end[](https://freemwiki.com/wiki/Module:Documentation/#L-481)end[](https://freemwiki.com/wiki/Module:Documentation/#L-482)-- Generate the start box html.[](https://freemwiki.com/wiki/Module:Documentation/#L-483)local data = p.makeStartBoxData(args, env, links)[](https://freemwiki.com/wiki/Module:Documentation/#L-484)if data then[](https://freemwiki.com/wiki/Module:Documentation/#L-485)return p.renderStartBox(data)[](https://freemwiki.com/wiki/Module:Documentation/#L-486)else[](https://freemwiki.com/wiki/Module:Documentation/#L-487)-- User specified no heading.[](https://freemwiki.com/wiki/Module:Documentation/#L-488)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-489)end[](https://freemwiki.com/wiki/Module:Documentation/#L-490)end[](https://freemwiki.com/wiki/Module:Documentation/#L-491)[](https://freemwiki.com/wiki/Module:Documentation/#L-492)function p.makeStartBoxLinksData(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-493)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-494) -- Does initial processing of data to make the [view] [edit] [history] [purge] links.[](https://freemwiki.com/wiki/Module:Documentation/#L-495) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-496) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-497) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-498) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-499) -- 'view-link-display' --> 'view'[](https://freemwiki.com/wiki/Module:Documentation/#L-500) -- 'edit-link-display' --> 'edit'[](https://freemwiki.com/wiki/Module:Documentation/#L-501) -- 'history-link-display' --> 'history'[](https://freemwiki.com/wiki/Module:Documentation/#L-502) -- 'purge-link-display' --> 'purge'[](https://freemwiki.com/wiki/Module:Documentation/#L-503) -- 'module-preload' --> 'Template:Documentation/preload-module-doc'[](https://freemwiki.com/wiki/Module:Documentation/#L-504) -- 'docpage-preload' --> 'Template:Documentation/preload'[](https://freemwiki.com/wiki/Module:Documentation/#L-505) -- 'create-link-display' --> 'create'[](https://freemwiki.com/wiki/Module:Documentation/#L-506) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-507)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-508)local title = env.title[](https://freemwiki.com/wiki/Module:Documentation/#L-509)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-510)if not title or not docTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-511)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-512)end[](https://freemwiki.com/wiki/Module:Documentation/#L-513)if docTitle.isRedirect then [](https://freemwiki.com/wiki/Module:Documentation/#L-514)docTitle = docTitle.redirectTarget[](https://freemwiki.com/wiki/Module:Documentation/#L-515)end[](https://freemwiki.com/wiki/Module:Documentation/#L-516)[](https://freemwiki.com/wiki/Module:Documentation/#L-517)-- Create link if /doc doesn't exist.[](https://freemwiki.com/wiki/Module:Documentation/#L-518)local preload = args.preload[](https://freemwiki.com/wiki/Module:Documentation/#L-519)if not preload then[](https://freemwiki.com/wiki/Module:Documentation/#L-520)if subjectSpace == 828 then -- Module namespace[](https://freemwiki.com/wiki/Module:Documentation/#L-521)preload = message('module-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-522)else[](https://freemwiki.com/wiki/Module:Documentation/#L-523)preload = message('docpage-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-524)end[](https://freemwiki.com/wiki/Module:Documentation/#L-525)end[](https://freemwiki.com/wiki/Module:Documentation/#L-526)[](https://freemwiki.com/wiki/Module:Documentation/#L-527)return {[](https://freemwiki.com/wiki/Module:Documentation/#L-528)title = title,[](https://freemwiki.com/wiki/Module:Documentation/#L-529)docTitle = docTitle,[](https://freemwiki.com/wiki/Module:Documentation/#L-530)-- View, display, edit, and purge links if /doc exists.[](https://freemwiki.com/wiki/Module:Documentation/#L-531)viewLinkDisplay = message('view-link-display'),[](https://freemwiki.com/wiki/Module:Documentation/#L-532)editLinkDisplay = message('edit-link-display'),[](https://freemwiki.com/wiki/Module:Documentation/#L-533)historyLinkDisplay = message('history-link-display'),[](https://freemwiki.com/wiki/Module:Documentation/#L-534)purgeLinkDisplay = message('purge-link-display'),[](https://freemwiki.com/wiki/Module:Documentation/#L-535)preload = preload,[](https://freemwiki.com/wiki/Module:Documentation/#L-536)createLinkDisplay = message('create-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-537)}[](https://freemwiki.com/wiki/Module:Documentation/#L-538)end[](https://freemwiki.com/wiki/Module:Documentation/#L-539)[](https://freemwiki.com/wiki/Module:Documentation/#L-540)function p.renderStartBoxLinks(data)[](https://freemwiki.com/wiki/Module:Documentation/#L-541)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-542) -- Generates the [view][edit][history][purge] or [create][purge] links from the data table.[](https://freemwiki.com/wiki/Module:Documentation/#L-543) -- @data - a table of data generated by p.makeStartBoxLinksData[](https://freemwiki.com/wiki/Module:Documentation/#L-544) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-545)local docTitle = data.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-546)-- yes, we do intend to purge the template page on which the documentation appears[](https://freemwiki.com/wiki/Module:Documentation/#L-547)local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-548)[](https://freemwiki.com/wiki/Module:Documentation/#L-549)if docTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-550)local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-551)local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-552)local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-553)return "[" .. viewLink .. "] [" .. editLink .. "] [" .. historyLink .. "] [" .. purgeLink .. "]"[](https://freemwiki.com/wiki/Module:Documentation/#L-554)else[](https://freemwiki.com/wiki/Module:Documentation/#L-555)local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-556)return "[" .. createLink .. "] [" .. purgeLink .. "]"[](https://freemwiki.com/wiki/Module:Documentation/#L-557)end[](https://freemwiki.com/wiki/Module:Documentation/#L-558)return ret[](https://freemwiki.com/wiki/Module:Documentation/#L-559)end[](https://freemwiki.com/wiki/Module:Documentation/#L-560)[](https://freemwiki.com/wiki/Module:Documentation/#L-561)function p.makeStartBoxData(args, env, links)[](https://freemwiki.com/wiki/Module:Documentation/#L-562)--[=[[](https://freemwiki.com/wiki/Module:Documentation/#L-563) -- Does initial processing of data to pass to the start-box render function, p.renderStartBox.[](https://freemwiki.com/wiki/Module:Documentation/#L-564) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-565) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-566) -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.[](https://freemwiki.com/wiki/Module:Documentation/#L-567) --[](https://freemwiki.com/wiki/Module:Documentation/#L-568) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-569) -- 'documentation-icon-wikitext' --> '[[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]](https://freemwiki.com/wiki/File:Test_Template_Info-Icon_-_Version_(2).svg "File:Test Template Info-Icon - Version (2).svg")'[](https://freemwiki.com/wiki/Module:Documentation/#L-570) -- 'template-namespace-heading' --> 'Template documentation'[](https://freemwiki.com/wiki/Module:Documentation/#L-571) -- 'module-namespace-heading' --> 'Module documentation'[](https://freemwiki.com/wiki/Module:Documentation/#L-572) -- 'file-namespace-heading' --> 'Summary'[](https://freemwiki.com/wiki/Module:Documentation/#L-573) -- 'other-namespaces-heading' --> 'Documentation'[](https://freemwiki.com/wiki/Module:Documentation/#L-574) -- 'testcases-create-link-display' --> 'create'[](https://freemwiki.com/wiki/Module:Documentation/#L-575) --]=][](https://freemwiki.com/wiki/Module:Documentation/#L-576)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-577)if not subjectSpace then[](https://freemwiki.com/wiki/Module:Documentation/#L-578)-- Default to an "other namespaces" namespace, so that we get at least some output[](https://freemwiki.com/wiki/Module:Documentation/#L-579)-- if an error occurs.[](https://freemwiki.com/wiki/Module:Documentation/#L-580)subjectSpace = 2[](https://freemwiki.com/wiki/Module:Documentation/#L-581)end[](https://freemwiki.com/wiki/Module:Documentation/#L-582)local data = {}[](https://freemwiki.com/wiki/Module:Documentation/#L-583)[](https://freemwiki.com/wiki/Module:Documentation/#L-584)-- Heading[](https://freemwiki.com/wiki/Module:Documentation/#L-585)local heading = args.heading -- Blank values are not removed.[](https://freemwiki.com/wiki/Module:Documentation/#L-586)if heading == '' then[](https://freemwiki.com/wiki/Module:Documentation/#L-587)-- Don't display the start box if the heading arg is defined but blank.[](https://freemwiki.com/wiki/Module:Documentation/#L-588)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-589)end[](https://freemwiki.com/wiki/Module:Documentation/#L-590)if heading then[](https://freemwiki.com/wiki/Module:Documentation/#L-591)data.heading = heading[](https://freemwiki.com/wiki/Module:Documentation/#L-592)elseif subjectSpace == 10 then -- Template namespace[](https://freemwiki.com/wiki/Module:Documentation/#L-593)data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')[](https://freemwiki.com/wiki/Module:Documentation/#L-594)elseif subjectSpace == 828 then -- Module namespace[](https://freemwiki.com/wiki/Module:Documentation/#L-595)data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')[](https://freemwiki.com/wiki/Module:Documentation/#L-596)elseif subjectSpace == 6 then -- File namespace[](https://freemwiki.com/wiki/Module:Documentation/#L-597)data.heading = message('file-namespace-heading')[](https://freemwiki.com/wiki/Module:Documentation/#L-598)else[](https://freemwiki.com/wiki/Module:Documentation/#L-599)data.heading = message('other-namespaces-heading')[](https://freemwiki.com/wiki/Module:Documentation/#L-600)end[](https://freemwiki.com/wiki/Module:Documentation/#L-601)[](https://freemwiki.com/wiki/Module:Documentation/#L-602)-- Heading CSS[](https://freemwiki.com/wiki/Module:Documentation/#L-603)local headingStyle = args['heading-style'][](https://freemwiki.com/wiki/Module:Documentation/#L-604)if headingStyle then[](https://freemwiki.com/wiki/Module:Documentation/#L-605)data.headingStyleText = headingStyle[](https://freemwiki.com/wiki/Module:Documentation/#L-606)else[](https://freemwiki.com/wiki/Module:Documentation/#L-607)-- 'documentation-heading'[](https://freemwiki.com/wiki/Module:Documentation/#L-608)data.headingClass = message('main-div-heading-class')[](https://freemwiki.com/wiki/Module:Documentation/#L-609)end[](https://freemwiki.com/wiki/Module:Documentation/#L-610)[](https://freemwiki.com/wiki/Module:Documentation/#L-611)-- Data for the [view][edit][history][purge] or [create] links.[](https://freemwiki.com/wiki/Module:Documentation/#L-612)if links then[](https://freemwiki.com/wiki/Module:Documentation/#L-613)-- 'mw-editsection-like plainlinks'[](https://freemwiki.com/wiki/Module:Documentation/#L-614)data.linksClass = message('start-box-link-classes')[](https://freemwiki.com/wiki/Module:Documentation/#L-615)data.links = links[](https://freemwiki.com/wiki/Module:Documentation/#L-616)end[](https://freemwiki.com/wiki/Module:Documentation/#L-617)[](https://freemwiki.com/wiki/Module:Documentation/#L-618)return data[](https://freemwiki.com/wiki/Module:Documentation/#L-619)end[](https://freemwiki.com/wiki/Module:Documentation/#L-620)[](https://freemwiki.com/wiki/Module:Documentation/#L-621)function p.renderStartBox(data)[](https://freemwiki.com/wiki/Module:Documentation/#L-622)-- Renders the start box html.[](https://freemwiki.com/wiki/Module:Documentation/#L-623)-- @data - a table of data generated by p.makeStartBoxData.[](https://freemwiki.com/wiki/Module:Documentation/#L-624)local sbox = mw.html.create('div')[](https://freemwiki.com/wiki/Module:Documentation/#L-625)sbox[](https://freemwiki.com/wiki/Module:Documentation/#L-626)-- 'documentation-startbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-627):addClass(message('start-box-class'))[](https://freemwiki.com/wiki/Module:Documentation/#L-628):newline()[](https://freemwiki.com/wiki/Module:Documentation/#L-629):tag('span')[](https://freemwiki.com/wiki/Module:Documentation/#L-630):addClass(data.headingClass)[](https://freemwiki.com/wiki/Module:Documentation/#L-631):attr('id', 'documentation-heading')[](https://freemwiki.com/wiki/Module:Documentation/#L-632):cssText(data.headingStyleText)[](https://freemwiki.com/wiki/Module:Documentation/#L-633):wikitext(data.heading)[](https://freemwiki.com/wiki/Module:Documentation/#L-634)local links = data.links[](https://freemwiki.com/wiki/Module:Documentation/#L-635)if links then[](https://freemwiki.com/wiki/Module:Documentation/#L-636)sbox:tag('span')[](https://freemwiki.com/wiki/Module:Documentation/#L-637):addClass(data.linksClass)[](https://freemwiki.com/wiki/Module:Documentation/#L-638):attr('id', data.linksId)[](https://freemwiki.com/wiki/Module:Documentation/#L-639):wikitext(links)[](https://freemwiki.com/wiki/Module:Documentation/#L-640)end[](https://freemwiki.com/wiki/Module:Documentation/#L-641)return tostring(sbox)[](https://freemwiki.com/wiki/Module:Documentation/#L-642)end[](https://freemwiki.com/wiki/Module:Documentation/#L-643)[](https://freemwiki.com/wiki/Module:Documentation/#L-644)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-645)-- Documentation content[](https://freemwiki.com/wiki/Module:Documentation/#L-646)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-647)[](https://freemwiki.com/wiki/Module:Documentation/#L-648)p.content = makeInvokeFunc('_content')[](https://freemwiki.com/wiki/Module:Documentation/#L-649)[](https://freemwiki.com/wiki/Module:Documentation/#L-650)function p._content(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-651)-- Displays the documentation contents[](https://freemwiki.com/wiki/Module:Documentation/#L-652)-- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-653)-- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-654)env = env or p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-655)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-656)local content = args.content[](https://freemwiki.com/wiki/Module:Documentation/#L-657)if not content and docTitle and docTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-658)content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}[](https://freemwiki.com/wiki/Module:Documentation/#L-659)end[](https://freemwiki.com/wiki/Module:Documentation/#L-660)-- The line breaks below are necessary so that "=== Headings ===" at the start and end[](https://freemwiki.com/wiki/Module:Documentation/#L-661)-- of docs are interpreted correctly.[](https://freemwiki.com/wiki/Module:Documentation/#L-662)return '\n' .. (content or '') .. '\n' [](https://freemwiki.com/wiki/Module:Documentation/#L-663)end[](https://freemwiki.com/wiki/Module:Documentation/#L-664)[](https://freemwiki.com/wiki/Module:Documentation/#L-665)p.contentTitle = makeInvokeFunc('_contentTitle')[](https://freemwiki.com/wiki/Module:Documentation/#L-666)[](https://freemwiki.com/wiki/Module:Documentation/#L-667)function p._contentTitle(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-668)env = env or p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-669)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-670)if not args.content and docTitle and docTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-671)return docTitle.prefixedText[](https://freemwiki.com/wiki/Module:Documentation/#L-672)else[](https://freemwiki.com/wiki/Module:Documentation/#L-673)return ''[](https://freemwiki.com/wiki/Module:Documentation/#L-674)end[](https://freemwiki.com/wiki/Module:Documentation/#L-675)end[](https://freemwiki.com/wiki/Module:Documentation/#L-676)[](https://freemwiki.com/wiki/Module:Documentation/#L-677)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-678)-- End box[](https://freemwiki.com/wiki/Module:Documentation/#L-679)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-680)[](https://freemwiki.com/wiki/Module:Documentation/#L-681)p.endBox = makeInvokeFunc('_endBox')[](https://freemwiki.com/wiki/Module:Documentation/#L-682)[](https://freemwiki.com/wiki/Module:Documentation/#L-683)function p._endBox(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-684)--[=[[](https://freemwiki.com/wiki/Module:Documentation/#L-685) -- This function generates the end box (also known as the link box).[](https://freemwiki.com/wiki/Module:Documentation/#L-686) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-687) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-688) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-689) --]=][](https://freemwiki.com/wiki/Module:Documentation/#L-690)[](https://freemwiki.com/wiki/Module:Documentation/#L-691)-- Get environment data.[](https://freemwiki.com/wiki/Module:Documentation/#L-692)env = env or p.getEnvironment(args)[](https://freemwiki.com/wiki/Module:Documentation/#L-693)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-694)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-695)if not subjectSpace or not docTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-696)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-697)end[](https://freemwiki.com/wiki/Module:Documentation/#L-698)[](https://freemwiki.com/wiki/Module:Documentation/#L-699)-- Check whether we should output the end box at all. Add the end[](https://freemwiki.com/wiki/Module:Documentation/#L-700)-- box by default if the documentation exists or if we are in the[](https://freemwiki.com/wiki/Module:Documentation/#L-701)-- user, module or template namespaces.[](https://freemwiki.com/wiki/Module:Documentation/#L-702)local linkBox = args['link box'][](https://freemwiki.com/wiki/Module:Documentation/#L-703)if linkBox == 'off'[](https://freemwiki.com/wiki/Module:Documentation/#L-704)or not ([](https://freemwiki.com/wiki/Module:Documentation/#L-705)docTitle.exists[](https://freemwiki.com/wiki/Module:Documentation/#L-706)or subjectSpace == 2[](https://freemwiki.com/wiki/Module:Documentation/#L-707)or subjectSpace == 828[](https://freemwiki.com/wiki/Module:Documentation/#L-708)or subjectSpace == 10[](https://freemwiki.com/wiki/Module:Documentation/#L-709))[](https://freemwiki.com/wiki/Module:Documentation/#L-710)then[](https://freemwiki.com/wiki/Module:Documentation/#L-711)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-712)end[](https://freemwiki.com/wiki/Module:Documentation/#L-713)[](https://freemwiki.com/wiki/Module:Documentation/#L-714)-- Assemble the link box.[](https://freemwiki.com/wiki/Module:Documentation/#L-715)local text = ''[](https://freemwiki.com/wiki/Module:Documentation/#L-716)if linkBox then[](https://freemwiki.com/wiki/Module:Documentation/#L-717)text = text .. linkBox[](https://freemwiki.com/wiki/Module:Documentation/#L-718)else[](https://freemwiki.com/wiki/Module:Documentation/#L-719)text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[[Foo]]](https://freemwiki.com/wiki/Foo "Foo")." [](https://freemwiki.com/wiki/Module:Documentation/#L-720)if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-721)-- We are in the user, template or module namespaces.[](https://freemwiki.com/wiki/Module:Documentation/#L-722)-- Add sandbox and testcases links.[](https://freemwiki.com/wiki/Module:Documentation/#L-723)-- "Editors can experiment in this template's sandbox and testcases pages."[](https://freemwiki.com/wiki/Module:Documentation/#L-724)text = text .. (p.makeExperimentBlurb(args, env) or '') .. '
'[](https://freemwiki.com/wiki/Module:Documentation/#L-725)if not args.content and not args[1] then[](https://freemwiki.com/wiki/Module:Documentation/#L-726)-- "Please add categories to the /doc subpage."[](https://freemwiki.com/wiki/Module:Documentation/#L-727)-- Don't show this message with inline docs or with an explicitly specified doc page,[](https://freemwiki.com/wiki/Module:Documentation/#L-728)-- as then it is unclear where to add the categories.[](https://freemwiki.com/wiki/Module:Documentation/#L-729)text = text .. (p.makeCategoriesBlurb(args, env) or '')[](https://freemwiki.com/wiki/Module:Documentation/#L-730)end[](https://freemwiki.com/wiki/Module:Documentation/#L-731)text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"[](https://freemwiki.com/wiki/Module:Documentation/#L-732)end[](https://freemwiki.com/wiki/Module:Documentation/#L-733)end[](https://freemwiki.com/wiki/Module:Documentation/#L-734)[](https://freemwiki.com/wiki/Module:Documentation/#L-735)local box = mw.html.create('div')[](https://freemwiki.com/wiki/Module:Documentation/#L-736)-- 'documentation-metadata'[](https://freemwiki.com/wiki/Module:Documentation/#L-737)box:attr('role', 'note')[](https://freemwiki.com/wiki/Module:Documentation/#L-738):addClass(message('end-box-class'))[](https://freemwiki.com/wiki/Module:Documentation/#L-739)-- 'plainlinks'[](https://freemwiki.com/wiki/Module:Documentation/#L-740):addClass(message('end-box-plainlinks'))[](https://freemwiki.com/wiki/Module:Documentation/#L-741):wikitext(text)[](https://freemwiki.com/wiki/Module:Documentation/#L-742):done()[](https://freemwiki.com/wiki/Module:Documentation/#L-743)[](https://freemwiki.com/wiki/Module:Documentation/#L-744)return '\n' .. tostring(box)[](https://freemwiki.com/wiki/Module:Documentation/#L-745)end[](https://freemwiki.com/wiki/Module:Documentation/#L-746)[](https://freemwiki.com/wiki/Module:Documentation/#L-747)function p.makeDocPageBlurb(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-748)--[=[[](https://freemwiki.com/wiki/Module:Documentation/#L-749) -- Makes the blurb "This documentation is transcluded from [[[Template:Foo]]](https://freemwiki.com/wiki/Template:Foo "Template:Foo") (edit, history)".[](https://freemwiki.com/wiki/Module:Documentation/#L-750) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-751) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-752) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-753) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-754) -- 'edit-link-display' --> 'edit'[](https://freemwiki.com/wiki/Module:Documentation/#L-755) -- 'history-link-display' --> 'history'[](https://freemwiki.com/wiki/Module:Documentation/#L-756) -- 'transcluded-from-blurb' --> [](https://freemwiki.com/wiki/Module:Documentation/#L-757) -- 'The above [[[Wikipedia:Template documentation|documentation]]](https://freemwiki.com/wiki/Wikipedia:Template_documentation "Wikipedia:Template documentation") [](https://freemwiki.com/wiki/Module:Documentation/#L-758) -- is [[[Help:Transclusion|transcluded]]](https://freemwiki.com/wiki/Help:Transclusion "Help:Transclusion") from $1.'[](https://freemwiki.com/wiki/Module:Documentation/#L-759) -- 'module-preload' --> 'Template:Documentation/preload-module-doc'[](https://freemwiki.com/wiki/Module:Documentation/#L-760) -- 'create-link-display' --> 'create'[](https://freemwiki.com/wiki/Module:Documentation/#L-761) -- 'create-module-doc-blurb' -->[](https://freemwiki.com/wiki/Module:Documentation/#L-762) -- 'You might want to $1 a documentation page for this [[[Wikipedia:Lua|Scribunto module]]](https://freemwiki.com/wiki/Wikipedia:Lua "Wikipedia:Lua").'[](https://freemwiki.com/wiki/Module:Documentation/#L-763) --]=][](https://freemwiki.com/wiki/Module:Documentation/#L-764)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-765)if not docTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-766)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-767)end[](https://freemwiki.com/wiki/Module:Documentation/#L-768)if docTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-769)-- /doc exists; link to it.[](https://freemwiki.com/wiki/Module:Documentation/#L-770)local docLink = makeWikilink(docTitle.prefixedText)[](https://freemwiki.com/wiki/Module:Documentation/#L-771)local editDisplay = message('edit-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-772)local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, editDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-773)local historyDisplay = message('history-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-774)local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, historyDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-775)return message('transcluded-from-blurb', {docLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-776).. ' '[](https://freemwiki.com/wiki/Module:Documentation/#L-777).. makeToolbar(editLink, historyLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-778).. '
'[](https://freemwiki.com/wiki/Module:Documentation/#L-779)elseif env.subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-780)-- /doc does not exist; ask to create it.[](https://freemwiki.com/wiki/Module:Documentation/#L-781)local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')}[](https://freemwiki.com/wiki/Module:Documentation/#L-782)local createDisplay = message('create-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-783)local createLink = makeUrlLink(createUrl, createDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-784)return message('create-module-doc-blurb', {createLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-785).. '
'[](https://freemwiki.com/wiki/Module:Documentation/#L-786)end[](https://freemwiki.com/wiki/Module:Documentation/#L-787)end[](https://freemwiki.com/wiki/Module:Documentation/#L-788)[](https://freemwiki.com/wiki/Module:Documentation/#L-789)function p.makeExperimentBlurb(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-790)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-791) -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages."[](https://freemwiki.com/wiki/Module:Documentation/#L-792) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-793) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-794) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-795) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-796) -- 'sandbox-link-display' --> 'sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-797) -- 'sandbox-edit-link-display' --> 'edit'[](https://freemwiki.com/wiki/Module:Documentation/#L-798) -- 'compare-link-display' --> 'diff'[](https://freemwiki.com/wiki/Module:Documentation/#L-799) -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-800) -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-801) -- 'sandbox-create-link-display' --> 'create'[](https://freemwiki.com/wiki/Module:Documentation/#L-802) -- 'mirror-edit-summary' --> 'Create sandbox version of $1'[](https://freemwiki.com/wiki/Module:Documentation/#L-803) -- 'mirror-link-display' --> 'mirror'[](https://freemwiki.com/wiki/Module:Documentation/#L-804) -- 'mirror-link-preload' --> 'Template:Documentation/mirror'[](https://freemwiki.com/wiki/Module:Documentation/#L-805) -- 'sandbox-link-display' --> 'sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-806) -- 'testcases-link-display' --> 'testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-807) -- 'testcases-edit-link-display'--> 'edit'[](https://freemwiki.com/wiki/Module:Documentation/#L-808) -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'[](https://freemwiki.com/wiki/Module:Documentation/#L-809) -- 'testcases-create-link-display' --> 'create'[](https://freemwiki.com/wiki/Module:Documentation/#L-810) -- 'testcases-link-display' --> 'testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-811) -- 'testcases-edit-link-display' --> 'edit'[](https://freemwiki.com/wiki/Module:Documentation/#L-812) -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-813) -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-814) -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.'[](https://freemwiki.com/wiki/Module:Documentation/#L-815) -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.'[](https://freemwiki.com/wiki/Module:Documentation/#L-816) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-817)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-818)local templateTitle = env.templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-819)local sandboxTitle = env.sandboxTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-820)local testcasesTitle = env.testcasesTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-821)local templatePage = templateTitle.prefixedText[](https://freemwiki.com/wiki/Module:Documentation/#L-822)if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-823)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-824)end[](https://freemwiki.com/wiki/Module:Documentation/#L-825)-- Make links.[](https://freemwiki.com/wiki/Module:Documentation/#L-826)local sandboxLinks, testcasesLinks[](https://freemwiki.com/wiki/Module:Documentation/#L-827)if sandboxTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-828)local sandboxPage = sandboxTitle.prefixedText[](https://freemwiki.com/wiki/Module:Documentation/#L-829)local sandboxDisplay = message('sandbox-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-830)local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-831)local sandboxEditDisplay = message('sandbox-edit-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-832)local sandboxEditLink = makeWikilink("Special:EditPage/" .. sandboxPage, sandboxEditDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-833)local compareUrl = env.compareUrl[](https://freemwiki.com/wiki/Module:Documentation/#L-834)local compareLink[](https://freemwiki.com/wiki/Module:Documentation/#L-835)if compareUrl then[](https://freemwiki.com/wiki/Module:Documentation/#L-836)local compareDisplay = message('compare-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-837)compareLink = makeUrlLink(compareUrl, compareDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-838)end[](https://freemwiki.com/wiki/Module:Documentation/#L-839)sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-840)else[](https://freemwiki.com/wiki/Module:Documentation/#L-841)local sandboxPreload[](https://freemwiki.com/wiki/Module:Documentation/#L-842)if subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-843)sandboxPreload = message('module-sandbox-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-844)else[](https://freemwiki.com/wiki/Module:Documentation/#L-845)sandboxPreload = message('template-sandbox-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-846)end[](https://freemwiki.com/wiki/Module:Documentation/#L-847)local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload}[](https://freemwiki.com/wiki/Module:Documentation/#L-848)local sandboxCreateDisplay = message('sandbox-create-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-849)local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-850)local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})[](https://freemwiki.com/wiki/Module:Documentation/#L-851)local mirrorPreload = message('mirror-link-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-852)local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}[](https://freemwiki.com/wiki/Module:Documentation/#L-853)if subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-854)mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}[](https://freemwiki.com/wiki/Module:Documentation/#L-855)end[](https://freemwiki.com/wiki/Module:Documentation/#L-856)local mirrorDisplay = message('mirror-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-857)local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-858)sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-859)end[](https://freemwiki.com/wiki/Module:Documentation/#L-860)if testcasesTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-861)local testcasesPage = testcasesTitle.prefixedText[](https://freemwiki.com/wiki/Module:Documentation/#L-862)local testcasesDisplay = message('testcases-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-863)local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-864)local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'}[](https://freemwiki.com/wiki/Module:Documentation/#L-865)local testcasesEditDisplay = message('testcases-edit-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-866)local testcasesEditLink = makeWikilink("Special:EditPage/" .. testcasesPage, testcasesEditDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-867)-- for Modules, add testcases run link if exists[](https://freemwiki.com/wiki/Module:Documentation/#L-868)if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then[](https://freemwiki.com/wiki/Module:Documentation/#L-869)local testcasesRunLinkDisplay = message('testcases-run-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-870)local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-871)testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-872)else[](https://freemwiki.com/wiki/Module:Documentation/#L-873)testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-874)end[](https://freemwiki.com/wiki/Module:Documentation/#L-875)else[](https://freemwiki.com/wiki/Module:Documentation/#L-876)local testcasesPreload[](https://freemwiki.com/wiki/Module:Documentation/#L-877)if subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-878)testcasesPreload = message('module-testcases-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-879)else[](https://freemwiki.com/wiki/Module:Documentation/#L-880)testcasesPreload = message('template-testcases-preload')[](https://freemwiki.com/wiki/Module:Documentation/#L-881)end[](https://freemwiki.com/wiki/Module:Documentation/#L-882)local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload}[](https://freemwiki.com/wiki/Module:Documentation/#L-883)local testcasesCreateDisplay = message('testcases-create-link-display')[](https://freemwiki.com/wiki/Module:Documentation/#L-884)local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)[](https://freemwiki.com/wiki/Module:Documentation/#L-885)testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)[](https://freemwiki.com/wiki/Module:Documentation/#L-886)end[](https://freemwiki.com/wiki/Module:Documentation/#L-887)local messageName[](https://freemwiki.com/wiki/Module:Documentation/#L-888)if subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-889)messageName = 'experiment-blurb-module'[](https://freemwiki.com/wiki/Module:Documentation/#L-890)else[](https://freemwiki.com/wiki/Module:Documentation/#L-891)messageName = 'experiment-blurb-template'[](https://freemwiki.com/wiki/Module:Documentation/#L-892)end[](https://freemwiki.com/wiki/Module:Documentation/#L-893)return message(messageName, {sandboxLinks, testcasesLinks})[](https://freemwiki.com/wiki/Module:Documentation/#L-894)end[](https://freemwiki.com/wiki/Module:Documentation/#L-895)[](https://freemwiki.com/wiki/Module:Documentation/#L-896)function p.makeCategoriesBlurb(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-897)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-898) -- Generates the text "Please add categories to the /doc subpage."[](https://freemwiki.com/wiki/Module:Documentation/#L-899) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-900) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-901) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-902) -- 'doc-link-display' --> '/doc'[](https://freemwiki.com/wiki/Module:Documentation/#L-903) -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.'[](https://freemwiki.com/wiki/Module:Documentation/#L-904) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-905)local docTitle = env.docTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-906)if not docTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-907)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-908)end[](https://freemwiki.com/wiki/Module:Documentation/#L-909)local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))[](https://freemwiki.com/wiki/Module:Documentation/#L-910)return message('add-categories-blurb', {docPathLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-911)end[](https://freemwiki.com/wiki/Module:Documentation/#L-912)[](https://freemwiki.com/wiki/Module:Documentation/#L-913)function p.makeSubpagesBlurb(args, env)[](https://freemwiki.com/wiki/Module:Documentation/#L-914)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-915) -- Generates the "Subpages of this template" link.[](https://freemwiki.com/wiki/Module:Documentation/#L-916) -- @args - a table of arguments passed by the user[](https://freemwiki.com/wiki/Module:Documentation/#L-917) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-918)[](https://freemwiki.com/wiki/Module:Documentation/#L-919) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-920) -- 'template-pagetype' --> 'template'[](https://freemwiki.com/wiki/Module:Documentation/#L-921) -- 'module-pagetype' --> 'module'[](https://freemwiki.com/wiki/Module:Documentation/#L-922) -- 'default-pagetype' --> 'page'[](https://freemwiki.com/wiki/Module:Documentation/#L-923) -- 'subpages-link-display' --> 'Subpages of this $1'[](https://freemwiki.com/wiki/Module:Documentation/#L-924) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-925)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-926)local templateTitle = env.templateTitle[](https://freemwiki.com/wiki/Module:Documentation/#L-927)if not subjectSpace or not templateTitle then[](https://freemwiki.com/wiki/Module:Documentation/#L-928)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-929)end[](https://freemwiki.com/wiki/Module:Documentation/#L-930)local pagetype[](https://freemwiki.com/wiki/Module:Documentation/#L-931)if subjectSpace == 10 then[](https://freemwiki.com/wiki/Module:Documentation/#L-932)pagetype = message('template-pagetype')[](https://freemwiki.com/wiki/Module:Documentation/#L-933)elseif subjectSpace == 828 then[](https://freemwiki.com/wiki/Module:Documentation/#L-934)pagetype = message('module-pagetype')[](https://freemwiki.com/wiki/Module:Documentation/#L-935)else[](https://freemwiki.com/wiki/Module:Documentation/#L-936)pagetype = message('default-pagetype')[](https://freemwiki.com/wiki/Module:Documentation/#L-937)end[](https://freemwiki.com/wiki/Module:Documentation/#L-938)local subpagesLink = makeWikilink([](https://freemwiki.com/wiki/Module:Documentation/#L-939)'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',[](https://freemwiki.com/wiki/Module:Documentation/#L-940)message('subpages-link-display', {pagetype})[](https://freemwiki.com/wiki/Module:Documentation/#L-941))[](https://freemwiki.com/wiki/Module:Documentation/#L-942)return message('subpages-blurb', {subpagesLink})[](https://freemwiki.com/wiki/Module:Documentation/#L-943)end[](https://freemwiki.com/wiki/Module:Documentation/#L-944)[](https://freemwiki.com/wiki/Module:Documentation/#L-945)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-946)-- Tracking categories[](https://freemwiki.com/wiki/Module:Documentation/#L-947)----------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Documentation/#L-948)[](https://freemwiki.com/wiki/Module:Documentation/#L-949)function p.addTrackingCategories(env)[](https://freemwiki.com/wiki/Module:Documentation/#L-950)--[[[](https://freemwiki.com/wiki/Module:Documentation/#L-951) -- Check if {{[documentation](https://freemwiki.com/wiki/Template:Documentation "Template:Documentation")}} is transcluded on a /doc or /testcases page.[](https://freemwiki.com/wiki/Module:Documentation/#L-952) -- @env - environment table containing title objects, etc., generated with p.getEnvironment[](https://freemwiki.com/wiki/Module:Documentation/#L-953)[](https://freemwiki.com/wiki/Module:Documentation/#L-954) -- Messages:[](https://freemwiki.com/wiki/Module:Documentation/#L-955) -- 'display-strange-usage-category' --> true[](https://freemwiki.com/wiki/Module:Documentation/#L-956) -- 'doc-subpage' --> 'doc'[](https://freemwiki.com/wiki/Module:Documentation/#L-957) -- 'testcases-subpage' --> 'testcases'[](https://freemwiki.com/wiki/Module:Documentation/#L-958) -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'[](https://freemwiki.com/wiki/Module:Documentation/#L-959) -- [](https://freemwiki.com/wiki/Module:Documentation/#L-960) -- /testcases pages in the module namespace are not categorised, as they may have[](https://freemwiki.com/wiki/Module:Documentation/#L-961) -- {{[documentation](https://freemwiki.com/wiki/Template:Documentation "Template:Documentation")}} transcluded automatically.[](https://freemwiki.com/wiki/Module:Documentation/#L-962) --]][](https://freemwiki.com/wiki/Module:Documentation/#L-963)local title = env.title[](https://freemwiki.com/wiki/Module:Documentation/#L-964)local subjectSpace = env.subjectSpace[](https://freemwiki.com/wiki/Module:Documentation/#L-965)if not title or not subjectSpace then[](https://freemwiki.com/wiki/Module:Documentation/#L-966)return nil[](https://freemwiki.com/wiki/Module:Documentation/#L-967)end[](https://freemwiki.com/wiki/Module:Documentation/#L-968)local subpage = title.subpageText[](https://freemwiki.com/wiki/Module:Documentation/#L-969)if message('display-strange-usage-category', nil, 'boolean')[](https://freemwiki.com/wiki/Module:Documentation/#L-970)and ([](https://freemwiki.com/wiki/Module:Documentation/#L-971)subpage == message('doc-subpage')[](https://freemwiki.com/wiki/Module:Documentation/#L-972)or subjectSpace ~= 828 and subpage == message('testcases-subpage')[](https://freemwiki.com/wiki/Module:Documentation/#L-973))[](https://freemwiki.com/wiki/Module:Documentation/#L-974)then[](https://freemwiki.com/wiki/Module:Documentation/#L-975)return makeCategoryLink(message('strange-usage-category'))[](https://freemwiki.com/wiki/Module:Documentation/#L-976)end[](https://freemwiki.com/wiki/Module:Documentation/#L-977)return ''[](https://freemwiki.com/wiki/Module:Documentation/#L-978)end[](https://freemwiki.com/wiki/Module:Documentation/#L-979)[](https://freemwiki.com/wiki/Module:Documentation/#L-980)return p
Retrieved from "[https://freemwiki.com/index.php?title=Module:Documentation&oldid=579600](https://freemwiki.com/index.php?title=Module:Documentation&oldid=579600)"
* This page was last edited on 21 October 2025, at 06:18.
* Content is available under [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/) unless otherwise noted. FreemWiki is operated by **FINGERPOWER DIGITAL TECHNOLOGY LLC** (Colorado, Entity ID 20221978727).
* [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy)
* [About](https://freemwiki.com/wiki/About)
* [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service)
* [Mobile view](https://freemwiki.com/index.php?title=Module:Documentation&mobileaction=toggle_view_mobile)