Difference between revisions 51809 and 51810 on wikimaniawiki-- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local htmlBuilder = require('Module:HtmlBuilder') local messageBox = require('Module:Message box') -- Get the config table. (contracted; show full) p.content = makeInvokeFunc('_content') function p._content(args, env) -- Get the /doc title object local success, docTitle = env:grab('docTitle') if not success then return err(docTitle) -- docTitle is an error message end -- Get the documentation content. local content = args.content if not content and docTitle.exists then local frame = mw.getCurrentFrame() content = frame:preprocess('{{ ' .. docTitle.prefixedText .. ' }}') end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. return '\n' .. (content or '') .. '\n' end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) -- This function generates the end box (also known as the link box). -- Get environment data. local subjectSpace = env.subjectSpace local success, docTitle = env:grab('docTitle') if not success then return err(docTitle) -- Error message end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. if linkBox == 'off' or not ( (contracted; show full) return messageBox.main('fmbox', fmargs) end function p.makePrintBlurb(args, env) -- Get the /Print title object local success, printTitle = env:grab('printTitle') if not success then return err(printTitle) -- Error message end -- Make the print blurb. local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('printLinkDisplay', 'string')) ret = message('printBlurb', 'string', {printLink}) local displayPrintCategory = message('displayPrintCategory', 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('printCategory', 'string')) end end return ret end function p.makeSubpagesBlurb(args, env) -- Get the template title object local success, templateTitle = env:grab('templateTitle') if not success then return err(templateTitle) -- Error message. end -- Make the subpages blurb. local pagetype if subjectSpace == 10 then pagetype = message('templatePagetype', 'string') elseif subjectSpace == 828 then pagetype = message('modulePagetype', 'string') else pagetype = message('defaultPagetype', 'string') end return makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpagesLinkDisplay', 'string', {pagetype}) ) end function p.makeCategoriesBlurb(args, env) -- Get the title object. local success, docTitle = env:grab('docTitle') if not success then -- docTitle is the error message. return docTitlreturn err(docTitle) -- Error message end -- Make the blurb. local docPathLink = makeWikilink(docTitle.prefixedText, message('docLinkDisplay', 'string')) return message('addCategoriesBlurb', 'string', {docPathLink}) end function p.makeDocPageBlurb(args, env) -- Get the title object. local success, docTitle = env:grab('docTitle') if not success then -- docTitle is the error message. return docTitlreturn err(docTitle) -- Error message end -- Make the blurb. local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} (contracted; show full) local sort = (title.namespace == 0 and message('strangeUsageCategoryMainspaceSort', 'string') or '') .. title.prefixedText -- Sort on namespace. ret = ret .. makeCategoryLink(message('strangeUsageCategory', 'string'), sort) end return ret end return p All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://wikimania.wikimedia.org/w/index.php?diff=prev&oldid=51810.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|