Skip to content

Commit 3615fb2

Browse files
authored
format using runic (#5134)
1 parent 2301af9 commit 3615fb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4275
-4311
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,16 @@ jobs:
3434
- '1' # latest stable
3535
experimental:
3636
- false
37-
os: [ubuntu-latest, windows-latest, macos-13]
37+
os: [ubuntu-latest, windows-latest, macos-13] # cannot use macos-latest a.k.a macos-14 on x64 (only aarch64)
3838
arch: [x64]
3939
include:
40-
# In its place, test Julia 1.6 on x86 macOS
4140
- os: macos-latest
4241
experimental: false
4342
arch: aarch64
4443
version: '1'
4544
- os: ubuntu-latest
4645
experimental: false
47-
prefix: xvfb-run # julia-actions/julia-runtest/blob/master/README.md
48-
# - os: ubuntu-latest
49-
# experimental: false
50-
# prefix: xvfb-run
51-
# version: '1.7' # only test intermediate release on `ubuntu` to spare resources
52-
# - os: ubuntu-latest
53-
# experimental: false
54-
# prefix: xvfb-run
55-
# version: '1.8' # only test intermediate release on `ubuntu` to spare resources
56-
# - os: ubuntu-latest
57-
# experimental: false
58-
# prefix: xvfb-run
59-
# version: '1.9' # only test intermediate release on `ubuntu` to spare resources
46+
prefix: xvfb-run # add `xvfb-run` prefix julia-actions/julia-runtest/blob/master/README.md
6047
- os: ubuntu-latest
6148
experimental: true
6249
prefix: xvfb-run
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CompatHelper
1+
name: compathelper
22

33
on:
44
schedule:

.github/workflows/format.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: format
2+
3+
on:
4+
push:
5+
branches: ['release-', 'master']
6+
tags:
7+
- '*'
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
runic:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: julia-actions/setup-julia@latest
20+
- uses: julia-actions/cache@v2
21+
- uses: fredrikekre/runic-action@v1

.github/workflows/format_check.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.github/workflows/format_pr.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: TagBot
1+
name: tagbot
22
on:
33
issue_comment:
44
types:
@@ -21,7 +21,7 @@ permissions:
2121
security-events: read
2222
statuses: read
2323
jobs:
24-
TagBot:
24+
tagbot:
2525
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
2626
runs-on: ubuntu-latest
2727
steps:

RecipesBase/src/RecipesBase.jl

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export @recipe,
1414

1515
# Common abstract types for the Plots ecosystem
1616
abstract type AbstractBackend end
17-
abstract type AbstractPlot{T<:AbstractBackend} end
17+
abstract type AbstractPlot{T <: AbstractBackend} end
1818
abstract 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)
5353
function is_default end
5454

5555
# --------------------------------------------------------------------------
5656

5757
# this holds the data and attributes of one series, and is returned from apply_recipe
5858
struct RecipeData
59-
plotattributes::AbstractDict{Symbol,Any}
59+
plotattributes::AbstractDict{Symbol, Any}
6060
args::Tuple
6161
end
6262

@@ -82,13 +82,13 @@ _equals_symbol(x, sym::Symbol) = false
8282
# build an apply_recipe function header from the recipe function header
8383
function 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
134134
end
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
215216
end
216217

217218
# --------------------------------------------------------------------------
@@ -335,7 +336,7 @@ end
335336
```
336337
"""
337338
macro 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
"""
364365
macro userplot(expr)
365-
_userplot(expr)
366+
return _userplot(expr)
366367
end
367368

368369
function _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
387388
end
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

393398
gettypename(sym::Symbol) = sym
394399

395400
function gettypename(expr::Expr)
396401
expr.head :curly || @error "Unexpected struct name: $expr"
397-
expr.args[1]
402+
return expr.args[1]
398403
end
399404

400405
#----------------------------------------------------------------------------
@@ -422,7 +427,7 @@ Plot my series type!
422427
"""
423428
macro 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
481486
rowsize(v) = isrow(v) ? length(v.args) : 1
482487

483488
create_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

500505
function 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
"""
595600
macro layout(mat::Expr)
596-
create_grid(mat)
601+
return create_grid(mat)
597602
end
598603

599604
# COV_EXCL_START

0 commit comments

Comments
 (0)