JuliaDocs / Documenter.jl

A documentation generator for Julia.
https://documenter.juliadocs.org
MIT License
799 stars 474 forks source link

Deserialization in Julia code blocks can throw an error. #2531

Open ablaom opened 2 weeks ago

ablaom commented 2 weeks ago

The error I'm seeing is the same one reported in this Julia issue, which I'm pretty sure explains the problem, since Documenter.jl wraps code in anonymous modules, right?

mortenpi commented 1 week ago

Documenter.jl wraps code in anonymous modules, right?

Yes it does.

ablaom commented 1 week ago

For a little more context, I'm getting the error below when I change julia to @example MNIST here.

┌ Warning: failed to run `@example` block in src/extended_examples/MNIST/notebook.md:328-331
│ ```@example MNIST
│ mach2 = machine(joinpath(tempdir(), "mnist3.jls"))
│ predict_mode(mach2, images[501:503])
│ ```
│   exception =
│    UndefVarError: `__atexample__named__MNIST` not defined
│    Stacktrace:
│      [1] deserialize_module(s::Serialization.Serializer{IOStream})
│        @ Serialization /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:997

| Yes it does.

Then I'm guessing there so easy workaround or adaptation, apart from not evaluating the block as I am doing here, and we will need to wait on the Julia issue.