Skip to content

Commit d56ff26

Browse files
authored
Add automatic formatting checks using Runic (#667)
1 parent 5991f97 commit d56ff26

Some content is hidden

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

51 files changed

+1398
-1142
lines changed

.github/workflows/Formatting.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Formatting
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
- 'release-'
7+
tags:
8+
- '*'
9+
pull_request:
10+
jobs:
11+
runic:
12+
name: Runic formatting
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: julia-actions/setup-julia@v2
17+
with:
18+
version: '1'
19+
- uses: julia-actions/cache@v2
20+
- uses: fredrikekre/runic-action@v1
21+
with:
22+
version: '1.4'

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.DS_Store
2-
/Manifest.toml
3-
test/coverage/Manifest.toml
4-
docs/Manifest.toml
2+
**/Manifest.toml
53
docs/build
64
docs/src/democards
75
docs/node_modules
@@ -10,4 +8,3 @@ docs/package-lock.json
108
docs/src/changelog.md
119
.vscode/settings.json
1210
/scratch
13-
/_readme/Manifest.toml

_readme/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Pkg.precompile()
66

77
run(`quarto render README.qmd`)
88
mv("README.md", "../README.md", force = true)
9-
mv("README_files/", "../README_files/", force = true)
9+
mv("README_files/", "../README_files/", force = true)

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using DocumenterVitepress
44
using Literate, Glob
55
using CairoMakie
66

7-
DocMeta.setdocmeta!(AlgebraOfGraphics, :DocTestSetup, :(using AlgebraOfGraphics); recursive=true)
7+
DocMeta.setdocmeta!(AlgebraOfGraphics, :DocTestSetup, :(using AlgebraOfGraphics); recursive = true)
88

99
cp(joinpath(@__DIR__, "..", "CHANGELOG.md"), joinpath(@__DIR__, "src", "changelog.md"), force = true)
1010

examples/gui.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,47 @@ using AlgebraOfGraphics: linear, smooth, density, AlgebraicList, layoutplot!
1111

1212
function clean!(g::GridLayout)
1313
foreach(delete!, Any, g)
14-
foreach(GridLayoutBase.remove_from_gridlayout!, g.content)
14+
return foreach(GridLayoutBase.remove_from_gridlayout!, g.content)
1515
end
1616

1717
function gui!(scene, layout, df)
1818
table = data(df)
1919

2020
plot_options = [("none", nothing), ("scatter", Scatter), ("lines", Lines), ("barplot", BarPlot)]
21-
plot_menu = LMenu(scene, options = plot_options, textsize=30, width=500)
21+
plot_menu = LMenu(scene, options = plot_options, textsize = 30, width = 500)
2222

23-
layout[1, 1] = Label(scene, "plot type", fontsize=30)
23+
layout[1, 1] = Label(scene, "plot type", fontsize = 30)
2424
layout[1, 2] = plot_menu
2525

26-
analysis_options = [("none", nothing), ("linear", linear), ("smooth", smooth),
27-
("density", density)]
26+
analysis_options = [
27+
("none", nothing), ("linear", linear), ("smooth", smooth),
28+
("density", density),
29+
]
2830

29-
analysis_menu = LMenu(scene, options = analysis_options, textsize=30, width=500)
31+
analysis_menu = LMenu(scene, options = analysis_options, textsize = 30, width = 500)
3032

31-
layout[2, 1] = Label(scene, "analysis", fontsize=30)
33+
layout[2, 1] = Label(scene, "analysis", fontsize = 30)
3234
layout[2, 2] = analysis_menu
3335

3436
axis_options = vcat([("None", nothing)], [(s, Symbol(s)) for s in propertynames(table.data)])
3537

3638
mappings = ["x", "y", "color", "marker", "markersize", "linestyle", "layout_x", "layout_y"]
37-
mapping_menus = [LMenu(scene, options=axis_options, textsize=30, width=500) for mapping in mappings]
39+
mapping_menus = [LMenu(scene, options = axis_options, textsize = 30, width = 500) for mapping in mappings]
3840
N = length(mappings)
3941

4042
for i in 1:N
41-
layout[2+i, 1] = Label(scene, mappings[i], fontsize=30)
42-
layout[2+i, 2] = mapping_menus[i]
43+
layout[2 + i, 1] = Label(scene, mappings[i], fontsize = 30)
44+
layout[2 + i, 2] = mapping_menus[i]
4345
end
4446

45-
plot_button = Button(scene, label="Plot", textsize=30)
46-
add_and_plot_button = Button(scene, label="Add and Plot", buttoncolor="powderblue", textsize=30)
47+
plot_button = Button(scene, label = "Plot", textsize = 30)
48+
add_and_plot_button = Button(scene, label = "Add and Plot", buttoncolor = "powderblue", textsize = 30)
4749

4850
layout[1, 3] = plot_button
4951
layout[1, 4] = add_and_plot_button
5052

51-
axs = layout[1:2+N, 5] = GridLayout(1, 2) # for plot and legend
52-
colsize!(axs, 2, Relative(1/5)) # make legend a fourth of the plot's width
53+
axs = layout[1:(2 + N), 5] = GridLayout(1, 2) # for plot and legend
54+
colsize!(axs, 2, Relative(1 / 5)) # make legend a fourth of the plot's width
5355

5456
state = AlgebraicList()
5557

@@ -66,7 +68,7 @@ function gui!(scene, layout, df)
6668
end
6769
clean!(axs)
6870
state += acc
69-
layoutplot!(scene, axs, state)
71+
return layoutplot!(scene, axs, state)
7072
end
7173

7274
on(plot_button.clicks) do _

ext/AlgebraOfGraphicsDynamicQuantitiesExt.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ const DQ = DynamicQuantities
66

77
AlgebraOfGraphics.extrema_finite(v::AbstractVector{<:DQ.Quantity}) = extrema(Iterators.filter(isfinite, skipmissing(v)))
88

9-
struct DimensionMismatch{X1,X2} <: Exception
9+
struct DimensionMismatch{X1, X2} <: Exception
1010
x1::X1
1111
x2::X2
1212
end
1313

14-
dimensionless(x, u::DQ.Quantity{<:Any,<:DQ.SymbolicDimensions}) = DQ.ustrip(DQ.uconvert(u, x))
15-
function dimensionless(x, u::DQ.Quantity{<:Any,<:DQ.Dimensions})
14+
dimensionless(x, u::DQ.Quantity{<:Any, <:DQ.SymbolicDimensions}) = DQ.ustrip(DQ.uconvert(u, x))
15+
function dimensionless(x, u::DQ.Quantity{<:Any, <:DQ.Dimensions})
1616
xexp = DQ.uexpand(x)
1717
uexp = DQ.uexpand(u)
1818
DQ.dimension(xexp) == DQ.dimension(uexp) || throw(DimensionMismatch(x, u))
19-
DQ.ustrip(xexp)
19+
return DQ.ustrip(xexp)
2020
end
2121

2222
function AlgebraOfGraphics.strip_units(scale, data::AbstractVector{<:DQ.Quantity})
@@ -29,10 +29,10 @@ end
2929
AlgebraOfGraphics.is_unit(::DynamicQuantities.Quantity) = true # there seems to be no FreeUnits equivalent in DQ
3030

3131
function AlgebraOfGraphics.unit_string(u::DQ.Quantity)
32-
string(DQ.dimension(u))
32+
return string(DQ.dimension(u))
3333
end
3434

35-
function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T}) where T <: DynamicQuantities.Quantity
35+
function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T}) where {T <: DynamicQuantities.Quantity}
3636
o1, o2 = oneunit.(scale.extrema)
3737
o1 == o2 || error("Different ones $o1 $o2")
3838
o = o1
@@ -47,7 +47,7 @@ function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T})
4747
end
4848

