Skip to content

Commit fef99b4

Browse files
author
Alessandro
committed
literate tutorials. found bug
1 parent 8362709 commit fef99b4

File tree

9 files changed

+208
-152
lines changed

9 files changed

+208
-152
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ wip/
1818
# Build artifacts for creating documentation generated by the Documenter package
1919
docs/build/
2020
docs/site/
21+
docs/src/tutorials/*
2122

2223
# File generated by Pkg, the package manager, based on a corresponding Project.toml
2324
# It records a fixed state of all packages used by the project. As such, it should not be

Project.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ julia = "1.8"
2222

2323
[extras]
2424
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
25+
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
2526
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
2627
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2728

2829
[targets]
29-
test = ["Test", "Documenter", "SafeTestsets"]
30+
test = ["Test", "Documenter", "SafeTestsets", "Literate"]

docs/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
34
Metatheory = "e9d8d322-4543-424a-9be4-0cc815abe26c"
45

56
[compat]

docs/make.jl

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
using Documenter
22
using Metatheory
3+
using Literate
34

45
using Metatheory.EGraphs
56
using Metatheory.Library
67

8+
TUTORIALSDIR = joinpath(dirname(pathof(Metatheory)), "../test/tutorials/")
9+
OUTDIR = abspath(joinpath(@__DIR__, "src", "tutorials"))
10+
11+
for f in readdir(TUTORIALSDIR)
12+
if endswith(f, ".jl")
13+
input = abspath(joinpath(TUTORIALSDIR, f))
14+
name = basename(input)
15+
Literate.markdown(input, OUTDIR)
16+
elseif f != "README.md"
17+
@info "Copying $f"
18+
cp(joinpath(TUTORIALSDIR, input), joinpath(OUTDIR, f); force=true)
19+
end
20+
end
21+
22+
tutorials = [joinpath("tutorials", f[1:end-3]) * ".md" for f in readdir(TUTORIALSDIR) if endswith(f, ".jl")]
23+
724
makedocs(
825
modules = [Metatheory, Metatheory.EGraphs],
926
sitename = "Metatheory.jl",
@@ -13,7 +30,8 @@ makedocs(
1330
"egraphs.md"
1431
"interface.md"
1532
"api.md"
33+
"Tutorials" => tutorials
1634
],
1735
)
1836

19-
deploydocs(repo = "github.com/JuliaSymbolics/Metatheory.jl.git")
37+
#deploydocs(repo = "github.com/JuliaSymbolics/Metatheory.jl.git")

src/Rewriters.jl

+2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ instrument(x::Fixpoint, f) = Fixpoint(instrument(x.rw, f))
115115

116116
function (rw::Fixpoint)(x)
117117
f = rw.rw
118+
@show "fixpoint" x
118119
y = @timer cached_repr(f) f(x)
119120
while x !== y && !isequal(x, y)
120121
y === nothing && return x
121122
x = y
122123
y = @timer cached_repr(f) f(x)
124+
@show y
123125
end
124126
return x
125127
end

test/integration/while_interpreter.jl

-150
This file was deleted.

test/tutorials/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Literate tests
2+
3+
This folder contains Julia scripts in the [Literate.jl](https://fredrikekre.github.io/Literate.jl/v2/) format.
4+
Such scripts are executed by tests, and are also included in the generated documentation.

test/tutorials/literatetest.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#=
2+
3+
# Test
4+
5+
markdown foo ~bar~
6+
7+
=#
8+
9+
println("foo")
10+
11+
# ok
12+
13+
2

0 commit comments

Comments
 (0)