Modul:Vorlage:ArmFrGrandeGuerre/test
Zur Navigation springen
Zur Suche springen
Die Dokumentation für dieses Modul kann unter Modul:Vorlage:ArmFrGrandeGuerre/test/Doku erstellt werden
function merge(t1, t2)
for k, v in pairs(t1) do
if (type(v) == "table") and (type(t2[k] or false) == "table") then
merge(t2[k], t1[k])
else
t2[k] = v
end
end
return t2
end
local p = {}
function p.testvolumes(frame)
local r, ret = "", "{| class=\"wikitable\"\n"
local ok, afgg = pcall(require, "Module:Vorlage:ArmFrGrandeGuerre")
if (not ok) then ret = ret .. debug.traceback("afgg") end
local ok, tomes = pcall(require, "Module:Vorlage:ArmFrGrandeGuerre/data")
if (not ok) then ret = ret .. debug.traceback("tomes") end
fs = { "kurz", "semi", "lang" }
mw.log(fs)
local f, fi, t, ti, v, vi, p, pi, a, ai
for fi, f in ipairs(fs) do
for ti, t in ipairs(tomes) do
if (not t.volumes) then
ok, r = pcall(afgg.formatbook, merge(frame, {args={tome=ti, format=f}}))
if (not ok) then ret = ret .. debug.traceback("formatbook_" .. ti .. "_" .. f)
else ret = ret .. "|-\n|" .. r .. "\n"
end
else
for vi, v in ipairs(t.volumes) do
if (not v.precis or #v.precis < 2) then
ok, r = pcall(afgg.formatbook, merge(frame, {args={tome=ti, vol=vi, format=f}}))
if (not ok) then ret = ret .. debug.traceback("formatbook_" .. ti .. "_" .. vi .. "_" .. f)
else ret = ret .. "|-\n|" .. r .. "\n"
end
else
for pi, p in ipairs(v.precis) do
ok, r = pcall(afgg.formatbook, merge(frame, {args={tome=ti, vol=vi, ed=pi, format=f}}))
if (not ok) then ret = ret .. debug.traceback("formatbook_" .. ti .. "_" .. vi .. "_" .. pi .. "_" .. f)
else ret = ret .. "|-\n|" .. r .. "\n"
end
end
end
if (t.annexes) then
for ai, a in ipairs(v.annexes) do
ok, r = pcall(afgg.formatbook, merge(frame, {args={tome=ti, vol=vi, annex=a.code, format=f}}))
if (not ok) then ret = ret .. debug.traceback("formatbook_" .. ti .. "_" .. vi .. "_" .. ai .. "_" .. f)
else ret = ret .. "|-\n|" .. r .. "\n"
end
end
end
end
end
end
end
return ret .. "|}"
end
return p