4949
function AlgebraOfGraphics.dimensionally_compatible(q1::DynamicQuantities.Quantity, q2::DynamicQuantities.Quantity)
50-
try
50+
return try
5151
# because we can't uconvert to Dimensions its not super straightforward
5252
# to check if the units are compatible, so we reuse the conversion mechanism
5353
dimensionless(q1, q2)
@@ -61,4 +61,4 @@ function AlgebraOfGraphics.dimensionally_compatible(q1::DynamicQuantities.Quanti
6161
end
6262
end
6363

64-
end
64+
end

ext/AlgebraOfGraphicsUnitfulExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function AlgebraOfGraphics.strip_units(scale, data::AbstractVector{<:Unitful.Qua
1111
end
1212

1313
function AlgebraOfGraphics.unit_string(u::Unitful.FreeUnits)
14-
string(u)
14+
return string(u)
1515
end
1616

1717
AlgebraOfGraphics.is_unit(::Unitful.FreeUnits) = true
1818

19-
function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T}) where T <: Unitful.Quantity
19+
function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T}) where {T <: Unitful.Quantity}
2020
u = Unitful.unit(eltype(scale.extrema))
2121
if scale.props.unit === nothing
2222
return u
@@ -30,7 +30,7 @@ function AlgebraOfGraphics.getunit(scale::AlgebraOfGraphics.ContinuousScale{T})
3030
end
3131

3232
function AlgebraOfGraphics.dimensionally_compatible(u1::Unitful.FreeUnits, u2::Unitful.FreeUnits)
33-
Unitful.dimension(u1) == Unitful.dimension(u2)
33+
return Unitful.dimension(u1) == Unitful.dimension(u2)
3434
end
3535

36-
end
36+
end

src/AlgebraOfGraphics.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ using PlotUtils: AbstractColorList
1111
using Makie
1212
using Makie: current_default_theme, to_value, automatic, Automatic, Block, ATTRIBUTES
1313
import Makie: hidexdecorations!,
14-
hideydecorations!,
15-
hidedecorations!,
16-
linkaxes!,
17-
linkxaxes!,
18-
linkyaxes!
14+
hideydecorations!,
15+
hidedecorations!,
16+
linkaxes!,
17+
linkxaxes!,
18+
linkyaxes!
1919
using GridLayoutBase: update!, Protrusion, protrusionsobservable
2020
using PooledArrays: PooledArray
2121
using Dictionaries: AbstractDictionary, Dictionary, Indices, getindices, set!, dictionary

0 commit comments

Comments
 (0)