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

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Fri Oct 7 19:38:33 UTC 2011


Revision: 3901
          http://rkward.svn.sourceforge.net/rkward/?rev=3901&view=rev
Author:   m-eik
Date:     2011-10-07 19:38:33 +0000 (Fri, 07 Oct 2011)
Log Message:
-----------
rkwarddev: plugin.skeleton() and rk.XML.pluginmap() now use rk.XML.about() results for "aout" option only

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
    trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
    trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-07 19:38:33 UTC (rev 3901)
@@ -3,6 +3,9 @@
 ## 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.
+  - rk.plugin.skeleton() and rk.XML.pluginmap() now only accept rk.XML.about() made objects
+    for "about"
+  - rk.plugin.skeleton() uses internal function XML2person() to create nicer Authors at R entries in DESCRIPTION
 
 ## 0.02-5 (2011-10-06)
   - added functions rk.rkh.caption(), rk.rkh.link(), rk.rkh.related(), rk.rkh.section(), rk.rkh.setting(),

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-07 19:38:33 UTC (rev 3901)
@@ -213,9 +213,48 @@
 		stop(simpleError("Nodes must be of class XiMpLe.node!"))
 	}
 	return(the.soup)
-}
-## end function node.soup()
+} ## end function node.soup()
 
+## function XML2person()
+# extracts the person/author info from XML "about" nodes
+XML2person <- function(node, eval=FALSE){
+		if(inherits(node, "XiMpLe.node")){
+			# check if this is *really* a about section, otherwise die of boredom
+			if(!identical(node at name, "about")){
+				stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
+			} else {}
+		} else {
+			stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
+		}
+	make.vector <- function(value){
+		if(grepl(",", value)){
+			value <- paste("c(\"", paste(trim(unlist(strsplit(value, ","))), collapse="\", \""), "\")", sep="")
+		} else {
+			value <- paste("\"", value, "\"", sep="")
+		}
+		return(value)
+	}
+	all.authors <- c()
+	for (this.child in node at children){
+		if(identical(this.child at name, "author")){
+			attrs <- this.child at attributes
+			given <- make.vector(attrs[["given"]])
+			family <- make.vector(attrs[["family"]])
+			email <- make.vector(attrs[["email"]])
+			role <- make.vector(attrs[["role"]])
+			this.author <- paste("person(given=", given, ", family=", family, ", email=", email, ", role=", role, ")", sep="")
+			all.authors[length(all.authors) + 1] <- this.author
+		} else {}
+	}
+	if(length(all.authors) > 1){
+		all.authors <- paste("c(", paste(all.authors, collapse=", "), ")", sep="")
+	} else {}
+	if(isTRUE(eval)){
+		all.authors <- eval(parse(text=all.authors))
+	} else {}
+	return(all.authors)
+} ## end function XML2person()
+
 ## function get.by.role()
 # filters a vector with person objects by roles
 get.by.role <- function(persons, role="aut"){

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.plugin.R	2011-10-07 19:38:33 UTC (rev 3901)
@@ -80,10 +80,10 @@
 					new("XiMpLe.node",
 						# add these as comments because they need editing
 						name="!--",
-						value="<convert id=\"!edit!\", mode=\"!edit!\", sources=\"!edit!\", standard=\"!edit!\" />"),
+						value="convert id=\"!edit!\", mode=\"!edit!\", sources=\"!edit!\", standard=\"!edit!\" /"),
 					new("XiMpLe.node",
 						name="!--",
-						value="<connect client=\"!edit!\", governor=\"!edit!\" />")
+						value="connect client=\"!edit!\", governor=\"!edit!\" /")
 				)
 			all.children[[length(all.children)+1]] <- new("XiMpLe.node",
 				name="logic",

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2011-10-07 19:38:33 UTC (rev 3901)
@@ -1,9 +1,8 @@
 #' Write a pluginmap file for RKWard
 #'
 #' @param name Character string, name of the plugin.
-#' @param about Either an object of class \code{XiMpLe.node} to be pasted as the \code{<about>} section,
-#'		or a list with descriptive information on the plugin,its authors and dependencies.
-#'		See \code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for details! Skipped if \code{NULL}.
+#' @param about An object of class \code{XiMpLe.node} to be pasted as the \code{<about>} section,
+#'		See \code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for details. Skipped if \code{NULL}.
 #' @param components Either an object of class \code{XiMpLe.node} to be pasted as the \code{<components>} section (see
 #'		\code{\link[rkwarddev:rk.XML.components]{rk.XML.components}} for details). Or a character vector with at least
 #'		one plugin component file name, relative path from the pluginmap file and ending with ".xml".
@@ -61,15 +60,7 @@
 				all.children <- list(about)
 			}
 		} else {
-			about.XML <- rk.XML.about(
-				name=name.orig,
-				author=about[["author"]],
-				about=about[["about"]],
-				dependencies=about[["dependencies"]],
-				package=about[["package"]],
-				pluginmap=about[["pluginmap"]])
-			# initialize all.children list
-			all.children <- list(about.XML)
+			stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
 		}
 	} else {
 		if(isTRUE(hints)){

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-07 19:38:33 UTC (rev 3901)
@@ -1,16 +1,15 @@
 #' Generate skeletons for RKWard plugins
 #'
 #' @param name Character sting, name of the plugin package.
-#' @param about A list with descriptive information on the plugin, its authors and dependencies.
-#'		At the very least you must specify \code{name} and \code{author}.
-#'		See \code{\link[rkwarddev:rk.XML.about]{rk.XML.about}} for details and a full list of elements!
+#' @param about An object of class \code{XiMpLe.node} with descriptive information on the plugin, its authors and dependencies,
+#'		see \code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for details. Skipped if \code{NULL}.
 #'		If \code{NULL}, no \code{DESCRIPTION} file will be created either.
 #' @param path Character sting, path to the main directory where the skeleton should be created.
 #' @param provides Character vector with possible entries of \code{"logic"}, \code{"dialog"} or \code{"wizard"}, defining what
 #'		sections the GUI XML file should provide even if \code{dialog}, \code{wizard} and \code{logic} are \code{NULL}.
 #'		These sections must be edited manually and some parts are therefore commented out.
 #' @param scan A character vector to trigger various automatic scans of the generated GUI XML file. Valid enties are:
-#'		\itemize{
+#'		\describe{
 #'			\item{\code{"var"}}{Calls \code{\link{rk.JS.scan}} to define all needed variables in the \code{calculate()} function
 #'				of the JavaScript file. These variables will be added to variables defined by the \code{js} option, if any (see below).}
 #'			\item{\code{"saveobj"}}{Calls \code{\link{rk.JS.saveobj}} to generate code to save R results in the \code{printout()}
@@ -35,7 +34,6 @@
 #'		Not all options are supported because some don't make sense in this context. Valid options are:
 #'		\code{"summary"}, \code{"usage"}, \code{"sections"}, \code{"settings"}, \code{"related"} and \code{"technical"}.
 #'		If not set, their default values are used. See \code{\link[rkwarddev:rk.rkh.doc]{rk.rkh.doc}} for details.
-
 #' @param overwrite Logical, whether existing files should be replaced. Defaults to \code{FALSE}.
 #' @param tests Logical, whether directories and files for plugin tests should be created.
 #'		Defaults to \code{TRUE}.
@@ -63,7 +61,7 @@
 #' @examples
 #' \dontrun{
 #' # a simple example with only basic information
-#' about.info <- list(
+#' about.info <- rk.XML.about(
 #' 	name="Square the circle",
 #' 	author=c(
 #' 		person(given="E.A.", family="Dölle",
@@ -75,7 +73,7 @@
 #' rk.plugin.skeleton("Square the Circle", about=about.info)
 #' 
 #' # a more complex example, already including some dialog elements
-#' about.info <- list(
+#' about.info <- rk.XML.about(
 #' 	name="Square the circle",
 #' 	author=c(
 #' 		person(given="E.A.", family="Dölle",
@@ -140,15 +138,7 @@
 				about.node <- about
 			}
 		} else {
-			# create an about.node, which probably has some default values
-			about.node <- rk.XML.about(
-				name=about[["name"]],
-				author=about[["author"]],
-				about=about[["about"]],
-				dependencies=about[["dependencies"]],
-				package=about[["package"]],
-				pluginmap=about[["pluginmap"]]
-			)
+			stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
 		}
 	} else {
 		about.node <- NULL
@@ -329,9 +319,10 @@
 	## create DESCRIPTION file
 	if("desc" %in% create){
 		if(isTRUE(checkCreateFiles(description.file))){
-			all.authors <- format(get.by.role(about[["author"]], role="aut"),
+			authors <- XML2person(about.node, eval=TRUE)
+			all.authors <- format(get.by.role(authors, role="aut"),
 				include=c("given", "family", "email"), braces=list(email=c("<", ">")))
-			all.maintainers <- format(get.by.role(about[["author"]], role="cre"),
+			all.maintainers <- format(get.by.role(authors, role="cre"),
 				include=c("given", "family", "email"), braces=list(email=c("<", ">")))
 
 ## TODO: check and add the commented values here:
@@ -343,7 +334,7 @@
 				Version=about.node at attributes[["version"]],
 				Date=about.node at attributes[["releasedate"]],
 				Author=all.authors,
-				AuthorsR=paste(deparse(about[["author"]]), collapse=" "),
+				AuthorsR=XML2person(about.node, eval=FALSE),
 				Maintainer=all.maintainers,
 #				Depends="R (>= 2.9.0)",
 				Enhances="rkward",

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2011-10-07 19:38:33 UTC (rev 3901)
@@ -9,12 +9,10 @@
 \arguments{
   \item{name}{Character string, name of the plugin.}
 
-  \item{about}{Either an object of class \code{XiMpLe.node}
-  to be pasted as the \code{<about>} section, or a list
-  with descriptive information on the plugin,its authors
-  and dependencies. See
+  \item{about}{An object of class \code{XiMpLe.node} to be
+  pasted as the \code{<about>} section, See
   \code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for
-  details! Skipped if \code{NULL}.}
+  details. Skipped if \code{NULL}.}
 
   \item{components}{Either an object of class
   \code{XiMpLe.node} to be pasted as the

Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2011-10-07 15:22:53 UTC (rev 3900)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd	2011-10-07 19:38:33 UTC (rev 3901)
@@ -13,11 +13,11 @@
 \arguments{
   \item{name}{Character sting, name of the plugin package.}
 
-  \item{about}{A list with descriptive information on the
-  plugin, its authors and dependencies. At the very least
-  you must specify \code{name} and \code{author}. See
-  \code{\link[rkwarddev:rk.XML.about]{rk.XML.about}} for
-  details and a full list of elements! If \code{NULL}, no
+  \item{about}{An object of class \code{XiMpLe.node} with
+  descriptive information on the plugin, its authors and
+  dependencies, see
+  \code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for
+  details. Skipped if \code{NULL}. If \code{NULL}, no
   \code{DESCRIPTION} file will be created either.}
 
   \item{path}{Character sting, path to the main directory
@@ -32,7 +32,7 @@
 
   \item{scan}{A character vector to trigger various
   automatic scans of the generated GUI XML file. Valid
-  enties are: \itemize{ \item{\code{"var"}}{Calls
+  enties are: \describe{ \item{\code{"var"}}{Calls
   \code{\link{rk.JS.scan}} to define all needed variables
   in the \code{calculate()} function of the JavaScript
   file. These variables will be added to variables defined
@@ -143,7 +143,7 @@
 \examples{
 \dontrun{
 # a simple example with only basic information
-about.info <- list(
+about.info <- rk.XML.about(
 name="Square the circle",
 author=c(
 person(given="E.A.", family="Dölle",
@@ -155,7 +155,7 @@
 rk.plugin.skeleton("Square the Circle", about=about.info)
 
 # a more complex example, already including some dialog elements
-about.info <- list(
+about.info <- rk.XML.about(
 name="Square the circle",
 author=c(
 person(given="E.A.", family="Dölle",

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