-
Notifications
You must be signed in to change notification settings - Fork 11
/
README.Rmd
120 lines (88 loc) · 3.73 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
output: github_document
always_allow_html: yes
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE, cache = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
asciicast_at = "all",
asciicast_theme = if (Sys.getenv("IN_PKGDOWN") == "true") "pkgdown" else "readme"
)
asciicast::init_knitr_engine()
```
# asciicast
> Turn R scripts into terminal screencasts
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/asciicast)](https://cran.r-project.org/package=asciicast)
[![Codecov test coverage](https://codecov.io/gh/r-lib/asciicast/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/asciicast?branch=main)
[![R-CMD-check](https://github.com/r-lib/asciicast/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/asciicast/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
asciicast takes an R script and turns it into an
[asciinema](https://asciinema.org/) cast. It can simulate typing, and
records all terminal output in real time as it happens.
## Features
* Input is an R script, output is a
[v2 asciicast recording](https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md).
* Record all terminal output in real time, as it happens.
* Simulate typing in the commands, with a configurable, randomized speed.
* Alternatively, whole comment blocks or expressions can just appear on
the screen.
* Convert casts to SVG images using
[svg-term](https://github.com/marionebl/svg-term). The package comes with
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 between paragraphs.
* [HTML widget](http://www.htmlwidgets.org), to be used in Rmarkdown
documents, e.g. in vignettes.
* Read casts from asciinema JSON files (version 2), or from
<https://asciinema.org> directly.
* Special knitr engine to create R markdown files with ascii casts. See
the `asciicast-demo` vignette.
* Create ascii casts in GitHub READMEs via animated SVG files. See an
example in `inst/examples` or the `README.Rmd` source of the README
file you are reading.
## Limitations
* asciicast works best in an UTF-8 locale. It also works well if all output
is ASCII, but non-ASCII output might cause problems
(https://github.com/r-lib/asciicast/issues/36).
## Installation
You can install the released version of asciicast from
[CRAN](https://CRAN.R-project.org):
``` r
install.packages("asciicast")
```
## Examples
See the [`inst/examples` directory](https://github.com/r-lib/asciicast/tree/main/inst/examples)
for these examples.
### Hello world
The input script:
```{r code = readLines("inst/examples/hello.R"), eval = FALSE}
```
The result:
```{asciicast, code = readLines("inst/examples/hello.R"), cache = TRUE}
```
### Asciicast demo in asciicast
Input script that uses asciicast itself:
```{r code = readLines("inst/examples/asciicast.R"), eval = FALSE}
```
```{asciicast, code = readLines("inst/examples/asciicast.R"), cache = TRUE}
```
### Errors are recorded
Input script with errors:
```{r code = readLines("inst/examples/errors.R"), eval = FALSE}
```
```{asciicast, code = readLines("inst/examples/errors.R"), cache = TRUE}
```
## Related tools
* asciinema: https://asciinema.org/
* The original terminal session recorder:
https://github.com/asciinema/asciinema
* svg-term: https://github.com/marionebl/svg-term,
https://github.com/marionebl/svg-term-cli
## License
MIT @ [RStudio](https://github.com/rstudio)