Module:form of doc/templates: Difference between revisions
Jump to navigation
Jump to search
Created page with "--[=[ This module contains functions to implement {{form of/*doc}} templates. The module contains the wrappers meant to be called directly from templates. The actual implem..." |
No edit summary |
||
| Line 13: | Line 13: | ||
local function create_introdoc_params() | local function create_introdoc_params() | ||
local boolean = {type = "boolean"} | |||
local plain = {} | |||
return { | return { | ||
["lang"] = | ["lang"] = plain, | ||
["exlang"] = {list = true}, | ["exlang"] = {list = true, sublist = "comma without whitespace", flatten = true}, | ||
["pldesc"] = | ["usedwithlimitedlangs"] = boolean, | ||
["primaryentrytext"] = | ["pldesc"] = plain, | ||
["cat"] = {list = true}, | ["primaryentrytext"] = plain, | ||
["addlintrotext"] = | ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, | ||
["etymtemp"] = | ["addlintrotext"] = plain, | ||
["withdot"] = | ["etymtemp"] = plain, | ||
["withcap"] = | ["withdot"] = boolean, | ||
["withcap"] = boolean, | |||
["withencap"] = boolean, | |||
} | } | ||
end | |||
local function preprocess(frame, txt) | |||
if txt:find("{{") then | |||
txt = frame:preprocess(txt) | |||
end | |||
return txt | |||
end | end | ||
| Line 29: | Line 40: | ||
local params = create_introdoc_params() | local params = create_introdoc_params() | ||
local args = m_parameters.process(frame:getParent().args, params) | local args = m_parameters.process(frame:getParent().args, params) | ||
return m_form_of_doc.introdoc(args) | return preprocess(frame, m_form_of_doc.introdoc(args)) | ||
end | end | ||
local function create_paramdoc_params() | local function create_paramdoc_params() | ||
local boolean = {type = "boolean"} | |||
local plain = {} | |||
return { | return { | ||
["lang"] = | ["lang"] = plain, | ||
["sgdescof"] = | ["sgdescof"] = plain, | ||
["art"] = | ["art"] = plain, | ||
[" | ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, | ||
["withdot"] = | ["withfrom"] = boolean, | ||
["withcap"] = | ["withdot"] = boolean, | ||
["withcap"] = boolean, | |||
["withencap"] = boolean, | |||
["addlparamtext"] = plain, | |||
} | } | ||
end | end | ||
| Line 46: | Line 62: | ||
local params = create_paramdoc_params() | local params = create_paramdoc_params() | ||
local args = m_parameters.process(frame:getParent().args, params) | local args = m_parameters.process(frame:getParent().args, params) | ||
return m_form_of_doc.paramdoc(args) | return preprocess(frame, m_form_of_doc.paramdoc(args)) | ||
end | end | ||
local function create_usagedoc_params() | local function create_usagedoc_params() | ||
local params = create_paramdoc_params() | local params = create_paramdoc_params() | ||
params["exlang"] = {list = true} | params["exlang"] = {list = true, sublist = "comma without whitespace", flatten = true} | ||
params["usedwithlimitedlangs"] = {type = "boolean"} | |||
return params | return params | ||
end | end | ||
| Line 58: | Line 75: | ||
local params = create_usagedoc_params() | local params = create_usagedoc_params() | ||
local args = m_parameters.process(frame:getParent().args, params) | local args = m_parameters.process(frame:getParent().args, params) | ||
return m_form_of_doc.usagedoc(args) | return preprocess(frame, m_form_of_doc.usagedoc(args)) | ||
end | end | ||
| Line 67: | Line 84: | ||
params[k] = v | params[k] = v | ||
end | end | ||
-- We allow sublists but this is handled by {{shortcut|...}} when we preprocess. | |||
params["shortcut"] = {list = true} | params["shortcut"] = {list = true} | ||
return params | return params | ||
| Line 74: | Line 92: | ||
local params = create_fulldoc_params() | local params = create_fulldoc_params() | ||
local args = m_parameters.process(frame:getParent().args, params) | local args = m_parameters.process(frame:getParent().args, params) | ||
return m_form_of_doc.fulldoc(args) | return preprocess(frame, m_form_of_doc.fulldoc(args)) | ||
end | end | ||
| Line 80: | Line 98: | ||
local params = create_fulldoc_params() | local params = create_fulldoc_params() | ||
params["pldesc"] = nil | params["pldesc"] = nil | ||
params["sgdesc"] = | local plain = {} | ||
params["form"] = | params["sgdesc"] = plain | ||
params["form"] = plain | |||
return params | return params | ||
end | end | ||
| Line 88: | Line 107: | ||
local params = create_infldoc_params() | local params = create_infldoc_params() | ||
local args = m_parameters.process(frame:getParent().args, params) | local args = m_parameters.process(frame:getParent().args, params) | ||
return m_form_of_doc.infldoc(args) | return preprocess(frame, m_form_of_doc.infldoc(args)) | ||
end | end | ||
function export.tagtable_t(frame) | function export.tagtable_t(frame) | ||
return m_form_of_doc.tagtable() | return m_form_of_doc.tagtable() | ||
end | |||
function export.non_alias_shortcut_table_t(frame) | |||
return m_form_of_doc.non_alias_shortcut_table() | |||
end | |||
function export.lang_specific_tables_t(frame) | |||
return m_form_of_doc.lang_specific_tables() | |||
end | end | ||
| Line 99: | Line 126: | ||
end | end | ||
function export. | function export.lang_independent_category_table_t(frame) | ||
return m_form_of_doc. | return m_form_of_doc.lang_independent_category_table() | ||
end | |||
function export.lang_independent_label_table_t(frame) | |||
return m_form_of_doc.lang_independent_label_table() | |||
end | end | ||
return export | return export | ||
Latest revision as of 08:20, 18 May 2026
- This module lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
--[=[
This module contains functions to implement {{form of/*doc}} templates.
The module contains the wrappers meant to be called directly from templates.
The actual implementations are in [[Module:form of doc]].
Author: Benwing2
]=]
local export = {}
local m_parameters = require("Module:parameters")
local m_form_of_doc = require("Module:form of doc")
local function create_introdoc_params()
local boolean = {type = "boolean"}
local plain = {}
return {
["lang"] = plain,
["exlang"] = {list = true, sublist = "comma without whitespace", flatten = true},
["usedwithlimitedlangs"] = boolean,
["pldesc"] = plain,
["primaryentrytext"] = plain,
["cat"] = {list = true, sublist = "comma without whitespace", flatten = true},
["addlintrotext"] = plain,
["etymtemp"] = plain,
["withdot"] = boolean,
["withcap"] = boolean,
["withencap"] = boolean,
}
end
local function preprocess(frame, txt)
if txt:find("{{") then
txt = frame:preprocess(txt)
end
return txt
end
function export.introdoc_t(frame)
local params = create_introdoc_params()
local args = m_parameters.process(frame:getParent().args, params)
return preprocess(frame, m_form_of_doc.introdoc(args))
end
local function create_paramdoc_params()
local boolean = {type = "boolean"}
local plain = {}
return {
["lang"] = plain,
["sgdescof"] = plain,
["art"] = plain,
["cat"] = {list = true, sublist = "comma without whitespace", flatten = true},
["withfrom"] = boolean,
["withdot"] = boolean,
["withcap"] = boolean,
["withencap"] = boolean,
["addlparamtext"] = plain,
}
end
function export.paramdoc_t(frame)
local params = create_paramdoc_params()
local args = m_parameters.process(frame:getParent().args, params)
return preprocess(frame, m_form_of_doc.paramdoc(args))
end
local function create_usagedoc_params()
local params = create_paramdoc_params()
params["exlang"] = {list = true, sublist = "comma without whitespace", flatten = true}
params["usedwithlimitedlangs"] = {type = "boolean"}
return params
end
function export.usagedoc_t(frame)
local params = create_usagedoc_params()
local args = m_parameters.process(frame:getParent().args, params)
return preprocess(frame, m_form_of_doc.usagedoc(args))
end
local function create_fulldoc_params()
local params = create_introdoc_params()
local usageparams = create_usagedoc_params()
for k, v in pairs(usageparams) do
params[k] = v
end
-- We allow sublists but this is handled by {{shortcut|...}} when we preprocess.
params["shortcut"] = {list = true}
return params
end
function export.fulldoc_t(frame)
local params = create_fulldoc_params()
local args = m_parameters.process(frame:getParent().args, params)
return preprocess(frame, m_form_of_doc.fulldoc(args))
end
local function create_infldoc_params()
local params = create_fulldoc_params()
params["pldesc"] = nil
local plain = {}
params["sgdesc"] = plain
params["form"] = plain
return params
end
function export.infldoc_t(frame)
local params = create_infldoc_params()
local args = m_parameters.process(frame:getParent().args, params)
return preprocess(frame, m_form_of_doc.infldoc(args))
end
function export.tagtable_t(frame)
return m_form_of_doc.tagtable()
end
function export.non_alias_shortcut_table_t(frame)
return m_form_of_doc.non_alias_shortcut_table()
end
function export.lang_specific_tables_t(frame)
return m_form_of_doc.lang_specific_tables()
end
function export.postable_t(frame)
return m_form_of_doc.postable()
end
function export.lang_independent_category_table_t(frame)
return m_form_of_doc.lang_independent_category_table()
end
function export.lang_independent_label_table_t(frame)
return m_form_of_doc.lang_independent_label_table()
end
return export