Skip to content

Commit 7cf45f4

Browse files
authored
Merge pull request #33 from MakieOrg/jk/docs-fixes
Docs fixes
2 parents b53d451 + 46f7840 commit 7cf45f4

File tree

14 files changed

+51
-136
lines changed

14 files changed

+51
-136
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
shell: julia --project=docs --color=yes {0}
5656
run: |
5757
using Pkg
58-
Pkg.develop(PackageSpec(path=pwd()))
5958
Pkg.instantiate()
6059
- uses: julia-actions/julia-buildpkg@v1
6160
- uses: julia-actions/julia-docdeploy@v1

docs/Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
66
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
77
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
88
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
9+
Librsvg_jll = "925c91fb-5dd6-59dd-8e8c-345e74382d89"
910
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
10-
MakieTeX = "6d554a22-29e7-47bd-aee5-0c5f06619414"
11-
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
1211
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
13-
Rsvg = "c4c386cf-5103-5370-be45-f3a111cca3b8"
1412
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1513
SwarmMakie = "0b1c068e-6a84-4e66-8136-5c95cafa83ed"
14+
15+
[sources]
16+
SwarmMakie = {path = ".."}

docs/documenter_figure_block.jl

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

docs/make.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ using SwarmMakie
22
using Documenter, DocumenterVitepress, Literate
33
using CairoMakie
44

5-
CairoMakie.activate!(type="svg", pt_per_unit = 1)
6-
7-
include("documenter_figure_block.jl")
8-
95
DocMeta.setdocmeta!(SwarmMakie, :DocTestSetup, :(using SwarmMakie); recursive=true)
106

11-
ENV["DATADEPS_ALWAYS_ACCEPT"] = true
12-
137
# Now, we convert the source code to markdown files using Literate.jl
148
source_path = joinpath(dirname(@__DIR__), "src")
159
output_path = joinpath(@__DIR__, "src", "source")
@@ -30,10 +24,6 @@ function _add_meta_edit_link_generator(path)
3024
end
3125
end
3226

33-
function _replace_example_with_figure(input)
34-
return replace(input, "```@example" => "```@figure")
35-
end
36-
3727
# First letter of `str` is made uppercase and returned
3828
ucfirst(str::String) = string(uppercase(str[1]), str[2:end])
3929

