Module:Dochead: Difference between revisions

Ganaram inukshuk (talk | contribs)
bugfix again
Ganaram inukshuk (talk | contribs)
bugfix /doc logic (hopefully)
Line 82: Line 82:
if has_template then
if has_template then
result = string.format(
result = string.format(
"This module may be invoked by templates using its corresponding [[Template:%s|template]], or used directly from other modules.",
"This module may be invoked by templates using its corresponding template [[Template:%s]], or used directly from other modules.",
corr_template
corr_template
)
)
Line 95: Line 95:
if has_template then
if has_template then
result = string.format(
result = string.format(
"This module implements a metatemplate, and may be invoked by templates using its corresponding [[Template:%s|template]], or used directly from other modules.",
"This module implements a metatemplate, and may be invoked by templates using its corresponding template [[Template:%s]], or used directly from other modules.",
corr_template
corr_template
)
)
Line 105: Line 105:
if has_template then
if has_template then
result = string.format(
result = string.format(
"This module should not be invoked directly; use its corresponding [[Template:%s|template]] instead.",
"This module should not be invoked directly; use its corresponding instead: [[Template:%s]].",
corr_template
corr_template
)
)
Line 276: Line 276:
return categorize(namespace, pagename)
return categorize(namespace, pagename)
end
end
-- Remove /doc suffix, if this is on a /doc page
corr_template = corr_template:gsub("/doc$", "")
corr_module  = corr_module:gsub("/doc$", "")


-- Call appropriate hatnote-making function
-- Call appropriate hatnote-making function
-- Remove /doc suffix if this is on a /doc page to ensure links are made
-- properly.
local result = ""
local result = ""
if namespace == "Module" then
if namespace == "Module" then
result = p.make_module_hatnote(header, pagename, corr_template)
result = p.make_module_hatnote(header, pagename:gsub("/doc$", ""), corr_template:gsub("/doc$", ""), detect_corr_page)
elseif namespace == "Template" then
elseif namespace == "Template" then
result = p.make_template_hatnote(header, pagename, corr_module)
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 template is in the wrong namespace. It should be within the Template or Module namespaces.''\n"