[rkward-cvs] SF.net SVN: rkward:[3908] trunk/rkward/packages/rkwarddev

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Sat Oct 8 12:25:14 UTC 2011


Revision: 3908
          http://rkward.svn.sourceforge.net/rkward/?rev=3908&view=rev
Author:   m-eik
Date:     2011-10-08 12:25:13 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
rkwarddev: improvements to JS generation, incl. some comments in the code and new shortcut function qp()

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/DESCRIPTION
    trunk/rkward/packages/rkwarddev/NAMESPACE
    trunk/rkward/packages/rkwarddev/R/echo.R
    trunk/rkward/packages/rkwarddev/R/id.R
    trunk/rkward/packages/rkwarddev/R/ite.R
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.options.R
    trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
    trunk/rkward/packages/rkwarddev/inst/CITATION
    trunk/rkward/packages/rkwarddev/man/echo.Rd
    trunk/rkward/packages/rkwarddev/man/id.Rd
    trunk/rkward/packages/rkwarddev/man/ite.Rd
    trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd
    trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd
    trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd

Added Paths:
-----------
    trunk/rkward/packages/rkwarddev/R/qp.R
    trunk/rkward/packages/rkwarddev/man/qp.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-08 12:25:13 UTC (rev 3908)
@@ -1,5 +1,11 @@
 ChangeLog for package rkwarddev
 
+## 0.03-1 (2011-10-08)
+  - added new shortcut function qp() -- "quote + plus" -- for id()
+  - added option to create arrays with rk.JS.options()
+  - enhanced class rk.JS.opt
+  - rk.paste.JS() now adds some comments to the generated code
+
 ## 0.03-0 (2011-10-07)
   - redesigned options for rk.plugin.skeleton() again, to make them more intuitive and flexible
     at the same time. unfortunately, this breaks backwards compatibility again.

Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION	2011-10-08 12:25:13 UTC (rev 3908)
@@ -14,13 +14,14 @@
 URL: http://rkward.sourceforge.net
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
-Version: 0.03-0
-Date: 2011-10-07
+Version: 0.03-1
+Date: 2011-10-08
 Collate:
     'echo.R'
     'id.R'
     'rk.JS.ite-class.R'
     'ite.R'
+    'qp.R'
     'rk.build.plugin.R'
     'rk-internal.R'
     'rk.JS.array.R'

Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE	2011-10-08 12:25:13 UTC (rev 3908)
@@ -5,6 +5,7 @@
 export(id)
 export(ite)
 exportMethods(show)
+export(qp)
 export(rk.build.plugin)
 export(rk.JS.array)
 export(rk.JS.doc)

Modified: trunk/rkward/packages/rkwarddev/R/echo.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/echo.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/echo.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -13,6 +13,7 @@
 #'		\code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
 #'		\code{\link[rkwarddev:ite]{ite}},
 #'		\code{\link[rkwarddev:id]{id}},
+#'		\code{\link[rkwarddev:id]{qp}},
 #'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
 #' @examples
@@ -20,7 +21,7 @@
 #' echo("bar <- \"", cbox1, "\"")
 
 echo <- function(..., newline=""){
-	ID.content <- id(..., quote=TRUE,  collapse=" + ")
+	ID.content <- qp(...)
 	result <- paste("echo(", ID.content, ");", newline, sep="")
 	return(result)
 }

Modified: trunk/rkward/packages/rkwarddev/R/id.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/id.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/id.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -10,27 +10,36 @@
 #' @param quote Logical, it the character strings sould be deparsed, so they come out "as-is" when
 #'		written to files, e.g. by \code{cat}.
 #' @param collapse Character string, defining if and how the individual elements should be glued together.
+#' @param js Logical, if \code{TRUE} returns JavaScript varaible names for \code{XiMpLe.node} objects.
+#'		Otherwise their actual ID is returned.
 #' @return A character string.
 #' @export
 #' @seealso \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
 #'		\code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
 #'		\code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
 #'		\code{\link[rkwarddev:echo]{echo}},
+#'		\code{\link[rkwarddev:qp]{qp}} (a shortcut for \code{id} with different defaults),
 #'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @examples
 #' # an example checkbox XML node
 #' cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
