Module:Documentation: Difference between revisions
From The FunKey Wiki
Content added Content deleted
m (1 revision imported) |
(Only load Module:Module wikitext if it's actually needed) |
||
Line 129: | Line 129: | ||
local root = mw.html.create() |
local root = mw.html.create() |
||
root |
root |
||
:wikitext(p._getModuleWikitext(args, env)) |
|||
:wikitext(p.protectionTemplate(env)) |
:wikitext(p.protectionTemplate(env)) |
||
:wikitext(p.sandboxNotice(args, env)) |
:wikitext(p.sandboxNotice(args, env)) |
||
Line 323: | Line 324: | ||
-- Auxiliary templates |
-- Auxiliary templates |
||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') |
|||
function p._getModuleWikitext(args, env) |
|||
local currentTitle = mw.title.getCurrentTitle() |
|||
if currentTitle.contentModel ~= 'Scribunto' then return end |
|||
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care |
|||
local moduleWikitext = package.loaded["Module:Module wikitext"] |
|||
if moduleWikitext then |
|||
return moduleWikitext.main() |
|||
end |
|||
end |
|||
function p.sandboxNotice(args, env) |
function p.sandboxNotice(args, env) |
||
Line 376: | Line 389: | ||
local testcasesTitle = env.testcasesTitle |
local testcasesTitle = env.testcasesTitle |
||
if testcasesTitle and testcasesTitle.exists then |
if testcasesTitle and testcasesTitle.exists then |
||
if testcasesTitle. |
if testcasesTitle.contentModel == "Scribunto" then |
||
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') |
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') |
||
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') |
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') |
||
Line 445: | Line 458: | ||
local links |
local links |
||
local content = args.content |
local content = args.content |
||
if not content then |
if not content or args[1] then |
||
-- No need to include the links if the documentation is on the template page itself. |
-- No need to include the links if the documentation is on the template page itself. |
||
local linksData = p.makeStartBoxLinksData(args, env) |
local linksData = p.makeStartBoxLinksData(args, env) |
||
Line 483: | Line 496: | ||
if not title or not docTitle then |
if not title or not docTitle then |
||
return nil |
return nil |
||
end |
|||
if docTitle.isRedirect then |
|||
docTitle = docTitle.redirectTarget |
|||
end |
end |
||
Line 870: | Line 886: | ||
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) |
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) |
||
-- for Modules, add testcases run link if exists |
-- for Modules, add testcases run link if exists |
||
if |
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then |
||
local testcasesRunLinkDisplay = message('testcases-run-link-display') |
local testcasesRunLinkDisplay = message('testcases-run-link-display') |
||
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) |
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) |