[rkward] packages/rkwarddev: added the same "opt.sep" feature to JS option objects

m.eik michalke meik.michalke at uni-duesseldorf.de
Sat Jun 27 21:45:12 UTC 2015


Git commit 5ffad1a85ffd8a83458742ec2e4fa286abfc5177 by m.eik michalke.
Committed on 27/06/2015 at 21:44.
Pushed by meikm into branch 'master'.

added the same "opt.sep" feature to JS option objects

M  +1    -1    packages/rkwarddev/R/00_class_01_rk.JS.arr.R
M  +5    -2    packages/rkwarddev/R/00_class_04_rk.JS.opt.R
M  +9    -2    packages/rkwarddev/R/rk-internal.R
M  +5    -2    packages/rkwarddev/R/rk.JS.options.R
M  +4    -2    packages/rkwarddev/R/rk.paste.JS.R
M  +-    --    packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
M  +3    -0    packages/rkwarddev/man/rk.JS.opt-class.Rd
M  +4    -1    packages/rkwarddev/man/rk.JS.options.Rd
M  +3    -2    packages/rkwarddev/man/rk.paste.JS.Rd

http://commits.kde.org/rkward/5ffad1a85ffd8a83458742ec2e4fa286abfc5177

diff --git a/packages/rkwarddev/R/00_class_01_rk.JS.arr.R b/packages/rkwarddev/R/00_class_01_rk.JS.arr.R
index ac9238d..8a2b90f 100644
--- a/packages/rkwarddev/R/00_class_01_rk.JS.arr.R
+++ b/packages/rkwarddev/R/00_class_01_rk.JS.arr.R
@@ -52,6 +52,6 @@ setClass("rk.JS.arr",
     funct="c",
     quote=FALSE,
     option=character(),
-    option=", "
+    opt.sep=", "
   )
 )
diff --git a/packages/rkwarddev/R/00_class_04_rk.JS.opt.R b/packages/rkwarddev/R/00_class_04_rk.JS.opt.R
index 1436dd7..3d7e9c9 100644
--- a/packages/rkwarddev/R/00_class_04_rk.JS.opt.R
+++ b/packages/rkwarddev/R/00_class_04_rk.JS.opt.R
@@ -28,6 +28,7 @@
 #' @slot ifs A list with objects of class rk.JS.ite.
 #' @slot array Logical, whether to use an array for options.
 #' @slot funct Character string, name of the R function to be called to combine the options.
+#' @slot opt.sep Character string, separates previous options from the one defined here.
 #' @keywords Classes
 #' @rdname rk.JS.opt-class
 #' @export
