add deprecation

This commit is contained in:
Simon Christ 2022-05-05 10:22:33 +02:00
parent e73f880a11
commit 41e3721018
3 changed files with 16 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)