Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(more efficient code for the subpages link) |
(make startBox, content and endBox accessible from #invoke) |
||
Line 41: | Line 41: | ||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
-- Argument processing |
|||
⚫ | |||
---------------------------------------------------------------------------- |
---------------------------------------------------------------------------- |
||
function |
local function makeInvokeFunc(funcName) |
||
return function (frame) |
|||
local args = getArgs(frame, { |
|||
valueFunc = function (key, value) |
valueFunc = function (key, value) |
||
if type(value) == 'string' then |
|||
value = |
if type(value) == 'string' then |
||
value = value:match('^%s*(.-)%s*$') -- Remove whitespace. |
|||
if key == 'heading' or value ~= '' then |
|||
if key == 'heading' or value ~= '' then |
|||
⚫ | |||
⚫ | |||
return nil |
|||
end |
|||
else |
else |
||
return |
return value |
||
end |
end |
||
⚫ | |||
⚫ | |||
end |
end |
||
}) |
|||
⚫ | |||
}) |
|||
end |
|||
⚫ | |||
end |
end |
||
---------------------------------------------------------------------------- |
|||
⚫ | |||
---------------------------------------------------------------------------- |
|||
p.main = makeInvokeFunc('_main') |
|||
function p._main(args) |
function p._main(args) |
||
Line 72: | Line 80: | ||
.attr('id', 'template-documentation') |
.attr('id', 'template-documentation') |
||
.addClass('template-documentation iezoomfix') |
.addClass('template-documentation iezoomfix') |
||
.wikitext(p. |
.wikitext(p._startBox(args)) |
||
.wikitext(p. |
.wikitext(p._content(args)) |
||
.tag('div') |
.tag('div') |
||
.css('clear', 'both') -- So right or left floating items don't stick out of the doc box. |
.css('clear', 'both') -- So right or left floating items don't stick out of the doc box. |
||
.done() |
.done() |
||
.done() |
.done() |
||
.wikitext(p. |
.wikitext(p._endBox(args)) |
||
.wikitext(p.addTrackingCategories()) |
.wikitext(p.addTrackingCategories()) |
||
return tostring(root) |
return tostring(root) |
||
Line 120: | Line 128: | ||
end |
end |
||
p.startBox = makeInvokeFunc('_startBox') |
|||
function p._startBox(args) |
|||
-- Arg processing from {{documentation}}. |
-- Arg processing from {{documentation}}. |
||
local preload = args.preload -- Allow custom preloads. |
local preload = args.preload -- Allow custom preloads. |
||
Line 214: | Line 224: | ||
end |
end |
||
p.content = makeInvokeFunc('_content') |
|||
function p._content(args) |
|||
local content = args.content |
local content = args.content |
||
if not content then |
if not content then |
||
Line 234: | Line 246: | ||
end |
end |
||
p.endBox = makeInvokeFunc('_endBox') |
|||
function p._endBox(args) |
|||
-- Argument processing in {{documentation}}. |
-- Argument processing in {{documentation}}. |
||
local preload = args.preload -- Allow custom preloads. |
local preload = args.preload -- Allow custom preloads. |