Skip to content

Commit

Permalink
Added examples and a few doc links
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jul 29, 2016
1 parent 21a60df commit 9a89444
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 6 deletions.
19 changes: 17 additions & 2 deletions R/display.r
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#' Display data by mimetype, with optional alternative representations.
#'
#' Calls the function stored as option value of \code{jupyter.base_display_func}.
#' 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' = '<h1>Hi!</h1>'))
#' publish_mimebundle(
#' list('image/svg+xml' = '<svg xmlns="http://www.w3.org/2000/svg"><circle r="100"/></svg>'),
#' list('image/svg+xml' = list(width = 100, height = 100)))}
#'
#' @export
publish_mimebundle <- function(data, metadata = NULL) {
getOption('jupyter.base_display_func')(data, metadata)
Expand All @@ -18,13 +25,21 @@ publish_mimebundle <- function(data, metadata = NULL) {
#' \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
#' @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
#' dev.new(); plot(sqrt); p <- recordPlot(); dev.off()
#' bundle <- prepare_mimebundle(p)
#'
#' \dontrun{## (Run inside of an IRkernel)
#' display(help(display))}
#'
#' @name display
#' @export
display <- function(obj) {
Expand Down
10 changes: 10 additions & 0 deletions R/display_images.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#' @param height The height to display the image
#'
#' @seealso \code{\link{display_<text>}}
#'
#' @examples \dontrun{## (Run inside of an IRkernel)
#' display_png(file = 'image.png')
#' display_svg('
#' <svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 2 2">
#' <circle r="1"/>
#' </svg>
#' ')
#' display_jpeg(file = url('http://example.com/example.jpg'), width = 100)}
#'
#' @name display_<image>
NULL

Expand Down
6 changes: 6 additions & 0 deletions R/display_textual.r
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#' @param file The path to a file or a \code{\link[base]{connection}} containing the content
#'
#' @seealso \code{\link{display_<image>}}
#'
#' @examples \dontrun{## (Run inside of an IRkernel)
#' display_text('Just text')
#' display_markdown('[MD](http://commonmark.org) *formatted*')
#' display_javascript('execute(this)')}
#'
#' @name display_<text>
NULL

Expand Down
2 changes: 1 addition & 1 deletion R/options.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' IRdisplay options
#'
#' Options to control the formats \code{\link{display}} and \code{\link{prepare_mimebundle}} emit,
#' 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:
Expand Down
2 changes: 1 addition & 1 deletion man/IRdisplay-options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/display.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/display_-less-than-image-greater-than.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions man/display_-less-than-text-greater-than.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/publish_mimebundle.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a89444

Please sign in to comment.