Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
update
wp>PerfektesChaos (update) |
wp>PerfektesChaos (update) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2013-05- | --[=[ 2013-05-19 | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
* nav() | * nav() | ||
Zeile 8: | Zeile 8: | ||
-- Module globals | -- Module globals | ||
local | local lucky, LuaWiki = pcall( require, "Module:LuaWiki" ) | ||
local currentTitle | local currentTitle | ||
local function navDevelop( nsDocs, start, script ) | |||
-- Most interesting test and development page | |||
-- Precondition: | |||
-- nsDocs -- number; central documentation namespace number | |||
-- start -- string; central documentation root | |||
-- script -- string; basic module name | |||
-- Return: | |||
-- string or false: full page name, if any | |||
-- Uses: | |||
-- mw.title.makeTitle() | |||
local n = nsDocs | |||
local r = false | |||
local s = start .. "/" .. script .. "/Test" | |||
local t = mw.title.makeTitle( n, s ) | |||
if not t.exists then | |||
s = start .. "/" .. script .. "/test" | |||
t = mw.title.makeTitle( n, s ) | |||
if not t.exists then | |||
n = mw.site.namespaces.Module.id | |||
s = script .. "/Test" | |||
t = mw.title.makeTitle( n, s ) | |||
if not t.exists then | |||
s = script .. "/test" | |||
t = mw.title.makeTitle( n, s ) | |||
t = t.exists | |||
end | |||
end | |||
end | |||
if t then | |||
r = mw.site.namespaces[ n ].name .. ":" .. s | |||
end | |||
return r | |||
end -- navError() | |||
Zeile 76: | Zeile 112: | ||
-- Precondition: | -- Precondition: | ||
-- current page is supposed to transclude LuaModuleDoc | -- current page is supposed to transclude LuaModuleDoc | ||
-- nsDocs -- number; central documentation namespace | -- nsDocs -- number; central documentation namespace number | ||
-- start -- string; central documentation root | -- start -- string; central documentation root | ||
-- script -- string; basic module name | -- script -- string; basic module name | ||
Zeile 131: | Zeile 167: | ||
-- start -- string; defined pageDocRoot argument | -- start -- string; defined pageDocRoot argument | ||
-- swift -- string; defined pageNav argument | -- swift -- string; defined pageNav argument | ||
-- | -- ns -- number; current namespace number | ||
-- | -- nsDocs -- number; central documentation namespace number | ||
-- script -- string; modul name | -- script -- string; modul name | ||
-- Uses: | -- Uses: | ||
Zeile 145: | Zeile 181: | ||
local s | local s | ||
local super | local super | ||
local collect = navLangs( nsDocs, start, script ) | local collect = navLangs( nsDocs, start, script ) | ||
local t = navDevelop( nsDocs, start, script ) | |||
if t then | |||
collect.Test = t | |||
end | |||
if ns == nsDocs and | if ns == nsDocs and | ||
currentTitle.text == start .. "/" .. script then | currentTitle.text == start .. "/" .. script then | ||
Zeile 154: | Zeile 193: | ||
end | end | ||
r = LuaWiki.transclude( swift, collect ) | r = LuaWiki.transclude( swift, collect ) | ||
t = currentTitle.talkPageTitle | |||
if t then | if t then | ||
s = t.exists | s = t.exists | ||
Zeile 246: | Zeile 286: | ||
local swift = LuaWiki.getArg( "pageNav" ) | local swift = LuaWiki.getArg( "pageNav" ) | ||
if type( swift ) == "string" then | if type( swift ) == "string" then | ||
r = navMerge( start, swift, nsDocs | r = navMerge( start, swift, ns, nsDocs, script ) | ||
else | else | ||
r = navError( "configMissing", "pageNav" ) | r = navError( "configMissing", "pageNav" ) | ||
Zeile 297: | Zeile 337: | ||
local r | local r | ||
if type( LuaWiki ) == "table" then | if type( LuaWiki ) == "table" then | ||
r = navigation | lucky, r = pcall( navigation ) | ||
r = r or "" | |||
else | else | ||
r = "<span class='error'>" .. LuaWiki .. "</span>" | r = "<span class='error'>" .. LuaWiki .. "</span>" |