ericphanson / Asciicast.jl

Easy REPL animations in READMEs, Documenter docs, and more!
https://ericphanson.github.io/Asciicast.jl/
Other
42 stars 0 forks source link

Include not defined #32

Closed KronosTheLate closed 11 months ago

KronosTheLate commented 11 months ago

I am having an issue with include not being defined.

julia> cast"""include("my_file.jl")"""
ERROR: LoadError: CastExecutionException: Failed to run `cast` block:

include("my_file.jl")

ERROR: UndefVarError: `include` not defined

Stacktrace:
 [1] cast_from_string!(code_string::String, cast::Cast{…}; doc::Asciicast.FakeDoc, page::Asciicast.FakePage, ansicolor::Bool, mod::Module, multicodeblock::Vector{…}, allow_errors::Bool, x::Nothing, remove_prompt::Bool)
   @ Asciicast ~/.julia/packages/Asciicast/39KUb/src/runner.jl:204
 [2] cast_from_string!
   @ ~/.julia/packages/Asciicast/39KUb/src/runner.jl:142 [inlined]
 [3] _cast_str(code_string::String, delay::Int64; height::Nothing, allow_errors::Bool, mod::Module)
   @ Asciicast ~/.julia/packages/Asciicast/39KUb/src/runner.jl:262
 [4] var"@cast_str"(__source__::LineNumberNode, __module__::Module, code_string::Any, delay::Any, allow_errors::Any)
   @ Asciicast ~/.julia/packages/Asciicast/39KUb/src/runner.jl:255
in expression starting at REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.

I also tried defining a custum function, but got the same error. What is up with that? I just installed the package into a 1.10 RC environment, so I should have the latest version.

ericphanson commented 11 months ago

It works just like an @repl block in Documenter, so everything has to be defined in the block. I’m not sure why include doesn’t work though, I’ll have to look into that. using should work though.

ericphanson commented 11 months ago

https://github.com/ericphanson/Asciicast.jl/pull/33 fixes the issue with include, and adds documentation explaining why everything must be defined within the cast"" block.