Created
February 2, 2022 11:11
-
-
Save Pangoraw/63e6f6c2c2bcd12c0b0f170ae9191742 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.17.7 | |
using Markdown | |
using InteractiveUtils | |
# ╔═╡ bc0afc08-4320-4fdd-a09c-06c553c30db8 | |
import Pkg | |
# ╔═╡ e9c29457-523f-432e-abaf-800f4c3cbb7b | |
begin | |
Pkg.activate(mktempdir()) | |
Pkg.add("PlutoHooks") | |
Pkg.add("Revise") | |
Pkg.add("PlutoTest") | |
Pkg.develop(path="/home/paul/Projects/PlotuDiff.jl") | |
end | |
# ╔═╡ 98e662cc-8407-11ec-29f9-1dcf48b4d326 | |
import PlutoHooks, Revise | |
# ╔═╡ 21dcbc2f-7b0b-488a-bb48-6af9f7e86dc0 | |
using PlutoTest | |
# ╔═╡ 5d3b18ce-e0e9-4fec-b370-1a80672ea800 | |
macro revise(using_) | |
@assert Meta.isexpr(using_, :using, 1) && Meta.isexpr(using_.args[1], :(.), 1) "Expected expression of from :(using Package) but got $(repr(using_))" | |
mod = last(using_.args[1].args) | |
quote | |
$(esc(using_)) | |
# let block might be important to prevent Pluto from setting the values | |
# to nothing when jumping to a new workspace | |
let | |
_, rerun = @PlutoHooks.use_state(nothing) | |
@PlutoHooks.use_task([]) do | |
Revise.entr(() -> rerun(nothing), | |
[], [$(esc(mod))]; all=false, postpone=true) | |
end | |
end | |
nothing | |
end | |
end | |
# ╔═╡ daa5e0da-faf1-4f22-8f5a-be30a3227a69 | |
@revise using PlotuDiff | |
# ╔═╡ e4dd0b85-988a-4152-a1d0-7db71a766b30 | |
@test (stringdiff("Pluto", "Plotu").diffs |> merge_diffs) == [ | |
PlotuDiff.Equality("Pl"), | |
PlotuDiff.Deletion("ut"), | |
PlotuDiff.Equality(only("o")), | |
PlotuDiff.Insertion("tu"), | |
] | |
# ╔═╡ Cell order: | |
# ╠═98e662cc-8407-11ec-29f9-1dcf48b4d326 | |
# ╠═5d3b18ce-e0e9-4fec-b370-1a80672ea800 | |
# ╠═daa5e0da-faf1-4f22-8f5a-be30a3227a69 | |
# ╠═e4dd0b85-988a-4152-a1d0-7db71a766b30 | |
# ╠═21dcbc2f-7b0b-488a-bb48-6af9f7e86dc0 | |
# ╠═bc0afc08-4320-4fdd-a09c-06c553c30db8 | |
# ╠═e9c29457-523f-432e-abaf-800f4c3cbb7b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One issue that I found so far: when the module under consideration has a syntax error,
@revise
doesn't show an error.Apart from that, I thought the thing was broken a few times because it gave an error, but each time it turned out to be me who was messing things up xD