[rkward] packages/rkwarddev: added noquote feature to rk.JS.header()

m.eik michalke meik.michalke at uni-duesseldorf.de
Wed Nov 11 17:02:49 UTC 2015


Git commit d9f0a3b525edb6e78e9de73ad6108ca403f926fb by m.eik michalke.
Committed on 11/11/2015 at 17:01.
Pushed by meikm into branch 'master'.

added noquote feature to rk.JS.header()

  - can be used to print parts of the plugin results as parameters

M  +2    -0    packages/rkwarddev/ChangeLog
M  +3    -4    packages/rkwarddev/DESCRIPTION
M  +15   -2    packages/rkwarddev/R/rk.JS.header.R
M  +1    -1    packages/rkwarddev/R/rk.get.indent.R
M  +2    -0    packages/rkwarddev/inst/NEWS.Rd
M  +10   -1    packages/rkwarddev/man/rk.JS.header.Rd
M  +1    -1    packages/rkwarddev/man/rk.set.indent.Rd

http://commits.kde.org/rkward/d9f0a3b525edb6e78e9de73ad6108ca403f926fb

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index 304ebb6..22a5353 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -33,6 +33,8 @@ added:
     node easier
   - new functions rk.get.indent() and rk.set.indent() to globally set
     indentation string
+  - in rk.JS.header(), the second value provided by "add" can now be named
+    "noquote" to have it nested in the JS noquote() function
 changed:
   - improved error handling in rk.JS.header(), error messages are more
     informative now
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index d127189..b7e52b8 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -8,14 +8,13 @@ Depends:
 Suggests:
     testthat
 Enhances: rkward
-Description: Provides functions to create plugin skeletons and XML
-    structures for RKWard.
+Description: Provides functions to create plugin skeletons and XML structures
+    for RKWard.
 License: GPL (>= 3)
 Encoding: UTF-8
 LazyLoad: yes
 URL: https://rkward.kde.org
