Skip to content

Commit

Permalink
Merge pull request #400 from LuxDL/ap/processes
Browse files Browse the repository at this point in the history
Use separate processes to generate the tutorials
  • Loading branch information
avik-pal authored Aug 26, 2023
2 parents 37ddb78 + a337838 commit 24ca790
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions docs/tutorials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ using Literate
get_example_path(p) = joinpath(@__DIR__, "..", "examples", p)
OUTPUT = joinpath(@__DIR__, "src", "tutorials")

function preprocess(path, str)
dir = dirname(path)
str = replace(str, "__DIR = @__DIR__" => "__DIR = \"$dir\"")
return str
end

BEGINNER_TUTORIALS = ["Basics/main.jl", "PolynomialFitting/main.jl", "SimpleRNN/main.jl"]
INTERMEDIATE_TUTORIALS = ["NeuralODE/main.jl", "BayesianNN/main.jl", "HyperNet/main.jl"]
ADVANCED_TUTORIALS = ["GravitationalWaveForm/main.jl"]
Expand All @@ -19,7 +13,8 @@ withenv("JULIA_DEBUG" => "Literate") do
("advanced", ADVANCED_TUTORIALS)), (i, p) in enumerate(paths)
name = "$(i)_$(first(rsplit(p, "/")))"
p_ = get_example_path(p)
Literate.markdown(p_, joinpath(OUTPUT, d); execute=true, name, documenter=true,
preprocess=Base.Fix1(preprocess, p_))
jl_expr = "using Literate; preprocess(path, str) = replace(str, \"__DIR = @__DIR__\" => \"__DIR = \\\"\$(dirname(path))\\\"\"); Literate.markdown(\"$(p_)\", \"$(joinpath(OUTPUT, d))\"; execute=true, name=\"$name\", documenter=true, preprocess=Base.Fix1(preprocess, \"$(p_)\"))"
cm = `julia --project=$(@__DIR__) -e $(jl_expr)`
run(cm)
end
end

0 comments on commit 24ca790

Please sign in to comment.