Changes

Jump to: navigation, search

Module:Documentation

1,345 bytes added, 21:54, 27 December 2013
put argument names into a config file for easy porting to other wikis
-- This module implements {{documentation}}.
 
----------------------------------------------------------------------------
-- Configuration
----------------------------------------------------------------------------
 
-- Here you can set the values of the parameters and messages used in this module, so that it
-- can be easily ported to other wikis.
 
local cfg = {}
 
-- Argument names
-- The following are all names of arguments that affect the behaviour of {{documentation}}.
-- The comments next to the configuration values are the effects that the argument has
-- on the module. (Not the effects of the argument names themselves.)
 
cfg.livepageArg = 'livepage' -- Name of the live template; used in {{template sandbox notice}}.
cfg.headingArg = 'heading' -- Custom heading used in the start box.
cfg.preloadArg = 'preload' -- Custom preload page for creating documentation.
cfg.headingStyleArg = 'heading-style' -- Custom CSS style for the start box heading.
cfg.contentArg = 'content' -- Passes documentation content directly from the {{documentation}} invocation.
cfg.linkBoxArg = 'link box' -- Specifies a custom link box (end box) or prevents it from being generated.
 
----------------------------------------------------------------------------
-- End configuration
----------------------------------------------------------------------------
-- Get required modules.
local function makeInvokeFunc(funcName)
return function (frame)
local headingArg = cfg.headingArg
local args = getArgs(frame, {
valueFunc = function (key, value)
if type(value) == 'string' then
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
if key == 'heading' headingArg or value ~= '' then
return value
else
.css('clear', 'both')
.done()
.wikitext(frame:expandTemplate{title = 'template sandbox notice', args = {args[cfg.livepagelivepageArg]}})
return tostring(root)
else
function p._startBox(args)
-- Arg processing from {{documentation}}.
local preload = args[cfg.preload preloadArg] -- Allow custom preloads. local heading = args[cfg.heading headingArg] -- Blank values are not removed. local headingStyle = args['heading-style'cfg.headingStyleArg] local content = args[cfg.contentcontentArg]
local docspace = p.docspace()
local docname = args[1] -- Other docname, if fed.
function p._content(args)
local content = args[cfg.contentcontentArg]
if not content then
local docpage = args[1]
function p._endBox(args)
-- Argument processing in {{documentation}}.
local preload = args.preload -- Allow custom preloads. local content = args[cfg.contentcontentArg] local linkBox = args['link box'cfg.linkBoxArg] -- So "link box=off" works.
local docspace = p.docspace()
local docname = args[1] -- Other docname, if fed.
Anonymous user

Navigation menu