From 41e37210181de1a15cf78aa763700f0e1f33cfee Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 5 May 2022 10:22:33 +0200 Subject: [PATCH] add deprecation --- src/args.jl | 17 ++++++++++++++--- src/consts.jl | 1 + test/test_args.jl | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/args.jl b/src/args.jl index 9376b30d..ce97ff30 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1612,6 +1612,10 @@ function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes) already_warned = get!(_already_warned, bend, Set{Symbol}()) extra_kwargs = Dict{Symbol,Any}() for k in keys(plotattributes) + if k in keys(_deprecated_attributes) + k in already_warned || push!(_to_warn, k) + continue + end is_attr_supported(pkg, k) && continue k in _suppress_warnings && continue default_value = default(k) @@ -1626,9 +1630,16 @@ function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes) get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg)) for k in sort(collect(_to_warn)) push!(already_warned, k) - @warn( - "Keyword argument $k not supported with $pkg. Choose from: $(join(supported_attrs(pkg), ", "))" - ) + if k in keys(_deprecated_attributes) + @warn(""" + Keyword argument `$k` is deprecated. + Please use `$(_deprecated_attributes[k])` instead. + """) + else + @warn( + "Keyword argument $k not supported with $pkg. Choose from: $(join(supported_attrs(pkg), ", "))" + ) + end end end return extra_kwargs diff --git a/src/consts.jl b/src/consts.jl index 3f2a8653..794e12a3 100644 --- a/src/consts.jl +++ b/src/consts.jl @@ -1,4 +1,5 @@ +const _deprecated_attributes = Dict{Symbol, Symbol}(:orientation => :series_permutation) const _all_defaults = KW[_series_defaults, _plot_defaults, _subplot_defaults] const _initial_defaults = deepcopy(_all_defaults) diff --git a/test/test_args.jl b/test/test_args.jl index f472e40e..fd2a43f1 100644 --- a/test/test_args.jl +++ b/test/test_args.jl @@ -1,4 +1,4 @@ -using Plots, Test, NaNMath +using Plots, Test @testset "Series Attributes" begin pl = plot([[1, 2, 3], [2, 3, 4]], lw = 5)