Doctests and array printing

Printing of arrays changed recently:

julia> [1] # 1.5
1-element Array{Int64,1}:
 1

julia> [1] # master
1-element Vector{Int64}:
 1

This breaks quite some doctests. I would like to have my doctests pass on 1.x and master. What options do I have?

You can apply doctest filters. For this particular case you can try something like https://github.com/JuliaLang/julia/pull/37085#issuecomment-683356098

3 Likes

Thanks @fredrikekre Is there a way to apply these globally using the doctests function, without touching the docstrings?

    doctestfilters = [
        r"{([a-zA-Z0-9]+,\s?)+[a-zA-Z0-9]+}",
        r"(Array{[a-zA-Z0-9]+,\s?1}|Vector{[a-zA-Z0-9]+})",
        r"(Array{[a-zA-Z0-9]+,\s?2}|Matrix{[a-zA-Z0-9]+})",
    ]
    Documenter.doctest(TiledIteration, doctestfilters = doctestfilters)

does not work.

You can pass them to makedocs like that, but it was missed for the doctest function (https://github.com/JuliaDocs/Documenter.jl/issues/1364).

Edit: Fixed by https://github.com/JuliaDocs/Documenter.jl/pull/1435

3 Likes