Solution by @fredrikekre in Accessing an artifact inside a doctest · Issue #1963 · JuliaDocs/Documenter.jl · GitHub
Easiest (and most common?) way is to expand the macro in your package and only use a regular binding from the outside, e.g.
myartifact = artifact"myartifact"
in your package, and then use
MyPackage.myartifact
from the outside.
The fact that artifact"..." works in the REPL/Main (I think it does?) is mostly for convenience IIRC, but it doesn’t work in arbitrary modules, like the temp ones that are used for doctesting in Documenter.