diff --git a/test/examples/images/big.png b/test/examples/images/big.png new file mode 100644 index 0000000000..1b35084a36 Binary files /dev/null and b/test/examples/images/big.png differ diff --git a/test/examples/images/tiny.png b/test/examples/images/tiny.png new file mode 100644 index 0000000000..ea062c1e1c Binary files /dev/null and b/test/examples/images/tiny.png differ diff --git a/test/examples/make.jl b/test/examples/make.jl index b2e4024462..5001b93598 100644 --- a/test/examples/make.jl +++ b/test/examples/make.jl @@ -142,6 +142,15 @@ module AutoDocs end end +struct MIMEBytes{M <: MIME} + bytes :: Vector{UInt8} + MIMEBytes(mime::AbstractString, bytes::AbstractVector{UInt8}) = new{MIME{Symbol(mime)}}(bytes) +end +Base.show(io::IO, ::M, obj::MIMEBytes{M}) where {M <: MIME} = write(io, obj.bytes) + +const BIGPNG = MIMEBytes("image/png", read(joinpath(@__DIR__, "images", "big.png"))) +const TINYPNG = MIMEBytes("image/png", read(joinpath(@__DIR__, "images", "tiny.png"))) + # Helper functions function withassets(f, assets...) src(asset) = joinpath(@__DIR__, asset) diff --git a/test/examples/src/index.md b/test/examples/src/index.md index f4ce44aae0..a0d5dce330 100644 --- a/test/examples/src/index.md +++ b/test/examples/src/index.md @@ -655,3 +655,12 @@ They do not get evaluated. !!! ukw "Unknown admonition class" Admonition with an unknown admonition class. + +## Example outputs to file + +```@example +Main.BIGPNG +``` +```@example +Main.TINYPNG +``` diff --git a/test/examples/src/man/tutorial.md b/test/examples/src/man/tutorial.md index 1555a513b4..c2727a0eb3 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -279,8 +279,8 @@ SVG(""" Large inline SVG to exceed size threashold. ```@example inlinesvg -jlcolors = download(https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-colors.svg) -open(io->read(io, String), jlcolors) |> SVG +# jlcolors = download(https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-colors.svg) +# open(io->read(io, String), jlcolors) |> SVG ``` _Note: we can't define the `show` method in the `@example` block due to the world age diff --git a/test/examples/tests.jl b/test/examples/tests.jl index 32fc9c95c0..4054add022 100644 --- a/test/examples/tests.jl +++ b/test/examples/tests.jl @@ -182,6 +182,12 @@ end @test haskey(siteinfo_json["documenter"], "julia_version") @test haskey(siteinfo_json["documenter"], "generation_timestamp") end + + @testset "at-example outputs" begin + @show build_dir + @test isfile(joinpath(build_dir, "index-40245173.png")) + @test read(joinpath(build_dir, "index-40245173.png")) == read(joinpath(@__DIR__, "images", "big.png")) + end end end