Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Turn R scripts into terminal screencasts

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

r-lib/asciicast

Turn R scripts into terminal screencasts

Lifecycle: experimentalCRAN statusR-CMD-checkCodecov test coverage

asciicast takes an R script and turns it into anasciinema cast. It can simulate typing, andrecords all terminal output in real time as it happens.

Features

  • Input is an R script, output is av2 asciicastrecording.
  • Record all terminal output in real time, as it happens.
  • Simulate typing in the commands, with a configurable, randomizedspeed.
  • Alternatively, whole comment blocks or expressions can just appearon the screen.
  • Convert casts to SVG images usingsvg-term. The package comeswith its own svg-term bundle, no external dependencies are needed.
  • Render a single frame of a cast as an SVG image.
  • Configurable delay at the beginning, at the end and betweenparagraphs.
  • HTML widget, to be used in Rmarkdowndocuments, e.g. in vignettes.
  • Read casts from asciinema JSON files (version 2), or fromhttps://asciinema.org directly.
  • Special knitr engine to create R markdown files with ascii casts.See theasciicast-demo vignette.
  • Create ascii casts in GitHub READMEs via animated SVG files. See anexample ininst/examples or theREADME.Rmd source of the READMEfile you are reading.

Limitations

  • asciicast works best in an UTF-8 locale. It also works well if alloutput is ASCII, but non-ASCII output might cause problems(#36).

Installation

You can install the released version of asciicast fromCRAN:

install.packages("asciicast")

Examples

See theinst/examplesdirectoryfor these examples.

Hello world

The input script:

print("Hello world!")

The result:

Asciicast demo in asciicast

Input script that uses asciicast itself:

#' Title: asciicast example recorded in asciicast#' Empty_wait: 3#' End_wait: 20# An example for using asciicast, recorded in asciicast itself!      #!# First, save the R code you want to run, in a script file.          #!# The file can contain any code, including interactive code,         #!# as long as it is a syntactically valid R file.                     #!# Second, perform the recording with the `record()` function.        #!# We are recording an example file now, that comes with the package. #!src<- system.file("examples","hello.R",package="asciicast")cast<-asciicast::record(src)# `cast` is an `asciicast` object, which has some metadata and the   #!# recording itself:                                                  #!cast# You can write `cast` to a JSON file that can be played by any      #!# asciinema player. Or you can write it to an SVG file that can      #!# be embedded into a web page, or a GitHub README.                   #!svg<- tempfile(fileext=".svg")asciicast::write_svg(cast,svg,window=TRUE)

Errors are recorded

Input script with errors:

#' End_wait: 20# Demonstrate that errors are handled well# Base R errorlibrary("not-this-really")traceback()# callr errors are saved to `.Last.error`, including a stack tracelibrary(cli)callr::r(function() library("another-failure")).Last.error

Related tools

License

MIT @RStudio

About

Turn R scripts into terminal screencasts

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp