mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
gears.debug: Use the API level as the source of truth.
Rather than the version.
This commit is contained in:
parent
ee80fe052f
commit
e0b982fa1a
1 changed files with 21 additions and 16 deletions
|
@ -82,7 +82,8 @@ local displayed_deprecations = {}
|
|||
--- Display a deprecation notice, but only once per traceback.
|
||||
--
|
||||
-- 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.
|
||||
-- @tparam table args Extra arguments
|
||||
|
@ -90,17 +91,18 @@ local displayed_deprecations = {}
|
|||
-- @tparam integer args.deprecated_in Print the message only when Awesome's
|
||||
-- version is equal to or greater than deprecated_in.
|
||||
-- @staticfct gears.debug.deprecate
|
||||
-- @emits debug::deprecation
|
||||
-- @emitstparam @emitstparam string msg The full formatted message.
|
||||
-- @emitstparam @emitstparam string see A message provided by the caller.
|
||||
-- @emitstparam @emitstparam table args Some extra context.
|
||||
-- @emits debug::deprecation This is usually routed to stdout when the API is
|
||||
-- newly deprecated.
|
||||
-- @emitstparam debug::deprecation string msg The full formatted message.
|
||||
-- @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)
|
||||
args = args or {}
|
||||
if args.deprecated_in then
|
||||
local dep_ver = "v" .. tostring(args.deprecated_in)
|
||||
if awesome.version < dep_ver then
|
||||
return
|
||||
end
|
||||
if args.deprecated_in and awesome.api_level < args.deprecated_in then
|
||||
return
|
||||
end
|
||||
local tb = _G.debug.traceback()
|
||||
if displayed_deprecations[tb] then
|
||||
|
@ -123,9 +125,15 @@ function debug.deprecate(see, args)
|
|||
end
|
||||
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)
|
||||
end
|
||||
|
||||
if args.deprecated_in and awesome.api_level > args.deprecated_in then
|
||||
awesome.emit_signal(
|
||||
"debug::error", msg, false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
--- Create a class proxy with deprecation messages.
|
||||
|
@ -140,11 +148,8 @@ end
|
|||
-- @staticfct gears.debug.deprecate_class
|
||||
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
|
||||
if args.deprecated_in and awesome.api_level < args.deprecated_in then
|
||||
return fallback
|
||||
end
|
||||
|
||||
local message = old_name.." has been renamed to "..new_name
|
||||
|
|
Loading…
Reference in a new issue