rework warn_on_unsupported

This commit is contained in:
t-bltg 2022-01-28 12:40:49 +01:00
parent 824dbe9948
commit 6db248dbde
2 changed files with 7 additions and 3 deletions

View File

@ -1588,6 +1588,8 @@ end
const _already_warned = Dict{Symbol,Set{Symbol}}() const _already_warned = Dict{Symbol,Set{Symbol}}()
const _to_warn = Set{Symbol}() const _to_warn = Set{Symbol}()
should_warn_on_unsupported(::AbstractBackend) = _plot_defaults[:warn_on_unsupported]
function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes) function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
empty!(_to_warn) empty!(_to_warn)
bend = backend_name(pkg) bend = backend_name(pkg)
@ -1605,7 +1607,7 @@ function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
end end
if !isempty(_to_warn) && if !isempty(_to_warn) &&
get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported]) get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
for k in sort(collect(_to_warn)) for k in sort(collect(_to_warn))
push!(already_warned, k) push!(already_warned, k)
@warn( @warn(
@ -1621,7 +1623,7 @@ end
# _markershape_supported(pkg::AbstractBackend, shapes::AVec) = all([_markershape_supported(pkg, shape) for shape in shapes]) # _markershape_supported(pkg::AbstractBackend, shapes::AVec) = all([_markershape_supported(pkg, shape) for shape in shapes])
function warn_on_unsupported(pkg::AbstractBackend, plotattributes) function warn_on_unsupported(pkg::AbstractBackend, plotattributes)
if !get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported]) if !get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
return return
end end
if !is_seriestype_supported(pkg, plotattributes[:seriestype]) if !is_seriestype_supported(pkg, plotattributes[:seriestype])
@ -1642,7 +1644,7 @@ function warn_on_unsupported(pkg::AbstractBackend, plotattributes)
end end
function warn_on_unsupported_scales(pkg::AbstractBackend, plotattributes::AKW) function warn_on_unsupported_scales(pkg::AbstractBackend, plotattributes::AKW)
if !get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported]) if !get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
return return
end end
for k in (:xscale, :yscale, :zscale, :scale) for k in (:xscale, :yscale, :zscale, :scale)

View File

@ -1,5 +1,7 @@
# https://github.com/JuliaPlots/UnicodePlots.jl # https://github.com/JuliaPlots/UnicodePlots.jl
should_warn_on_unsupported(::UnicodePlotsBackend) = false
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------
const _canvas_map = ( const _canvas_map = (
braille = UnicodePlots.BrailleCanvas, braille = UnicodePlots.BrailleCanvas,