[education/rkward] rkward/rbackend/rpackages/rkward: more fixes to satisfy R CMD check:

m.eik michalke null at kde.org
Wed Sep 13 14:34:15 BST 2023


Git commit 43dd4d8ec211ea1943f72b26a240fce1979e94d4 by m.eik michalke.
Committed on 13/09/2023 at 15:31.
Pushed by meikm into branch 'master'.

more fixes to satisfy R CMD check:

- documented base override functions
- fixed some missing import defintions
- added Cairo package to replace the deprecated cairoDevice package
- fixed typo in htmlwidgets package reference

M  +1    -1    rkward/rbackend/rpackages/rkward/DESCRIPTION
M  +3    -0    rkward/rbackend/rpackages/rkward/NAMESPACE
M  +30   -0    rkward/rbackend/rpackages/rkward/R/base_overrides.R
M  +1    -0    rkward/rbackend/rpackages/rkward/R/internal_debugger.R
M  +10   -6    rkward/rbackend/rpackages/rkward/R/public_graphics.R
M  +1    -1    rkward/rbackend/rpackages/rkward/R/rk.print-functions.R

https://invent.kde.org/education/rkward/-/commit/43dd4d8ec211ea1943f72b26a240fce1979e94d4

diff --git a/rkward/rbackend/rpackages/rkward/DESCRIPTION b/rkward/rbackend/rpackages/rkward/DESCRIPTION
index 4c1522377..bc763f0ad 100755
--- a/rkward/rbackend/rpackages/rkward/DESCRIPTION
+++ b/rkward/rbackend/rpackages/rkward/DESCRIPTION
@@ -8,7 +8,7 @@ Description: This package contains functions which are useful in
 Author: Thomas Friedrichsmeier, RKWard Team
 Maintainer: RKWard-devel mailing list <rkward-devel at kde.org>
 Depends: R (>= 2.9.0),methods
-Suggests: googleVis,htmlwidgets,lattice,R2HTML
+Suggests: Cairo,googleVis,htmlwidgets,lattice,R2HTML
 URL: https://rkward.kde.org
 BugReports: https://rkward.kde.org/Bugs.html
 License: GPL (>= 2)
diff --git a/rkward/rbackend/rpackages/rkward/NAMESPACE b/rkward/rbackend/rpackages/rkward/NAMESPACE
index ac5bfb021..57f00c0df 100644
--- a/rkward/rbackend/rpackages/rkward/NAMESPACE
+++ b/rkward/rbackend/rpackages/rkward/NAMESPACE
@@ -144,6 +144,9 @@ importFrom(utils,compareVersion)
 importFrom(utils,contrib.url)
 importFrom(utils,getCRANmirrors)
 importFrom(utils,getFromNamespace)
+importFrom(utils,getSrcFilename)
+importFrom(utils,getSrcLocation)
+importFrom(utils,getSrcref)
 importFrom(utils,help)
 importFrom(utils,help.search)
 importFrom(utils,installed.packages)
diff --git a/rkward/rbackend/rpackages/rkward/R/base_overrides.R b/rkward/rbackend/rpackages/rkward/R/base_overrides.R
index 790330629..894c96655 100644
--- a/rkward/rbackend/rpackages/rkward/R/base_overrides.R
+++ b/rkward/rbackend/rpackages/rkward/R/base_overrides.R
@@ -3,6 +3,22 @@
 # SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
 # SPDX-License-Identifier: GPL-2.0-or-later
 
+#' Overrides for base functions
+#'
+#' RKWard replaces these functions seamlessly with wrappers that add specific
+#' features, i.e. to integrate well with the GUI:
+#'
+#' \itemize{
+#'   \item{\code{\link[base:require]{require}}}
+#'   \item{\code{\link[base:q]{q/quit}}}
+#'   \item{\code{\link[base:Sys.setlocale]{Sys.setlocale}}}
+#'   \item{\code{\link[base:setwd]{setwd}}}
+#' }
+#'
+#' @param ... additional arguments, see respective base function.
+#' @return See \code{\link[base:require]{require}}, \code{\link[base:q]{q}},
+#'   \code{\link[base:Sys.setlocale]{Sys.setlocale}}, or \code{\link[base:setwd]{setwd}}.
+
 ### this is currently unused and therefore commented out
 ## override makeActiveBinding: If active bindings are created in globalenv (), watch them properly
 ## Ideally this would not be needed, but there seems to be no user-accessible way to copy unevaluated active bindings.
@@ -21,7 +37,11 @@
 #}
 
 
+#' @param package see \code{\link[base:require]{require}}
+#' @param quietly see \code{\link[base:require]{require}}
+#' @param character.only see \code{\link[base:require]{require}}
 #' @export
