Module:Dochead: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
autocategorize metatemplates |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 128: | Line 128: | ||
return "" .. cats | return "" .. cats | ||
else | else | ||
return string.format(":''%s''%s\n", result, cats) | return string.format(": ''%s''%s\n", result, cats) | ||
end | end | ||
end | end | ||
-- Helper function: categorize template | -- Helper function: categorize template | ||
local function categorize_template(pagename, has_invoke) | local function categorize_template(pagename, has_invoke, is_metatemplate) | ||
local cats = "" | local cats = "" | ||
if pagename:match("/doc$") then | if pagename:match("/doc$") then | ||
| Line 141: | Line 141: | ||
if has_invoke then | if has_invoke then | ||
cats = cats .. " [[Category:Lua-based templates]]" | cats = cats .. " [[Category:Lua-based templates]]" | ||
end | |||
if is_metatemplate then | |||
cats = cats .. " [[Category:Metatemplates]]" | |||
end | end | ||
end | end | ||
| Line 267: | Line 270: | ||
-- Categorize | -- Categorize | ||
local cats = categorize_template(pagename, #invokes > 0) | local cats = categorize_template(pagename, #invokes > 0, header == "metatemplate") | ||
if header == "none" then | if header == "none" then | ||
| Line 274: | Line 277: | ||
return "" | return "" | ||
elseif result == "" and invocation_hatnote ~= "" then | elseif result == "" and invocation_hatnote ~= "" then | ||
return string.format(":''%s''%s\n", invocation_hatnote, cats) | return string.format(": ''%s''%s\n", invocation_hatnote, cats) | ||
elseif result ~= "" and invocation_hatnote == "" then | elseif result ~= "" and invocation_hatnote == "" then | ||
return string.format(":''%s''%s\n", result, cats) | return string.format(": ''%s''%s\n", result, cats) | ||
else | else | ||
return string.format(":''%s''\n:''%s''%s\n", result, invocation_hatnote, cats) | return string.format(": ''%s''\n: ''%s'' %s\n", result, invocation_hatnote, cats) | ||
end | end | ||
end | end | ||
| Line 306: | Line 309: | ||
result = p.make_template_hatnote(header, pagename, corr_module, detect_corr_page) | result = p.make_template_hatnote(header, pagename, corr_module, detect_corr_page) | ||
else | else | ||
result = ":''This documentation 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 | ||