Giter Club home page Giter Club logo

asciicast.jl's Introduction

Asciicast

Devcodecov

Asciicast.jl is all about showcasing Julia code running in a REPL using technologies developed by the open-source asciinema project. (It is totally unaffiliated with the authors of that project, however).

It does so in a few ways:

  • provides a convenient way to generate and maintain gifs showing code execution in READMEs and other documents. See the Markdown Usage portion of the docs.
  • provides integration with Documenter, providing @cast Documenter blocks that render code outputs as gifs in Documenter websites. See the Documenter Usage portion of the docs.
  • provides functionality to generate asciicast files (using the v2 file format) from Julia code, using the cast"" string macro, a record_output function, or using low-level write_event commands. These files can be played in the terminal or uploaded to asciinema.org with the asciinema player, or played in a web browser using asciinema-player. See the docs for more.

Demo:

@info "Hello!"
println("That was a logging statement, but this is printing.")
x = rand(10, 10)
using LinearAlgebra
svd(x)
println("Now I'll wait a second")
sleep(1)
println("ok, done!")

Alternatives to Asciicast.jl

  • It is easy to use the CLI tool asciinema directly to record sessions to .cast files or otherwise. That can be a good option if you need keyboard input or face some of the other Limitations of asciicast.jl.
    • In contrast, Asciicast.jl has an advantage in maintainability, in that you don't need to manually re-run sessions to regenerate the outputs.
  • Replay.jl provides a similar Julia-based alternative. Some of the differences I can ascertain:
    • Asciicast.jl is based on Documenter's code execution sandboxes (which have their limitations), while Replay.jl has it's own implementation.
    • Asciicast.jl provides Documenter and pandoc-based document integration with @cast blocks and {cast="true"} blocks, while Replay seems focused on the core replaying-of-sessions. Perhaps these could be composed together somehow?
    • Possibly other differences; I am not very familiar with Replay.jl. PRs to improve this comparison are appreciated!

asciicast.jl's People

Contributors

ericphanson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

asciicast.jl's Issues

replace `allow_errors` with 3-valued `errors`?

Could be:

  • errors=true: must error or else we throw. Like @test_throws.
  • errors=false (default): must not error or else we throw
  • errors=missing: may or may not error, like allow_errors=true.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

use with Documenter has JS dependency load order issues

which is what

# Very hacky fix to load the asciinema JS before Documenter's require.js
# <https://github.com/JuliaDocs/Documenter.jl/issues/1433>
requires_regex = r"""<script src="https://cdnjs\.cloudflare\.com/ajax/libs/require\.js/[0-9]+\.[0-9]+\.[0-9]+/require\.min\.js" data-main="assets/documenter\.js"></script>"""
asciinema_script = """<script src="https://cdnjs.cloudflare.com/ajax/libs/asciinema-player/$(asciinema_version)/asciinema-player.min.js"></script>"""
index_path = joinpath(@__DIR__, "build", "index.html")
index = read(index_path, String)
requires_script = match(requires_regex, index).match # get the right version numbers for requires.js
index = replace(index, asciinema_script => "")
index = replace(index, requires_script => asciinema_script*requires_script)
write(index_path, index)
tries to work around.

Xref JuliaDocs/Documenter.jl#1433

(this is problem #4 of JuliaDocs/Documenter.jl#1675)

No tests!

Need some kind of test coverage to avoid bugs and regressions. Should look at how Documenter.jl does it.

Include not defined

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.