+#' @rdname base_overrides
 "require" <- function (package, quietly = FALSE, character.only = FALSE, ...)
 {
 	if (!character.only) {
@@ -40,7 +60,11 @@
 
 
 # overriding q, to ask via GUI instead. Arguments are not interpreted.
+#' @param save see \code{\link[base:q]{q}}
+#' @param status see \code{\link[base:q]{q}}
+#' @param runLast see \code{\link[base:q]{q}}
 #' @export
+#' @rdname base_overrides
 "q" <- function (save = "default", status = 0, runLast = TRUE, ...) {
 	# test if this is running in RKWard, otherwise pass through to the actual q()
 	if (isTRUE(.rk.inside.rkward.session())){
@@ -52,12 +76,16 @@
 
 
 #' @export
+#' @rdname base_overrides
 "quit" <- function (save = "default", status = 0, runLast = TRUE, ...) {
 	q (save, status, runLast, ...)
 }
 
 
+#' @param category see \code{\link[base:Sys.setlocale]{Sys.setlocale}}
+#' @param locale see \code{\link[base:Sys.setlocale]{Sys.setlocale}}
 #' @export
+#' @rdname base_overrides
 "Sys.setlocale" <- function (category = "LC_ALL", locale = "", ...) {
 	if (category == "LC_ALL" || category == "LC_CTYPE" || category == "LANG") {
 		 .rk.do.plain.call ("preLocaleChange", NULL)
@@ -72,7 +100,9 @@
 }
 
 
+#' @param dir see \code{\link[base:setwd]{setwd}}
 #' @export
+#' @rdname base_overrides
 "setwd" <- function () {
 	ret <- eval (body (base::setwd))
 	.rk.do.plain.call ("wdChange", base::getwd (), synchronous=FALSE)
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_debugger.R b/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
index 49ce331c0..3a2276cd5 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
@@ -28,6 +28,7 @@
 
 # get relative source location
 # NOTE: this requires R >= 2.13.0
+#' @importFrom utils getSrcref getSrcFilename getSrcLocation
 #' @export
 rk.relative.src.line <- function (inner, outer) {
 	if (!inherits (inner, "srcref")) inner <- getSrcref (inner)
diff --git a/rkward/rbackend/rpackages/rkward/R/public_graphics.R b/rkward/rbackend/rpackages/rkward/R/public_graphics.R
index c71ba26df..cf2130adf 100644
--- a/rkward/rbackend/rpackages/rkward/R/public_graphics.R
+++ b/rkward/rbackend/rpackages/rkward/R/public_graphics.R
@@ -81,11 +81,15 @@
 			"\" height=\"", height, "\"><br>", sep = ""))
 	} else if (device.type == "SVG") {
 		if (!capabilities ("cairo")) {	# cairo support is not always compiled in
-			requireNamespace ("cairoDevice")
-			svg <- Cairo_svg
+			# requireNamespace ("cairoDevice")
+			# svg <- Cairo_svg
+			requireNamespace ("Cairo")
+			svg <- Cairo::CairoSVG
 		}
 		filename <- rk.get.tempfile.name(prefix = "graph", extension = ".svg")
-		ret <- svg(filename = file.path(filename), ...)
+		# ret <- svg(filename = file.path(filename), ...)
+		# CairoSVG() uses "file" as first argument, grDevices uses "filename" in svg()
+		ret <- svg(file.path(filename), ...)
 		.rk.cat.output(paste("<object data=\"", make.url (names (filename)), "\" type=\"image/svg+xml\" width=\"", width,
 			"\" height=\"", height, "\">\n", sep = ""))
 		.rk.cat.output(paste("<param name=\"src\" value=\"", make.url (names (filename)), "\">\n", sep = ""))
@@ -211,15 +215,15 @@
 				if (missing (height)) height <- getOption ("rk.screendevice.height")
 				if (!is.numeric (height)) height <- 7
 				# rk.embed.device (eval (body (grDevices::devicename)))
-				rk.embed.device (eval (body (getFromNamespace (devicename, ns="grDevices"))))
+				rkward::rk.embed.device (eval (body (utils::getFromNamespace (devicename, ns="grDevices"))))
 			} else {
 				# eval (body (grDevices::devicename))
-				eval (body (getFromNamespace (devicename, ns="grDevices")))
+				eval (body (utils::getFromNamespace (devicename, ns="grDevices")))
 			}
 		}
 	))
 	if (exists (devicename, envir=asNamespace ("grDevices"), inherits=FALSE)) {
-		devfun <- getFromNamespace (devicename, ns="grDevices")
+		devfun <- utils::getFromNamespace (devicename, ns="grDevices")
 		formals (ret) <- formals (devfun)
 		environment (ret) <- environment (devfun)
 	}
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
index e83f46ffd..c0b8f079f 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
@@ -101,7 +101,7 @@
 		name <- deparse (substitute (x))
 		filename <- rk.get.tempfile.name (name, ".html")
 		dir <- rk.get.tempfile.name (name, "_data")
-		htmlwidget::saveWidget (x, filename, selfcontained=FALSE, libdir=dir)
+		htmlwidgets::saveWidget (x, filename, selfcontained=FALSE, libdir=dir)
 		.rk.cat.output (paste0 ("<object width=\"100%\" height=\"100%\" data=\"file://", filename, "\" onload=\"this.style.height = this.contentWindow.document.body.scrollHeight + 'px';\"></object>"))
 	} else if (inherits (x, "gvis")) {
 		requireNamespace ("googleVis", quietly = TRUE)


More information about the rkward-tracker mailing list