-Authors at R: c(person(given="m.eik", family="michalke",
-        email="meik.michalke at hhu.de", role=c("aut", "cre")))
+Authors at R: c(person(given="m.eik", family="michalke", email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.07-4
 Date: 2015-11-11
 RoxygenNote: 5.0.0
diff --git a/packages/rkwarddev/R/rk.JS.header.R b/packages/rkwarddev/R/rk.JS.header.R
index 1481c5f..1d8bd96 100644
--- a/packages/rkwarddev/R/rk.JS.header.R
+++ b/packages/rkwarddev/R/rk.JS.header.R
@@ -22,7 +22,8 @@
 #' @param ... An optional number of additional info to add to the header. Each entry must be named \code{add}
 #'    or \code{addFromUI} -- note that you can use multiple entries with the same name here. Entries named
 #'    \code{add} must be vectors of legth 2, the first being the caption (character), the second its value (either
-#'    character or a XiMpLe node from the dialog). Entries named \code{addFromUI} must have exactly one value
+#'    character or a XiMpLe node from the dialog); if the second value is named \code{noquote} or \code{nq},
+#'    the JS output will be nested inside \code{noquote()}. Entries named \code{addFromUI} must have exactly one value
 #'    specifying the GUI element to query (either character or a XiMpLe node from the dialog).
 #' @param level Integer, if not \code{NULL} will be added as the header level.
 #' @param guess.getter Locigal, if \code{TRUE} try to get a good default getter function for JavaScript
@@ -33,6 +34,14 @@
 #' @examples
 #' my.cbox <- rk.XML.cbox("This is a test")
 #' rk.JS.header("Test results", addFromUI=my.cbox)
+#' 
+#' # let's assume we create an R object called "results"
+#' # in the plugin dialog, this is how you could fetch
+#' # portions of it to be added as a parameter in the output
+#' rk.JS.header(
+#'   "Test results",
+#'   add=c("Significance level", noquote="results[[\\\"alpha\\\"]]")
+#' )
 
 rk.JS.header <- function(title, ..., level=NULL, guess.getter=FALSE, .add=list()){
   addToHeaderChar <- addLevel <- NULL
@@ -61,7 +70,11 @@ rk.JS.header <- function(title, ..., level=NULL, guess.getter=FALSE, .add=list()
             stop(simpleError("rk.JS.header: \"add\" must have exactly two values. please use several elements of the same name if needed!"))
           } else {}
           if(is.character(content[[2]])){
-            value <- paste0("\"", content[[2]], "\"")
+            if(names(content)[[2]] %in% c("nq","noquote")){
+              value <- paste0("noquote(\"", content[[2]], "\")")
+            } else {
+              value <- paste0("\"", content[[2]], "\"")
+            }
           } else if(is.XiMpLe.node(content[[2]])){
             JS.var.value <- rk.JS.vars(content[[2]], guess.getter=guess.getter)
             value <- paste0(slot(JS.var.value, "getter"), "(\"", id(content[[2]], js=FALSE), "\")")
diff --git a/packages/rkwarddev/R/rk.get.indent.R b/packages/rkwarddev/R/rk.get.indent.R
index 00db075..f01c809 100644
--- a/packages/rkwarddev/R/rk.get.indent.R
+++ b/packages/rkwarddev/R/rk.get.indent.R
@@ -16,7 +16,7 @@
 # along with rkwarddev.  If not, see <http://www.gnu.org/licenses/>.
 
 #' @rdname rk.set.indent
-#' @param escape Logical, if set to \code{TRUE} each occurring "\t" will be escaped by an additional "\".
+#' @param escape Logical, if set to \code{TRUE} each occurring "\\t" will be escaped by an additional "\\".
 #' @export
 rk.get.indent <- function(escape=FALSE){
   indent.by <- get.rk.env("indent.by", value="\t")
diff --git a/packages/rkwarddev/inst/NEWS.Rd b/packages/rkwarddev/inst/NEWS.Rd
index 9b8b1ef..4ab2c24 100644
--- a/packages/rkwarddev/inst/NEWS.Rd
+++ b/packages/rkwarddev/inst/NEWS.Rd
@@ -41,6 +41,8 @@
         node easier
       \item new functions \code{rk.get.indent()} and \code{rk.set.indent()} to globally set
         indentation string
+      \item in \code{rk.JS.header()}, the second value provided by \code{"add"} can now be named
+        \code{"noquote"} to have it nested in the JS \code{noquote()} function
     }
   }
   \subsection{changed}{
diff --git a/packages/rkwarddev/man/rk.JS.header.Rd b/packages/rkwarddev/man/rk.JS.header.Rd
index d8d0009..720505e 100644
--- a/packages/rkwarddev/man/rk.JS.header.Rd
+++ b/packages/rkwarddev/man/rk.JS.header.Rd
@@ -15,7 +15,8 @@ nested in an i18n() call.}
 or \code{addFromUI} -- note that you can use multiple entries with the same name here. Entries named
 \code{add} must be vectors of legth 2, the first being the caption (character),
       the second its value (either
-character or a XiMpLe node from the dialog). Entries named \code{addFromUI} must have exactly one value
+character or a XiMpLe node from the dialog); if the second value is named \code{noquote} or \code{nq},
+the JS output will be nested inside \code{noquote()}. Entries named \code{addFromUI} must have exactly one value
 specifying the GUI element to query (either character or a XiMpLe node from the dialog).}
 
 \item{level}{Integer, if not \code{NULL} will be added as the header level.}
@@ -36,5 +37,13 @@ Generate JavaScript header object
 \examples{
 my.cbox <- rk.XML.cbox("This is a test")
 rk.JS.header("Test results", addFromUI=my.cbox)
+
+# let's assume we create an R object called "results"
+# in the plugin dialog, this is how you could fetch
+# portions of it to be added as a parameter in the output
+rk.JS.header(
+  "Test results",
+  add=c("Significance level", noquote="results[[\\\\\\"alpha\\\\\\"]]")
+)
 }
 
diff --git a/packages/rkwarddev/man/rk.set.indent.Rd b/packages/rkwarddev/man/rk.set.indent.Rd
index c362c60..eb772dd 100644
--- a/packages/rkwarddev/man/rk.set.indent.Rd
+++ b/packages/rkwarddev/man/rk.set.indent.Rd
@@ -11,7 +11,7 @@ rk.set.indent(by = "\\t")
 }
 \arguments{
 \item{escape}{Logical,
-      if set to \code{TRUE} each occurring "\t" will be escaped by an additional "\".}
+      if set to \code{TRUE} each occurring "\\t" will be escaped by an additional "\\".}
 
 \item{by}{Character string, indentation string to be defined globally.}
 }



More information about the rkward-tracker mailing list