Jump to content

Module:Documentation and Module:Documentation/sandbox: Difference between pages

(Difference between pages)
Content deleted Content added
cherry pick Module wikitext support from w:en:Module:Documentation
 
use sandbox version of /i18n
 
Line 1: Line 1:
--[[
Add your experimental module code here.
--]]
-- This module implements {{documentation}}.
-- This module implements {{documentation}}.


Line 6: Line 9:


-- Get the config table.
-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')
local cfg = mw.loadData('Module:Documentation/config')
local i18n = mw.loadData('Module:Documentation/i18n')
local i18n = mw.loadData('Module:Documentation/i18n')
local p = {}
local p = {}


Line 137: Line 140:
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 327: Line 329:
-- 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 650: Line 640:
local content = args.content
local content = args.content
if not content and docTitle and docTitle.exists then
if not content and docTitle and docTitle.exists then
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle}
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle}
end
end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end
-- The line breaks below are necessary so that "=== Headings ===" at the start and end