@@ -14,11 +14,11 @@ export @recipe,
1414
1515# Common abstract types for the Plots ecosystem
1616abstract type AbstractBackend end
17- abstract type AbstractPlot{T<: AbstractBackend } end
17+ abstract type AbstractPlot{T <: AbstractBackend } end
1818abstract type AbstractLayout end
1919
20- const KW = Dict{Symbol,Any}
21- const AKW = AbstractDict{Symbol,Any}
20+ const KW = Dict{Symbol, Any}
21+ const AKW = AbstractDict{Symbol, Any}
2222
2323# a placeholder to establish the name so that other packages (Plots.jl for example)
2424# can add their own definition of RecipesBase.plot since RecipesBase is the common
@@ -45,18 +45,18 @@ group_as_matrix(t) = false
4545# This holds the recipe definitions to be dispatched on
4646# the function takes in an attribute dict `d` and a list of args.
4747# This default definition specifies the "no-arg" case.
48- apply_recipe(plotattributes:: AbstractDict{Symbol,Any} ) = ()
48+ apply_recipe(plotattributes:: AbstractDict{Symbol, Any} ) = ()
4949
5050# Is a key explicitly provided by the user?
5151# Should be overridden for subtypes representing plot attributes.
52- is_explicit(d:: AbstractDict{Symbol,Any} , k) = haskey(d, k)
52+ is_explicit(d:: AbstractDict{Symbol, Any} , k) = haskey(d, k)
5353function is_default end
5454
5555# --------------------------------------------------------------------------
5656
5757# this holds the data and attributes of one series, and is returned from apply_recipe
5858struct RecipeData
59- plotattributes:: AbstractDict{Symbol,Any}
59+ plotattributes:: AbstractDict{Symbol, Any}
6060 args:: Tuple
6161end
6262
@@ -82,13 +82,13 @@ _equals_symbol(x, sym::Symbol) = false
8282# build an apply_recipe function header from the recipe function header
8383function get_function_def(func_signature:: Expr , args:: Vector )
8484 front = func_signature. args[1 ]
85- if func_signature. head ≡ :where
85+ return if func_signature. head ≡ :where
8686 Expr(:where, get_function_def(front, args), esc.(func_signature. args[2 : end ]). .. )
8787 elseif func_signature. head ≡ :call
8888 func = Expr(
8989 :call,
9090 :($ RecipesBase. apply_recipe),
91- esc.([:(plotattributes:: AbstractDict{Symbol,Any} ); args]). .. ,
91+ esc.([:(plotattributes:: AbstractDict{Symbol, Any} ); args]). .. ,
9292 )
9393 if isa(front, Expr) && front. head ≡ :curly
9494 Expr(:where, func, esc.(front. args[2 : end ]). .. )
@@ -124,13 +124,13 @@ function create_kw_body(func_signature::Expr)
124124 cleanup_body. args,
125125 :(
126126 $ RecipesBase. is_key_supported($ (QuoteNode(k))) ||
127- delete!(plotattributes, $ (QuoteNode(k)))
127+ delete!(plotattributes, $ (QuoteNode(k)))
128128 ),
129129 )
130130 end
131131 args = args[2 : end ]
132132 end
133- args, kw_body, cleanup_body
133+ return args, kw_body, cleanup_body
134134end
135135
136136# process the body of the recipe recursively.
@@ -191,11 +191,11 @@ function process_recipe_body!(expr::Expr)
191191 # error when not supported by the backend
192192 :(
193193 $ RecipesBase. is_key_supported($ k) ? $ set_expr :
194- error(
195- " In recipe: required keyword " ,
196- $ k,
197- " is not supported by backend $(backend_name()) " ,
198- )
194+ error(
195+ " In recipe: required keyword " ,
196+ $ k,
197+ " is not supported by backend $(backend_name()) " ,
198+ )
199199 )
200200 else
201201 set_expr
@@ -212,6 +212,7 @@ function process_recipe_body!(expr::Expr)
212212 end
213213 end
214214 end
215+ return
215216end
216217
217218# --------------------------------------------------------------------------
335336```
336337"""
337338macro series(expr:: Expr )
338- quote
339+ return quote
339340 let plotattributes = copy(plotattributes)
340341 args = $ expr
341342 push!(
@@ -362,7 +363,7 @@ grouphist(rand(1_000, 4))
362363```
363364"""
364365macro userplot(expr)
365- _userplot(expr)
366+ return _userplot(expr)
366367end
367368
368369function _userplot(expr:: Expr )
@@ -374,7 +375,7 @@ function _userplot(expr::Expr)
374375 funcname2 = Symbol(funcname, " !" )
375376
376377 # return a code block with the type definition and convenience plotting methods
377- quote
378+ return quote
378379 $ expr
379380 export $ funcname, $ funcname2
380381 Core. @__doc__ $ funcname(args... ; kw... ) =
@@ -386,15 +387,19 @@ function _userplot(expr::Expr)
386387 end |> esc
387388end
388389
389- _userplot(sym:: Symbol ) = _userplot(:(mutable struct $ sym
390- args
391- end ))
390+ _userplot(sym:: Symbol ) = _userplot(
391+ :(
392+ mutable struct $ sym
393+ args
394+ end
395+ )
396+ )
392397
393398gettypename(sym:: Symbol ) = sym
394399
395400function gettypename(expr:: Expr )
396401 expr. head ≡ :curly || @error " Unexpected struct name: $expr "
397- expr. args[1 ]
402+ return expr. args[1 ]
398403end
399404
400405# ----------------------------------------------------------------------------
@@ -422,7 +427,7 @@ Plot my series type!
422427"""
423428macro shorthands(funcname:: Symbol )
424429 funcname2 = Symbol(funcname, " !" )
425- quote
430+ return quote
426431 export $ funcname, $ funcname2
427432 Core. @__doc__ $ funcname(args... ; kw... ) =
428433 $ RecipesBase. plot(args... ; kw... , seriestype = $ (Meta. quot(funcname)))
@@ -481,26 +486,26 @@ iscol(v) = isa(v, Expr) && v.head ≡ :vcat
481486rowsize(v) = isrow(v) ? length(v. args) : 1
482487
483488create_grid(expr:: Expr ) =
484- if iscol(expr)
485- create_grid_vcat(expr)
486- elseif isrow(expr)
487- sub(x) = :(cell[1 , $ (first(x))] = $ (create_grid(last(x))))
488- quote
489- let cell = Matrix(undef, 1 , $ (length(expr. args)))
490- $ (map(sub, enumerate(expr. args)). .. )
491- cell
492- end
489+ if iscol(expr)
490+ create_grid_vcat(expr)
491+ elseif isrow(expr)
492+ sub(x) = :(cell[1 , $ (first(x))] = $ (create_grid(last(x))))
493+ quote
494+ let cell = Matrix(undef, 1 , $ (length(expr. args)))
495+ $ (map(sub, enumerate(expr. args)). .. )
496+ cell
493497 end
494- elseif expr. head ≡ :curly
495- create_grid_curly(expr)
496- else
497- esc(expr) # if it's something else, just return that (might be an existing layout?)
498498 end
499+ elseif expr. head ≡ :curly
500+ create_grid_curly(expr)
501+ else
502+ esc(expr) # if it's something else, just return that (might be an existing layout?)
503+ end
499504
500505function create_grid_vcat(expr:: Expr )
501506 rowsizes = map(rowsize, expr. args)
502507 rmin, rmax = extrema(rowsizes)
503- if rmin > 0 && rmin == rmax
508+ return if rmin > 0 && rmin == rmax
504509 # we have a grid... build the whole thing
505510 # note: rmin is the number of columns
506511 nr = length(expr. args)
@@ -539,7 +544,7 @@ function create_grid_curly(expr::Expr)
539544 add_layout_pct!(kw, arg, i, length(expr. args) - 1 )
540545 end
541546 s = expr. args[1 ]
542- if isa(s, Expr) && s. head ≡ :call && s. args[1 ] ≡ :grid
547+ return if isa(s, Expr) && s. head ≡ :call && s. args[1 ] ≡ :grid
543548 create_grid(
544549 quote
545550 grid(
@@ -593,7 +598,7 @@ julia> @layout [_ ° _; ° ° °; ° ° °]
593598```
594599"""
595600macro layout(mat:: Expr )
596- create_grid(mat)
601+ return create_grid(mat)
597602end
598603
599604# COV_EXCL_START
0 commit comments