diff --git a/R/print.R b/R/print.R index b899ecdf..23810027 100644 --- a/R/print.R +++ b/R/print.R @@ -37,10 +37,17 @@ knit_print.tinytable <- function(x, } -#' Print a tinytable to console or viewer pane +#' Print a tinytable to console or in an HTML viewer pane +#' +#' This function is called automatically by `R` whenever a `tinytable` object is anprinted to the console or in an HTML viewer pane. #' #' @inheritParams tt -#' @param output One of "latex", "markdown", "html". If NULL, will guess the output based on the environment (interactive, RStudio, etc.). +#' @param output format in which a Tiny Table is printed: `NULL` or one of `"latex"`, `"markdown"`, `"html"`, `"typst"`. If `NULL`, the output is chosen based on these rules: +#' + When called from a script in non-interactive mode, the default is "markdown" (`interactive() == FALSE`). +#' + When called interactively in RStudio, the default is to display an HTML table in the viewer pane. +#' + When called interactively in another development environment, the default is "markdown". +#' + The default print output can be changed for an entire R session by calling: `options(tinytable_print_output = "html")` +#' + The default print output can be changed for a single `tinytable` object by modifying the `output` element of the meta data attribute: `attr(x,"tinytable_meta")` #' @param ... Other arguments are ignored. #' @return launch a browser window or cat() the table to console. #' @export @@ -88,6 +95,6 @@ print.tinytable <- function(x, stop("here be dragons") } - + return(invisible(x)) } diff --git a/altdoc/quarto_website.yml b/altdoc/quarto_website.yml index 37aeb725..db420bef 100644 --- a/altdoc/quarto_website.yml +++ b/altdoc/quarto_website.yml @@ -42,6 +42,8 @@ website: file: man/group_tt.qmd - text: "`plot_tt`" file: man/plot_tt.qmd + - text: "`print`" + file: man/print.tyinytable.qmd - text: "`save_tt`" file: man/save_tt.qmd - text: News diff --git a/man/print.tinytable.Rd b/man/print.tinytable.Rd index a36d0616..f490dde3 100644 --- a/man/print.tinytable.Rd +++ b/man/print.tinytable.Rd @@ -2,14 +2,21 @@ % Please edit documentation in R/print.R \name{print.tinytable} \alias{print.tinytable} -\title{Print a tinytable to console or viewer pane} +\title{Print a tinytable to console or in an HTML viewer pane} \usage{ \method{print}{tinytable}(x, output = getOption("tinytable_print_output", default = NULL), ...) } \arguments{ \item{x}{A data frame or data table to be rendered as a table.} -\item{output}{One of "latex", "markdown", "html". If NULL, will guess the output based on the environment (interactive, RStudio, etc.).} +\item{output}{format in which a Tiny Table is printed: \code{NULL} or one of \code{"latex"}, \code{"markdown"}, \code{"html"}, \code{"typst"}. If \code{NULL}, the output is chosen based on these rules: +\itemize{ +\item When called from a script in non-interactive mode, the default is "markdown" (\code{interactive() == FALSE}). +\item When called interactively in RStudio, the default is to display an HTML table in the viewer pane. +\item When called interactively in another development environment, the default is "markdown". +\item The default print output can be changed for an entire R session by calling: \code{options(tinytable_print_output = "html")} +\item The default print output can be changed for a single \code{tinytable} object by modifying the \code{output} element of the meta data attribute: \code{attr(x,"tinytable_meta")} +}} \item{...}{Other arguments are ignored.} } @@ -17,5 +24,5 @@ launch a browser window or cat() the table to console. } \description{ -Print a tinytable to console or viewer pane +This function is called automatically by \code{R} whenever a \code{tinytable} object is anprinted to the console or in an HTML viewer pane. }