Skip to content

Commit

Permalink
Use roxygen2 markdown links to fix new r-devel warning 'Non-file pack…
Browse files Browse the repository at this point in the history
…age-anchored link(s) in documentation object'

Note this leverages r-lib/roxygen2@fix/link-to-file
  • Loading branch information
cpsievert committed Jun 13, 2020
1 parent 4ebfa82 commit f7c6e45
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 54 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Enhances: knitr
License: GPL (>= 2)
URL: https://github.com/rstudio/htmltools
BugReports: https://github.com/rstudio/htmltools/issues
RoxygenNote: 7.1.0
RoxygenNote: 7.1.0.9000
Encoding: UTF-8
Collate:
'colors.R'
Expand Down
60 changes: 29 additions & 31 deletions R/images.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
#'
#' @param expr A plotting expression that generates a plot (or yields an object
#' that generates a plot when printed, like a ggplot2). We evaluate this
#' expression after activating the graphics device (\code{device}).
#' @param filename The output filename. By default, a temp file with \code{.png}
#' expression after activating the graphics device (`device`).
#' @param filename The output filename. By default, a temp file with `.png`
#' extension will be used; you should provide a filename with a different
#' extension if you provide a non-PNG graphics device function.
#' @param device A graphics device function; by default, this will be either
#' \code{\link[grDevices:png]{grDevices::png()}},
#' \code{\link[ragg:agg_png]{ragg::agg_png()}}, or
#' \code{\link[Cairo:CairoPNG]{Cairo::CairoPNG()}}, depending on
#' your system and configuration. See \code{\link{defaultPngDevice}}.
#' @param width,height,res,... Additional arguments to the \code{device} function.
#' [grDevices::png()], [ragg::agg_png()], or [Cairo::CairoPNG()], depending on
#' your system and configuration. See [defaultPngDevice()].
#' @param width,height,res,... Additional arguments to the `device` function.
#'
#' @seealso \code{\link{plotTag}} saves plots as a self-contained \code{<img>}
#' @seealso [plotTag()] saves plots as a self-contained `<img>`
#' tag.
#'
#' @md
#' @examples
#'
#' # Default settings
Expand Down Expand Up @@ -98,43 +97,41 @@ capturePlot <- function(expr, filename = tempfile(fileext = ".png"),
})
}

#' Capture a plot as a self-contained \code{<img>} tag
#' Capture a plot as a self-contained `<img>` tag
#'
#' @param expr A plotting expression that generates a plot (or yields an object
#' that generates a plot when printed, like a ggplot2).
#' @param alt A single-element character vector that contains a text description
#' of the image. This is used by accessibility tools, such as screen readers
#' for vision impaired users.
#' @param device A graphics device function; by default, this will be either
#' \code{\link[grDevices:png]{grDevices::png()}},
#' \code{\link[ragg:agg_png]{ragg::agg_png()}}, or
#' \code{\link[Cairo:CairoPNG]{Cairo::CairoPNG()}}, depending on your system
#' and configuration. See \code{\link{defaultPngDevice}}.
#' [grDevices::png()], [ragg::agg_png()], or [Cairo::CairoPNG()], depending on
#' your system and configuration. See [defaultPngDevice()].
#' @param width,height The width/height that the generated tag should be
#' displayed at, in logical (browser) pixels.
#' @param pixelratio Indicates the ratio between physical and logical units of
#' length. For PNGs that may be displayed on high-DPI screens, use \code{2};
#' length. For PNGs that may be displayed on high-DPI screens, use `2`;
#' for graphics devices that express width/height in inches (like
#' \code{\link[grDevices:svg]{grDevices::svg()}}), try \code{1/72} or
#' \code{1/96}.
#' @param mimeType The MIME type associated with the \code{device}. Examples are
#' \code{image/png}, \code{image/tiff}, \code{image/svg+xml}.
#' [grDevices::svg()], try `1/72` or `1/96`.
#' @param mimeType The MIME type associated with the `device`. Examples are
#' `image/png`, `image/tiff`, `image/svg+xml`.
#' @param deviceArgs A list of additional arguments that should be included when
#' the \code{device} function is invoked.
#' the `device` function is invoked.
#' @param attribs A list of additional attributes that should be included on the
#' generated \code{<img>} (e.g. \code{id}, \code{class}).
#' @param suppressSize By default, \code{plotTag} will include a \code{style}
#' attribute with \code{width} and \code{height} properties specified in
#' generated `<img>` (e.g. `id`, `class`).
#' @param suppressSize By default, `plotTag` will include a `style`
#' attribute with `width` and `height` properties specified in
#' pixels. If you'd rather specify the image size using other methods (like
#' responsive CSS rules) you can use this argument to suppress width
#' (\code{"x"}), height (\code{"y"}), or both (\code{"xy"}) properties.
#' (`"x"`), height (`"y"`), or both (`"xy"`) properties.
#'
#' @return A \code{\link{browsable}} HTML \code{<img>} tag object. Print it at
#' the console to preview, or call \code{\link{as.character}} on it to view the HTML
#' @return A [browsable()] HTML `<img>` tag object. Print it at
#' the console to preview, or call [as.character()] on it to view the HTML
#' source.
#'
#' @seealso \code{\link{capturePlot}} saves plots as an image file.
#' @seealso [capturePlot()] saves plots as an image file.
#'
#' @md
#' @examples
#'
#' img <- plotTag({
Expand Down Expand Up @@ -183,15 +180,16 @@ plotTag <- function(expr, alt, device = defaultPngDevice(), width = 400, height
#' Determine the best PNG device for your system
#'
#' Returns the best PNG-based graphics device for your system, in the opinion of
#' the \code{htmltools} maintainers. On Mac,
#' \code{\link[grDevices:png]{grDevices::png()}} is used; on all other
#' platforms, either \code{\link[ragg:agg_png]{ragg::agg_png()}} or
#' \code{\link[Cairo:CairoPNG]{Cairo::CairoPNG()}} are used if their packages
#' are installed. Otherwise, \code{\link[grDevices:png]{grDevices::png()}} is
#' the `htmltools` maintainers. On Mac,
#' [grDevices::png()] is used; on all other
#' platforms, either [ragg::agg_png()] or
#' [Cairo::CairoPNG()] are used if their packages
#' are installed. Otherwise, [grDevices::png()] is
#' used.
#'
#' @return A graphics device function.
#'
#' @md
#' @export
defaultPngDevice <- function() {
if (capabilities("aqua")) {
Expand Down
2 changes: 1 addition & 1 deletion R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ flattenTags <- function(x) {
#'
#' An S3 method for converting arbitrary values to a value that can be used as
#' the child of a tag or \code{tagList}. The default implementation simply calls
#' \code{\link[base]{as.character}}.
#' \code{\link{as.character}}.
#'
#' @param x Object to be converted.
#' @param ... Any additional parameters.
Expand Down
2 changes: 1 addition & 1 deletion man/as.tags.Rd

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

10 changes: 4 additions & 6 deletions man/capturePlot.Rd

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

2 changes: 1 addition & 1 deletion man/defaultPngDevice.Rd

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

23 changes: 10 additions & 13 deletions man/plotTag.Rd

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

0 comments on commit f7c6e45

Please sign in to comment.