From 5f8e8e33b14678414daddeb72fbc366e2114cb97 Mon Sep 17 00:00:00 2001 From: Artem Klevtsov Date: Fri, 12 Jul 2019 07:55:40 +0700 Subject: [PATCH] Move htmlwidgets to suggests (closes #18) --- DESCRIPTION | 19 +++++++++++++------ R/widget.R | 10 +++++++--- R/zzz.R | 1 - 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b6f8bc3..b1c0a95 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,13 +22,20 @@ License: BSD_3_clause + file LICENSE LazyData: TRUE Depends: R (>= 3.3) Imports: - Rcpp (>= 0.12.2), stringi, RcppParallel, - htmlwidgets (>= 0.6), -LinkingTo: Rcpp, RcppParallel + Rcpp (>= 0.12.2), + stringi, + RcppParallel +LinkingTo: + Rcpp, + RcppParallel Suggests: - knitr (>= 1.12.3),testthat, - rmarkdown (>= 0.9.5),microbenchmark, - ggplot2, directlabels + htmlwidgets (>= 0.6), + knitr (>= 1.12.3), + testthat, + rmarkdown (>= 0.9.5), + microbenchmark, + ggplot2, + directlabels URL: https://github.com/qinwf/re2r/ BugReports: https://github.com/qinwf/re2r/issues VignetteBuilder: knitr diff --git a/R/widget.R b/R/widget.R index 4175c47..ed3979d 100644 --- a/R/widget.R +++ b/R/widget.R @@ -34,11 +34,15 @@ remove_named = function(string){ #' @export show_regex <- function(pattern, width = NULL, height = NULL) { - if (is.character(pattern)){ + if (!requireNamespace("htmlwidgets", quietly = TRUE)) { + stop("'htmlwidgets' package is not installed.") + } + + if (is.character(pattern)) { res = re2(pattern) - }else if (inherits(pattern,"re2c")) { + } else if (inherits(pattern,"re2c")) { res = pattern - } else if (is.list(pattern)){ + } else if (is.list(pattern)) { return(show_regex(pattern[[1]], width, height)) } else { stop("pattern is a string or a pre-compiled regular expression.") diff --git a/R/zzz.R b/R/zzz.R index 1c574bf..d26f5a8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -32,7 +32,6 @@ ##' @useDynLib re2r ##' @import Rcpp -##' @import htmlwidgets ##' @importFrom stringi stri_enc_toutf8 ##' @importFrom RcppParallel RcppParallelLibs NULL