Skip to content

Commit

Permalink
Un-export knit_print methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Aug 23, 2018
1 parent 3aee819 commit 455c6f2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Package: htmltools
Type: Package
Title: Tools for HTML
Version: 0.3.6.9001
Date: 2017-04-26
Version: 0.3.6.9002
Author: RStudio, Inc.
Maintainer: Joe Cheng <joe@rstudio.com>
Description: Tools for HTML generation and output.
Expand All @@ -19,5 +18,5 @@ Enhances: knitr
License: GPL (>= 2)
URL: https://github.com/rstudio/htmltools
BugReports: https://github.com/rstudio/htmltools/issues
RoxygenNote: 6.0.1.9000
RoxygenNote: 6.1.0
LinkingTo: Rcpp
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export(includeScript)
export(includeText)
export(is.browsable)
export(is.singleton)
export(knit_print.html)
export(knit_print.shiny.tag)
export(knit_print.shiny.tag.list)
export(makeDependencyRelative)
export(p)
export(pre)
Expand Down
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
htmltools 0.3.6.9001
htmltools 0.3.6.9002
--------------------------------------------------------------------------------

* The `knit_print` methods are no longer exported; they are registered as S3
methods when both knitr and htmltools are loaded. (#108)

* Updated RcppExports for new version of Rcpp. (#93)

* `as.character.shiny.tags()` will handle non-ASCII attributes correctly if they
Expand Down
3 changes: 0 additions & 3 deletions R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,6 @@ restorePreserveChunks <- function(strval, chunks) {
NULL

#' @rdname knitr_methods
#' @export
knit_print.shiny.tag <- function(x, ...) {
x <- tagify(x)
output <- surroundSingletons(x)
Expand All @@ -1202,15 +1201,13 @@ knit_print.shiny.tag <- function(x, ...) {
}

#' @rdname knitr_methods
#' @export
knit_print.html <- function(x, ...) {
deps <- resolveDependencies(findDependencies(x, tagify = FALSE))
knitr::asis_output(htmlPreserve(as.character(x)),
meta = if (length(deps)) list(deps))
}

#' @rdname knitr_methods
#' @export
knit_print.shiny.tag.list <- knit_print.shiny.tag


Expand Down
30 changes: 30 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
register_s3_method <- function(pkg, generic, class, fun = NULL) {
stopifnot(is.character(pkg), length(pkg) == 1)
stopifnot(is.character(generic), length(generic) == 1)
stopifnot(is.character(class), length(class) == 1)

if (is.null(fun)) {
fun <- get(paste0(generic, ".", class), envir = parent.frame())
} else {
stopifnot(is.function(fun))
}

if (pkg %in% loadedNamespaces()) {
registerS3method(generic, class, fun, envir = asNamespace(pkg))
}

# Always register hook in case package is later unloaded & reloaded
setHook(
packageEvent(pkg, "onLoad"),
function(...) {
registerS3method(generic, class, fun, envir = asNamespace(pkg))
}
)
}


.onLoad <- function(...) {
register_s3_method("knitr", "knit_print", "shiny.tag")
register_s3_method("knitr", "knit_print", "html")
register_s3_method("knitr", "knit_print", "shiny.tag.list")
}

0 comments on commit 455c6f2

Please sign in to comment.