[rkward-cvs] SF.net SVN: rkward:[3985] trunk/rkward/packages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Fri Oct 21 21:36:05 UTC 2011
Revision: 3985
http://rkward.svn.sourceforge.net/rkward/?rev=3985&view=rev
Author: m-eik
Date: 2011-10-21 21:36:05 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
rkwarddev: rk.plugin.skeleton() and rk.plugin.component() lost their "name" options, info is now supplied by "about"
Modified Paths:
--------------
trunk/rkward/packages/rkwarddev/ChangeLog
trunk/rkward/packages/rkwarddev/R/rk-internal.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.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-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/ChangeLog 2011-10-21 21:36:05 UTC (rev 3985)
@@ -1,12 +1,16 @@
ChangeLog for package rkwarddev
## 0.04-2 (2011-10-21)
+ - removed the superfluous "name" option from rk.plugin.skeleton() and rk.plugin.component(); names are now
+ always provided by "about", either as an <about> node or just the name.
- result headers now start at level 1 by default in rk.JS.doc()
+ - added option "suggest.required" to rk.plugin.skeleton() to add package requirements as suggestions,
+ not dependencies
## 0.04-1 (2011-10-20)
- added "about" option to rk.XML.plugin() to overrule pluginmap defaults
- added rk.plugin.component(), i.e. modularized the component generation, to allow for more than one
- component in rk.plugin.skeleton(), wich subsequently gained the new option "components"
+ component in rk.plugin.skeleton(), which subsequently gained the new option "components"
- improved dependency support, rk.plugin.skeleton() writes dependencies from <about> to DESCRIPTION now
- fixed dependency definition in rk.XML.about()
- fixed "verion" typo in rk.XML.about()
Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R 2011-10-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R 2011-10-21 21:36:05 UTC (rev 3985)
@@ -297,7 +297,13 @@
## function XML2dependencies()
# extracts the package dependencies info from XML "about" nodes
-XML2dependencies <- function(node){
+# in "suggest" mode only suggestions will be returned, in "depends" mode only dependencies.
+# suggest=TRUE: Depends: R & RKWard; Suggests: packages
+# suggest=FALSE: Depends: R & RKWard & packages; suggests: none
+XML2dependencies <- function(node, suggest=TRUE, mode="suggest"){
+ if(!isTRUE(suggest) & identical(mode, "suggest")){
+ return("")
+ } else {}
if(inherits(node, "XiMpLe.node")){
# check if this is *really* a about section, otherwise die of boredom
if(!identical(node at name, "about")){
@@ -316,17 +322,17 @@
R.min <- ifelse("R_min_version" %in% deps.RkR.options, paste(">= ", deps.RkR[["R_min_version"]], sep=""), "")
R.max <- ifelse("R_max_version" %in% deps.RkR.options, paste("< ", deps.RkR[["R_max_version"]], sep=""), "")
R.version.indices <- sum(!identical(R.min, ""), !identical(R.max, ""))
- if(R.version.indices > 0){
+ if(R.version.indices > 0 & identical(mode, "depends")){
deps.packages[[length(deps.packages) + 1]] <- paste("R (", R.min, ifelse(R.version.indices > 1, ", ", ""), R.max, ")", sep="")
} else {}
Rk.min <- ifelse("rkward_min_version" %in% deps.RkR.options, paste(">= ", deps.RkR[["rkward_min_version"]], sep=""), "")
Rk.max <- ifelse("rkward_max_version" %in% deps.RkR.options, paste("< ", deps.RkR[["rkward_max_version"]], sep=""), "")
Rk.version.indices <- sum(!identical(Rk.min, ""), !identical(Rk.max, ""))
- if(Rk.version.indices > 0){
+ if(Rk.version.indices > 0 & identical(mode, "depends")){
deps.packages[[length(deps.packages) + 1]] <- paste("rkward (", Rk.min, ifelse(Rk.version.indices > 1, ", ", ""), Rk.max, ")", sep="")
} else {}
check.deps.pckg <- sapply(got.deps at children, function(this.child){identical(this.child at name, "package")})
- if(any(check.deps.pckg)){
+ if(any(check.deps.pckg & ((isTRUE(suggest) & identical(mode, "suggest")) | !isTRUE(suggest)))){
deps.packages[[length(deps.packages) + 1]] <- paste(sapply(which(check.deps.pckg), function(this.pckg){
this.pckg.dep <- got.deps at children[[this.pckg]]@attributes
pckg.options <- names(this.pckg.dep)
@@ -337,14 +343,12 @@
if(version.indices > 0){
pckg.version <- paste(" (", pckg.min, ifelse(version.indices > 1, ", ", ""), pckg.max, ")", sep="")
} else {
- pckg.version <- NULL
+ pckg.version <- ""
}
return(paste(pckg.name, pckg.version, sep=""))
}), collapse=", ")
- results <- paste(unlist(deps.packages), collapse=", ")
- } else {
- results <- ""
- }
+ } else {}
+ results <- paste(unlist(deps.packages), collapse=", ")
} else {
results <- ""
}
Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R 2011-10-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R 2011-10-21 21:36:05 UTC (rev 3985)
@@ -1,9 +1,8 @@
#' Generate RKWard plugin components
#'
-#' @param name Character sting, name of this plugin component.
-#' @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. Only useful for information that differs from the \code{<about>}
-#' section of the \code{.pluginmap} file. Skipped if \code{NULL}.
+#' @param about Either a character string with the name of this plugin component, or an object of class \code{XiMpLe.node}
+#' with further descriptive information on it, like its authors and dependencies (see \code{link[XiMpLe:rk.XML.about]{rk.XML.about}}
+#' for details). This is only useful for information that differs from the \code{<about>} section of the \code{.pluginmap} file.
#' @param xml A named list of options to be forwarded to \code{\link[rkwarddev:rk.XML.plugin]{rk.XML.plugin}}, to generate the GUI XML file.
#' Not all options are supported because some don't make sense in this context. Valid options are:
#' \code{"dialog"}, \code{"wizard"}, \code{"logic"} and \code{"snippets"}.
@@ -62,29 +61,33 @@
#' xml=list(dialog=test.tabbook))
#' }
-rk.plugin.component <- function(name, about=NULL, xml=list(), js=list(), rkh=list(),
+rk.plugin.component <- function(about, xml=list(), js=list(), rkh=list(),
provides=c("logic", "dialog"), scan=c("var", "saveobj", "settings"), hierarchy="test",
pluginmap=NULL, create=c("xml", "js", "rkh"), indent.by="\t"){
- # to besure, remove all non-character symbols from name
- name.orig <- name
- name <- clean.name(name)
- if(!is.null(about)){
- if(inherits(about, "XiMpLe.node")){
- about.node.name <- about at name
- # check if this is *really* a about section, otherwise quit and go dancing
- if(!identical(about.node.name, "about")){
- stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
- } else {
- about.node <- about
- }
+ if(inherits(about, "XiMpLe.node")){
+ about.node.name <- about at name
+ # check if this is *really* a about section, otherwise quit and go dancing
+ if(!identical(about.node.name, "about")){
+ stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
} else {
- stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
+ # fetch the plugin name
+ name <- about at attributes[["name"]]
+ about.node <- about
}
+ } else if(is.character(about) & length(about) == 1) {
+ name <- about
+ about.node <- NULL
+ # also stop creation of DESCRIPTION file
+ create <- create[!create %in% "desc"]
} else {
- about.node <- NULL
+ stop(simpleError("'about' must be a character string or XiMpLe.node, see ?rk.XML.about()!"))
}
+ # to besure, remove all non-character symbols from name
+ name.orig <- name
+ name <- clean.name(name)
+
# check hierarchy
if(is.null(hierarchy)){
hierarchy <- list()
Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R 2011-10-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R 2011-10-21 21:36:05 UTC (rev 3985)
@@ -4,10 +4,9 @@
#' components/dialogs. You should always define one main component (by \code{xml}, \code{js}, \code{rkh} etc.) before you provide
#' additional features by \code{components}.
#'
-#' @param name Character sting, name of the plugin package.
-#' @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 about Either 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), or a character string with the name of the plugin package.
+#' If the latter, no \code{DESCRIPTION} file will be created.
#' @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}.
@@ -52,6 +51,8 @@
#' \item{\code{"desc"}}{Create the \code{DESCRIPTION} file.}
#' }
#' Default is to create all of these files. Existing files will only be overwritten if \code{overwrite=TRUE}.
+#' @param suggest.required Logical, if \code{TRUE} R package dependencies in \code{about} will be added to the \code{Suggests:}
+#' field of the \code{DESCRIPTION} file, otherwise to the \code{Depends:} field.
#' @param edit Logical, if \code{TRUE} RKWard will automatically open the created files for editing, by calling \code{rk.edit.files}.
#' This applies to all files defined in \code{create}.
#' @param load Logical, if \code{TRUE} and \code{"pmap"} in \code{create}, RKWard will automatically add the created .pluginmap file
@@ -74,7 +75,7 @@
#' email="alterego@@eternalwondermaths.example.org", role=c("cre","ctb"))
#' ))
#'
-#' rk.plugin.skeleton("Square the Circle", about=about.info)
+#' rk.plugin.skeleton(about.info)
#'
#' # a more complex example, already including some dialog elements
#' about.info <- rk.XML.about(
@@ -117,39 +118,41 @@
#' test.tabbook <- rk.XML.dialog(rk.XML.tabbook("My Tabbook", tab.labels=c("First Tab",
#' "Second Tab"), children=list(test.checkboxes, test.vars)))
#'
-#' rk.plugin.skeleton("Square the Circle", about=about.info,
-#' xml=list(dialog=test.tabbook), overwrite=TRUE)
+#' rk.plugin.skeleton(about.info, xml=list(dialog=test.tabbook),
+#' overwrite=TRUE)
#' }
-rk.plugin.skeleton <- function(name, about=NULL, path=tempdir(),
+rk.plugin.skeleton <- function(about, path=tempdir(),
provides=c("logic", "dialog"),
scan=c("var", "saveobj", "settings"),
xml=list(), js=list(), pluginmap=list(), rkh=list(),
overwrite=FALSE, tests=TRUE, lazyLoad=TRUE,
- create=c("pmap", "xml", "js", "rkh", "desc"),
+ create=c("pmap", "xml", "js", "rkh", "desc"), suggest.required=TRUE,
components=list(), edit=FALSE, load=FALSE, show=FALSE, indent.by="\t"){
- # to besure, remove all non-character symbols from name
- name.orig <- name
- name <- clean.name(name)
- if(!is.null(about)){
- if(inherits(about, "XiMpLe.node")){
- about.node.name <- about at name
- # check if this is *really* a about section, otherwise quit and go dancing
- if(!identical(about.node.name, "about")){
- stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
- } else {
- about.node <- about
- }
+ if(inherits(about, "XiMpLe.node")){
+ about.node.name <- about at name
+ # check if this is *really* a about section, otherwise quit and go dancing
+ if(!identical(about.node.name, "about")){
+ stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
} else {
- stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
+ # fetch the plugin name
+ name <- about at attributes[["name"]]
+ about.node <- about
}
- } else {
+ } else if(is.character(about) & length(about) == 1) {
+ name <- about
about.node <- NULL
# also stop creation of DESCRIPTION file
create <- create[!create %in% "desc"]
+ } else {
+ stop(simpleError("'about' must be a character string or XiMpLe.node, see ?rk.XML.about()!"))
}
+ # to besure, remove all non-character symbols from name
+ name.orig <- name
+ name <- clean.name(name)
+
# define paths an file names
main.dir <- file.path(path, name)
description.file <- file.path(main.dir, "DESCRIPTION")
@@ -190,7 +193,7 @@
pluginmap[["hierarchy"]] <- eval(formals(rk.XML.pluginmap)[["hierarchy"]])
} else {}
main.component <- rk.plugin.component(
- name=pluginmap[["name"]],
+ about=pluginmap[["name"]],
xml=xml,
js=js,
rkh=rkh,
@@ -324,7 +327,8 @@
Author=all.authors,
AuthorsR=XML2person(about.node, eval=FALSE),
Maintainer=all.maintainers,
- Depends=XML2dependencies(about.node),
+ Depends=XML2dependencies(about.node, suggest=suggest.required, mode="depends"),
+ Suggests=XML2dependencies(about.node, suggest=suggest.required, mode="suggest"),
Enhances="rkward",
Description=about.node at attributes[["shortinfo"]],
License=about.node at attributes[["license"]],
@@ -333,6 +337,12 @@
URL=about.node at attributes[["url"]],
stringsAsFactors=FALSE)
+ for(this.entry in c("Depends","Suggests")){
+ if(desc[[this.entry]] == ""){
+ desc[[this.entry]] <- NULL
+ } else {}
+ }
+
# i have no clue how to circumvent this workaround:
desc$`Authors at R` <- desc[["AuthorsR"]]
desc <- subset(desc, select=-AuthorsR)
Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)
Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd 2011-10-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.component.Rd 2011-10-21 21:36:05 UTC (rev 3985)
@@ -2,23 +2,21 @@
\alias{rk.plugin.component}
\title{Generate RKWard plugin components}
\usage{
- rk.plugin.component(name, about = NULL, xml = list(), js
- = list(), rkh = list(), provides = c("logic", "dialog"),
- scan = c("var", "saveobj", "settings"), hierarchy =
- "test", pluginmap = NULL, create = c("xml", "js", "rkh"),
+ rk.plugin.component(about, xml = list(), js = list(), rkh
+ = list(), provides = c("logic", "dialog"), scan =
+ c("var", "saveobj", "settings"), hierarchy = "test",
+ pluginmap = NULL, create = c("xml", "js", "rkh"),
indent.by = "\t")
}
\arguments{
- \item{name}{Character sting, name of this plugin
- component.}
-
- \item{about}{An object of class \code{XiMpLe.node} with
- descriptive information on the plugin, its authors and
- dependencies, see
+ \item{about}{Either a character string with the name of
+ this plugin component, or an object of class
+ \code{XiMpLe.node} with further descriptive information
+ on it, like its authors and dependencies (see
\code{link[XiMpLe:rk.XML.about]{rk.XML.about}} for
- details. Only useful for information that differs from
- the \code{<about>} section of the \code{.pluginmap} file.
- Skipped if \code{NULL}.}
+ details). This is only useful for information that
+ differs from the \code{<about>} section of the
+ \code{.pluginmap} file.}
\item{xml}{A named list of options to be forwarded to
\code{\link[rkwarddev:rk.XML.plugin]{rk.XML.plugin}}, to
Modified: trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-10-21 11:32:22 UTC (rev 3984)
+++ trunk/rkward/packages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-10-21 21:36:05 UTC (rev 3985)
@@ -2,23 +2,23 @@
\alias{rk.plugin.skeleton}
\title{Generate skeletons for RKWard plugins}
\usage{
- rk.plugin.skeleton(name, about = NULL, path = tempdir(),
- provides = c("logic", "dialog"), scan = c("var",
- "saveobj", "settings"), xml = list(), js = list(),
- pluginmap = list(), rkh = list(), overwrite = FALSE,
- tests = TRUE, lazyLoad = TRUE, create = c("pmap", "xml",
- "js", "rkh", "desc"), components = list(), edit = FALSE,
- load = FALSE, show = FALSE, indent.by = "\t")
+ rk.plugin.skeleton(about, path = tempdir(), provides =
+ c("logic", "dialog"), scan = c("var", "saveobj",
+ "settings"), xml = list(), js = list(), pluginmap =
+ list(), rkh = list(), overwrite = FALSE, tests = TRUE,
+ lazyLoad = TRUE, create = c("pmap", "xml", "js", "rkh",
+ "desc"), suggest.required = TRUE, components = list(),
+ edit = FALSE, load = FALSE, show = FALSE, indent.by =
+ "\t")
}
\arguments{
- \item{name}{Character sting, name of the plugin package.}
-
- \item{about}{An object of class \code{XiMpLe.node} with
- descriptive information on the plugin, its authors and
- dependencies, see
+ \item{about}{Either 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.}
+ details), or a character string with the name of the
+ plugin package. If the latter, no \code{DESCRIPTION} file
+ will be created.}
\item{path}{Character sting, path to the main directory
where the skeleton should be created.}
@@ -114,6 +114,11 @@
these files. Existing files will only be overwritten if
\code{overwrite=TRUE}.}
+ \item{suggest.required}{Logical, if \code{TRUE} R package
+ dependencies in \code{about} will be added to the
+ \code{Suggests:} field of the \code{DESCRIPTION} file,
+ otherwise to the \code{Depends:} field.}
+
\item{edit}{Logical, if \code{TRUE} RKWard will
automatically open the created files for editing, by
calling \code{rk.edit.files}. This applies to all files
@@ -158,7 +163,7 @@
email="alterego at eternalwondermaths.example.org", role=c("cre","ctb"))
))
-rk.plugin.skeleton("Square the Circle", about=about.info)
+rk.plugin.skeleton(about.info)
# a more complex example, already including some dialog elements
about.info <- rk.XML.about(
@@ -201,8 +206,8 @@
test.tabbook <- rk.XML.dialog(rk.XML.tabbook("My Tabbook", tab.labels=c("First Tab",
"Second Tab"), children=list(test.checkboxes, test.vars)))
-rk.plugin.skeleton("Square the Circle", about=about.info,
-xml=list(dialog=test.tabbook), overwrite=TRUE)
+rk.plugin.skeleton(about.info, xml=list(dialog=test.tabbook),
+overwrite=TRUE)
}
}
\seealso{
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