Module:Template introspection: Difference between revisions

Ganaram inukshuk (talk | contribs)
Created page with "-- This module follows User:Ganaram inukshuk/Provisional style guide for Lua local getArgs = require("Module:Arguments").getArgs local p = {} -- Inspects a template for any modules' functions being invoked. -- TODO: write wrapper -- Helper function: preprocess wikitext so that: -- - Only text inside includeonly tags is captured. -- - That captured text has normalized spacing and line breaks function p.preprocess_wikitext(wikitext) if not wikitext or wikitext == "..."
 
Ganaram inukshuk (talk | contribs)
No edit summary
Line 57: Line 57:


function p._template_introspection(args)
function p._template_introspection(args)
args = args or {}
local template_name = args["Template Name"]
local template_name = args["Template Name"] or "Template:Module introspection"


-- Get template wikitext
-- Get template wikitext
Line 88: Line 87:
return table.concat(out, "\n")
return table.concat(out, "\n")
end
function p.template_introspection(frame)
local args = getArgs(frame) or {}
-- Get template name, and strip /doc for proper display on /doc subpage
local template_name = args["Template Name"] or mw.title.getCurrentTitle().text
template_name = template_name:gsub("/doc$", "")
return frame:preprocess(p._template_introspection(args))
end
end


return p
return p