Documenter.jl
Documenter.jl copied to clipboard
`doctest` `filter` keyword does not accept substitution
Is there a reason the filter
keyword does not accept substitutions? I am trying to define a filter for all doctests (e.g. for comparing floating point numbers only consider up to 10 decimal values):
julia> doctest(MyPackage; doctestfilters = [(r"(\d*).(\d{1,10})\d+" => s"\1.\2"),])
...
TypeError: in keyword argument doctestfilters, expected Vector{Regex}, got a value of type Vector{Pair{Regex, SubstitutionString{String}}}
...
passing this filter to each jldoctest
individually works, but I would rather do it just once.
Also, when using the filters at the individual test level, I need to use double backslash or get an error about invalid escape sequence. What works for me is:
jldoctest; filter = r"(\\d*).(\\d{1,10})\\d+" => s"\\1.\\2"
Maybe this should be documented.
Seems like an oversight when the substitutions got added. Probably just need to expand the version constraint on the function.
This would probably be a good thing to implement. As a workaround, I'll point out that lookbehinds and lookaheads suffice for many (but not all) applications instead of a substitution. I wrote an example here.