[education/rkward/devel/workspace_output] /: Mock up cleaner interface for output directoriess.

Thomas Friedrichsmeier null at kde.org
Sat Oct 10 09:18:45 BST 2020


Git commit 327211f0bf35fa78fa3caceff32cf09aabf11272 by Thomas Friedrichsmeier.
Committed on 10/10/2020 at 08:17.
Pushed by tfry into branch 'devel/workspace_output'.

Mock up cleaner interface for output directoriess.

Also: Roxygenize and move to a different branch name to re-instate regular commit hooks.

M  +1    -1    rkward/rbackend/rpackages/rkward/DESCRIPTION
M  +4    -2    rkward/rbackend/rpackages/rkward/NAMESPACE
M  +51   -0    rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
M  +26   -24   rkward/rbackend/rpackages/rkward/man/rk.get.tempfile.name.Rd
M  +2    -2    scripts/roxygenize.sh

https://invent.kde.org/education/rkward/commit/327211f0bf35fa78fa3caceff32cf09aabf11272

diff --git a/rkward/rbackend/rpackages/rkward/DESCRIPTION b/rkward/rbackend/rpackages/rkward/DESCRIPTION
index 5798feac..b106db1c 100755
--- a/rkward/rbackend/rpackages/rkward/DESCRIPTION
+++ b/rkward/rbackend/rpackages/rkward/DESCRIPTION
@@ -19,7 +19,7 @@ Authors at R: c(person(given="Thomas", family="Friedrichsmeier",
         email="rkward-devel at kde.org", role=c("cre","ctb")))
 Version: 0.7.2
 Date: 2020-10-06
-RoxygenNote: 7.1.0
+RoxygenNote: 7.1.1
 Collate: 
     'base_overrides.R'
     'internal.R'
diff --git a/rkward/rbackend/rpackages/rkward/NAMESPACE b/rkward/rbackend/rpackages/rkward/NAMESPACE
index c0f89d43..8a1d79b9 100644
--- a/rkward/rbackend/rpackages/rkward/NAMESPACE
+++ b/rkward/rbackend/rpackages/rkward/NAMESPACE
@@ -62,8 +62,8 @@ export(rk.duplicate.device)
 export(rk.edit)
 export(rk.edit.files)
 export(rk.embed.device)
-export(rk.export.output.dir)
 export(rk.end.capture.output)
+export(rk.export.output.dir)
 export(rk.first.plot)
 export(rk.flush.output)
 export(rk.force.append.plot)
@@ -78,8 +78,8 @@ export(rk.goto.plot)
 export(rk.graph.off)
 export(rk.graph.on)
 export(rk.header)
-export(rk.import.output.dir)
 export(rk.home)
+export(rk.import.output.dir)
 export(rk.last.plot)
 export(rk.list)
 export(rk.list.labels)
@@ -127,3 +127,5 @@ export(setwd)
 export(win.graph)
 export(windows)
 export(x11)
+exportClasses(RK.Output)
+import(methods)
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
index fe7d5e8a..f519c204 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
@@ -269,7 +269,58 @@
 	rk.set.output.html.file (x, ...)
 }
 
+
 ## TODO move the following functions (and some others to a dedicated file/help page)
+
+#' A Reference Class to represent an RKWard Output directory.
+#' @name RK.Output
+#' @description Reference class to represent an RKWard Output directory.
+#' \code{activate} Set this output directory as the one where output will be appended.
+#' @param index if specified: Write to a specific HTML file within the output directory, instead of the default.
+#' @returns NULL
+#' @import methods
+#' @exportClass RK.Output
+"RK.Output"<-setRefClass(Class="RK.Output",
+	fields=list(id="character"),
+	methods=list(
+		activate=function() {
+			.rk.do.call("output", c ("activate", id))
+		},
+		isEmpty=function() {
+			isTRUE(.rk.do.call("output", c ("isEmpty", id)))
+		},
+		isModified=function() {
+			isTRUE(.rk.do.call("output", c ("isModified", id)))
+		},
+		load=function(url, overwrite=FALSE, ask=FALSE) {
+			if (missing(url)) stop("No url specified")
+			.rk.do.call("output", c ("load", id, url, isTRUE(overwrite), isTRUE(ask)))
+		},
+		save=function(url, overwrite=FALSE, ask=FALSE) {
+			.rk.do.call("output", c ("save", id, url, isTRUE(overwrite), isTRUE(ask)))
+		},
+		export=function(url, overwrite=FALSE, ask=FALSE) {
+			if (missing(url)) stop("No url specified")
+			.rk.do.call("output", c ("export", id, url, isTRUE(overwrite), isTRUE(ask)))
+		},
+		clear=function(ask=TRUE) {
+			.rk.do.call("output", c ("clear", id, isTRUE(ask)))
+		},
+		close=function(discard=FALSE, ask=FALSE) {
+			.rk.do.call("output", c ("close", isTRUE(discard), isTRUE(ask)))
+		},
+		view=function(raise=TRUE) {
+			.rk.do.call("output", c ("view", isTRUE(raise)))
+		},
+		.workingDir=function() {
+			.rk.do.call("output", c ("workingDir"))
+		},
+		.targetDir=function() {
+			.rk.do.call("output", c ("targetDir"))
+		}
+	))
+
+
 # 
 # .rk.purge.target.dir (target, ask) {
 # 	if (dir.exists (target)) {
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.get.tempfile.name.Rd b/rkward/rbackend/rpackages/rkward/man/rk.get.tempfile.name.Rd
index 78b7e0a3..743d3e52 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.get.tempfile.name.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.get.tempfile.name.Rd
@@ -1,20 +1,23 @@
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/rk.filename-functions.R
 \name{rk.get.tempfile.name}
