Module:Util/tables/merge/Documentation/Spec

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search

Documentation for this module may be created at Module:Util/tables/merge/Documentation/Spec/Documentation

local p = {}

function p.Documentation()
	return {
		desc = "Recursively merges tables.",
		params = {"tbl", "..." },
		returns = "<code>tbl</code> with merged values. Subsequent sources overwrite key assignments of previous sources.",
		cases = {
			{
				snippet = 1,
				expect = {
					flib = "flob",
					foo = {
						bar = {"noot", "flob"},
						baz = "noot",
						wibble = "wobble",
					},
				}
			},
			{
				desc = "Common use: merging keys into new table.",
				args = {
					{}, 
					{ flib = "flob" }, 
					{ wibble = "wobble" },
				},
				expect = {
					flib = "flob",
					wibble = "wobble",
				},
			},
		}
	}
end

return p