-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,411 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ rsconnect/ | |
^\.eslintignore$ | ||
^\.vscode$ | ||
^inst/tutorials/*/*_files$ | ||
^tests/manual$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,53 +2,28 @@ Type: Package | |
Package: learnr | ||
Title: Interactive Tutorials for R | ||
Version: 0.10.1.9019 | ||
Authors@R: | ||
c(person(given = "Garrick", | ||
family = "Aden-Buie", | ||
role = c("aut", "cre"), | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-7111-0077")), | ||
person(given = "Barret", | ||
family = "Schloerke", | ||
role = "aut", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0001-9986-114X")), | ||
person(given = "JJ", | ||
family = "Allaire", | ||
role = c("aut", "ccp"), | ||
email = "[email protected]"), | ||
person(given = "Alexander", | ||
family = "Rossell Hayes", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0001-9412-0457")), | ||
person(given = "Nischal", | ||
family = "Shrestha", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0003-3321-1712")), | ||
person(given = "Angela", | ||
family = "Li", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = "vignette"), | ||
person(given = "RStudio", | ||
role = c("cph", "fnd")), | ||
person(family = "Ajax.org B.V.", | ||
role = c("ctb", "cph"), | ||
comment = "Ace library"), | ||
person(given = "Zeno", | ||
family = "Rocha", | ||
role = c("ctb", "cph"), | ||
comment = "clipboard.js library"), | ||
person(given = "Nick", | ||
family = "Payne", | ||
role = c("ctb", "cph"), | ||
comment = "Bootbox library"), | ||
person(given = "Jake", | ||
family = "Archibald", | ||
role = c("ctb", "cph"), | ||
comment = "idb-keyval library")) | ||
Authors@R:c( | ||
person("Garrick", "Aden-Buie", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-7111-0077")), | ||
person("Barret", "Schloerke", , "[email protected]", role = "aut", | ||
comment = c(ORCID = "0000-0001-9986-114X")), | ||
person("JJ", "Allaire", , "[email protected]", role = c("aut", "ccp")), | ||
person("Alexander", "Rossell Hayes", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0001-9412-0457")), | ||
person("Nischal", "Shrestha", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0003-3321-1712")), | ||
person("Angela", "Li", , "[email protected]", role = "ctb", | ||
comment = "vignette"), | ||
person("RStudio", role = c("cph", "fnd")), | ||
person(, "Ajax.org B.V.", role = c("ctb", "cph"), | ||
comment = "Ace library"), | ||
person("Zeno", "Rocha", role = c("ctb", "cph"), | ||
comment = "clipboard.js library"), | ||
person("Nick", "Payne", role = c("ctb", "cph"), | ||
comment = "Bootbox library"), | ||
person("Jake", "Archibald", role = c("ctb", "cph"), | ||
comment = "idb-keyval library") | ||
) | ||
Description: Create interactive tutorials using R Markdown. Use a | ||
combination of narrative, figures, videos, exercises, and quizzes to | ||
create self-paced tutorials for learning about R and R packages. | ||
|
@@ -65,6 +40,7 @@ Imports: | |
htmlwidgets, | ||
jsonlite, | ||
knitr (>= 1.31), | ||
lifecycle, | ||
markdown, | ||
parallel, | ||
promises, | ||
|
@@ -74,6 +50,7 @@ Imports: | |
rmarkdown (>= 1.12.0), | ||
rprojroot, | ||
shiny (>= 1.0), | ||
stats, | ||
utils, | ||
withr | ||
Suggests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# {learnr} functions are intended to be written into R Markdown documents, | ||
# but there are certain times when we'd like to warn tutorial authors of | ||
# potential issues without the warning text appearing in the actual tutorial. | ||
# Since we can't ask users to set message = FALSE globally, we have to do our | ||
# own thing. Instead, we have a way to create messages that are automatically | ||
# added to a queue of items when knitting is in progress -- if we're not knitting | ||
# then we just emit the message immediately. Then we take advantage of the | ||
# `tutorial` knit hook that runs before and after each chunk in the tutorial. | ||
# In the after run, we flush the queue and re-signal the condition so that it | ||
# appears in the render console, thus avoiding writing to the tutorial HTML. | ||
|
||
.learnr_messages <- local({ | ||
queue <- list() | ||
list( | ||
peek = function() { | ||
if (length(queue)) queue | ||
}, | ||
flush = function() { | ||
while(length(queue)) { | ||
cnd <- queue[[1]] | ||
if (inherits(cnd, "error")) { | ||
# throw errors, they're immediate | ||
rlang::cnd_signal(cnd) | ||
} else { | ||
# otherwise report condition as a message, but re-signal warnings | ||
msg <- rlang::cnd_message(cnd) | ||
|
||
if (inherits(cnd, "warning")) { | ||
mgs <- paste0("Warning: ", msg) | ||
rlang::cnd_signal(cnd) | ||
} | ||
|
||
rlang::inform(msg, class = "learnr_render_message") | ||
} | ||
queue[[1]] <<- NULL | ||
} | ||
}, | ||
add = function(cnd) { | ||
queue <<- c(queue, list(cnd)) | ||
invisible(cnd) | ||
} | ||
) | ||
}) | ||
|
||
learnr_render_message <- function(..., level = c("inform", "warn", "abort")) { | ||
create_cnd <- switch( | ||
tolower(level), | ||
inform = rlang::inform, | ||
warn = rlang::warn, | ||
abort = rlang::abort | ||
) | ||
cnd <- rlang::catch_cnd(create_cnd(paste0(..., "\n"), "learnr_render_message")) | ||
|
||
if (isTRUE(getOption('knitr.in.progress'))) { | ||
.learnr_messages$add(cnd) | ||
} else { | ||
rlang::cnd_signal(cnd) | ||
} | ||
} | ||
|
||
learnr_render_catch <- function(expr, env = rlang::caller_env()) { | ||
cnd <- tryCatch( | ||
rlang::eval_bare(expr, env), | ||
error = identity, | ||
warning = identity, | ||
message = identity | ||
) | ||
|
||
if (!inherits(cnd, "condition")) { | ||
return(invisible()) | ||
} | ||
|
||
if (isTRUE(getOption('knitr.in.progress'))) { | ||
.learnr_messages$add(cnd) | ||
} else { | ||
rlang::cnd_signal(cnd) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.