Module:Dochead: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
mNo edit summary
Line 9: Line 9:
-- template or module documentation) and can autodetect and categorize:
-- template or module documentation) and can autodetect and categorize:
-- - FOR MODULES:
-- - FOR MODULES:
--  - whether a module has an accompanying template (overridable)
--  - whether a module has an accompanying template (overridable/toggleable)
--  - whether a module is meant as a library for other modules
--  - whether a module is meant as a library for other modules
-- - FOR TEMPLATES:
-- - FOR TEMPLATES:
--  - whether a template has an accompanying module (overridable)
--  - whether a template has an accompanying module (overridable/toggleable)
--  - what functions from which modules are invoked
--  - what functions from which modules are invoked


Line 120: Line 120:
else
else
if has_template and header ~= "" then
if has_template and header ~= "" then
result = string.format("%s. This module implements [[Template:%s]].", header, corr_template)
result = string.format("%s This module implements [[Template:%s]].", header, corr_template)
elseif has_template and header == "" then
elseif has_template and header == "" then
result = string.format("This module implements [[Template:%s]].", corr_template)
result = string.format("This module implements [[Template:%s]].", corr_template)
Line 149: Line 149:
table.insert(calls, string.format("'''%s''' from %s", call.func, module_link))
table.insert(calls, string.format("'''%s''' from %s", call.func, module_link))
end
end
return string.format("%s %s", hatnote, table.concat(calls, ", "))
return string.format("%s %s.", hatnote, table.concat(calls, ", "))
end
end
end
end
Line 286: Line 286:
result = p.make_template_hatnote(header, pagename:gsub("/doc$", ""), corr_module:gsub("/doc$", ""), detect_corr_page)
result = p.make_template_hatnote(header, pagename:gsub("/doc$", ""), corr_module:gsub("/doc$", ""), detect_corr_page)
else
else
result = ":''This template is in the wrong namespace. It should be within the Template or Module namespaces.''\n"
result = ":''This documentation template is in the wrong namespace. It should be within the Template or Module namespaces.''\n"
end
end


-- Categorization and output
-- Categorization and output
-- has_link only has an effect if this is used for template documentation.
local has_link = namespace == "Template" and iutils.page_exists("Module:" .. corr_module)
local has_link = namespace == "Template" and iutils.page_exists("Module:" .. corr_module)
if result == "" then
if result == "" then
Line 321: Line 322:
-- Option to detect corresponding page (default true)
-- Option to detect corresponding page (default true)
args["detect_corr_page"] = args["detect_corr_page"] == nil and true or yesno(args["detect_corr_page"])
args["detect_corr_page"] = args["detect_corr_page"] == nil and true or yesno(args["detect_corr_page"])