Module:Module introspection: Difference between revisions
m mw-collapsible and mw-collapsed |
bugfix links to individual lines; remove comments so commented-out code is ignored |
||
| Line 12: | Line 12: | ||
local title = mw.title.new('Module:' .. module_name) | local title = mw.title.new('Module:' .. module_name) | ||
local content = title:getContent() | local content = title:getContent() | ||
-- Remove single-line comments | |||
content = content:gsub("%-%-.*", "") | |||
-- Remove multi-line comments | |||
content = content:gsub("%-%-%[%[.-%]%]", "") | |||
-- Get dependencies for that module | -- Get dependencies for that module | ||
| Line 83: | Line 88: | ||
local title = mw.title.new('Module:' .. module_name) | local title = mw.title.new('Module:' .. module_name) | ||
local content = title:getContent() | local content = title:getContent() | ||
-- Remove single-line comments | |||
content = content:gsub("%-%-.*", "") | |||
-- Remove multi-line comments | |||
content = content:gsub("%-%-%[%[.-%]%]", "") | |||
-- Iterate through file and find each function and the line found at | -- Iterate through file and find each function and the line found at | ||
| Line 164: | Line 174: | ||
for _, f in ipairs(module_functions) do | for _, f in ipairs(module_functions) do | ||
local link = string.format("[[Module:%s#%d|%s]]", module_name, f.line, f.name) | local link = string.format("[[Module:%s#L-%d|%s]]", module_name, f.line, f.name) | ||
table.insert(func_lines, "|-") | table.insert(func_lines, "|-") | ||
table.insert(func_lines, "| " .. link) | table.insert(func_lines, "| " .. link) | ||