Differences of Core.eval vs. running the code directly in other modules then Main

I don’t know the internals, but it seems to me that separating the creation of a module (which needs a fixed name) and the binding to another module’s namespace (possibly with another name) may be necessary to allow things like this:

julia> import Random as RNDM # I might want `Main.Random` to be a different thing

julia> @isdefined Random
false

julia> RNDM.eval(:@__MODULE__) # But this is the "real" name of the module
Random

With Module(:Sandbox) you are creating the module called Sandbox, but still have the possibility of using Main.Sandbox for a different thing, as in the previous example with the module Random.

I don’t know the answer to that, but I had never seen a module defined as a local object of a function - I didn’t even imagine that it could be allowed.

You comment that this is related to Documenter.jl, whose internals I don’t know, so that may be the reason of my failure to understand what you are trying to do. Could this other topic be related to the problem you report?