@@ -49,7 +39,7 @@ function process_literate_recursive!(pages::Vector{Any}, path::String; source_pa
4939
Literate.markdown(
5040
path, output_dir;
5141
flavor = Literate.CommonMarkFlavor(),
52-
postprocess = _add_meta_edit_link_generator(joinpath(relpath(source_path, output_dir), relative_path)) _replace_example_with_figure
42+
postprocess = _add_meta_edit_link_generator(joinpath(relpath(source_path, output_dir), relative_path))
5343
)
5444
push!(pages, joinpath("source", splitext(relative_path)[1] * ".md"))
5545
end
@@ -65,7 +55,9 @@ withenv("JULIA_DEBUG" => "Literate") do # allow Literate debug output to escape
6555
end
6656

6757
# As a special case, literatify the examples.jl file in docs/src to Documenter markdown
68-
Literate.markdown(joinpath(@__DIR__, "src", "examples", "examples.jl"), joinpath(@__DIR__, "src", "examples"); flavor = Literate.DocumenterFlavor(), postprocess = _replace_example_with_figure)
58+
Literate.markdown(joinpath(@__DIR__, "src", "examples", "examples.jl"), joinpath(@__DIR__, "src", "examples"); flavor = Literate.DocumenterFlavor())
59+
60+
is_ci() = get(ENV, "CI", "false") == "true"
6961

7062
makedocs(;
7163
modules=[SwarmMakie],
@@ -75,6 +67,7 @@ makedocs(;
7567
repo = "https://github.com/MakieOrg/SwarmMakie.jl",
7668
devurl = "dev",
7769
devbranch = "main",
70+
(is_ci() ? (;) : (; deploy_url = ""))..., # without deploy_url="" locally the build is broken due to a SwarmMakie.jl prefix
7871
),
7972
pages=[
8073
"Introduction" => "introduction.md",
@@ -88,7 +81,7 @@ makedocs(;
8881
"API Reference" => "api.md",
8982
"Source code" => literate_pages,
9083
],
91-
warnonly = true,
84+
warnonly = !is_ci(),
9285
)
9386

9487
deploydocs(;

docs/src/algorithms.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In addition, SwarmMakie offers jittered scatter plots as algorithms to `beeswarm
1010

1111
Here's a comparison of all the available algorithms:
1212

13-
```@figure all_algorithms
13+
```@example all_algorithms
1414
using SwarmMakie, CairoMakie
1515
algorithms = [NoBeeswarm() SimpleBeeswarm() WilkinsonBeeswarm(); UniformJitter() PseudorandomJitter() QuasirandomJitter()]
1616
fig = Figure(; size = (800, 450))
@@ -27,6 +27,7 @@ fig
2727

2828
```@docs; canonical=false
2929
SimpleBeeswarm
30+
SimpleBeeswarm2
3031
WilkinsonBeeswarm
3132
NoBeeswarm
3233
```

docs/src/assets/logo.png

-36.9 KB
Loading

docs/src/examples/examples.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ fig
1717
# ## Palmer Penguins
1818

1919
using AlgebraOfGraphics, CairoMakie, SwarmMakie
20-
using PalmerPenguins, DataFrames
2120

22-
penguins = dropmissing(DataFrame(PalmerPenguins.load()))
23-
24-
f = data(penguins) * mapping(:species, :bill_depth_mm, color=:sex) * visual(Beeswarm) |> draw
25-
f
21+
data(AlgebraOfGraphics.penguins()) *
22+
mapping(:species, :bill_depth_mm, color=:sex) *
23+
visual(Beeswarm) |> draw
2624

2725
# ## SwarmMakie logo
2826

docs/src/examples/scales.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Beeswarm plots can be plotted in any combination of `xscale` and `yscale`.
44

55
Specifically, beeswarm plots are correct in any [separable transform](https://geo.makie.org/stable/nonlinear_transforms/#Nonlinear-but-separable) - basically, any transform in which the x and y coordinates are independent of each other. This excludes most geographic transformations, but includes any transformation you can make using `xscale` and `yscale` in a Makie `Axis`.
66

7-
```@figure logscale
7+
```@example logscale
88
using SwarmMakie, CairoMakie
99
data = randn(75) .+ 3
1010
fig = Figure()
@@ -17,7 +17,7 @@ fig
1717

1818
Note how the shape of the beeswarm is transformed in the left plot, because of the log scale.
1919

20-
```@figure logscale
20+
```@example logscale
2121
ax2.xscale = Makie.pseudolog10
2222
ax2.title = "Log x and y axes"
2323
fig

docs/src/examples/unconventional.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can use swarm plots to simply separate scatter markers which share the same
1010
using Base.MathConstants
1111
using CSV
1212
using DataFrames
13-
using AlgebraOfGraphics, SwarmMakie, CairoMakie, MakieTeX
13+
using AlgebraOfGraphics, SwarmMakie, CairoMakie
1414
using StatsBase, CategoricalArrays
1515
1616
# Load benchmark data from file
@@ -149,21 +149,34 @@ f
149149
```@example julia-benchmark
150150
# Get logos for programming languages
151151
152-
using Rsvg
153152
using CairoMakie
154-
using CairoMakie.Cairo, CairoMakie.FileIO
155-
using MakieTeX
153+
using CairoMakie.FileIO
154+
using Librsvg_jll
155+
156+
function svg_to_img(svg)
157+
mktempdir() do dir
158+
pngpath = joinpath(dir, "img.png")
159+
Librsvg_jll.rsvg_convert() do bin
160+
open(`$bin -o $pngpath`, "w") do io
161+
write(io, svg)
162+
end
163+
end
164+
FileIO.load(pngpath)
165+
end
166+
end
156167
157168
language_logo_url(lang::String) = "https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/$(lowercase(lang))/$(lowercase(lang))-original.svg"
158169
170+
language_to_img(lang::String) = svg_to_img(read(download(language_logo_url(lang)), String))
171+
159172
language_marker_dict = Dict{String, Any}(
160-
[key => read(download(language_logo_url(key)), String) |> MakieTeX.CachedSVG for key in ("c", "fortran", "go", "java", "javascript", "julia", "matlab", "python", "r", "rust")]
173+
[key => language_to_img(key) for key in ("c", "fortran", "go", "java", "javascript", "julia", "matlab", "python", "r", "rust")]
161174
)
162175
163176
language_marker_dict["octave"] = FileIO.load(File{format"PNG"}(download("https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Gnu-octave-logo.svg/2048px-Gnu-octave-logo.svg.png"))) .|> Makie.Colors.ARGB32
164177
165-
language_marker_dict["luajit"] = read(download(language_logo_url("lua")), String) |> MakieTeX.CachedSVG
166-
language_marker_dict["mathematica"] = read(download("https://upload.wikimedia.org/wikipedia/commons/2/20/Mathematica_Logo.svg"), String) |> MakieTeX.CachedSVG
178+
language_marker_dict["luajit"] = language_to_img("lua")
179+
language_marker_dict["mathematica"] = read(download("https://upload.wikimedia.org/wikipedia/commons/2/20/Mathematica_Logo.svg"), String) |> svg_to_img
167180
168181
169182
f, a, p = beeswarm(
@@ -172,7 +185,7 @@ f, a, p = beeswarm(
172185
markersize = 11,
173186
axis = (;
174187
yscale = log10,
175-
xticklabelrotation = 0,
188+
xticklabelrotation = pi/8,
176189
xticklabelsize = 12,
177190
xticksvisible = false,
178191
topspinecolor = :gray,

docs/src/gutters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Gutters
22

3-
```@figure gutters; backend=:CairoMakie; type="svg"
3+
```@example gutters; backend=:CairoMakie; type="svg"
44
using SwarmMakie, CairoMakie
55
xs = rand(1:10, 2000)
66
beeswarm(xs, rand(2000); gutter = 0.3, color = xs)
@@ -14,7 +14,7 @@ A nice gutter size to avoid overlap in neighboring categories ranges between `0.
1414

1515
## Examples
1616

17-
```@figure gutters
17+
```@example gutters
1818
using SwarmMakie, CairoMakie
1919
f, a, p = beeswarm(
2020
rand(1:3, 300), randn(300);
@@ -23,7 +23,7 @@ f, a, p = beeswarm(
2323
p.gutter = 0.5
2424
```
2525
Note the warning messages printed here! These can be helpful to diagnose when your data is moving too far out of the gutter, but you can turn them off by passing `gutter_threshold = false` or setting the `gutter_threshold` to a higher value (must be an `Int` and >0).
26-
```@figure gutters
26+
```@example gutters
2727
f
2828
```
2929

0 commit comments

Comments
 (0)