@@ -39,7 +40,8 @@ setClass("rk.JS.opt",
     collapse="character",
     ifs="list",
     array="logical",
-    funct="character"
+    funct="character",
+    opt.sep="character"
   ),
   prototype(
     var.name=character(),
@@ -47,7 +49,8 @@ setClass("rk.JS.opt",
     collapse=character(),
     ifs=list(),
     array=NULL,
-    funct=character()
+    funct=character(),
+    opt.sep=", "
   )
 )
 
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 5dc3489..1e89044 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -917,7 +917,8 @@ paste.JS.array <- function(object, level=2, indent.by="\t", funct=NULL, opt.sep=
 
 
 ## function paste.JS.options()
-paste.JS.options <- function(object, level=2, indent.by="\t", array=NULL, funct=NULL){
+# opt.sep: the separator that comes *before* the option that is set, in the resulting code
+paste.JS.options <- function(object, level=2, indent.by="\t", array=NULL, funct=NULL, opt.sep=NULL){
   stopifnot(inherits(object, "rk.JS.opt"))
   # check indentation
   main.indent <- indent(level, by=indent.by)
@@ -941,6 +942,12 @@ paste.JS.options <- function(object, level=2, indent.by="\t", array=NULL, funct=
     funct.start <- paste0(funct, "(")
     funct.end <- ")"
   }
+  if(is.null(opt.sep)){
+    opt.sep <- slot(object, "opt.sep")
+    if(is.null(opt.sep)){
+      opt.sep <- ", "
+    } else {}
+  } else {}
 
   # a function to add the object stuff to ite objects
   add.opts <- function(this.ite, collapse, array){
@@ -993,7 +1000,7 @@ paste.JS.options <- function(object, level=2, indent.by="\t", array=NULL, funct=
         main.indent, arr.name, " = ", arr.name, ".filter(String);\n",
         main.indent, "// set the actual variable ", variable, " with all values for R option \"", option, "\"\n",
         main.indent, "if(", arr.name, ".length > 0) {\n",
-        scnd.indent, "var ", variable, " = \"", collapse,
+        scnd.indent, "var ", variable, " = \"", opt.sep,
         ifelse(identical(option, ""), "", paste0(option, "=")),
         funct.start, "\" + ", arr.name, ".join(\", \") + \"",funct.end,"\";\n",
         main.indent, "} else {\n",
diff --git a/packages/rkwarddev/R/rk.JS.options.R b/packages/rkwarddev/R/rk.JS.options.R
index 8260a36..33c2c7d 100644
--- a/packages/rkwarddev/R/rk.JS.options.R
+++ b/packages/rkwarddev/R/rk.JS.options.R
@@ -32,6 +32,7 @@
 #'    Only used if \code{array=TRUE}.
 #' @param array Logical, if \code{TRUE} will generate the options as an array, otherwise in one
 #'    concatenated character string (probably only useful for mandatory options).
+#' @param opt.sep Character string, will be printed in the resulting R code before the option name.
 #' @return An object of class \code{rk.JS.opt}, use \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
 #'    on that.
 #' @seealso
@@ -48,7 +49,7 @@
 #'   ite(checkB, "fast=TRUE")
 #' )
 
-rk.JS.options <- function(var, ..., collapse=", ", option=NULL, funct=NULL, array=TRUE){
+rk.JS.options <- function(var, ..., collapse=", ", option=NULL, funct=NULL, array=TRUE, opt.sep=", "){
   all.opts <- list(...)
 
   if(is.null(option)){
@@ -64,7 +65,9 @@ rk.JS.options <- function(var, ..., collapse=", ", option=NULL, funct=NULL, arra
     collapse=collapse,
     ifs=all.opts,
     array=array,
-    funct=funct)
+    funct=funct,
+    opt.sep=opt.sep
+  )
 
   return(result)
 }
\ No newline at end of file
diff --git a/packages/rkwarddev/R/rk.paste.JS.R b/packages/rkwarddev/R/rk.paste.JS.R
index f643000..d1abca7 100644
--- a/packages/rkwarddev/R/rk.paste.JS.R
+++ b/packages/rkwarddev/R/rk.paste.JS.R
@@ -44,7 +44,8 @@
 #'    and the JS keyword "var" will be omitted.
 #' @param empty.e For \code{rk.JS.ite} objects only: Logical, if \code{TRUE} will force to add empty \code{else \{\}} brackets when
 #'    there is no \code{else} statement defined, which is considered to enhance code readability by some.
-#' @param opt.sep For \code{rk.JS.arr} objects only: Character string, will be printed in the resulting R code before the option name.
+#' @param opt.sep For \code{rk.JS.arr} and \code{rk.JS.opt} objects only: Character string, will be printed in the resulting R code
+#'    before the option name.
 #' @return A character string.
 #' @include 00_class_01_rk.JS.arr.R
 #' @include 00_class_03_rk.JS.ite.R
@@ -80,7 +81,8 @@ rk.paste.JS <- function(..., level=2, indent.by="\t", funct=NULL, array=NULL,
       # done by an internal function, to ease handling of recursions
       result <- paste.JS.array(this.object, level=level, indent.by=indent.by, funct=funct, opt.sep=opt.sep)
     } else if(inherits(this.object, "rk.JS.opt")){
-      result <- paste.JS.options(this.object, level=level, indent.by=indent.by, array=array, funct=funct)
+      result <- paste.JS.options(this.object, level=level, indent.by=indent.by, array=array, funct=funct,
+        opt.sep=opt.sep)
     } else if(inherits(this.object, "rk.JS.oset")){
       result <- paste.JS.optionsset(this.object, level=level, indent.by=indent.by)
     } else if(inherits(this.object, "rk.JS.var")){
diff --git a/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf b/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
index 8d7c7a6..08726dd 100644
Binary files a/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf and b/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf differ
diff --git a/packages/rkwarddev/man/rk.JS.opt-class.Rd b/packages/rkwarddev/man/rk.JS.opt-class.Rd
index d6b7d0b..60285db 100644
--- a/packages/rkwarddev/man/rk.JS.opt-class.Rd
+++ b/packages/rkwarddev/man/rk.JS.opt-class.Rd
@@ -25,6 +25,9 @@ type of class manually.
 
 \item{\code{funct}}{Character string,
       name of the R function to be called to combine the options.}
+
+\item{\code{opt.sep}}{Character string,
+      separates previous options from the one defined here.}
 }}
 \keyword{Classes}
 
diff --git a/packages/rkwarddev/man/rk.JS.options.Rd b/packages/rkwarddev/man/rk.JS.options.Rd
index a2cbf3b..8279ab9 100644
--- a/packages/rkwarddev/man/rk.JS.options.Rd
+++ b/packages/rkwarddev/man/rk.JS.options.Rd
@@ -5,7 +5,7 @@
 \title{Combine several options in one JavaScript variable}
 \usage{
 rk.JS.options(var, ..., collapse = ", ", option = NULL, funct = NULL,
-  array = TRUE)
+  array = TRUE, opt.sep = ", ")
 }
 \arguments{
 \item{var}{Character string, name of the JavaScript variable to use in the script code.}
@@ -31,6 +31,9 @@ Only used if \code{array=TRUE}.}
 \item{array}{Logical, if \code{TRUE} will generate the options as an array,
       otherwise in one
 concatenated character string (probably only useful for mandatory options).}
+
+\item{opt.sep}{Character string,
+      will be printed in the resulting R code before the option name.}
 }
 \value{
 An object of class \code{rk.JS.opt}, use \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
diff --git a/packages/rkwarddev/man/rk.paste.JS.Rd b/packages/rkwarddev/man/rk.paste.JS.Rd
index 7abb3f1..a750cb6 100644
--- a/packages/rkwarddev/man/rk.paste.JS.Rd
+++ b/packages/rkwarddev/man/rk.paste.JS.Rd
@@ -59,8 +59,9 @@ and the JS keyword "var" will be omitted.}
 there is no \code{else} statement defined,
       which is considered to enhance code readability by some.}
 
-\item{opt.sep}{For \code{rk.JS.arr} objects only: Character string,
-      will be printed in the resulting R code before the option name.}
+\item{opt.sep}{For \code{rk.JS.arr} and \code{rk.JS.opt} objects only: Character string,
+      will be printed in the resulting R code
+before the option name.}
 }
 \value{
 A character string.



More information about the rkward-tracker mailing list