From aebd26d03ae2a9fd27c4b01c2b463eb35db620c3 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Mon, 27 Dec 2021 19:36:15 -0500 Subject: [PATCH] [lib/dtutils.lua] - Added deprecated function to use when deprecating scripts [contrib/rename-tags.lua] - Added deprecation warning --- contrib/rename-tags.lua | 1 + lib/dtutils.lua | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/contrib/rename-tags.lua b/contrib/rename-tags.lua index d440c5f..74d9bfe 100644 --- a/contrib/rename-tags.lua +++ b/contrib/rename-tags.lua @@ -34,6 +34,7 @@ local debug = require "darktable.debug" -- check API version du.check_min_api_version("7.0.0", "rename-tags") +du.deprecated("contrib/rename-tags.lua","darktable release 4.0") -- return data structure for script_manager diff --git a/lib/dtutils.lua b/lib/dtutils.lua index 1b06a15..0a6d441 100644 --- a/lib/dtutils.lua +++ b/lib/dtutils.lua @@ -330,4 +330,29 @@ function dtutils.find_image_by_id(imgid) end end +dtutils.libdoc.functions["deprecated"] = { + Name = [[deprecated]], + Synopsis = [[print deprecation warning]], + Usage = [[local du = require "lib/dtutils" + + du.deprecated(script_name, removal_string) + script_name - name of the script being deprecated + removal_strubg - a string explaining when the script will be removed]], + Description = [[deprecated prints an error message saying the script is deprecated and when it will be removed]], + Return_Value = [[]], + Limitations = [[]], + Example = [[local du = require "lib/dtutils" + du.deprecated("contrib/rename-tags.lua", "darktable release 4.0")]], + See_Also = [[]], + Reference = [[]], + License = [[]], + Copyright = [[]], +} + +function dtutils.deprecated(script_name, removal_string) + dt.print_toast("WARNING: " .. script_name .. " is deprecated and will be removed in " .. removal_string) + dt.print_error("WARNING: " .. script_name .. " is deprecated and will be removed in " .. removal_string) +end + + return dtutils