debug: Add a signal for deprecation warnings (#1832)

Fixes #1612.
This commit is contained in:
Emmanuel Lepage Vallée 2017-06-20 20:06:32 -04:00 committed by Daniel Hahler
parent 983fd4710f
commit 1f8b07d475
2 changed files with 11 additions and 1 deletions

View File

@ -75,6 +75,10 @@ end
local displayed_deprecations = {} 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::deprecate` signal on the `awesome`
-- global object.
--
-- @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
-- @tparam boolean args.raw Print the message as-is without the automatic context -- @tparam boolean args.raw Print the message as-is without the automatic context
@ -108,6 +112,10 @@ function debug.deprecate(see, args)
end end
end end
debug.print_warning(msg .. ".\n" .. tb) debug.print_warning(msg .. ".\n" .. tb)
if awesome then
awesome.emit_signal("debug::deprecation", msg, see, args)
end
end end
--- Create a class proxy with deprecation messages. --- Create a class proxy with deprecation messages.

4
luaa.c
View File

@ -88,8 +88,10 @@ extern const struct luaL_Reg awesome_mouse_meta[];
/** A deprecated Lua function was called. /** A deprecated Lua function was called.
* *
* @param hint String with a hint on what to use instead of the * @tparam string hint String with a hint on what to use instead of the
* deprecated functionality. * deprecated functionality.
* @tparam[opt=nil] string|nil see The name of the newer API
* @tparam[opt=nil] table|nil args The name of the newer API
* @signal debug::deprecation * @signal debug::deprecation
*/ */