Module:Documentation: Difference between revisions
Content added Content deleted
(add an entry point for MediaWiki:Scribunto-doc-page-does-not-exist to use) |
SecurityXP (talk | contribs) m (1 revision imported: Template) Tags: Mobile edit Mobile web edit |
||
Line 112: | Line 112: | ||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
-- |
-- Main function |
||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
function p.nonexistent(frame) |
|||
if mw.title.getCurrentTitle().subpageText == 'testcases' then |
|||
return frame:expandTemplate{title = 'module test cases notice'} |
|||
⚫ | |||
return p.main(frame) |
|||
⚫ | |||
end |
|||
p.main = makeInvokeFunc('_main') |
p.main = makeInvokeFunc('_main') |
||
Line 137: | 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 332: | Line 323: | ||
-- 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 383: | Line 362: | ||
else |
else |
||
pagetype = message('sandbox-notice-pagetype-other') |
pagetype = message('sandbox-notice-pagetype-other') |
||
⚫ | |||
local pagetypee |
|||
if subjectSpace == 10 then |
|||
pagetypee = message('template-pagetype') |
|||
elseif subjectSpace == 828 then |
|||
pagetypee = message('module-pagetype') |
|||
⚫ | |||
pagetypee = message('other-pagetype') |
|||
end |
end |
||
local templateLink = makeWikilink(templateTitle.prefixedText) |
local templateLink = makeWikilink(templateTitle.prefixedText) |
||
Line 397: | Line 384: | ||
local testcasesTitle = env.testcasesTitle |
local testcasesTitle = env.testcasesTitle |
||
if testcasesTitle and testcasesTitle.exists then |
if testcasesTitle and testcasesTitle.exists then |
||
if testcasesTitle. |
if testcasesTitle.namespace == mw.site.namespaces.Module.id 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') |
||
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) |
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) |
||
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) |
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) |
||
text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) |
text = text .. '<br /><small>' .. message('sandbox-notice-testcases-run-blurb', {pagetypee, testcasesLink, testcasesRunLink}) .. '</small>' |
||
else |
else |
||
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') |
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') |
||
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) |
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) |
||
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) |
text = text .. '<br /><small>' .. message('sandbox-notice-testcases-blurb', {pagetypee, testcasesLink}) .. '</small>' |
||
end |
end |
||
end |
end |
||
Line 466: | Line 453: | ||
local links |
local links |
||
local content = args.content |
local content = args.content |
||
if not content |
if not content 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 504: | Line 491: | ||
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 894: | Line 878: | ||
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 subjectSpace == 828 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) |