Module:Dochead: Difference between revisions

Ganaram inukshuk (talk | contribs)
comments
Ganaram inukshuk (talk | contribs)
comments again
Line 53: Line 53:
elseif namespace == "Module" then
elseif namespace == "Module" then
cats = "[[Category:Lua modules]]"
cats = "[[Category:Lua modules]]"
else
--cats = "[[Category:Templates in the incorrect namespace]]"
end
end
end
end
Line 83: Line 85:
-- presence of a corresponding template or module.
-- presence of a corresponding template or module.
if header == "dualuse" then
if header == "dualuse" then
-- A dual-use module MUST have a corresponding template; if not, say
-- it's missing.
-- A dual-use template MUST link to its corresponding module; if not,
-- say it's missing (even though it wouldn't work without its module).
if namespace == "Module" then
if namespace == "Module" then
-- A dual-use module MUST have a corresponding template; if not, say
-- it's missing.
if has_template then
if has_template then
result = string.format("This module may be invoked by templates using its corresponding [[%s|template]], or used directly from other modules.", corr_template)
result = string.format("This module may be invoked by templates using its corresponding [[%s|template]], or used directly from other modules.", corr_template)
else
else
result = "This module has a template that is currently missing, so should be used directly from other modules."
result = "This module has a template that is currently missing. [[create]]"
end
elseif namespace == "Template" then
if has_module then
result = string.format("This template is implemented by the Lua module [[%s]]. See its module page for Lua-based implementation.", corr_module)
else
result = "This template is implemented by a module that is currently missing. [[create]]"
end
end
else
else
result = "This template or its options is in the wrong namespace. It should be used within the Module namespace."
result = "This template is in the wrong namespace. It should be within the Template or Module namespaces."
end
end


elseif header == "metatemplate" then
elseif header == "metatemplate" then
-- A metatemplate-implementing module does not necessarly need to have a
-- template (as infobox was this way before).
-- A metatemplate does not need to be made using Lua.
if namespace == "Module" then
if namespace == "Module" then
-- A metatemplate-implementing module MUST have a corresponding
-- template since it's expected to be dual-use.
if has_template then
if has_template then
result = string.format("This module implements a metatemplate, and may be invoked by templates using its corresponding [[%s|template]], or used directly from other modules.", corr_template)
result = string.format("This module implements a metatemplate, and may be invoked by templates using its corresponding [[%s|template]], or used directly from other modules.", corr_template)
else
else
result = "This module implements a metatemplate whose template is currently missing."
result = "This module is used to create other Lua-based templates and has no corresponding template."
end
end
elseif namespace == "Template" then
elseif namespace == "Template" then
-- A metatemplate may either be lua-implemented or not.
if has_module then
if has_module then
result = string.format("This template is a metatemplate. It is used to build other templates and should not be used standalone, except for testing or simple usage. This template is implemented by the Lua module [[%s]].", corr_module)
result = string.format("This template is a metatemplate. It is used to build other templates and should not be used standalone, except for testing or simple usage. This template is implemented by the Lua module [[%s]].", corr_module)
Line 112: Line 122:
end
end
else
else
result = "This template or its options is in the wrong namespace. It should be within the Template or Module namespaces."
result = "This template is in the wrong namespace. It should be within the Template or Module namespaces."
end
end


Line 119: Line 129:
-- the default for modules, the absence of a template results in the
-- the default for modules, the absence of a template results in the
-- message being blank.
-- message being blank.
-- This type doesn't work on templates, as those are non-Lua templates.
if namespace == "Module" then
if namespace == "Module" then
if has_template then
if has_template then
result = string.format("This module should not be invoked directly; use its corresponding [[%s|template]] instead.", corr_template)
result = string.format("This module should not be invoked directly; use its corresponding [[%s|template]] instead.", corr_template)
else
else
result = header
result = "This module implements a template that is currently missing. [[create]]"
--result = "This module's corresponding template is currently missing."
end
end
else
else
result = "This template or its options is in the wrong namespace. It should be used within the Module namespace."
result = "This template is in the wrong namespace. It should be used within the Module namespace."
end
end


elseif header == "library" or header == "metamodule" then
elseif header == "library" or header == "metamodule" then
-- A metamodule should NOT have a corresponding template.
-- A metamodule should NOT have a corresponding template. This type only
-- works on modules.
if namespace == "Module" then
if namespace == "Module" then
result = "This module primarily serves as a library for other modules."
result = "This module primarily serves as a library for other modules."
else
else
result = "This template or its options is in the wrong namespace. It should be used within the Module namespace."
result = "This template is in the wrong namespace. It should be used within the Module namespace."
end
end


else
else
-- For any other case, just say that the module implements a template,
-- For any other case, just say that the module implements a template,
-- or a template invokes a module's function.
-- or a template invokes a module's function.  
if namespace == "Module" then
if namespace == "Module" then
if has_template then
if has_template and header ~= "" then
result = string.format("%s This module implements [[%s]].", header, corr_template)
result = string.format("%s. This module implements [[%s]].", header, corr_template)
else
else
result = header
result = header
end
end
elseif namespace == "Template" then
elseif namespace == "Template" then
if has_module then
if has_module and header ~= ""  then
result = string.format("%s This template is implemented by the Lua module [[%s]].", header, corr_module)
result = string.format("%s. This template is implemented by the Lua module [[%s]].", header, corr_module)
else
else
result = header
result = header
end
end
else
else
result = "This template or its options is in the wrong namespace. It should be used within the Template or Module namespaces."
result = "This template is in the wrong namespace. It should be within the Template or Module namespaces."
end
end
end
end