JuliaDocs / Documenter.jl

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

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

Open ablaom opened 4 months ago

ablaom commented 4 months 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 4 months ago

Documenter.jl wraps code in anonymous modules, right?

Yes it does.

ablaom commented 4 months 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.