Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
update: ++ subModule subDoc
wp>PerfektesChaos (update: Unterseiten im Modul-Namensraum) |
wp>PerfektesChaos (update: ++ subModule subDoc) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2013- | --[=[ 2013-10-16 | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
* nav() | * nav() | ||
Zeile 169: | Zeile 169: | ||
local function navMerge( start, swift, ns, nsDocs, script ) | local function navMerge( start, swift, ns, nsDocs, script, sub, lead ) | ||
-- Include various external content into page | -- Include various external content into page | ||
-- Precondition: | -- Precondition: | ||
Zeile 176: | Zeile 176: | ||
-- ns -- number; current namespace number | -- ns -- number; current namespace number | ||
-- nsDocs -- number; central documentation namespace number | -- nsDocs -- number; central documentation namespace number | ||
-- script -- string; | -- script -- string; module name (main) | ||
-- sub -- string or false; possible sub-module name | |||
-- lead -- true: Module: namespace; false: text namespace | |||
-- Uses: | -- Uses: | ||
-- >< currentTitle | -- >< currentTitle | ||
Zeile 187: | Zeile 189: | ||
local r | local r | ||
local s | local s | ||
local super | local super = false | ||
local collect = navLangs( nsDocs, start, script ) | local collect = navLangs( nsDocs, start, script ) | ||
local t = navDevelop( nsDocs, start, script ) | local t = navDevelop( nsDocs, start, script ) | ||
Zeile 193: | Zeile 195: | ||
collect.Test = t | collect.Test = t | ||
end | end | ||
if ns == nsDocs | if ns == nsDocs then | ||
s = string.format( "%s/%s", start, script ) | |||
if currentTitle.text == s then | |||
super = currentTitle.text .. "/" | |||
elseif sub then | |||
collect.subDoc = sub | |||
collect.subModule = sub | |||
end | |||
elseif lead and sub then | |||
collect.subDoc = sub | |||
end | end | ||
r = LuaWiki.transclude( swift, collect ) | r = LuaWiki.transclude( swift, collect ) | ||
Zeile 234: | Zeile 241: | ||
else | else | ||
r = r .. LuaWiki.transclude( t.prefixedText ) | r = r .. LuaWiki.transclude( t.prefixedText ) | ||
break | break -- for i | ||
end | end | ||
end | end | ||
Zeile 242: | Zeile 249: | ||
local suppress = LuaWiki.getArg( "noHint", "" ) | local suppress = LuaWiki.getArg( "noHint", "" ) | ||
if #suppress == 0 then | if #suppress == 0 then | ||
r = r .. LuaWiki.transclude( s, collect[ 1 ] ) | |||
end | end | ||
end | end | ||
Zeile 275: | Zeile 282: | ||
local start = LuaWiki.getArg( "pageDocRoot" ) | local start = LuaWiki.getArg( "pageDocRoot" ) | ||
if type( start ) == "string" then | if type( start ) == "string" then | ||
local | local s = "^" | ||
local script | local script | ||
if lead then | if not lead then | ||
s = "^" .. start .. "/" | |||
end | end | ||
if script then | s = s .. "([^/]+)/(.*/?)$" | ||
script, s = mw.ustring.match( currentTitle.text .. "/", s ) | |||
if type( script ) == "string" then | |||
local sub = false | |||
local swift = LuaWiki.getArg( "pageNav" ) | local swift = LuaWiki.getArg( "pageNav" ) | ||
if type( s ) == "string" then | |||
if #s > 1 then | |||
local q | |||
s = s:match( "^([^/]+)/.*/?$" ) | |||
q = mw.title.makeTitle( "Module", | |||
script .. "/" .. s ) | |||
if q.exists and q.contentModel == "Scribunto" then | |||
sub = s | |||
end | |||
end | |||
end | |||
if type( swift ) == "string" then | if type( swift ) == "string" then | ||
r = navMerge( start, swift, ns, nsDocs, script ) | r = navMerge( start, swift, ns, nsDocs, script, sub, lead ) | ||
else | else | ||
r = navError( "configMissing", "pageNav" ) | r = navError( "configMissing", "pageNav" ) | ||
end | end | ||
else | |||
r = navError( "BadPage" ) .. currentTitle.text | |||
end | end | ||
else | else |