gears.debug: Use the API level as the source of truth.
Rather than the version.
This commit is contained in:
parent
ee80fe052f
commit
e0b982fa1a
|
@ -82,7 +82,8 @@ local displayed_deprecations = {}
|
||||||
--- Display a deprecation notice, but only once per traceback.
|
--- Display a deprecation notice, but only once per traceback.
|
||||||
--
|
--
|
||||||
-- This function also emits the `debug::deprecation` signal on the `awesome`
|
-- This function also emits the `debug::deprecation` signal on the `awesome`
|
||||||
-- global object.
|
-- global object. If the deprecated API has been deprecated for more than one
|
||||||
|
-- API level, it will also send a non-fatal error.
|
||||||
--
|
--
|
||||||
-- @param[opt] see The message to a new method / function to use.
|
-- @param[opt] see The message to a new method / function to use.
|
||||||
-- @tparam table args Extra arguments
|
-- @tparam table args Extra arguments
|
||||||
|
@ -90,17 +91,18 @@ local displayed_deprecations = {}
|
||||||
-- @tparam integer args.deprecated_in Print the message only when Awesome's
|
-- @tparam integer args.deprecated_in Print the message only when Awesome's
|
||||||
-- version is equal to or greater than deprecated_in.
|
-- version is equal to or greater than deprecated_in.
|
||||||
-- @staticfct gears.debug.deprecate
|
-- @staticfct gears.debug.deprecate
|
||||||
-- @emits debug::deprecation
|
-- @emits debug::deprecation This is usually routed to stdout when the API is
|
||||||
-- @emitstparam @emitstparam string msg The full formatted message.
|
-- newly deprecated.
|
||||||
-- @emitstparam @emitstparam string see A message provided by the caller.
|
-- @emitstparam debug::deprecation string msg The full formatted message.
|
||||||
-- @emitstparam @emitstparam table args Some extra context.
|
-- @emitstparam debug::deprecation string see A message provided by the caller.
|
||||||
|
-- @emitstparam debug::deprecation table args Some extra context.
|
||||||
|
-- @emits debug::error When the API has been deprecated for more than
|
||||||
|
-- one API level.
|
||||||
|
-- @emitstparam debug::error string msg The full formatted message.
|
||||||
function debug.deprecate(see, args)
|
function debug.deprecate(see, args)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
if args.deprecated_in then
|
if args.deprecated_in and awesome.api_level < args.deprecated_in then
|
||||||
local dep_ver = "v" .. tostring(args.deprecated_in)
|
return
|
||||||
if awesome.version < dep_ver then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local tb = _G.debug.traceback()
|
local tb = _G.debug.traceback()
|
||||||
if displayed_deprecations[tb] then
|
if displayed_deprecations[tb] then
|
||||||
|
@ -123,9 +125,15 @@ function debug.deprecate(see, args)
|
||||||
end
|
end
|
||||||
debug.print_warning(msg .. ".\n" .. tb)
|
debug.print_warning(msg .. ".\n" .. tb)
|
||||||
|
|
||||||
if awesome then
|
if awesome and awesome.api_level == args.deprecated_in then
|
||||||
awesome.emit_signal("debug::deprecation", msg, see, args)
|
awesome.emit_signal("debug::deprecation", msg, see, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if args.deprecated_in and awesome.api_level > args.deprecated_in then
|
||||||
|
awesome.emit_signal(
|
||||||
|
"debug::error", msg, false
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a class proxy with deprecation messages.
|
--- Create a class proxy with deprecation messages.
|
||||||
|
@ -140,11 +148,8 @@ end
|
||||||
-- @staticfct gears.debug.deprecate_class
|
-- @staticfct gears.debug.deprecate_class
|
||||||
function debug.deprecate_class(fallback, old_name, new_name, args)
|
function debug.deprecate_class(fallback, old_name, new_name, args)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
if args.deprecated_in then
|
if args.deprecated_in and awesome.api_level < args.deprecated_in then
|
||||||
local dep_ver = "v" .. tostring(args.deprecated_in)
|
return fallback
|
||||||
if awesome.version < dep_ver then
|
|
||||||
return fallback
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local message = old_name.." has been renamed to "..new_name
|
local message = old_name.." has been renamed to "..new_name
|
||||||
|
|
Loading…
Reference in New Issue