Module:Module introspection: Difference between revisions

Ganaram inukshuk (talk | contribs)
m remove unused modules, as those were added for testing the code with itself as input
Ganaram inukshuk (talk | contribs)
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["module_name"  ]
local module_name  = args["Module Name"  ]
local main_function = args["main_function"]
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["module_name"] or mw.title.getCurrentTitle().text
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["main_function"] or "_" .. normalized_name
local main_function = args["Main Function"] or "_" .. normalized_name


-- Return
-- Return
return p._module_introspection({
return p._module_introspection({
["module_name"]  = module_name,
["Module Name"]  = module_name,
["main_function"] = main_function,
["Main Function"] = main_function,
})
})
end
end


return p
return p