-#' id("The variable name is: ", cbox1, "!", quote=TRUE, collapse=" + ")
+#' id("The variable name is: ", cbox1, "!", js=TRUE)
 
-id <- function(..., quote=FALSE, collapse=""){
+id <- function(..., quote=FALSE, collapse="", js=FALSE){
 	full.content <- list(...)
 	ID.content <- sapply(full.content, function(this.part){
 			if(inherits(this.part, "XiMpLe.node")){
-				node.id <- camelCode(this.part at attributes$id)
+				node.id <- this.part at attributes$id
+					if(isTRUE(js)){
+						node.id <- camelCode(node.id)
+					} else {}
 				return(node.id)
-			} else if(inherits(this.part, "rk.JS.arr") | inherits(this.part, "rk.JS.opt")){
+			} else if(inherits(this.part, "rk.JS.arr")){
 				node.id <- this.part at opt.name
 				return(node.id)
+			} else if(inherits(this.part, "rk.JS.opt")){
+				node.id <- this.part at var.name
+				return(node.id)
 			}else {
 				if(isTRUE(quote)){
 					text.part <- deparse(this.part)

Modified: trunk/rkward/packages/rkwarddev/R/ite.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/ite.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/ite.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -10,6 +10,7 @@
 #'		\code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
 #'		\code{\link[rkwarddev:echo]{echo}},
 #'		\code{\link[rkwarddev:id]{id}},
+#'		\code{\link[rkwarddev:qp]{qp}},
 #'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
 #' @examples
@@ -30,7 +31,7 @@
 		} else {}
 	}
 	result <- new("rk.JS.ite",
-		ifJS=id(ifjs),
+		ifJS=id(ifjs, js=TRUE),
 		thenJS=thenjs,
 		elseJS=elsejs,
 		elifJS=elifJS

Added: trunk/rkward/packages/rkwarddev/R/qp.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/qp.R	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/qp.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -0,0 +1,24 @@
+#' Replace XiMpLe.node objects with their ID value
+#' 
+#' This function is a shortcut for \code{\link[rkwarddev:id]{id}} which sets some useful defaults
+#' (\code{quote=TRUE, collapse=" + ", js=TRUE}). The abbreviation stands for "quote + plus".
+#' 
+#' @param ... One or several character strings and/or \code{XiMpLe.node} objects with plugin nodes,
+#' 	and/or objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}, simply separated by comma.
+#' @return A character string.
+#' @export
+#' @seealso \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
+#'		\code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
+#'		\code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
+#'		\code{\link[rkwarddev:echo]{echo}},
+#'		\code{\link[rkwarddev:id]{id}},
+#'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+#' @examples
+#' # an example checkbox XML node
+#' cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
+#' qp("The variable name is: ", cbox1, "!")
+
+qp <- function(...){
+	result <- id(..., quote=TRUE, collapse=" + ", js=TRUE)
+	return(result)
+}

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -427,10 +427,13 @@
 	} else {}
 
 	JS.array <- paste(
+		main.indent, "// define the array ", arr.name, " for values of R option \"", option, "\"\n",
 		main.indent, "var ", arr.name, " = new Array();\n",
 		main.indent, arr.name, ".push(",
 		paste(variables, collapse=", "), ");\n",
+		main.indent, "// clean array ", arr.name, " from empty strings\n",
 		main.indent, arr.name, " = ", arr.name, ".filter(String);\n",
+		main.indent, "// set the actual variable ", opt.name, " for R option \"", option, "=", funct, "()\"\n",
 		main.indent, "if(", arr.name, ".length > 0) {\n",
 		scnd.indent, "var ", opt.name, " = \", ", option,"=",
 		funct, "(\" + ", arr.name, ".join(\", \") + \")\";\n",
@@ -449,21 +452,53 @@
 # 
 # 	echo ('result <- t.test (' + x + ", " + y + options + ')\n');
 
+# array solution:
+# 	var arrAuthor = new Array();
+# 	if(inpGivennam) {
+# 		arrAuthor.push("given=\"" + inpGivennam + "\"");
+# 	} else {}
+# 	if(inpFamilynm) {
+# 		arrAuthor.push("family=\"" + inpFamilynm + "\"");
+# 	} else {}
+# 	if(inpEmail) {
+# 		arrAuthor.push("email=\"" + inpEmail + "\"");
+# 	} else {}
+# 	arrAuthor = arrAuthor.filter(String);
+# 
+# 	if(arrAuthor.length > 0) {
+# 		var author = ", author=person(" + arrAuthor.join(", ") + ")";
+# 	} else {
+# 		var author = "";
+# 	}
+
 ## function paste.JS.options()
-paste.JS.options <- function(object, level=2, indent.by="\t"){
+paste.JS.options <- function(object, level=2, indent.by="\t", array=NULL, funct=NULL){
 	stopifnot(inherits(object, "rk.JS.opt"))
 	# check indentation
 	main.indent <- indent(level, by=indent.by)
 	scnd.indent <- indent(level+1, by=indent.by)
 
+	variable  <- object at var.name
 	option    <- object at opt.name
+	arr.name  <- camelCode(c("arr", variable))
+	collapse  <- object at collapse
 	ifs       <- object at ifs
+	if(is.null(array)){
+		array  <- object at array
+	} else {}
+	if(is.null(funct)){
+		funct <- object at funct
+	} else {}
 
 	# a function to add the object stuff to ite objects
-	add.opts <- function(this.ite){
+	add.opts <- function(this.ite, collapse, array){
 		# remove quotes, we'll add them ourselves where needed
 		to.add <-  gsub("(.*)(\")$", "\\1", gsub("(^\")(.*)", "\\2", this.ite at thenJS, perl=TRUE), perl=TRUE)
-		this.ite at thenJS <- paste(option, " += \"", to.add,"\";", sep="")
+		if(isTRUE(array)){
+			this.ite at thenJS <- paste(arr.name, ".push(\"", to.add,"\");", sep="")
+		} else {
+			this.ite at thenJS <- paste(variable, " += \"", collapse, to.add,"\";", sep="")
+		}
 		if(length(this.ite at elifJS) == 1){
 			this.ite at elifJS <- list(add.opts(this.ite at elifJS[[1]]))
 		} else {}
@@ -471,15 +506,41 @@
 	}
 
 	# the object class makes sure this is a list of rk.JS.ite objects
-	ifs.pasted <- sapply(ifs, function(thisIf){
-		paste.JS.ite(add.opts(thisIf), level=level, indent.by=indent.by)
+	ifs.pasted <- sapply(1:length(ifs), function(thisIf.num){
+		thisIf <- ifs[[thisIf.num]]
+		# skip the first collapse
+		if(thisIf.num > 1){
+			this.collapse <- collapse
+		} else {
+			this.collapse <- ""
+		}
+		paste.JS.ite(add.opts(thisIf, collapse=this.collapse, array=array), level=level+1, indent.by=indent.by)
 	})
 
 #return(ifs.pasted)
 
 	JS.options <- paste(
-		main.indent, "var ", option, ";\n",
+		if(isTRUE(array)){
+			paste(
+				main.indent, "// define the array ", arr.name, " for values of R option \"", option, "\"\n",
+				main.indent, "var ", arr.name, " = new Array();\n", sep="")
+		} else {
+			paste(main.indent, "var ", variable, " = \"\";\n", sep="")
+		},
 		paste(ifs.pasted, sep="", collapse="\n"), "\n",
+		if(isTRUE(array)){
+			paste(
+				main.indent, "// clean array ", arr.name, " from empty strings\n",
+				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, " = \", ", option,"=",
+				funct, "(\" + ", arr.name, ".join(\", \") + \")\";\n",
+				main.indent, "} else {\n",
+				scnd.indent, "var ", variable, " = \"\";\n",
+				main.indent, "}\n",
+				sep="")
+		} else {},
 		sep="")
 
 	return(JS.options)

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -5,12 +5,20 @@
 
 setClass("rk.JS.opt",
 	representation=representation(
+		var.name="character",
 		opt.name="character",
-		ifs="list"
+		collapse="character",
+		ifs="list",
+		array="logical",
+		funct="character"
 	),
 	prototype(
+		var.name=character(),
 		opt.name=character(),
-		ifs=list()
+		collapse=character(),
+		ifs=list(),
+		array=NULL,
+		funct=character()
 	)
 )
 

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.options.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.options.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.options.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -3,7 +3,14 @@
 #' @param var Character string, name of the JavaScript variable to use in the script code.
 #' @param ... A list of objects of class \code{rk.JS.ite} (see \code{\link[rkwarddev:ite]{ite}}).
 #'		Use the \code{thenjs} element only to define the value to add to the option
-#'		(e.g., \code{", paired=TRUE"} or \code{id(", conf.level=\"", conflevel, "\"", quote=TRUE, collapse= " + ")}.
+#'		(e.g., \code{"paired=TRUE"} or \code{qp("conf.level=\"", conflevel, "\"")}.
+#' @param collapse Character string, how all options should be concatenated on the R code level.
+#' @param option A character string, naming, e.g., an option of an R function which should be
+#'		constructed from several variables. Only used if \code{array=TRUE}.
+#' @param funct Character string, name of the R function to be called to combine the options,
+#'		e.g. "list" for \code{list()}, or "c" for \code{c()}. 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).
 #' @return An object of class \code{rk.JS.opt}, use \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
 #'		on that.
 #' @seealso
@@ -16,15 +23,24 @@
 #' checkB <- rk.XML.cbox(label="Run it fast", value="true")
 #' # combine them into one JavaScript options variable
 #' rk.JS.options("optionsTestA",
-#'   ite(checkA, id("test=\"", checkA, "\"", quote=TRUE, collapse= " + ")),
+#'   ite(checkA, qp("test=\"", checkA, "\"")),
 #'   ite(checkB, "fast=TRUE")
 #' )
 
-rk.JS.options <- function(var, ...){
+rk.JS.options <- function(var, ..., collapse=", ", option=NULL, funct="c", array=TRUE){
 	all.opts <- list(...)
+
+	if(is.null(option)){
+		option <- ""
+	} else {}
+
 	result <- new("rk.JS.opt",
-		opt.name=var,
-		ifs=all.opts)
+		var.name=var,
+		opt.name=option,
+		collapse=collapse,
+		ifs=all.opts,
+		array=array,
+		funct=funct)
 
 	return(result)
 }
\ No newline at end of file

Modified: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -3,8 +3,10 @@
 #' @param ... Objects of class \code{rk.JS.ite}, \code{rk.JS.arr}, \code{rk.JS.opt} or character.
 #' @param level Integer, which indentation level to use, minimum is 1.
 #' @param indent.by A character string defining the indentation string to use.
-#' @param funct For \code{rk.JS.arr} objects only: Character string, name of the R function
+#' @param funct For \code{rk.JS.arr} and \code{rk.JS.opt} objects only: Character string, name of the R function
 #' 	to be called to combine the options, e.g. "list" for \code{list()}, or "c" for \code{c()}.
+#' @param array For \code{rk.JS.opt} objects only: Logical, whether the options should be collected
+#'		in an array or a concatenated character string.
 #' @return A character string.
 #' @include rk.JS.ite-class.R
 #' @include rk.JS.arr-class.R
@@ -16,7 +18,7 @@
 #'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
 
-rk.paste.JS <- function(..., level=1, indent.by="\t", funct=NULL){
+rk.paste.JS <- function(..., level=1, indent.by="\t", funct=NULL, array=NULL){
 	stopifnot(level > 0)
 	all.objects <- list(...)
 	
@@ -28,7 +30,7 @@
 			# done by an internal function, to ease handling of recursions
 			result <- paste.JS.array(this.object, level=level, indent.by=indent.by, funct=funct)
 		} else if(inherits(this.object, "rk.JS.opt")){
-			result <- paste.JS.options(this.object, level=level, indent.by=indent.by)
+			result <- paste.JS.options(this.object, level=level, indent.by=indent.by, array=array, funct=funct)
 		} else {
 			result <- paste(indent(level, by=indent.by), this.object, sep="")
 		}

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2011-10-08 12:25:13 UTC (rev 3908)
@@ -3,8 +3,8 @@
 #' \tabular{ll}{
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
-#' Version: \tab 0.03-0\cr
-#' Date: \tab 2011-10-07\cr
+#' Version: \tab 0.03-1\cr
+#' Date: \tab 2011-10-08\cr
 #' Depends: \tab R (>= 2.9.0),XiMpLe,rkward (>= 0.5.6)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr

Modified: trunk/rkward/packages/rkwarddev/inst/CITATION
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/CITATION	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/inst/CITATION	2011-10-08 12:25:13 UTC (rev 3908)
@@ -2,12 +2,12 @@
 		title="rkwarddev: A collection of tools for RKWard plugin development",
 		author="Meik Michalke",
 		year="2011",
-		note="(Version 0.03-0)",
+		note="(Version 0.03-1)",
 		url="http://rkward.sourceforge.net",
 
 		textVersion =
 		paste("Michalke, M. (2011). ",
-				"rkwarddev: A collection of tools for RKWard plugin development (Version 0.03-0). ",
+				"rkwarddev: A collection of tools for RKWard plugin development (Version 0.03-1). ",
 				"Available from http://rkward.sourceforge.net",
 				sep=""),
 

Modified: trunk/rkward/packages/rkwarddev/man/echo.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/echo.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/echo.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -33,7 +33,8 @@
   \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
   \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
   \code{\link[rkwarddev:ite]{ite}},
-  \code{\link[rkwarddev:id]{id}}, and the
+  \code{\link[rkwarddev:id]{id}},
+  \code{\link[rkwarddev:id]{qp}}, and the
   \href{help:rkwardplugins}{Introduction to Writing Plugins
   for RKWard}
 }

Modified: trunk/rkward/packages/rkwarddev/man/id.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/id.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/id.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -2,7 +2,7 @@
 \alias{id}
 \title{Replace XiMpLe.node objects with their ID value}
 \usage{
-  id(..., quote = FALSE, collapse = "")
+  id(..., quote = FALSE, collapse = "", js = FALSE)
 }
 \arguments{
   \item{...}{One or several character strings and/or
@@ -16,6 +16,10 @@
 
   \item{collapse}{Character string, defining if and how the
   individual elements should be glued together.}
+
+  \item{js}{Logical, if \code{TRUE} returns JavaScript
+  varaible names for \code{XiMpLe.node} objects. Otherwise
+  their actual ID is returned.}
 }
 \value{
   A character string.
@@ -32,13 +36,15 @@
 \examples{
 # an example checkbox XML node
 cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
-id("The variable name is: ", cbox1, "!", quote=TRUE, collapse=" + ")
+id("The variable name is: ", cbox1, "!", js=TRUE)
 }
 \seealso{
   \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
   \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
   \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
-  \code{\link[rkwarddev:echo]{echo}}, and the
+  \code{\link[rkwarddev:echo]{echo}},
+  \code{\link[rkwarddev:qp]{qp}} (a shortcut for \code{id}
+  with different defaults), and the
   \href{help:rkwardplugins}{Introduction to Writing Plugins
   for RKWard}
 }

Modified: trunk/rkward/packages/rkwarddev/man/ite.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/ite.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/ite.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -31,7 +31,8 @@
   \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
   \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
   \code{\link[rkwarddev:echo]{echo}},
-  \code{\link[rkwarddev:id]{id}}, and the
+  \code{\link[rkwarddev:id]{id}},
+  \code{\link[rkwarddev:qp]{qp}}, and the
   \href{help:rkwardplugins}{Introduction to Writing Plugins
   for RKWard}
 }

Added: trunk/rkward/packages/rkwarddev/man/qp.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/qp.Rd	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/qp.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -0,0 +1,36 @@
+\name{qp}
+\alias{qp}
+\title{Replace XiMpLe.node objects with their ID value}
+\usage{
+  qp(...)
+}
+\arguments{
+  \item{...}{One or several character strings and/or
+  \code{XiMpLe.node} objects with plugin nodes, and/or
+  objects of classes \code{rk.JS.arr} or \code{rk.JS.opt},
+  simply separated by comma.}
+}
+\value{
+  A character string.
+}
+\description{
+  This function is a shortcut for
+  \code{\link[rkwarddev:id]{id}} which sets some useful
+  defaults (\code{quote=TRUE, collapse=" + ", js=TRUE}).
+  The abbreviation stands for "quote + plus".
+}
+\examples{
+# an example checkbox XML node
+cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
+qp("The variable name is: ", cbox1, "!")
+}
+\seealso{
+  \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
+  \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
+  \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
+  \code{\link[rkwarddev:echo]{echo}},
+  \code{\link[rkwarddev:id]{id}}, and the
+  \href{help:rkwardplugins}{Introduction to Writing Plugins
+  for RKWard}
+}
+

Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -2,7 +2,8 @@
 \alias{rk.JS.options}
 \title{Combine several options in one JavaScript variable}
 \usage{
-  rk.JS.options(var, ...)
+  rk.JS.options(var, ..., collapse = ", ", option = NULL,
+  funct = "c", array = TRUE)
 }
 \arguments{
   \item{var}{Character string, name of the JavaScript
@@ -11,9 +12,25 @@
   \item{...}{A list of objects of class \code{rk.JS.ite}
   (see \code{\link[rkwarddev:ite]{ite}}). Use the
   \code{thenjs} element only to define the value to add to
-  the option (e.g., \code{", paired=TRUE"} or \code{id(",
-  conf.level=\"", conflevel, "\"", quote=TRUE, collapse= "
-  + ")}.}
+  the option (e.g., \code{"paired=TRUE"} or
+  \code{qp("conf.level=\"", conflevel, "\"")}.}
+
+  \item{collapse}{Character string, how all options should
+  be concatenated on the R code level.}
+
+  \item{option}{A character string, naming, e.g., an option
+  of an R function which should be constructed from several
+  variables. Only used if \code{array=TRUE}.}
+
+  \item{funct}{Character string, name of the R function to
+  be called to combine the options, e.g. "list" for
+  \code{list()}, or "c" for \code{c()}. 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).}
 }
 \value{
   An object of class \code{rk.JS.opt}, use
@@ -28,7 +45,7 @@
 checkB <- rk.XML.cbox(label="Run it fast", value="true")
 # combine them into one JavaScript options variable
 rk.JS.options("optionsTestA",
-ite(checkA, id("test=\\"", checkA, "\\"", quote=TRUE, collapse= " + ")),
+ite(checkA, qp("test=\\"", checkA, "\\"")),
 ite(checkB, "fast=TRUE")
 )
 }

Modified: trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -3,7 +3,7 @@
 \title{Paste JavaScript objects and character strings}
 \usage{
   rk.paste.JS(..., level = 1, indent.by = "\t", funct =
-  NULL)
+  NULL, array = NULL)
 }
 \arguments{
   \item{...}{Objects of class \code{rk.JS.ite},
@@ -15,10 +15,14 @@
   \item{indent.by}{A character string defining the
   indentation string to use.}
 
-  \item{funct}{For \code{rk.JS.arr} objects only: Character
-  string, name of the R function to be called to combine
-  the options, e.g. "list" for \code{list()}, or "c" for
-  \code{c()}.}
+  \item{funct}{For \code{rk.JS.arr} and \code{rk.JS.opt}
+  objects only: Character string, name of the R function to
+  be called to combine the options, e.g. "list" for
+  \code{list()}, or "c" for \code{c()}.}
+
+  \item{array}{For \code{rk.JS.opt} objects only: Logical,
+  whether the options should be collected in an array or a
+  concatenated character string.}
 }
 \value{
   A character string.

Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2011-10-07 21:58:44 UTC (rev 3907)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2011-10-08 12:25:13 UTC (rev 3908)
@@ -8,8 +8,8 @@
 }
 \details{
   \tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
-  Package\cr Version: \tab 0.03-0\cr Date: \tab
-  2011-10-07\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward
+  Package\cr Version: \tab 0.03-1\cr Date: \tab
+  2011-10-08\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward
   (>= 0.5.6)\cr Enhances: \tab rkward\cr Encoding: \tab
   UTF-8\cr License: \tab GPL (>= 3)\cr LazyLoad: \tab
   yes\cr URL: \tab http://rkward.sourceforge.net\cr }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list