Module:Template introspection: Difference between revisions
No edit summary |
No edit summary |
||
| Line 54: | Line 54: | ||
return results | return results | ||
end | |||
function p.make_hatnote(invokes) | |||
local hatnote = "" | |||
if #invokes == 0 then | |||
hatnote = "This template does not invoke any functions." | |||
return hatnote | |||
else | |||
hatnote = "This template invokes functions from Lua modules:" | |||
local calls = {} | |||
for _, call in ipairs(invokes) do | |||
table.insert(calls, string.format("function %s from %s")) | |||
end | |||
return string.format(":''%s %s''", hatnote, table.concat(calls, ", ")) | |||
end | |||
end | end | ||
| Line 65: | Line 80: | ||
end | end | ||
-- Get template's code and preprocess | |||
local wikitext = titleObj:getContent() | local wikitext = titleObj:getContent() | ||
wikitext = p.preprocess_wikitext(wikitext) | wikitext = p.preprocess_wikitext(wikitext) | ||
| Line 72: | Line 88: | ||
end | end | ||
-- Run invoke finder | -- Run invoke finder and return as a hatnote | ||
local invokes = p.find_invokes(wikitext) | local invokes = p.find_invokes(wikitext) | ||
return p.make_hatnote(invokes) | |||
end | end | ||