Difference between revisions 51760 and 51761 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') local p = {} (contracted; show full)end function p._main(args) local root = htmlBuilder.create() root .wikitext(p.protectionTemplate()) .wikitext(p.sandboxNotice(args)) -- This div tag is from {{documentation/start box}}, but moving it here ⏎ -- so that we don't have to worry about unclosed tags. .tag('div') .attr('id', 'template-documentation') .addClass('template-documentation iezoomfix') .wikitext(p.startBox(args)) .wikitext(p.content(args)) .tag('div') .css('clear', 'both') -- So right or left floating items don't stick out of the doc box. (contracted; show full) text = text .. linkBox else if docExist then -- /doc exists; link to it. local docLink = makeWikilink(docpage) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, 'edit') local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, 'history') text = text .. 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from ' ⏎ ⏎ .. docLink .. '. '⏎ ⏎ .. makeToolbar(editLink, historyLink) .. '<br />' elseif subjectSpace == 828 then -- /doc does not exist; ask to create it. local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = 'Template:Documentation/preload-module-doc'}, 'create') text = text .. 'You might want to ' .. createLink .. ' a documentation page for this [[Wikipedia:Lua|Scribunto module]].<br />' end (contracted; show full) text = text .. ' ' .. makeWikilink('Special:PrefixIndex/' .. templatePage .. '/', 'Subpages of this page') end -- Show the "print" link if it exists. local printPage = templatePage .. '/Print' local printTitle = mw.title.new(printPage) if printTitle.exists then text = text .. '<br />A [[Help:Books/for experts#Improving the book layout|print version]] of this template exists at ' ⏎ ⏎ .. makeWikilink(printPage, '/Print') .. '.' .. ' If you make a change to this template, please update the print version as well.' .. '[[Category:Templates with print versions]]' end end end fmargs.text = text -- Return the fmbox output. return messageBox.main('fmbox', fmargs) end function p.addTrackingCategories() -- Check if {{documentation}} is transcluded on a /doc or /testcases page. local ret = '' local subpage = currentTitle.subpageText if subpage == 'doc' or subpage == 'testcases' then local sort = (currentTitle.namespace == 0 and 'Main:' or '') .. currentTitle.prefixedText -- Sort on namespace. ret = ret .. makeWikilink('Category:Wikipedia pages with strange ((documentation)) usage', sort) end return ret end function p.docspace() -- Determines the namespace of the documentation. if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then -- Pages in the Article, File, MediaWiki or Category namespaces must have their -- /doc, /sandbox and /testcases pages in talk space. return mw.site.namespaces[subjectSpace].talk.name else return currentTitle.subjectNsText end end function p.templatePage() -- Determines the template page. No namespace or interwiki prefixes are included. local subpage = currentTitle.subpageText if subpage == 'sandbox' or subpage == 'testcases' then return currentTitle.baseText else return currentTitle.text end 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=51761.
![]() ![]() 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.
|