Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 19:08, 28 September 2024 by PenguinEncounter (talk | contribs)

Documentation for this module may be created at Module:Type/doc

local exports = {}

local BUILTINS = {
	["nil"] = true,
	["number"] = true,
	["integer"] = true,
	["boolean"] = true,
	["string"] = true,
	["true"] = true,
	["false"] = true,
	["function"] = true,
	["table"] = true,
}
local NOT_PLURAL = {
	["Matrixs"] = true,
}
local ALIASES = {
	
}

local function exists(frame, page_name)
	return frame:callParserFunction("PAGEID", page_name) ~= "0"
end

local function create(frame, primary_text, link, css_name, extra_attr, secondary_text)
	local secondary = string.format([[<span class="lua-type-mod">%s</span>]], secondary_text or "")
	return string.format(
		[=[<span class="lua-type" data-name="%s" %s>[[%s|%s]]%s</span>]=],
		css_name, extra_attr, link, primary_text,
		secondary_text ~= nil and secondary or ""
	)
end

-- local function resolve_type()

local function expand_types(type_name)
	local name, modifiers = type_name:match("^([^?[]-)([[%]?]*)$")
	if not name then error("Couldn't parse type name " .. type_name) end
	local result = {}
	if modifiers:find("?$") then
		modifiers = modifiers:sub(1, -2) -- cut off the ?
		table.insert(result, {{name="nil"}})
	end
	table.insert(result, 1, {name=name, modifiers=modifiers})
	return result
end

function exports.run(frame)
	local sb = ""
	local input_args = frame:getParent().args
	
	if not (input_args[1] or input_args.name) then error "need to specify at least one type name" end
	
	local name = input_args[1] or input_args.name
	local compatibility_mode = {["?"]=true,["[]"]=true, ["[]?"]=true}
	if input_args[2] and compatibility_mode[input_args[2]] then
		name = name .. input_args[2]
	end
	
	local type_structs = expand_types(name)
	if input_args.text then type_structs[1].text = input_args.text end
	if input_args.link then type_structs[1].link = input_args.link end
	local strings = {}
end

return exports