diff --git a/NAMESPACE b/NAMESPACE index 4a09078..05cd196 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,7 @@ S3method(flair_lines,decorated) S3method(flair_lines,default) S3method(flair_rx,decorated) S3method(flair_rx,default) +S3method(knit_print,decorated) S3method(mask_rx,decorated) S3method(mask_rx,default) S3method(print,decorated) @@ -22,7 +23,7 @@ export(flair_input_vals) export(flair_lines) export(flair_quick) export(flair_rx) -export(knit_print.decorated) +export(is.decorated) export(mask) export(mask_quick) export(mask_rx) @@ -42,6 +43,7 @@ export(txt_ul) export(wrap_html) import(stringr) importFrom(glue,glue) +importFrom(knitr,knit_print) importFrom(magrittr,"%>%") importFrom(purrr,map) importFrom(purrr,map2) diff --git a/R/decorated-print.R b/R/decorated-print.R index 389d326..7ecae36 100644 --- a/R/decorated-print.R +++ b/R/decorated-print.R @@ -21,7 +21,9 @@ decorated <- function(x) { #' @return "as-is" html output, to be rendered when knitted #' #' @importFrom purrr map +#' @importFrom knitr knit_print #' +#' @method knit_print decorated #' @export knit_print.decorated <- function(x, ...) { @@ -161,3 +163,12 @@ print.decorated <- function(x, ...) { } + +#' Method check +#' +#' @param x An object +#' +#' @return Whether the object is a \code{decorated} class object. +#' +#' @export +is.decorated <- function(x) inherits(x, "decorated") diff --git a/man/is.decorated.Rd b/man/is.decorated.Rd new file mode 100644 index 0000000..53aa64e --- /dev/null +++ b/man/is.decorated.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/decorated-print.R +\name{is.decorated} +\alias{is.decorated} +\title{Method check} +\usage{ +is.decorated(x) +} +\arguments{ +\item{x}{An object} +} +\value{ +Whether the object is a \code{decorated} class object. +} +\description{ +Method check +} diff --git a/man/knit_print.decorated.Rd b/man/knit_print.decorated.Rd index aa6db52..5852e5b 100644 --- a/man/knit_print.decorated.Rd +++ b/man/knit_print.decorated.Rd @@ -4,7 +4,7 @@ \alias{knit_print.decorated} \title{S3 method for knitting a \code{decorated} object} \usage{ -knit_print.decorated(x, ...) +\method{knit_print}{decorated}(x, ...) } \arguments{ \item{x}{A \code{decorated} object.}