|
|
|
@ -293,7 +293,8 @@ const GITLAB_ENV = Dict( |
|
|
|
(k => nothing for k in keys(TRAVIS_ENV))..., |
|
|
|
(k => nothing for k in keys(TRAVIS_ENV))..., |
|
|
|
(k => nothing for k in keys(ACTIONS_ENV))..., |
|
|
|
(k => nothing for k in keys(ACTIONS_ENV))..., |
|
|
|
) |
|
|
|
) |
|
|
|
@testset "Literate.script" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
@testset "Literate.script" begin |
|
|
|
|
|
|
|
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
cd(sandbox) do |
|
|
|
cd(sandbox) do |
|
|
|
# write content to inputfile |
|
|
|
# write content to inputfile |
|
|
|
@ -353,69 +354,123 @@ const GITLAB_ENV = Dict( |
|
|
|
@test script == expected_script |
|
|
|
@test script == expected_script |
|
|
|
|
|
|
|
|
|
|
|
# Travis with with PR preview build |
|
|
|
# Travis with with PR preview build |
|
|
|
withenv(TRAVIS_ENV..., |
|
|
|
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "", "TRAVIS_PULL_REQUEST" => "42") do |
|
|
|
"TRAVIS_TAG" => "", |
|
|
|
|
|
|
|
"TRAVIS_PULL_REQUEST" => "42") do |
|
|
|
|
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", script) |
|
|
|
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", script) |
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Travis with no tag -> dev directory |
|
|
|
# Travis with no tag -> dev directory |
|
|
|
withenv(TRAVIS_ENV..., |
|
|
|
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do |
|
|
|
"TRAVIS_TAG" => "") do |
|
|
|
|
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", script) |
|
|
|
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", script) |
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions with a tag |
|
|
|
# GitHub Actions with a tag |
|
|
|
withenv(ACTIONS_ENV...) do |
|
|
|
withenv(ACTIONS_ENV...) do |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", script) |
|
|
|
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", script) |
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions with PR preview build |
|
|
|
# GitHub Actions with PR preview build |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv( |
|
|
|
|
|
|
|
ACTIONS_ENV..., |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request", |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request", |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge") do |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", script) |
|
|
|
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", script) |
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions without a tag -> dev directory |
|
|
|
# GitHub Actions without a tag -> dev directory |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do |
|
|
|
"GITHUB_REF" => "refs/heads/master") do |
|
|
|
|
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", script) |
|
|
|
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", script) |
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
withenv("DOCUMENTATIONGENERATOR" => "true", |
|
|
|
withenv( |
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do |
|
|
|
"DOCUMENTATIONGENERATOR" => "true", |
|
|
|
|
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
Literate.script(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", script) |
|
|
|
@test occursin( |
|
|
|
@test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script) |
|
|
|
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_broken occursin( |
|
|
|
|
|
|
|
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
|
|
|
|
script, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# pre- and post-processing |
|
|
|
# pre- and post-processing |
|
|
|
Literate.script(inputfile, outdir, |
|
|
|
Literate.script( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir, |
|
|
|
preprocess = x -> replace(x, "PLACEHOLDER3" => "3REDLOHECALP"), |
|
|
|
preprocess = x -> replace(x, "PLACEHOLDER3" => "3REDLOHECALP"), |
|
|
|
postprocess = x -> replace(x, "PLACEHOLDER4" => "4REDLOHECALP")) |
|
|
|
postprocess = x -> replace(x, "PLACEHOLDER4" => "4REDLOHECALP"), |
|
|
|
|
|
|
|
) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@test !occursin("PLACEHOLDER1", script) |
|
|
|
@test !occursin("PLACEHOLDER1", script) |
|
|
|
@test !occursin("PLACEHOLDER2", script) |
|
|
|
@test !occursin("PLACEHOLDER2", script) |
|
|
|
@ -442,7 +497,9 @@ const GITLAB_ENV = Dict( |
|
|
|
|
|
|
|
|
|
|
|
# mdstrings |
|
|
|
# mdstrings |
|
|
|
mdstrings_file = "inputfile_mdstrings.jl" |
|
|
|
mdstrings_file = "inputfile_mdstrings.jl" |
|
|
|
write(mdstrings_file, """ |
|
|
|
write( |
|
|
|
|
|
|
|
mdstrings_file, |
|
|
|
|
|
|
|
""" |
|
|
|
md\"\"\" |
|
|
|
md\"\"\" |
|
|
|
# Markdown header |
|
|
|
# Markdown header |
|
|
|
|
|
|
|
|
|
|
|
@ -457,9 +514,14 @@ const GITLAB_ENV = Dict( |
|
|
|
comment |
|
|
|
comment |
|
|
|
===# |
|
|
|
===# |
|
|
|
2 + 2 |
|
|
|
2 + 2 |
|
|
|
""") |
|
|
|
""", |
|
|
|
Literate.script(mdstrings_file, outdir, |
|
|
|
) |
|
|
|
keep_comments = true, credit=false) |
|
|
|
Literate.script( |
|
|
|
|
|
|
|
mdstrings_file, |
|
|
|
|
|
|
|
outdir, |
|
|
|
|
|
|
|
keep_comments = true, |
|
|
|
|
|
|
|
credit = false, |
|
|
|
|
|
|
|
) |
|
|
|
script = read(joinpath(outdir, mdstrings_file), String) |
|
|
|
script = read(joinpath(outdir, mdstrings_file), String) |
|
|
|
@test strip(script) == """ |
|
|
|
@test strip(script) == """ |
|
|
|
md\"\"\" |
|
|
|
md\"\"\" |
|
|
|
@ -476,8 +538,13 @@ const GITLAB_ENV = Dict( |
|
|
|
# comment |
|
|
|
# comment |
|
|
|
|
|
|
|
|
|
|
|
2 + 2""" |
|
|
|
2 + 2""" |
|
|
|
Literate.script(mdstrings_file, outdir, |
|
|
|
Literate.script( |
|
|
|
keep_comments = true, mdstrings = true, credit=false) |
|
|
|
mdstrings_file, |
|
|
|
|
|
|
|
outdir, |
|
|
|
|
|
|
|
keep_comments = true, |
|
|
|
|
|
|
|
mdstrings = true, |
|
|
|
|
|
|
|
credit = false, |
|
|
|
|
|
|
|
) |
|
|
|
script = read(joinpath(outdir, mdstrings_file), String) |
|
|
|
script = read(joinpath(outdir, mdstrings_file), String) |
|
|
|
@test strip(script) == """ |
|
|
|
@test strip(script) == """ |
|
|
|
# # Markdown header |
|
|
|
# # Markdown header |
|
|
|
@ -501,9 +568,11 @@ const GITLAB_ENV = Dict( |
|
|
|
@test_throws ArgumentError Literate.script(inputfile) |
|
|
|
@test_throws ArgumentError Literate.script(inputfile) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@testset "Literate.markdown" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
@testset "Literate.markdown" begin |
|
|
|
|
|
|
|
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
cd(sandbox) do |
|
|
|
cd(sandbox) do |
|
|
|
# write content to inputfile |
|
|
|
# write content to inputfile |
|
|
|
@ -639,84 +708,171 @@ end end |
|
|
|
@test markdown == expected_markdown |
|
|
|
@test markdown == expected_markdown |
|
|
|
|
|
|
|
|
|
|
|
# Travis with PR preview build |
|
|
|
# Travis with PR preview build |
|
|
|
withenv(TRAVIS_ENV..., |
|
|
|
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "", "TRAVIS_PULL_REQUEST" => "42") do |
|
|
|
"TRAVIS_TAG" => "", |
|
|
|
|
|
|
|
"TRAVIS_PULL_REQUEST" => "42") do |
|
|
|
|
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", markdown) |
|
|
|
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Travis with no tag -> dev directory |
|
|
|
# Travis with no tag -> dev directory |
|
|
|
withenv(TRAVIS_ENV..., |
|
|
|
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do |
|
|
|
"TRAVIS_TAG" => "") do |
|
|
|
|
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", markdown) |
|
|
|
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions with a tag |
|
|
|
# GitHub Actions with a tag |
|
|
|
withenv(ACTIONS_ENV...) do |
|
|
|
withenv(ACTIONS_ENV...) do |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", markdown) |
|
|
|
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions with PR preview build |
|
|
|
# GitHub Actions with PR preview build |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv( |
|
|
|
|
|
|
|
ACTIONS_ENV..., |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge", |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge", |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request") do |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", markdown) |
|
|
|
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions without a tag -> dev directory |
|
|
|
# GitHub Actions without a tag -> dev directory |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do |
|
|
|
"GITHUB_REF" => "refs/heads/master") do |
|
|
|
|
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", markdown) |
|
|
|
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitLab CI with GitLab Pages |
|
|
|
# GitLab CI with GitLab Pages |
|
|
|
withenv(GITLAB_ENV...) do |
|
|
|
withenv(GITLAB_ENV...) do |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("Link to repo root: https://gitlab.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test occursin("Link to nbviewer: https://nbviewer.jupyter.org/urls/fredrikekre.gitlab.io/Literate.jl/file.jl", markdown) |
|
|
|
"Link to repo root: https://gitlab.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
@test_broken occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown) |
|
|
|
markdown, |
|
|
|
@test occursin("EditURL = \"https://gitlab.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown) |
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"Link to nbviewer: https://nbviewer.jupyter.org/urls/fredrikekre.gitlab.io/Literate.jl/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_broken occursin( |
|
|
|
|
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"EditURL = \"https://gitlab.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
withenv("DOCUMENTATIONGENERATOR" => "true", |
|
|
|
withenv( |
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do |
|
|
|
"DOCUMENTATIONGENERATOR" => "true", |
|
|
|
|
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
Literate.markdown(inputfile, outdir) |
|
|
|
end |
|
|
|
end |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", markdown) |
|
|
|
@test occursin( |
|
|
|
@test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown) |
|
|
|
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_broken occursin( |
|
|
|
|
|
|
|
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
|
|
|
|
markdown, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# pre- and post-processing |
|
|
|
# pre- and post-processing |
|
|
|
Literate.markdown(inputfile, outdir, |
|
|
|
Literate.markdown( |
|
|
|
preprocess = x -> replace(replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), "PLACEHOLDER3" => "3REDLOHECALP"), |
|
|
|
inputfile, |
|
|
|
postprocess = x -> replace(replace(x, "PLACEHOLDER2" => "2REDLOHECALP"), "PLACEHOLDER4" => "4REDLOHECALP")) |
|
|
|
outdir, |
|
|
|
|
|
|
|
preprocess = x -> replace( |
|
|
|
|
|
|
|
replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), |
|
|
|
|
|
|
|
"PLACEHOLDER3" => "3REDLOHECALP", |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
postprocess = x -> replace( |
|
|
|
|
|
|
|
replace(x, "PLACEHOLDER2" => "2REDLOHECALP"), |
|
|
|
|
|
|
|
"PLACEHOLDER4" => "4REDLOHECALP", |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test !occursin("PLACEHOLDER1", markdown) |
|
|
|
@test !occursin("PLACEHOLDER1", markdown) |
|
|
|
@test !occursin("PLACEHOLDER2", markdown) |
|
|
|
@test !occursin("PLACEHOLDER2", markdown) |
|
|
|
@ -738,10 +894,21 @@ end end |
|
|
|
|
|
|
|
|
|
|
|
# flavor = QuartoFlavor() |
|
|
|
# flavor = QuartoFlavor() |
|
|
|
# execution of Quarto markdown is not allowed |
|
|
|
# execution of Quarto markdown is not allowed |
|
|
|
let expected_error = ErrorException("QuartoFlavor does not support argument execute=true!") |
|
|
|
let expected_error = ErrorException( |
|
|
|
@test_throws expected_error Literate.markdown("quarto.jl",flavor=Literate.QuartoFlavor(),execute=true) |
|
|
|
"QuartoFlavor does not support argument execute=true!", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_throws expected_error Literate.markdown( |
|
|
|
|
|
|
|
"quarto.jl", |
|
|
|
|
|
|
|
flavor = Literate.QuartoFlavor(), |
|
|
|
|
|
|
|
execute = true, |
|
|
|
|
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
Literate.markdown(inputfile, outdir, flavor = Literate.QuartoFlavor(),execute=false) |
|
|
|
Literate.markdown( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir, |
|
|
|
|
|
|
|
flavor = Literate.QuartoFlavor(), |
|
|
|
|
|
|
|
execute = false, |
|
|
|
|
|
|
|
) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.qmd"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.qmd"), String) |
|
|
|
@test occursin("```{julia}", markdown) |
|
|
|
@test occursin("```{julia}", markdown) |
|
|
|
@test !occursin(r"`{3,}@example", markdown) |
|
|
|
@test !occursin(r"`{3,}@example", markdown) |
|
|
|
@ -790,7 +957,9 @@ end end |
|
|
|
@test !occursin("blob/master/", markdown) |
|
|
|
@test !occursin("blob/master/", markdown) |
|
|
|
|
|
|
|
|
|
|
|
# execute |
|
|
|
# execute |
|
|
|
write(inputfile, """ |
|
|
|
write( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
""" |
|
|
|
using DisplayAs |
|
|
|
using DisplayAs |
|
|
|
#- |
|
|
|
#- |
|
|
|
1+1 |
|
|
|
1+1 |
|
|
|
@ -845,7 +1014,8 @@ end end |
|
|
|
(@__DIR__) == pwd() ? "cwd correct" : "cwd incorrect" |
|
|
|
(@__DIR__) == pwd() ? "cwd correct" : "cwd incorrect" |
|
|
|
#- |
|
|
|
#- |
|
|
|
basename(@__FILE__) |
|
|
|
basename(@__FILE__) |
|
|
|
""") |
|
|
|
""", |
|
|
|
|
|
|
|
) |
|
|
|
Literate.markdown(inputfile, outdir; execute = true) |
|
|
|
Literate.markdown(inputfile, outdir; execute = true) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("```\n2\n```", markdown) # text/plain |
|
|
|
@test occursin("```\n2\n```", markdown) # text/plain |
|
|
|
@ -871,14 +1041,25 @@ end end |
|
|
|
@test occursin("```\n\"inputfile.md\"\n```", markdown) # Correct source file (@__FILE__) |
|
|
|
@test occursin("```\n\"inputfile.md\"\n```", markdown) # Correct source file (@__FILE__) |
|
|
|
|
|
|
|
|
|
|
|
# FranklinFlavor |
|
|
|
# FranklinFlavor |
|
|
|
Literate.markdown(inputfile, outdir; execute=true, flavor=Literate.FranklinFlavor()) |
|
|
|
Literate.markdown( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir; |
|
|
|
|
|
|
|
execute = true, |
|
|
|
|
|
|
|
flavor = Literate.FranklinFlavor(), |
|
|
|
|
|
|
|
) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
markdown = read(joinpath(outdir, "inputfile.md"), String) |
|
|
|
@test occursin("# MD", markdown) # text/markdown |
|
|
|
@test occursin("# MD", markdown) # text/markdown |
|
|
|
@test occursin("~~~\n<h1>MD</h1>\n~~~", markdown) # text/html |
|
|
|
@test occursin("~~~\n<h1>MD</h1>\n~~~", markdown) # text/html |
|
|
|
|
|
|
|
|
|
|
|
# QuartoFlavor file extension |
|
|
|
# QuartoFlavor file extension |
|
|
|
write(inputfile, "#=\r\nhello world\n=#\r\n") |
|
|
|
write(inputfile, "#=\r\nhello world\n=#\r\n") |
|
|
|
_, config = Literate.preprocessor(inputfile, outdir; user_kwargs=(), user_config=Dict("flavor"=>Literate.QuartoFlavor()), type=:md) |
|
|
|
_, config = Literate.preprocessor( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir; |
|
|
|
|
|
|
|
user_kwargs = (), |
|
|
|
|
|
|
|
user_config = Dict("flavor" => Literate.QuartoFlavor()), |
|
|
|
|
|
|
|
type = :md, |
|
|
|
|
|
|
|
) |
|
|
|
@test config["literate_ext"] == ".qmd" |
|
|
|
@test config["literate_ext"] == ".qmd" |
|
|
|
|
|
|
|
|
|
|
|
# verify that inputfile exists |
|
|
|
# verify that inputfile exists |
|
|
|
@ -891,23 +1072,39 @@ end end |
|
|
|
|
|
|
|
|
|
|
|
# fredrikekre/Literate.jl#165: \r\n line endings with multiline comments/mdstrings |
|
|
|
# fredrikekre/Literate.jl#165: \r\n line endings with multiline comments/mdstrings |
|
|
|
write(inputfile, "#=\r\nhello world\r\nhej världen\r\n=#\r\n") |
|
|
|
write(inputfile, "#=\r\nhello world\r\nhej världen\r\n=#\r\n") |
|
|
|
chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=(), user_config=(), type=:md) |
|
|
|
chunks, _ = Literate.preprocessor( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir; |
|
|
|
|
|
|
|
user_kwargs = (), |
|
|
|
|
|
|
|
user_config = (), |
|
|
|
|
|
|
|
type = :md, |
|
|
|
|
|
|
|
) |
|
|
|
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] |
|
|
|
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] |
|
|
|
write(inputfile, "md\"\"\"\r\nhello world\r\nhej världen\r\n\"\"\"\r\n") |
|
|
|
write(inputfile, "md\"\"\"\r\nhello world\r\nhej världen\r\n\"\"\"\r\n") |
|
|
|
chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=pairs((; mdstrings=true)), |
|
|
|
chunks, _ = Literate.preprocessor( |
|
|
|
user_config=(), type=:md) |
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir; |
|
|
|
|
|
|
|
user_kwargs = pairs((; mdstrings = true)), |
|
|
|
|
|
|
|
user_config = (), |
|
|
|
|
|
|
|
type = :md, |
|
|
|
|
|
|
|
) |
|
|
|
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] |
|
|
|
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] |
|
|
|
|
|
|
|
|
|
|
|
# fredrikekre/Literate.jl#168 |
|
|
|
# fredrikekre/Literate.jl#168 |
|
|
|
f = "file with space.jl" |
|
|
|
f = "file with space.jl" |
|
|
|
write(f, "1 + 1") |
|
|
|
write(f, "1 + 1") |
|
|
|
Literate.markdown(f, outdir) |
|
|
|
Literate.markdown(f, outdir) |
|
|
|
@test occursin("file_with_space", read(joinpath(outdir, "file with space.md"), String)) |
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"file_with_space", |
|
|
|
|
|
|
|
read(joinpath(outdir, "file with space.md"), String), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@testset "Literate.notebook" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
@testset "Literate.notebook" begin |
|
|
|
|
|
|
|
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
cd(sandbox) do |
|
|
|
cd(sandbox) do |
|
|
|
# write content to inputfile |
|
|
|
# write content to inputfile |
|
|
|
@ -919,59 +1116,52 @@ end end |
|
|
|
withenv(TRAVIS_ENV...) do |
|
|
|
withenv(TRAVIS_ENV...) do |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
end |
|
|
|
end |
|
|
|
expected_cells = rstrip.(( |
|
|
|
expected_cells = |
|
|
|
|
|
|
|
rstrip.(( |
|
|
|
""" |
|
|
|
""" |
|
|
|
"cells": [ |
|
|
|
"cells": [ |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"# Example\\n", |
|
|
|
"# Example\\n", |
|
|
|
"foo, bar" |
|
|
|
"foo, bar" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"x = 1" |
|
|
|
"x = 1" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"Not markdown\\n", |
|
|
|
"Not markdown\\n", |
|
|
|
"Not markdown" |
|
|
|
"Not markdown" |
|
|
|
], |
|
|
|
], |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"x * 1\\n", |
|
|
|
"x * 1\\n", |
|
|
|
"x * 1" |
|
|
|
"x * 1" |
|
|
|
], |
|
|
|
], |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"Only notebook\\n", |
|
|
|
"Only notebook\\n", |
|
|
|
"Only notebook" |
|
|
|
"Only notebook" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"x + 2\\n", |
|
|
|
"x + 2\\n", |
|
|
|
"x + 2" |
|
|
|
"x + 2" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"Not script\\n", |
|
|
|
"Not script\\n", |
|
|
|
"Not script" |
|
|
|
"Not script" |
|
|
|
], |
|
|
|
], |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"x * 3\\n", |
|
|
|
"x * 3\\n", |
|
|
|
@ -981,7 +1171,6 @@ end end |
|
|
|
"#| echo: false Quarto parameters" |
|
|
|
"#| echo: false Quarto parameters" |
|
|
|
], |
|
|
|
], |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"for i in 1:10\\n", |
|
|
|
"for i in 1:10\\n", |
|
|
|
@ -990,7 +1179,6 @@ end end |
|
|
|
"end" |
|
|
|
"end" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"name: inputfile\\n", |
|
|
|
"name: inputfile\\n", |
|
|
|
@ -999,7 +1187,6 @@ end end |
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" |
|
|
|
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"# name: inputfile\\n", |
|
|
|
"# name: inputfile\\n", |
|
|
|
@ -1008,21 +1195,18 @@ end end |
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" |
|
|
|
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"PLACEHOLDER1\\n", |
|
|
|
"PLACEHOLDER1\\n", |
|
|
|
"PLACEHOLDER2" |
|
|
|
"PLACEHOLDER2" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"# PLACEHOLDER3\\n", |
|
|
|
"# PLACEHOLDER3\\n", |
|
|
|
"# PLACEHOLDER4" |
|
|
|
"# PLACEHOLDER4" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"Some inline math: \$\\\\frac{df}{dx}\$, some multiline inline math: \$y =\\n", |
|
|
|
"Some inline math: \$\\\\frac{df}{dx}\$, some multiline inline math: \$y =\\n", |
|
|
|
@ -1032,13 +1216,11 @@ end end |
|
|
|
"\$\$" |
|
|
|
"\$\$" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"Indented markdown" |
|
|
|
"Indented markdown" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"for i in 1:10\\n", |
|
|
|
"for i in 1:10\\n", |
|
|
|
@ -1047,27 +1229,25 @@ end end |
|
|
|
"end" |
|
|
|
"end" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"metadata": { |
|
|
|
"metadata": { |
|
|
|
"meta": "data" |
|
|
|
"meta": "data" |
|
|
|
} |
|
|
|
} |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"First multiline\\n", |
|
|
|
"First multiline\\n", |
|
|
|
"comment" |
|
|
|
"comment" |
|
|
|
] |
|
|
|
] |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"source": [ |
|
|
|
"source": [ |
|
|
|
"---\\n", |
|
|
|
"---\\n", |
|
|
|
"\\n", |
|
|
|
"\\n", |
|
|
|
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" |
|
|
|
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" |
|
|
|
] |
|
|
|
] |
|
|
|
""")) |
|
|
|
""", |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
|
|
|
|
|
|
|
|
@ -1078,16 +1258,25 @@ end end |
|
|
|
lastidx = nextind(notebook, last(idx)) |
|
|
|
lastidx = nextind(notebook, last(idx)) |
|
|
|
end |
|
|
|
end |
|
|
|
# test some of the required metadata |
|
|
|
# test some of the required metadata |
|
|
|
for metadata in (" \"nbformat\": ", " \"nbformat_minor\": ", " \"metadata\": {", " \"language_info\": {", |
|
|
|
for metadata in ( |
|
|
|
" \"file_extension\": \".jl\"", " \"mimetype\": \"application/julia\"", |
|
|
|
" \"nbformat\": ", |
|
|
|
" \"name\": \"julia\"", " \"version\": ", " \"kernelspec\": {", |
|
|
|
" \"nbformat_minor\": ", |
|
|
|
" \"name\": \"julia-", " \"display_name\": \"Julia ", " \"language\": \"julia\"") |
|
|
|
" \"metadata\": {", |
|
|
|
|
|
|
|
" \"language_info\": {", |
|
|
|
|
|
|
|
" \"file_extension\": \".jl\"", |
|
|
|
|
|
|
|
" \"mimetype\": \"application/julia\"", |
|
|
|
|
|
|
|
" \"name\": \"julia\"", |
|
|
|
|
|
|
|
" \"version\": ", |
|
|
|
|
|
|
|
" \"kernelspec\": {", |
|
|
|
|
|
|
|
" \"name\": \"julia-", |
|
|
|
|
|
|
|
" \"display_name\": \"Julia ", |
|
|
|
|
|
|
|
" \"language\": \"julia\"", |
|
|
|
|
|
|
|
) |
|
|
|
@test occursin(metadata, notebook) |
|
|
|
@test occursin(metadata, notebook) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# no tag -> latest directory |
|
|
|
# no tag -> latest directory |
|
|
|
withenv(TRAVIS_ENV..., |
|
|
|
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do |
|
|
|
"TRAVIS_TAG" => "") do |
|
|
|
|
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
end |
|
|
|
end |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@ -1101,44 +1290,65 @@ end end |
|
|
|
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/", notebook) |
|
|
|
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/", notebook) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions with PR preview build |
|
|
|
# GitHub Actions with PR preview build |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv( |
|
|
|
|
|
|
|
ACTIONS_ENV..., |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge", |
|
|
|
"GITHUB_REF" => "refs/pull/42/merge", |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request") do |
|
|
|
"GITHUB_EVENT_NAME" => "pull_request", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
end |
|
|
|
end |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/", notebook) |
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/", |
|
|
|
|
|
|
|
notebook, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# GitHub Actions without a tag |
|
|
|
# GitHub Actions without a tag |
|
|
|
withenv(ACTIONS_ENV..., |
|
|
|
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do |
|
|
|
"GITHUB_REF" => "refs/heads/master") do |
|
|
|
|
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
end |
|
|
|
end |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/dev/", notebook) |
|
|
|
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/dev/", notebook) |
|
|
|
|
|
|
|
|
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
# building under DocumentationGenerator.jl |
|
|
|
withenv("DOCUMENTATIONGENERATOR" => "true", |
|
|
|
withenv( |
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do |
|
|
|
"DOCUMENTATIONGENERATOR" => "true", |
|
|
|
|
|
|
|
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
Literate.notebook(inputfile, outdir, execute = false) |
|
|
|
end |
|
|
|
end |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", notebook) |
|
|
|
@test occursin( |
|
|
|
@test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", notebook) |
|
|
|
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", |
|
|
|
|
|
|
|
notebook, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_broken occursin( |
|
|
|
|
|
|
|
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", |
|
|
|
|
|
|
|
notebook, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# pre- and post-processing |
|
|
|
# pre- and post-processing |
|
|
|
function post(nb) |
|
|
|
function post(nb) |
|
|
|
for cell in nb["cells"] |
|
|
|
for cell in nb["cells"] |
|
|
|
for i in eachindex(cell["source"]) |
|
|
|
for i in eachindex(cell["source"]) |
|
|
|
cell["source"][i] = replace(cell["source"][i], "PLACEHOLDER2" => "2REDLOHECALP") |
|
|
|
cell["source"][i] = |
|
|
|
cell["source"][i] = replace(cell["source"][i], "PLACEHOLDER4" => "4REDLOHECALP") |
|
|
|
replace(cell["source"][i], "PLACEHOLDER2" => "2REDLOHECALP") |
|
|
|
|
|
|
|
cell["source"][i] = |
|
|
|
|
|
|
|
replace(cell["source"][i], "PLACEHOLDER4" => "4REDLOHECALP") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
return nb |
|
|
|
return nb |
|
|
|
end |
|
|
|
end |
|
|
|
Literate.notebook(inputfile, outdir, execute = false, |
|
|
|
Literate.notebook( |
|
|
|
preprocess = x -> replace(replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), "PLACEHOLDER3" => "3REDLOHECALP"), |
|
|
|
inputfile, |
|
|
|
postprocess = post) |
|
|
|
outdir, |
|
|
|
|
|
|
|
execute = false, |
|
|
|
|
|
|
|
preprocess = x -> replace( |
|
|
|
|
|
|
|
replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), |
|
|
|
|
|
|
|
"PLACEHOLDER3" => "3REDLOHECALP", |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
postprocess = post, |
|
|
|
|
|
|
|
) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test !occursin("PLACEHOLDER1", notebook) |
|
|
|
@test !occursin("PLACEHOLDER1", notebook) |
|
|
|
@test !occursin("PLACEHOLDER2", notebook) |
|
|
|
@test !occursin("PLACEHOLDER2", notebook) |
|
|
|
@ -1151,7 +1361,12 @@ end end |
|
|
|
|
|
|
|
|
|
|
|
# documenter = false (deprecated) |
|
|
|
# documenter = false (deprecated) |
|
|
|
@test_deprecated r"The documenter=false keyword to Literate.notebook is deprecated." begin |
|
|
|
@test_deprecated r"The documenter=false keyword to Literate.notebook is deprecated." begin |
|
|
|
Literate.notebook(inputfile, outdir, documenter = false, execute = false) |
|
|
|
Literate.notebook( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
outdir, |
|
|
|
|
|
|
|
documenter = false, |
|
|
|
|
|
|
|
execute = false, |
|
|
|
|
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test !occursin("# [Example](@id example-id", notebook) |
|
|
|
@test !occursin("# [Example](@id example-id", notebook) |
|
|
|
@ -1166,22 +1381,22 @@ end end |
|
|
|
|
|
|
|
|
|
|
|
# execute = true |
|
|
|
# execute = true |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
expected_outputs = rstrip.(( |
|
|
|
expected_outputs = |
|
|
|
|
|
|
|
rstrip.(( |
|
|
|
""" |
|
|
|
""" |
|
|
|
"cells": [ |
|
|
|
"cells": [ |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"data": { |
|
|
|
"data": { |
|
|
|
"text/plain": "3" |
|
|
|
"text/plain": "3" |
|
|
|
}, |
|
|
|
}, |
|
|
|
""", |
|
|
|
""", |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
"text": [ |
|
|
|
"text": [ |
|
|
|
"12345678910" |
|
|
|
"12345678910" |
|
|
|
] |
|
|
|
] |
|
|
|
""")) |
|
|
|
""", |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
|
|
|
|
|
|
|
|
@ -1197,18 +1412,27 @@ end end |
|
|
|
write(joinpath(outdir, "issue31.jl"), "10 + 21") |
|
|
|
write(joinpath(outdir, "issue31.jl"), "10 + 21") |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test occursin("\"data\": {\n \"text/plain\": \"31\"\n }", notebook) |
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"\"data\": {\n \"text/plain\": \"31\"\n }", |
|
|
|
|
|
|
|
notebook, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# test error when executing notebook |
|
|
|
# test error when executing notebook |
|
|
|
write(inputfile, "for i in 1:10\n println(i)") |
|
|
|
write(inputfile, "for i in 1:10\n println(i)") |
|
|
|
r = @test_logs((:error, r"error when executing notebook based on input file: "), match_mode=:any, |
|
|
|
r = @test_logs( |
|
|
|
|
|
|
|
(:error, r"error when executing notebook based on input file: "), |
|
|
|
|
|
|
|
match_mode = :any, |
|
|
|
try |
|
|
|
try |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
catch err |
|
|
|
catch err |
|
|
|
err |
|
|
|
err |
|
|
|
end) |
|
|
|
end |
|
|
|
|
|
|
|
) |
|
|
|
@test isa(r, ErrorException) |
|
|
|
@test isa(r, ErrorException) |
|
|
|
@test occursin("when executing the following code block from inputfile ", r.msg) |
|
|
|
@test occursin( |
|
|
|
|
|
|
|
"when executing the following code block from inputfile ", |
|
|
|
|
|
|
|
r.msg, |
|
|
|
|
|
|
|
) |
|
|
|
@test occursin(inputfile, r.msg) |
|
|
|
@test occursin(inputfile, r.msg) |
|
|
|
|
|
|
|
|
|
|
|
# verify that inputfile exists |
|
|
|
# verify that inputfile exists |
|
|
|
@ -1220,7 +1444,9 @@ end end |
|
|
|
@test isfile("inputfile.ipynb") |
|
|
|
@test isfile("inputfile.ipynb") |
|
|
|
|
|
|
|
|
|
|
|
# world time problem with `IJulia.display_dict` |
|
|
|
# world time problem with `IJulia.display_dict` |
|
|
|
write(inputfile, """ |
|
|
|
write( |
|
|
|
|
|
|
|
inputfile, |
|
|
|
|
|
|
|
""" |
|
|
|
struct VegaLiteRenderable end |
|
|
|
struct VegaLiteRenderable end |
|
|
|
Base.show(io::IO, ::MIME"application/vnd.vegalite.v2+json", ::VegaLiteRenderable) = |
|
|
|
Base.show(io::IO, ::MIME"application/vnd.vegalite.v2+json", ::VegaLiteRenderable) = |
|
|
|
write(io, \"\"\" |
|
|
|
write(io, \"\"\" |
|
|
|
@ -1228,7 +1454,8 @@ end end |
|
|
|
\"\"\") |
|
|
|
\"\"\") |
|
|
|
Base.Multimedia.istextmime(::MIME{Symbol("application/vnd.vegalite.v2+json")}) = true |
|
|
|
Base.Multimedia.istextmime(::MIME{Symbol("application/vnd.vegalite.v2+json")}) = true |
|
|
|
VegaLiteRenderable() |
|
|
|
VegaLiteRenderable() |
|
|
|
""") |
|
|
|
""", |
|
|
|
|
|
|
|
) |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
Literate.notebook(inputfile, outdir) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) |
|
|
|
@test occursin("\"application/vnd.vegalite.v2+json\":", notebook) |
|
|
|
@test occursin("\"application/vnd.vegalite.v2+json\":", notebook) |
|
|
|
@ -1269,7 +1496,7 @@ end end |
|
|
|
push!(xs, x) |
|
|
|
push!(xs, x) |
|
|
|
end |
|
|
|
end |
|
|
|
""" |
|
|
|
""" |
|
|
|
for i in 1:9 |
|
|
|
for i = 1:9 |
|
|
|
script *= "\n#-\nxs[$i]" |
|
|
|
script *= "\n#-\nxs[$i]" |
|
|
|
end |
|
|
|
end |
|
|
|
write(inputfile, script) |
|
|
|
write(inputfile, script) |
|
|
|
@ -1295,9 +1522,10 @@ end end |
|
|
|
# Cell 2 has 3 outputs: 2 display and one execute result |
|
|
|
# Cell 2 has 3 outputs: 2 display and one execute result |
|
|
|
cellout = cells[2]["outputs"] |
|
|
|
cellout = cells[2]["outputs"] |
|
|
|
@test length(cellout) == 3 |
|
|
|
@test length(cellout) == 3 |
|
|
|
for i in 1:3 |
|
|
|
for i = 1:3 |
|
|
|
exe_res = i == 3 |
|
|
|
exe_res = i == 3 |
|
|
|
@test cellout[i]["output_type"] == (exe_res ? "execute_result" : "display_data") |
|
|
|
@test cellout[i]["output_type"] == |
|
|
|
|
|
|
|
(exe_res ? "execute_result" : "display_data") |
|
|
|
@test keys(cellout[i]["data"]) == Set(("text/plain", "text/html")) |
|
|
|
@test keys(cellout[i]["data"]) == Set(("text/plain", "text/html")) |
|
|
|
@test cellout[i]["data"]["text/plain"] == "DF($i) as text/plain" |
|
|
|
@test cellout[i]["data"]["text/plain"] == "DF($i) as text/plain" |
|
|
|
@test cellout[i]["data"]["text/html"] == Any["DF($i) as text/html"] |
|
|
|
@test cellout[i]["data"]["text/html"] == Any["DF($i) as text/html"] |
|
|
|
@ -1312,9 +1540,11 @@ end end |
|
|
|
@test !haskey(cellout[1], "execution_count") |
|
|
|
@test !haskey(cellout[1], "execution_count") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@testset "Configuration" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
@testset "Configuration" begin |
|
|
|
|
|
|
|
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
mktempdir(@__DIR__) do sandbox |
|
|
|
cd(sandbox) do |
|
|
|
cd(sandbox) do |
|
|
|
# write content to inputfile |
|
|
|
# write content to inputfile |
|
|
|
@ -1329,10 +1559,12 @@ end end |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Overwriting of URLs |
|
|
|
# Overwriting of URLs |
|
|
|
withenv("TRAVIS_REPO_SLUG" => "fredrikekre/Literate.jl", |
|
|
|
withenv( |
|
|
|
|
|
|
|
"TRAVIS_REPO_SLUG" => "fredrikekre/Literate.jl", |
|
|
|
"TRAVIS_TAG" => "", |
|
|
|
"TRAVIS_TAG" => "", |
|
|
|
"TRAVIS_PULL_REQUEST" => "false", |
|
|
|
"TRAVIS_PULL_REQUEST" => "false", |
|
|
|
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true") do |
|
|
|
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true", |
|
|
|
|
|
|
|
) do |
|
|
|
Literate.script(inputfile, outdir; config = config) |
|
|
|
Literate.script(inputfile, outdir; config = config) |
|
|
|
end |
|
|
|
end |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
script = read(joinpath(outdir, "inputfile.jl"), String) |
|
|
|
@ -1341,19 +1573,35 @@ end end |
|
|
|
@test occursin("Link to binder: www.example3.com/file.jl", script) |
|
|
|
@test occursin("Link to binder: www.example3.com/file.jl", script) |
|
|
|
|
|
|
|
|
|
|
|
# Test pick_codefence function |
|
|
|
# Test pick_codefence function |
|
|
|
default_codefence=pick_codefence(Literate.DefaultFlavor(),true,"testname") |
|
|
|
default_codefence = |
|
|
|
|
|
|
|
pick_codefence(Literate.DefaultFlavor(), true, "testname") |
|
|
|
@test default_codefence == ("````julia" => "````") |
|
|
|
@test default_codefence == ("````julia" => "````") |
|
|
|
@test default_codefence == pick_codefence(Literate.FranklinFlavor(),true,"testname") |
|
|
|
@test default_codefence == |
|
|
|
@test default_codefence == pick_codefence(Literate.DocumenterFlavor(),true,"testname") |
|
|
|
pick_codefence(Literate.FranklinFlavor(), true, "testname") |
|
|
|
|
|
|
|
@test default_codefence == |
|
|
|
|
|
|
|
pick_codefence(Literate.DocumenterFlavor(), true, "testname") |
|
|
|
documenter_codefence = ("````@example testname" => "````") |
|
|
|
documenter_codefence = ("````@example testname" => "````") |
|
|
|
@test documenter_codefence == pick_codefence(Literate.DocumenterFlavor(),false,"testname") |
|
|
|
@test documenter_codefence == |
|
|
|
let expected_exception=ErrorException("QuartoFlavor does not support argument execute=true!") |
|
|
|
pick_codefence(Literate.DocumenterFlavor(), false, "testname") |
|
|
|
@test_throws expected_exception pick_codefence(Literate.QuartoFlavor(),true,"testname") |
|
|
|
let expected_exception = ErrorException( |
|
|
|
|
|
|
|
"QuartoFlavor does not support argument execute=true!", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
@test_throws expected_exception pick_codefence( |
|
|
|
|
|
|
|
Literate.QuartoFlavor(), |
|
|
|
|
|
|
|
true, |
|
|
|
|
|
|
|
"testname", |
|
|
|
|
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
@test ("```{julia}" => "```") == pick_codefence(Literate.QuartoFlavor(),false,"testname") |
|
|
|
@test ("```{julia}" => "```") == |
|
|
|
|
|
|
|
pick_codefence(Literate.QuartoFlavor(), false, "testname") |
|
|
|
|
|
|
|
|
|
|
|
# Misc default configs |
|
|
|
# Misc default configs |
|
|
|
create(; type, kw...) = Literate.create_configuration(inputfile; user_config=Dict(), user_kwargs=kw, type=type) |
|
|
|
create(; type, kw...) = Literate.create_configuration( |
|
|
|
|
|
|
|
inputfile; |
|
|
|
|
|
|
|
user_config = Dict(), |
|
|
|
|
|
|
|
user_kwargs = kw, |
|
|
|
|
|
|
|
type = type, |
|
|
|
|
|
|
|
) |
|
|
|
cfg = create(; type = :md, execute = true) |
|
|
|
cfg = create(; type = :md, execute = true) |
|
|
|
@test cfg["execute"] |
|
|
|
@test cfg["execute"] |
|
|
|
@test cfg["codefence"] == ("````julia" => "````") |
|
|
|
@test cfg["codefence"] == ("````julia" => "````") |
|
|
|
@ -1362,4 +1610,5 @@ end end |
|
|
|
@test cfg["codefence"] == ("````@example inputfile" => "````") |
|
|
|
@test cfg["codefence"] == ("````@example inputfile" => "````") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|