@@ -29,7 +29,7 @@ function build_examples(example_sources, destdir)
29
29
for source in example_sources
30
30
# Extract "example" from "path/example.jl"
31
31
name = splitext (basename (source))[1 ]
32
-
32
+
33
33
# Preprocess each example by adding a notebook download link at the top. The
34
34
# relative path is hardcoded according to the layout of `gh-pages` branch,
35
35
# which is set up by `Documenter.deploydocs`.
@@ -47,20 +47,25 @@ function build_examples(example_sources, destdir)
47
47
# Create Jupyter notebooks and Julia script for each Literate example. These
48
48
# will be stored in the `assets/` directory of the hosted docs.
49
49
for source in example_sources
50
- function preprocess (str)
50
+ function pp_vcheck (str)
51
+ check = " @assert pkgversion(Sunny) >= " * repr (pkgversion (Sunny))
52
+ return replace (str, r" ^(using.*Sunny.*)$" m => SubstitutionString (" \\ 1\n " * check))
53
+ end
54
+ function pp_wglmakie (str)
51
55
# Ideally, notebooks would use WGLMakie instead of GLMakie, but
52
56
# there are currently too many bugs to enable by default:
53
57
# https://github.com/SunnySuite/Sunny.jl/issues/211
54
58
#=
55
- str = replace(str, r"^using(.*?)GLMakie"m => s"using\1WGLMakie")
59
+ return replace(str, r"^using(.*?)GLMakie"m => s"using\1WGLMakie")
56
60
=#
57
- str
61
+ return str
58
62
end
63
+
59
64
# Build notebooks
60
- Literate. notebook (source, notebooks_path; preprocess, execute= false , credit= false )
65
+ Literate. notebook (source, notebooks_path; preprocess= pp_wglmakie ∘ pp_vcheck , execute= false , credit= false )
61
66
62
67
# Build julia scripts
63
- Literate. script (source, scripts_path; credit= false )
68
+ Literate. script (source, scripts_path; preprocess = pp_vcheck, credit= false )
64
69
end
65
70
66
71
# Return paths `$destpath/$name.md` for each new Markdown file (relative to
0 commit comments