-\alias{rk.create.output.dir}
-\alias{rk.export.output.dir}
-\alias{rk.flush.output}
-\alias{rk.get.output.html.file}
 \alias{rk.get.tempfile.name}
 \alias{rk.get.workspace.url}
-\alias{rk.import.output.dir}
+\alias{rk.get.output.html.file}
 \alias{rk.set.output.html.file}
 \alias{rk.tempdir}
 \alias{rk.home}
+\alias{rk.flush.output}
+\alias{rk.export.output.dir}
+\alias{rk.import.output.dir}
+\alias{rk.create.output.dir}
 \title{RKWard file names}
 \usage{
-rk.get.tempfile.name(prefix = "image", extension = ".jpg",
-  directory = dirname(rk.get.output.html.file()))
+rk.get.tempfile.name(
+  prefix = "image",
+  extension = ".jpg",
+  directory = dirname(rk.get.output.html.file())
+)
 
 rk.get.workspace.url()
 
@@ -25,19 +28,6 @@ rk.get.output.html.file()
 rk.set.output.html.file(
   x,
   additional.header.contents = getOption("rk.html.header.additions"),
-<<<<<<< HEAD
-  style = c("regular", "preview"), css = getOption("rk.output.css.file"))
-
-rk.flush.output(x = rk.get.output.html.file(), flush.images = TRUE,
-  ask = TRUE, ...)
-
-rk.export.output.dir(source.dir = basename(rk.get.output.html.file()),
-  target.dir, ask = TRUE)
-
-rk.import.output.dir(source.dir, activate = "index.html", ask = TRUE)
-
-rk.create.output.dir()
-=======
   style = c("regular", "preview"),
   css = getOption("rk.output.css.file"),
   silent = FALSE
@@ -49,7 +39,21 @@ rk.flush.output(
   ask = TRUE,
   ...
 )
->>>>>>> master
+
+rk.export.output.dir(
+  source.dir = basename(rk.get.output.html.file()),
+  target.dir,
+  ask = TRUE
+)
+
+rk.import.output.dir(
+  source.dir,
+  activate = "index.html",
+  mode = c("ask", "integrate", "keep.separate"),
+  ask = TRUE
+)
+
+rk.create.output.dir()
 }
 \arguments{
 \item{prefix}{a string, used as a filename prefix when saving images to the
@@ -60,14 +64,12 @@ are kept as is.}
 \item{extension}{a string, used as a filename extension when saving images
 to the output file}
 
-<<<<<<< HEAD
 \item{directory}{a string, The base directory for the file. If left empty, this will default to the
 write directory of the current output file (usually "~.rkward)}
-=======
+
 \item{component}{a string specifying the desired path. "home" (the default value) means to
 return the generic data dir used by RKWard. "lib" means to return the directory where
 the rkward R library is installed.}
->>>>>>> master
 
 \item{x}{a string, giving the filename of the of the output file}
 
diff --git a/scripts/roxygenize.sh b/scripts/roxygenize.sh
index 88987a4a..7366435d 100755
--- a/scripts/roxygenize.sh
+++ b/scripts/roxygenize.sh
@@ -29,8 +29,8 @@ echo "
 	library (roxygen2)
 	packages <- c ($PACKAGES)
 	for (package in packages) {
-#		dummy <- roxygen2:::source_package (package) # See https://github.com/klutometis/roxygen/issues/167
-		roxygenize (package)
+		#dummy <- roxygen2:::source_package (package) # See https://github.com/klutometis/roxygen/issues/167
+		roxygenize (package, load_code=load_source)
 		possibly_empty_dirs <- paste (package, c ('inst/doc', 'inst'), sep='/')
 		for (dir in possibly_empty_dirs) {
 			if (file.exists (dir)) suppressWarnings (try (file.remove (dir)))




More information about the rkward-tracker mailing list