Module:Module introspection: Difference between revisions
try to bugfix line count again |
fix issue with block comments prematurely halting introspection |
||
| Line 17: | Line 17: | ||
for line in content:gmatch("([^\n]*)\n") do | for line in content:gmatch("([^\n]*)\n") do | ||
local processed = line | local processed = line | ||
if in_multiline then | if in_multiline then | ||
-- check for end of multi-line comment first | |||
local s, e = processed:find(end_pattern) | |||
-- check for end of multi-line comment | if s then | ||
in_multiline = false | in_multiline = false | ||
-- replace only the comment part with spaces | |||
processed = string.rep(" ", e) .. processed:sub(e + 1) | |||
else | |||
-- entire line is inside comment | |||
processed = processed:gsub(".", " ") | |||
end | end | ||
else | else | ||
local start_eq = processed:match("%-%-%[(=*)%[") | local start_eq = processed:match("%-%-%[(=*)%[") | ||
if start_eq then | if start_eq then | ||
in_multiline = true | in_multiline = true | ||
end_pattern = "%]" .. start_eq .. "%]" | end_pattern = "%]" .. start_eq .. "%]" | ||
-- blank from the start of comment to the end of line | |||
local s, e = processed:find("%-%-%[" .. start_eq .. "%[") | |||
if s then | |||
processed = string.rep(" ", #processed) | |||
end | |||
else | else | ||
processed = processed:gsub("%-%-.*", function(s) | processed = processed:gsub("%-%-.*", function(s) | ||
return string.rep(" ", #s) | return string.rep(" ", #s) | ||
| Line 39: | Line 45: | ||
end | end | ||
end | end | ||
table.insert(lines, processed) | table.insert(lines, processed) | ||
end | end | ||
| Line 172: | Line 166: | ||
function p._module_introspection(args) | function p._module_introspection(args) | ||
local args = args or {} | local args = args or {} | ||
local module_name = args["module_name" ] or " | local module_name = args["module_name" ] or "Numlinks" | ||
local main_function = args["main_function"] | local main_function = args["main_function"] | ||