debug: Allow "deprecated_in" for class deprecation.

This commit is contained in:
Emmanuel Lepage Vallee 2019-06-29 23:10:34 -04:00
parent 5ad02d0b8b
commit da8daa8dfc
1 changed files with 15 additions and 4 deletions

View File

@ -130,12 +130,23 @@ end
--- Create a class proxy with deprecation messages. --- Create a class proxy with deprecation messages.
-- This is useful when a class has moved somewhere else. -- This is useful when a class has moved somewhere else.
-- @tparam table fallback The new class -- @tparam table fallback The new class.
-- @tparam string old_name The old class name -- @tparam string old_name The old class name.
-- @tparam string new_name The new class name -- @tparam string new_name The new class name.
-- @tparam[opt={}] args The name.
-- @tparam[opt] number args.deprecated_in The version which deprecated this
-- class.
-- @treturn table A proxy class. -- @treturn table A proxy class.
-- @staticfct gears.debug.deprecate_class -- @staticfct gears.debug.deprecate_class
function debug.deprecate_class(fallback, old_name, new_name) function debug.deprecate_class(fallback, old_name, new_name, args)
args = args or {}
if args.deprecated_in then
local dep_ver = "v" .. tostring(args.deprecated_in)
if awesome.version < dep_ver then
return fallback
end
end
local message = old_name.." has been renamed to "..new_name local message = old_name.." has been renamed to "..new_name
local function call(_,...) local function call(_,...)