Module:Format TemplateData/doc
Appearance
| This is a documentation subpage for Module:Format TemplateData. It may contain usage information, categories and other content that is not part of the original module page. |
Template:LuaModuleDoc
TemplateData – Module with auxilary functions for template documentation, especially by TemplateData.
Core functionality is improved presentation on documentation pages.
Functions for templates
Single functions
- f
- Improve TemplateData-presentation; used in Template:TemplateData
- Parameters of template transclusion environment (all optional):
- 1
- JSON string or
<templatedata>object - JSON
- JSON string
- (precedes 1)
- Transition from
<templatedata>objects with pipe symbols needs special attention: Pipes are to be represented as{{!}}, on double curly brackets one should be encoded by HTML entity. - TOC
1– Insert table of contents after general purpose descriptions; but before parameter list, if present- Example
- lazy
1– Presentation only, do not generate an effective data block- For general method descriptions.
- debug
1– developer mode
- Parameters of
#invokefor particular project adaption (all optional):- cat
- Title of a maintenance category on invalid parameter value etc.
- debug
- Development mode, if provided and not equal
0 - docpageCreate
- Pattern for creation of subpage names;
%s/Doku - docpageDetect
- Pattern for recognition of subpage names;
/Doku$ - msgDescMiss
- Localisation: complaint text on missing
description
- Returns: HTML code; and/or error message, probably with
class="error" - failsafe
- Version identification:
Script error: No such module "TemplateData". - Optional additional parameter
1– requested minimal version identification- Returns: empty, if minimal version condition not matched
Examples (test page)
A test page illustrates practical use.
Functions for Lua modules (API)
Some functions described above can be used by other modules:
local lucky, TemplateData = pcall( require, "Modul:TemplateData" )
if type( TemplateData ) == "table" then
TemplateData = TemplateData.TemplateData()
else
-- failure; TemplateData is the error message
return "<span class='error'>" .. TemplateData .. "</span>"
end
- TemplateData.failsafe(atleast)
-
- atleast
optional
nil or minimal version request
- atleast
- Returns: string or false
- TemplateData.getPlainJSON(adapt)
- Reduce enhanced JSON information to MediaWiki JSON
- adapt
string, with JSON (enhanced)
- adapt
- Returns: string, with JSON (MediaWiki )
- TemplateData.test(adapt, arglist)
- Simulation of template functionality
- adapt
table,#invokeparameters - arglist
table, template parameters
- adapt
- Returns: string
Usage
Currently focussing on one template only: