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

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Fri Oct 28 18:28:52 UTC 2011


Revision: 4011
          http://rkward.svn.sourceforge.net/rkward/?rev=4011&view=rev
Author:   m-eik
Date:     2011-10-28 18:28:52 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
rkwarddev: rk.JS.doc() has a new option "load.silencer" to decide via checkbox if you want package load messages in the result output

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk.JS.doc.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rk.JS.doc.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd
    trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd
    trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-28 18:28:52 UTC (rev 4011)
@@ -4,6 +4,8 @@
   - set dependency of rkward to >= 0.5.6 to work around a glitch in rkward's package versioning.
     this can cause errors on real 0.5.6 installations because they lack functions introduced
     in 0.5.7 (to add & load a plugin automatically), but shouldn't really break anything
+  - added support to turn off modifier checks to rk.XML.set()
+  - added option "load.silencer" to rk.JS.doc(), to easily add a switch to turn off package load messages in output.
 
 ## 0.04-4 (2011-10-26)
   - fixed bug in check for valid modifiers (used to warn when mixed lists with/without modifiers were given)

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.doc.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.doc.R	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.doc.R	2011-10-28 18:28:52 UTC (rev 4011)
@@ -13,7 +13,11 @@
 #' @param printout A character string to be included in the \code{printout()} function. This string will be
 #'		pasted as-is, after \code{results.header} has been evaluated. Ignored if \code{doPrintout} is set.
 #' @param doPrintout A character string to be included in the \code{doPrintout()} function. This string will be
-#'		pasted as-is. You don't need to define a \code{preview()} function, as this will be added automatically. Use \code{ite("full", ...)} style JavaScript code to include headers etc.
+#'		pasted as-is. You don't need to define a \code{preview()} function, as this will be added automatically.
+#'		Use \code{ite("full", ...)} style JavaScript code to include headers etc.
+#' @param load.silencer Either a character string (ID of probably a checkbox), or an object of class \code{XiMpLe.node}.
+#'		This defines a switch you can add to your plugin, to set the \code{require()} call inside \code{suppressMessages()},
+#'		hence suppressing all load messages (except for warnings and errors) of required packages in the output.
 #' @param gen.info Logical, if \code{TRUE} a comment note will be written into the document,
 #'		that it was generated by \code{rkwarddev} and changes should be done to the script.
 #' @param indent.by A character string defining how indentation should be done.
@@ -28,12 +32,22 @@
 #' @export
 
 rk.JS.doc <- function(require=c(), variables=NULL, results.header=NULL,
-	preprocess=NULL, calculate=NULL, printout=NULL, doPrintout=NULL, gen.info=TRUE, indent.by="\t"){
+	preprocess=NULL, calculate=NULL, printout=NULL, doPrintout=NULL, load.silencer=NULL, gen.info=TRUE, indent.by="\t"){
 
 	js.gen.info <- ifelse(isTRUE(gen.info), rk.paste.JS(generator.info, level=1), "")
 
 	js.require <- unlist(sapply(require, function(this.req){
-			rk.paste.JS(echo(id("require(", this.req, ")\n")), level=2, indent.by=indent.by)
+			if(is.null(load.silencer)){
+				req.result <- rk.paste.JS(echo(id("require(", this.req, ")\n")), level=2, indent.by=indent.by)
+			} else {
+				# get the ID, if it's a XiMpLe.node
+				req.result <- rk.paste.JS(
+					jsChkSuppress <- rk.JS.vars(load.silencer),
+					# somehow "quietly=TRUE" doens't always do the trick
+					ite(jsChkSuppress, echo("suppressMessages(require(", this.req, "))\n"), echo("require(", this.req, ")\n"))
+				)
+			}
+			return(req.result)
 		}))
 	js.preprocess <- paste("function preprocess(){\n",
 		indent(2, by=indent.by), "// add requirements etc. here\n",

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.set.R	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.set.R	2011-10-28 18:28:52 UTC (rev 4011)
@@ -2,15 +2,10 @@
 #'
 #' @param id Either a character string (the \code{id} of the property whose value should be set),
 #'		or an object of class \code{XiMpLe.node} (whose \code{id} will be extracted and used).
-#' @param set Character string, can be one of the following values:
-#'		\itemize{
-#'			\item{\code{"state"}}{Set the \code{id} boolean state.}
-#'			\item{\code{"string"}}{Set the \code{id} string value.}
-#'			\item{\code{"enabled"}}{Set the \code{id} enabled state.}
-#'			\item{\code{"visible"}}{Set the \code{id} visibility state.}
-#'			\item{\code{"required"}}{Set the \code{id} requirement state.}
-#'		}
+#' @param set Character string, a valid modifier.
 #' @param to Character string or logical, the value the property should be set to.
+#' @param check.modifiers Logical, if \code{TRUE} the given modifiers will be checked for validity. Should only be
+#'		turned off if you know what you're doing.
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
 #' @seealso
@@ -23,7 +18,7 @@
 #' test.set <- rk.XML.set(id="input_foo", set="required", to=TRUE)
 #' cat(pasteXMLNode(test.set))
 
-rk.XML.set <- function(id, set=NULL, to){
+rk.XML.set <- function(id, set=NULL, to, check.modifiers=TRUE){
 
 	if(length(id) > 1 | length(to) > 1){
 		stop(simpleError("'id' and 'to' must be of length 1!"))
@@ -33,11 +28,10 @@
 	prop.id <- check.ID(id)
 
 	if(!is.null(set)){
-		if(!set %in% c("state","string","enabled","required","visible")){
-			stop(simpleError(paste("The 'set' modifier you provided is invalid: ", set, sep="")))
-		} else {
-			prop.id <- paste(prop.id, set, sep=".")
-		}
+		if(isTRUE(check.modifiers)){
+			modif.validity(id, modifier=set, ignore.empty=TRUE, warn.only=FALSE, bool=TRUE)
+		} else {}
+		prop.id <- paste(prop.id, set, sep=".")
 	} else {}
 
 	attr.list <- list(id=as.character(prop.id))

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R	2011-10-28 18:28:52 UTC (rev 4011)
@@ -9,7 +9,8 @@
 #'		If not set, their default values are used. See \code{\link[rkwarddev:rk.XML.plugin]{rk.XML.plugin}} for details.
 #' @param js A named list of options to be forwarded to \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}}, to generate the JavaScript file.
 #'		Not all options are supported because some don't make sense in this context. Valid options are:
-#'		\code{"require"}, \code{"results.header"}, \code{"variables"}, \code{"preprocess"}, \code{"calculate"}, \code{"printout"} and \code{"doPrintout"}.
+#'		\code{"require"}, \code{"results.header"}, \code{"variables"}, \code{"preprocess"}, \code{"calculate"}, \code{"printout"}, \code{"doPrintout"}
+#'		and \code{"load.silencer"}.
 #'		If not set, their default values are used. See \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}} for details.
 #' @param rkh A named list of options to be forwarded to \code{\link[rkwarddev:rk.rkh.doc]{rk.rkh.doc}}, to generate the help file.
 #'		Not all options are supported because some don't make sense in this context. Valid options are:
@@ -131,7 +132,7 @@
 	## create plugin.js
 	if("js" %in% create & length(js) > 0){
 		got.JS.options <- names(js)
-		for (this.opt in c("require", "variables", "preprocess", "calculate", "printout", "doPrintout")){
+		for (this.opt in c("require", "variables", "preprocess", "calculate", "printout", "doPrintout", "load.silencer")){
 			if(!this.opt %in% got.JS.options) {
 				js[[this.opt]] <- eval(formals(rk.JS.doc)[[this.opt]])
 			} else {}
@@ -163,6 +164,7 @@
 			printout=js[["printout"]],
 			doPrintout=js[["doPrintout"]],
 			gen.info=gen.info,
+			load.silencer=js[["load.silencer"]],
 			indent.by=indent.by)
 		this.component at js <- JS.code
 	} else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-28 18:28:52 UTC (rev 4011)
@@ -27,7 +27,8 @@
 #'		If not set, their default values are used. See \code{\link[rkwarddev:rk.XML.plugin]{rk.XML.plugin}} for details.
 #' @param js A named list of options to be forwarded to \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}}, to generate the JavaScript file.
 #'		Not all options are supported because some don't make sense in this context. Valid options are:
-#'		\code{"require"}, \code{"results.header"}, \code{"variables"}, \code{"preprocess"}, \code{"calculate"}, \code{"printout"} and \code{"doPrintout"}.
+#'		\code{"require"}, \code{"results.header"}, \code{"variables"}, \code{"preprocess"}, \code{"calculate"}, \code{"printout"}, \code{"doPrintout"}
+#'		and \code{"load.silencer"}.
 #'		If not set, their default values are used. See \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}} for details.
 #' @param pluginmap A named list of options to be forwarded to \code{\link[rkwarddev:rk.XML.pluginmap]{rk.XML.pluginmap}}, to generate the pluginmap file.
 #'		Not all options are supported because some don't make sense in this context. Valid options are:

Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)

Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.doc.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.doc.Rd	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.doc.Rd	2011-10-28 18:28:52 UTC (rev 4011)
@@ -4,8 +4,8 @@
 \usage{
   rk.JS.doc(require = c(), variables = NULL, results.header
   = NULL, preprocess = NULL, calculate = NULL, printout =
-  NULL, doPrintout = NULL, gen.info = TRUE, indent.by =
-  "\t")
+  NULL, doPrintout = NULL, load.silencer = NULL, gen.info =
+  TRUE, indent.by = "\t")
 }
 \arguments{
   \item{require}{A character vector with names of R
@@ -39,6 +39,14 @@
   \code{ite("full", ...)} style JavaScript code to include
   headers etc.}
 
+  \item{load.silencer}{Either a character string (ID of
+  probably a checkbox), or an object of class
+  \code{XiMpLe.node}. This defines a switch you can add to
+  your plugin, to set the \code{require()} call inside
+  \code{suppressMessages()}, hence suppressing all load
+  messages (except for warnings and errors) of required
+  packages in the output.}
+
   \item{gen.info}{Logical, if \code{TRUE} a comment note
   will be written into the document, that it was generated
   by \code{rkwarddev} and changes should be done to the

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd	2011-10-28 18:28:52 UTC (rev 4011)
@@ -2,7 +2,7 @@
 \alias{rk.XML.set}
 \title{Create XML node "set" for RKWard plugins}
 \usage{
-  rk.XML.set(id, set = NULL, to)
+  rk.XML.set(id, set = NULL, to, check.modifiers = TRUE)
 }
 \arguments{
   \item{id}{Either a character string (the \code{id} of the
@@ -10,16 +10,14 @@
   class \code{XiMpLe.node} (whose \code{id} will be
   extracted and used).}
 
-  \item{set}{Character string, can be one of the following
-  values: \itemize{ \item{\code{"state"}}{Set the \code{id}
-  boolean state.} \item{\code{"string"}}{Set the \code{id}
-  string value.} \item{\code{"enabled"}}{Set the \code{id}
-  enabled state.} \item{\code{"visible"}}{Set the \code{id}
-  visibility state.} \item{\code{"required"}}{Set the
-  \code{id} requirement state.} }}
+  \item{set}{Character string, a valid modifier.}
 
   \item{to}{Character string or logical, the value the
   property should be set to.}
+
+  \item{check.modifiers}{Logical, if \code{TRUE} the given
+  modifiers will be checked for validity. Should only be
+  turned off if you know what you're doing.}
 }
 \value{
   An object of class \code{XiMpLe.node}.

Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd	2011-10-28 18:28:52 UTC (rev 4011)
@@ -34,10 +34,11 @@
   because some don't make sense in this context. Valid
   options are: \code{"require"}, \code{"results.header"},
   \code{"variables"}, \code{"preprocess"},
-  \code{"calculate"}, \code{"printout"} and
-  \code{"doPrintout"}. If not set, their default values are
-  used. See \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}}
-  for details.}
+  \code{"calculate"}, \code{"printout"},
+  \code{"doPrintout"} and \code{"load.silencer"}. If not
+  set, their default values are used. See
+  \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}} for
+  details.}
 
   \item{rkh}{A named list of options to be forwarded to
   \code{\link[rkwarddev:rk.rkh.doc]{rk.rkh.doc}}, to

Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2011-10-28 17:51:55 UTC (rev 4010)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2011-10-28 18:28:52 UTC (rev 4011)
@@ -65,10 +65,11 @@
   because some don't make sense in this context. Valid
   options are: \code{"require"}, \code{"results.header"},
   \code{"variables"}, \code{"preprocess"},
-  \code{"calculate"}, \code{"printout"} and
-  \code{"doPrintout"}. If not set, their default values are
-  used. See \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}}
-  for details.}
+  \code{"calculate"}, \code{"printout"},
+  \code{"doPrintout"} and \code{"load.silencer"}. If not
+  set, their default values are used. See
+  \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}} for
+  details.}
 
   \item{pluginmap}{A named list of options to be forwarded
   to

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