Defining methods in isolation in `jldoctest`s

With Documenter.jl, each code block evaluates in its own scope:

Every doctest block is evaluated inside its own module . This means that definitions (types, variables, functions etc.) from a block can not be used in the next block.

Is it possible to define explanatory methods in code blocks so that they don’t leak into the global environment?

For example, how can I achieve the following?

module MWE

"""
	foo(x)

Example method definition:

```jldoctest
julia> MWE.foo(x::Int) = @info "new method" x

julia> foo(42)
┌ Info: new method
└   x = 42
```
"""
function foo(x)
	@info "fallback method" x
end

"""
	bar(x)

```jldoctest
julia> foo(42)
┌ Info: fallback method
└   x = 42
```
"""
function bar(x) end

end # module MWE

Note that fixing the doctests with Documenter causes the new method to be used in bar’s docstring, instead of the fallback method.

Since we run the doctests in the same Julia session, just different modules, they are bound to leak (defining MWE.foo(x::Int) is basically type piracy). However, it might be possible to erase the temporary methods in DocTestSetup, similar to how Revise does it?