Module:Module introspection: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
No edit summary
Line 86: Line 86:
if func == "" then func = nil end -- If func was blank, replace with nil instead
if func == "" then func = nil end -- If func was blank, replace with nil instead
deps[var] = {  
deps[var] = {  
["dep"] = dep,
dep = dep,
["funcs"] = { },
funcs = { },
["direct_func"] = func -- For detecting whether one function out of a package was used
direct_func = func -- For detecting whether one function out of a package was used
}
}
end
end
Line 103: Line 103:
-- SPECIAL CASE 1: only one function imported from a package
-- SPECIAL CASE 1: only one function imported from a package
if code:match(var .. "%s*%(") then
if code:match(var .. "%s*%(") then
funcs = { info["direct_func"] }
funcs = { info.direct_func }
end
end
else
else
Line 120: Line 120:
end
end
info["funcs"] = funcs
info.funcs = funcs
end
end


Line 142: Line 142:
funcs_text = "''dependency not used''"
funcs_text = "''dependency not used''"
else
else
funcs_text = table.concat(info["funcs"], "<br />")
funcs_text = table.concat(info.funcs, "<br />")
end
end


table.insert(lines, "|-")
table.insert(lines, "|-")
table.insert(lines, "| " .. var)
table.insert(lines, "| " .. var)
table.insert(lines, "| [[" .. info["dep"] .. "]]")
table.insert(lines, "| [[" .. info.dep .. "]]")
table.insert(lines, "| " .. funcs_text)
table.insert(lines, "| " .. funcs_text)
end
end
Line 248: Line 248:
local num_deps = 0
local num_deps = 0
local deps_found = {}
local deps_found = {}
for _, v in ipairs(module_deps) do
for _, info in ipairs(module_deps) do
local dep = v["dep"]
local dep = info.dep
if not v["dep"] then
if not deps_found[dep] then
v["dep"] = true
info.dep = true
num_deps = num_deps + 1
num_deps = num_deps + 1
end
end