diff --git a/.gitignore b/.gitignore index c72e5df5a..70622c11b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ test/*.js *.log Manifest.toml docs/src/tutorial/*.json +docs/src/*/*.ipynb diff --git a/docs/Project.toml b/docs/Project.toml index 45fac2860..57b93181e 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,7 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" diff --git a/docs/make.jl b/docs/make.jl index e4d253a14..194cf4249 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -39,6 +39,18 @@ if FIX_DOCTESTS end end +function add_binder_links(filename, content) + filename = replace(filename, ".jl" => ".ipynb") + links = """ + + + #md # [![](https://mybinder.org/badge_logo.svg)](@__BINDER_ROOT_URL__/$filename) + #md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/$filename) + """ + m = match(r"(\# \# .+)", content) + return replace(content, m[1] => m[1] * links) +end + for dir in joinpath.(@__DIR__, "src", ("examples", "tutorial", "explanation")) for jl_filename in list_of_sorted_files(dir, dir, ".jl") Random.seed!(12345) @@ -52,8 +64,13 @@ for dir in joinpath.(@__DIR__, "src", ("examples", "tutorial", "explanation")) jl_filename, dir; documenter = true, + preprocess = content -> add_binder_links( + replace(jl_filename, joinpath(@__DIR__, "src", "") => ""), + content, + ), postprocess = content -> replace(content, "nothing #hide" => ""), ) + Literate.notebook(jl_filename, dir; execute = false) end end