Module:Module introspection: Difference between revisions
m remove unused modules, as those were added for testing the code with itself as input |
mNo edit summary |
||
| Line 245: | Line 245: | ||
function p._module_introspection(args) | function p._module_introspection(args) | ||
local args = args or {} | local args = args or {} | ||
local module_name = args[" | local module_name = args["Module Name" ] | ||
local main_function = args[" | local main_function = args["Main Function"] | ||
-- Preprocess module and blank-out comments | -- Preprocess module and blank-out comments | ||
| Line 286: | Line 286: | ||
-- Get module name from arguments, or default to current page | -- Get module name from arguments, or default to current page | ||
local module_name = args[" | local module_name = args["Module Name"] or mw.title.getCurrentTitle().text | ||
-- Strip trailing "/doc" if the template is used on a documentation subpage | -- Strip trailing "/doc" if the template is used on a documentation subpage | ||
| Line 295: | Line 295: | ||
-- is used for function names. (If this fails, it can be entered manually.) | -- is used for function names. (If this fails, it can be entered manually.) | ||
local normalized_name = module_name:gsub("[^%w]", "_"):lower() | local normalized_name = module_name:gsub("[^%w]", "_"):lower() | ||
local main_function = args[" | local main_function = args["Main Function"] or "_" .. normalized_name | ||
-- Return | -- Return | ||
return p._module_introspection({ | return p._module_introspection({ | ||
[" | ["Module Name"] = module_name, | ||
[" | ["Main Function"] = main_function, | ||
}) | }) | ||
end | end | ||
return p | return p | ||