Reproducible examples in blog posts
When migrating this blog recently from Hugo to Franklin.jl, the main difficulty I faced was reproducing old examples (so effectively I didn't rerun anything, and just moved the old generated HTML pages). I have been bothered by this for a long time, so I wrote a quick hack which I packaged up in ReproducibleLiteratePage.jl.
This page was processed using that package. Here is how it works:
take a Julia code file marked up with Literate.jl,
add a
Project.toml
and aManifest.toml
(eg activate the directory as a project and add packages)produce a markdown file using
ReproducibleLiteratePage.compile_directory()
.
Here is some code:
using UnPack # the lightest package I could think of
struct Foo
a
b
end
@unpack a, b = Foo(1, 2)
a, b
(1, 2)
The Julia source (again, marked up with Literate.jl), Project.toml
, and Manifest.toml
should be available as a tar
archive at the bottom of the page.