IRdisplay/0000755000176200001440000000000013377754572012176 5ustar liggesusersIRdisplay/tests/0000755000176200001440000000000012737425410013321 5ustar liggesusersIRdisplay/tests/testthat.R0000644000176200001440000000007612737425410015307 0ustar liggesuserslibrary(testthat) library(IRdisplay) test_check('IRdisplay') IRdisplay/tests/testthat/0000755000176200001440000000000013377754572015200 5ustar liggesusersIRdisplay/tests/testthat/test_base_display.r0000644000176200001440000000031412735162246021043 0ustar liggesuserscontext('jupyter.base_display_func') test_that('original jupyter.base_display_func raises a warning', { expect_warning(getOption('jupyter.base_display_func')(NULL), regexp = 'can only be used from') }) IRdisplay/tests/testthat/test_display_functions_textual.r0000644000176200001440000000262612737425622023721 0ustar liggesuserscontext('textual display functions') last_data <- NULL test_display_func <- function(data, metadata = NULL) { last_data <<- list(data, metadata) } get_last_data <- function() { ret <- last_data last_data <<- NULL ret } withr::with_options(list(jupyter.base_display_func = test_display_func), { test_that('display_json works', { exp <- list('application/json' = '{}') display_json('{}') expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display_javascript works', { exp <- list('application/javascript' = 'data') display_javascript('data') expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display_html works', { exp <- list('text/html' = 'data') display_html('data') expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display_html with full html page', { exp <- list('text/html' = 'text') exp_md <- list('text/html' = list(isolated = TRUE)) display_html('text') expect_equal(get_last_data(), list(exp, exp_md)) }) test_that('display_markdown works', { exp <- list('text/markdown' = 'data') display_markdown('data') expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display_latex works', { exp <- list('text/latex' = 'data') display_latex('data') expect_equal(get_last_data(), list(exp, NULL)) }) }) IRdisplay/tests/testthat/test_display_functions.r0000644000176200001440000000542712737425622022155 0ustar liggesuserscontext('general display functions') library(repr) last_data <- NULL test_display_func <- function(data, metadata = NULL) { last_data <<- list(data, metadata) } get_last_data <- function() { ret <- last_data last_data <<- NULL ret } test_that('display without a jupyter.base_display_func raises a warning', { expect_warning(display(NULL), regexp = 'can only be used from') }) withr::with_options(list(jupyter.base_display_func = test_display_func), { test_that('publish_mimebundle works', { publish_mimebundle(NULL) expect_equal(get_last_data(), list(NULL, NULL)) publish_mimebundle(1, 1) expect_equal(get_last_data(), list(1, 1)) }) test_that('display works', { # NULL only displays in text/plain exp <- list('text/plain' = repr_text(NULL)) display(NULL) expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display only creates the jupyter.display_mimetypes', { exp <- list( 'text/plain' = repr_text(1), 'text/html' = repr_html(1)) withr::with_options( list(jupyter.display_mimetypes = c('text/plain', 'text/html')), display(1)) expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display attaches metadata', { exp <- list( 'text/plain' = 'x', 'text/html' = 'x') exp_md <- list('text/html' = list(isolated = TRUE)) withr::with_options(list(jupyter.display_mimetypes = c('text/plain', 'text/html')), { .GlobalEnv$repr_text.html_literal <- .GlobalEnv$repr_html.html_literal <- function(obj, ...) unclass(obj) display(structure('x', class = 'html_literal')) }) expect_equal(get_last_data(), list(exp, exp_md)) }) test_that('display handles raw data', { dta <- as.raw(1:10) exp <- list( 'text/plain' = 'PNG data: 01 02 03 04 05...', 'image/png' = dta) withr::with_options(list(jupyter.display_mimetypes = c('text/plain', 'image/png')), { .GlobalEnv$repr_text.raw_png <- function(obj, ...) sprintf('PNG data: %s...', paste(obj[1:5], collapse = ' ')) .GlobalEnv$repr_png.raw_png <- function(obj, ...) unclass(obj) display(structure(dta, class = 'raw_png')) }) expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display needs > 0 display_mimetypes', { withr::with_options( list(jupyter.display_mimetypes = character(0L)), expect_error(display(1), 'may not be NULL or of length 0')) withr::with_options( list(jupyter.display_mimetypes = NULL), expect_error(display(1), 'may not be NULL or of length 0')) }) test_that('display_raw works', { exp <- list('text/plain' = 'data') display_raw('text/plain', FALSE, 'data', NULL) expect_equal(get_last_data(), list(exp, NULL)) }) }) IRdisplay/tests/testthat/test-options.r0000644000176200001440000000021513377730160020014 0ustar liggesuserscontext('default options') test_that('default options are set', { expect_equal(length(getOption('jupyter.display_mimetypes')), 15L) }) IRdisplay/tests/testthat/test_display_functions_images.r0000644000176200001440000000243412737425622023475 0ustar liggesuserscontext('image display functions') last_data <- NULL test_display_func <- function(data, metadata = NULL) { last_data <<- list(data, metadata) } get_last_data <- function() { ret <- last_data last_data <<- NULL ret } withr::with_options(list(jupyter.base_display_func = test_display_func), { test_that('display_png works', { dta <- as.raw(1:3) exp <- list('image/png' = dta) exp_md <- list(width = 1, height = 2) display_png(dta) expect_equal(get_last_data(), list(exp, NULL)) display_png(dta, width = 1, height = 2) expect_equal(get_last_data(), list(exp, exp_md)) }) test_that('display_jpeg works', { dta <- as.raw(1:3) exp <- list('image/jpeg' = dta) exp_md <- list(width = 1, height = 2) display_jpeg(dta) expect_equal(get_last_data(), list(exp, NULL)) display_jpeg(dta, width = 1, height = 2) expect_equal(get_last_data(), list(exp, exp_md)) }) test_that('display_pdf works', { dta <- as.raw(1:3) exp <- list('application/pdf' = dta) display_pdf(dta) expect_equal(get_last_data(), list(exp, NULL)) }) test_that('display_svg works', { exp <- list('image/svg+xml' = '') display_svg('') expect_equal(get_last_data(), list(exp, NULL)) }) }) IRdisplay/NAMESPACE0000644000176200001440000000061513377731275013412 0ustar liggesusers# Generated by roxygen2: do not edit by hand export(display) export(display_html) export(display_javascript) export(display_jpeg) export(display_json) export(display_latex) export(display_markdown) export(display_pdf) export(display_png) export(display_svg) export(irdisplay_option_defaults) export(prepare_mimebundle) export(publish_mimebundle) importFrom(methods,is) importFrom(repr,mime2repr) IRdisplay/R/0000755000176200001440000000000013377727742012376 5ustar liggesusersIRdisplay/R/display_images.r0000644000176200001440000000304313277264546015550 0ustar liggesusers#' Display a specific image output #' #' Either \code{data} or \code{file} must be passed. #' #' @param data The data as a \code{\link[base]{raw}} vector (\code{\link[base]{character}} vector for \code{display_svg}) #' @param file The path to a file or a \code{\link[base]{connection}} containing the content #' @param width The width to display the image #' @param height The height to display the image #' #' @seealso \code{\link{display_}} #' #' @examples \dontrun{## (Run inside of an IRkernel) #' display_png(file = 'image.png') #' display_svg(' #' #' #' #' ') #' display_jpeg(file = url('https://dummyimage.com/600x400.jpg', 'wb'), width = 100)} #' #' @name display_ NULL #' @name display_ #' @export display_png <- function(data = NULL, file = NULL, width = NULL, height = NULL) display_raw('image/png', TRUE, data, file, img_metadata(width, height)) #' @name display_ #' @export display_jpeg <- function(data = NULL, file = NULL, width = NULL, height = NULL) display_raw('image/jpeg', TRUE, data, file, img_metadata(width, height)) #' @name display_ #' @export display_pdf <- function(data = NULL, file = NULL, width = NULL, height = NULL) display_raw('application/pdf', TRUE, data, file, img_metadata(width, height)) #' @name display_ #' @export display_svg <- function(data = NULL, file = NULL, width = NULL, height = NULL) display_raw('image/svg+xml', FALSE, data, file, img_metadata(width, height)) IRdisplay/R/display_textual.r0000644000176200001440000000240012747650620015756 0ustar liggesusers#' Display a specific textual output #' #' Either \code{data} or \code{file} must be passed. #' #' @param data The code or markup content as a \code{\link[base]{character}} vector #' @param file The path to a file or a \code{\link[base]{connection}} containing the content #' #' @seealso \code{\link{display_}} #' #' @examples \dontrun{## (Run inside of an IRkernel) #' display_text('Just text') #' display_markdown('[MD](http://commonmark.org) *formatted*') #' display_javascript('execute(this)')} #' #' @name display_ NULL #' @name display_ #' @export display_json <- function(data = NULL, file = NULL) display_raw('application/json', FALSE, data, file) #' @name display_ #' @export display_javascript <- function(data = NULL, file = NULL) display_raw('application/javascript', FALSE, data, file) #' @name display_ #' @export display_html <- function(data = NULL, file = NULL) display_raw('text/html', FALSE, data, file, isolate_full_html(list('text/html' = data))) #' @name display_ #' @export display_markdown <- function(data = NULL, file = NULL) display_raw('text/markdown', FALSE, data, file) #' @name display_ #' @export display_latex <- function(data = NULL, file = NULL) display_raw('text/latex', FALSE, data, file) IRdisplay/R/utils.r0000644000176200001440000000310313352110075013670 0ustar liggesusers# maps a function and return a named list with the NULL results removed filter_map <- function(x, f, simplify = FALSE) Filter(Negate(is.null), sapply(x, f, simplify = simplify)) # create metadata bundle for images img_metadata <- function(width, height) { if (is.null(width) && is.null(height)) return(NULL) metadata <- list() if (!is.null(width)) metadata$width <- width if (!is.null(height)) metadata$height <- height metadata } # add an "isolate" flag to -containing data, or the unchanged metadata isolate_full_html <- function(data, metadata = NULL) { if (!('text/html' %in% names(data)) || !isTRUE(grepl('', data[['text/html']], ignore.case = TRUE))) return(metadata) if (is.null(metadata)) metadata <- list() if (is.null(metadata[['text/html']])) metadata[['text/html']] <- list() metadata[['text/html']]$isolated <- TRUE metadata } #' @importFrom methods is read_all <- function(file, isbinary) { read <- if (isbinary) function(s) readBin(file, 'raw', s) else function(s) readChar(file, s) size <- tryCatch(file.info(file)$size, error = function(e) NULL) if (!is.null(size)) { read(size) } else { if (is.character(file)) file <- base::file(file, 'rb') stopifnot(is(file, 'connection')) if (!isOpen(file)) open(file) rv <- if (isbinary) raw() else character() chunk <- read(1024) while (length(chunk) > 0) { rv <- c(rv, chunk) chunk <- read(1024) } rv } } IRdisplay/R/display.r0000644000176200001440000000774413377727742014242 0ustar liggesusers#' Display data by mimetype, with optional alternative representations. #' #' Calls the function stored as option value of \code{jupyter.base_display_func}. (see: \link{IRdisplay-options}) #' #' @param data A named list mapping mimetypes to content (\code{\link[base]{character}} or \code{\link[base]{raw} vectors}) #' @param metadata A named list mapping mimetypes to named lists of metadata, e.g. \code{list('image/png' = list(width = 5))} #' #' @seealso \code{\link{prepare_mimebundle}} #' #' @examples \dontrun{## (Run inside of an IRkernel) #' publish_mimebundle(list('text/html' = '

Hi!

')) #' publish_mimebundle( #' list('image/svg+xml' = ''), #' list('image/svg+xml' = list(width = 100, height = 100)))} #' #' @export publish_mimebundle <- function(data, metadata = NULL) { getOption('jupyter.base_display_func')(data, metadata) } #' Create and use multiple available reprs #' #' Both functions create a mimebundle for multiple reprs. #' \code{display} proceeds to publish it using \code{\link{publish_mimebundle}}. #' \code{prepare_mimebundle} returns it (see \emph{Value} for details) #' #' @param obj The object to create representations for #' @param mimetypes Mimetypes to create reprs for. The defaults are defined by the option \code{jupyter.display_mimetypes}. (see: \link{IRdisplay-options}) #' @param metadata,... Metadata to attach to the result (can be expanded by additional metadata) #' @param error_handler Function used when errors in individual reprs occur #' #' @return \code{prepare_mimebundle} returns a list with items corresponding to the parameters of \code{\link{publish_mimebundle}} (\code{data} and \code{metadata}) #' #' @seealso \code{\link{publish_mimebundle}} #' #' @examples #' bundle <- prepare_mimebundle(diag(3)) #' #' \dontrun{## (Run inside of an IRkernel) #' display(help(display))} #' #' @name display #' @export display <- function( obj, ..., mimetypes = getOption('jupyter.display_mimetypes'), error_handler = stop ) { metadata <- list(...) if (length(metadata) == 0L) metadata <- NULL bundle <- prepare_mimebundle(obj, mimetypes, metadata, error_handler) publish_mimebundle(bundle$data, bundle$metadata) } #' @importFrom repr mime2repr #' @name display #' @export prepare_mimebundle <- function( obj, mimetypes = getOption('jupyter.display_mimetypes'), metadata = NULL, error_handler = stop ) { if (length(mimetypes) == 0L) stop('option jupyter.display_mimetypes may not be NULL or of length 0') outer_handler <- if (identical(error_handler, stop)) stop else function(e) {} # Use withCallingHandlers as that shows the inner stacktrace: # https://stackoverflow.com/questions/15282471/get-stack-trace-on-trycatched-error-in-r # the tryCatch is still needed to prevent the error from showing # up outside further up the stack :-/ data <- filter_map(mimetypes, function(mime) { tryCatch(withCallingHandlers({ if (! mime %in% names(repr::mime2repr)) stop('No repr_* for mimetype ', mime, ' in repr::mime2repr') rpr <- repr::mime2repr[[mime]](obj) if (is.null(rpr)) return(NULL) prepare_content(is.raw(rpr), rpr) }, error = error_handler), error = outer_handler) }) list(data = data, metadata = isolate_full_html(data, metadata)) } prepare_content <- function(isbinary, data = NULL, file = NULL) { if (is.null(file) == is.null(data)) stop('Either need to specify data or file, but not both') if (is.null(file)) { if (isbinary) { if (!is.raw(data)) stop('Data needs to be a raw vector') } data } else { read_all(file, isbinary) } } display_raw <- function(mimetype, isbinary, data, file, metadata = NULL) { content <- prepare_content(isbinary, data, file) data <- list() data[[mimetype]] <- content publish_mimebundle(data, metadata) } IRdisplay/R/options.r0000644000176200001440000000320513377724763014254 0ustar liggesusers#' IRdisplay options #' #' Some \link{options} to control the formats \code{\link{display}} and \code{\link{prepare_mimebundle}} emit, #' and the function they use to display them. #' #' @section Options: #' #' \describe{ #' #' \item{\code{jupyter.display_mimetypes}}{ #' The default is all MIME types supported by Jupyter. #' } #' \item{\code{jupyter.base_display_func}}{ #' Function used by \code{\link{display}} and all \code{\link{display_}} / \code{\link{display_}} functions. #' Has the signature \code{function(data, metadata = NULL)}. #' Per default emits a \code{\link{warning}}, and is set when running an \code{IRkernel}. #' } #' #' } #' #' @name IRdisplay-options #' @export irdisplay_option_defaults <- list( jupyter.display_mimetypes = c( 'text/plain', 'text/html', 'text/markdown', 'text/latex', 'application/json', 'application/javascript', 'application/geo+json', 'application/vdom.v1+json', 'application/vnd.plotly.v1+json', 'application/vnd.vegalite.v2+json', 'application/vnd.vega.v4+json', 'application/pdf', 'image/png', 'image/jpeg', 'image/svg+xml'), jupyter.base_display_func = function(data, metadata = NULL) { warning('IRdisplay can only be used from the IPython R kernel and R magic.') }) .onLoad <- function(libname = NULL, pkgname = NULL) { for (option in names(irdisplay_option_defaults)) { if (is.null(getOption(option))) { do.call(options, irdisplay_option_defaults[option]) # single []: preserve name } } } IRdisplay/README.md0000644000176200001440000000343413377727742013460 0ustar liggesusersIRdisplay [![b-Travis]][Travis] [![b-CRAN]][CRAN] ========= [b-Travis]: https://travis-ci.org/IRkernel/IRdisplay.svg?branch=master "Build status" [Travis]: https://travis-ci.org/IRkernel/IRdisplay [b-CRAN]: https://www.r-pkg.org/badges/version/IRdisplay "Comprehensive R Archive Network" [CRAN]: https://cran.r-project.org/package=IRdisplay IRdisplay is a front-end package for Jupyter. It’s automatically integrated into [IRkernel][] when you open a Jupyter notebook using that kernel. The primary, high level functions are: ```r display(obj, ..., mimetypes=, error_handler=stop) display_png(data = NULL, file = NULL, width = NULL, height = NULL) # display_jpeg(…); display_pdf(…); display_svg(…) display_html(data = NULL, file = NULL) # display_javascript(…), display_json(…), display_markdown(…), display_latex(…) ``` Use `display` to display an object in all configured mime types (see **Configuration**), and the `display_*` functions to display raw data you have in form of a file or a variable. Manual use is possible via the `*_mimebundle` functions: ```r prepare_mimebundle(obj, mimetypes=, metadata=NULL, error_handler=stop) publish_mimebundle(data, metadata = NULL) ``` Where `prepare_mimebundle` uses `repr` to create a mimebundle containing representations of objects, and `publish_mimebundle` sends such mimebundles to Jupyter. [IRkernel]: https://irkernel.github.io/running/ Configuration ------------- You can add your own mime types that should be displayed via: ```r options(jupyter.display_mimetypes = union(getOption('jupyter.display_mimetypes'), ...)) ``` If you want to create your own kernel reacting to `display` / `publish_mimebundle` calls, you can use: ```r options(jupyter.base_display_func = function(data, metadata = NULL) ...) ``` IRdisplay/MD50000644000176200001440000000221513377754572012506 0ustar liggesusers90dcd4df1b0945b1b11584d0b18a257f *DESCRIPTION 3fd4786bf5351f2b5fa63d036ae8e5b2 *LICENSE cff9eaa100b9446d081cf29c1931e994 *NAMESPACE 34d6544d7cd7889ee948e112ff1e3b06 *R/display.r 0d4f129a1b2a1667c0475edff934d844 *R/display_images.r d401d364d5f881e9e82a5e9035aca434 *R/display_textual.r 4ee9aa59f6227853f5088d3350f6251d *R/options.r a65a898d0b87a50b6dbcf53535358be9 *R/utils.r 325abb69812eb81bc580104fd733fb69 *README.md 3ae675702486c2db25d79987138a6550 *man/IRdisplay-options.Rd 0e37d9b38b2b3ddd51d12d09bf15cd06 *man/display.Rd 0e2ee4c9d802876a0107b28e43e4135d *man/display_-less-than-image-greater-than.Rd b7bce1266af9836919d05548c44b0943 *man/display_-less-than-text-greater-than.Rd 7984f21effb42ea187e9b9cb9004a903 *man/publish_mimebundle.Rd 4fd1af4a33f903a0fbaba13bedd228e4 *tests/testthat.R f678acbe698354e19e40e1f53919bd2f *tests/testthat/test-options.r 5364bff55fac94ed7a91ae0811c7efc3 *tests/testthat/test_base_display.r 5e5473056c2bed085d656c147211a059 *tests/testthat/test_display_functions.r 8a143f86d38a8cde552e2513a8ba89a1 *tests/testthat/test_display_functions_images.r 22fe2c09e5910d045528110fd03d8cd8 *tests/testthat/test_display_functions_textual.r IRdisplay/DESCRIPTION0000644000176200001440000000207213377754572013705 0ustar liggesusersPackage: IRdisplay Title: 'Jupyter' Display Machinery Description: An interface to the rich display capabilities of 'Jupyter' front-ends (e.g. 'Jupyter Notebook') . Designed to be used from a running 'IRkernel' session . Version: 0.7.0 Authors@R: c( person('Thomas', 'Kluyver', role = c('aut', 'cph'), email = 'thomas@kluyver.me.uk'), person('Philipp', 'Angerer', role = c('aut', 'cph', 'cre'), email = 'phil.angerer@gmail.com', comment = c(ORCID = "0000-0002-0369-2888")), person('Jan', 'Schulz', role = c('aut', 'cph'), email = 'jasc@gmx.net')) Depends: R (>= 3.0.1) Suggests: testthat, withr Imports: methods, repr License: MIT + file LICENSE LazyData: true Encoding: UTF-8 RoxygenNote: 6.1.1 NeedsCompilation: no Packaged: 2018-11-29 09:34:55 UTC; angerer Author: Thomas Kluyver [aut, cph], Philipp Angerer [aut, cph, cre] (), Jan Schulz [aut, cph] Maintainer: Philipp Angerer Repository: CRAN Date/Publication: 2018-11-29 12:20:10 UTC IRdisplay/man/0000755000176200001440000000000013372304174012731 5ustar liggesusersIRdisplay/man/publish_mimebundle.Rd0000644000176200001440000000173113277264546017105 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/display.r \name{publish_mimebundle} \alias{publish_mimebundle} \title{Display data by mimetype, with optional alternative representations.} \usage{ publish_mimebundle(data, metadata = NULL) } \arguments{ \item{data}{A named list mapping mimetypes to content (\code{\link[base]{character}} or \code{\link[base]{raw} vectors})} \item{metadata}{A named list mapping mimetypes to named lists of metadata, e.g. \code{list('image/png' = list(width = 5))}} } \description{ Calls the function stored as option value of \code{jupyter.base_display_func}. (see: \link{IRdisplay-options}) } \examples{ \dontrun{## (Run inside of an IRkernel) publish_mimebundle(list('text/html' = '

Hi!

')) publish_mimebundle( list('image/svg+xml' = ''), list('image/svg+xml' = list(width = 100, height = 100)))} } \seealso{ \code{\link{prepare_mimebundle}} } IRdisplay/man/display_-less-than-text-greater-than.Rd0000644000176200001440000000174013277264546022277 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/display_textual.r \name{display_} \alias{display_} \alias{display_json} \alias{display_javascript} \alias{display_html} \alias{display_markdown} \alias{display_latex} \title{Display a specific textual output} \usage{ display_json(data = NULL, file = NULL) display_javascript(data = NULL, file = NULL) display_html(data = NULL, file = NULL) display_markdown(data = NULL, file = NULL) display_latex(data = NULL, file = NULL) } \arguments{ \item{data}{The code or markup content as a \code{\link[base]{character}} vector} \item{file}{The path to a file or a \code{\link[base]{connection}} containing the content} } \description{ Either \code{data} or \code{file} must be passed. } \examples{ \dontrun{## (Run inside of an IRkernel) display_text('Just text') display_markdown('[MD](http://commonmark.org) *formatted*') display_javascript('execute(this)')} } \seealso{ \code{\link{display_}} } IRdisplay/man/IRdisplay-options.Rd0000644000176200001440000000164613277264546016634 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/options.r \docType{data} \name{IRdisplay-options} \alias{IRdisplay-options} \alias{irdisplay_option_defaults} \title{IRdisplay options} \format{An object of class \code{list} of length 2.} \usage{ irdisplay_option_defaults } \description{ Some \link{options} to control the formats \code{\link{display}} and \code{\link{prepare_mimebundle}} emit, and the function they use to display them. } \section{Options}{ \describe{ \item{\code{jupyter.display_mimetypes}}{ The default is all MIME types supported by Jupyter. } \item{\code{jupyter.base_display_func}}{ Function used by \code{\link{display}} and all \code{\link{display_}} / \code{\link{display_}} functions. Has the signature \code{function(data, metadata = NULL)}. Per default emits a \code{\link{warning}}, and is set when running an \code{IRkernel}. } } } \keyword{datasets} IRdisplay/man/display.Rd0000644000176200001440000000251313372304744014671 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/display.r \name{display} \alias{display} \alias{prepare_mimebundle} \title{Create and use multiple available reprs} \usage{ display(obj, ..., mimetypes = getOption("jupyter.display_mimetypes"), error_handler = stop) prepare_mimebundle(obj, mimetypes = getOption("jupyter.display_mimetypes"), metadata = NULL, error_handler = stop) } \arguments{ \item{obj}{The object to create representations for} \item{mimetypes}{Mimetypes to create reprs for. The defaults are defined by the option \code{jupyter.display_mimetypes}. (see: \link{IRdisplay-options})} \item{error_handler}{Function used when errors in individual reprs occur} \item{metadata, ...}{Metadata to attach to the result (can be expanded by additional metadata)} } \value{ \code{prepare_mimebundle} returns a list with items corresponding to the parameters of \code{\link{publish_mimebundle}} (\code{data} and \code{metadata}) } \description{ Both functions create a mimebundle for multiple reprs. \code{display} proceeds to publish it using \code{\link{publish_mimebundle}}. \code{prepare_mimebundle} returns it (see \emph{Value} for details) } \examples{ bundle <- prepare_mimebundle(diag(3)) \dontrun{## (Run inside of an IRkernel) display(help(display))} } \seealso{ \code{\link{publish_mimebundle}} } IRdisplay/man/display_-less-than-image-greater-than.Rd0000644000176200001440000000233413277264546022375 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/display_images.r \name{display_} \alias{display_} \alias{display_png} \alias{display_jpeg} \alias{display_pdf} \alias{display_svg} \title{Display a specific image output} \usage{ display_png(data = NULL, file = NULL, width = NULL, height = NULL) display_jpeg(data = NULL, file = NULL, width = NULL, height = NULL) display_pdf(data = NULL, file = NULL, width = NULL, height = NULL) display_svg(data = NULL, file = NULL, width = NULL, height = NULL) } \arguments{ \item{data}{The data as a \code{\link[base]{raw}} vector (\code{\link[base]{character}} vector for \code{display_svg})} \item{file}{The path to a file or a \code{\link[base]{connection}} containing the content} \item{width}{The width to display the image} \item{height}{The height to display the image} } \description{ Either \code{data} or \code{file} must be passed. } \examples{ \dontrun{## (Run inside of an IRkernel) display_png(file = 'image.png') display_svg(' ') display_jpeg(file = url('https://dummyimage.com/600x400.jpg', 'wb'), width = 100)} } \seealso{ \code{\link{display_}} } IRdisplay/LICENSE0000644000176200001440000000011112750101502013141 0ustar liggesusersYEAR: 2014 COPYRIGHT HOLDER: Thomas Kluyver, Philipp Angerer, Jan Schulz