Module:Module introspection: Difference between revisions
add main function identification; bugfix comment removal so that it doesn't affect line numbers |
more bugfix |
||
| Line 9: | Line 9: | ||
-- Blanks comments but preserves line numbers | -- Blanks comments but preserves line numbers | ||
function p.strip_comments(content) | function p.strip_comments(content) | ||
if not content then return "" end | |||
-- Blank single-line comments | |||
content = content:gsub("%-%-[^\n]*", function(s) | |||
return string.rep(" ", #s) | |||
end) | |||
-- Blank multi-line comments (handles --[[...]] and --[=[...]=]) | |||
content = content:gsub("%-%-%[%[.-%]%]", function(s) | |||
local blank = s:gsub("[^\n]", " ") | |||
return blank | |||
end) | |||
content = content:gsub("%-%-%[%=[=]*%[.-%][=]*%]", function(s) | |||
local blank = s:gsub("[^\n]", " ") | |||
return blank | |||
end) | |||
return content | |||
end | end | ||
| Line 231: | Line 232: | ||
-- Call the introspection function | -- Call the introspection function | ||
local dep_table, func_table = p._module_introspection({ | local dep_table, func_table = p._module_introspection({ | ||
["module_name"] = module_name | ["module_name"] = module_name , | ||
["main_function"] = | ["main_function"] = main_function, | ||
}) | }) | ||