[rkward-cvs] [rkward] packages/rkwarddev: new function R.comment() and docs

m.eik michalke meik.michalke at uni-duesseldorf.de
Mon Dec 1 21:15:54 UTC 2014


Git commit d8bfa11415901055303ad47c04c2169ea65acb1e by m.eik michalke.
Committed on 01/12/2014 at 21:15.
Pushed by meikm into branch 'master'.

new function R.comment() and docs

M  +2    -0    packages/rkwarddev/ChangeLog
M  +3    -1    packages/rkwarddev/DESCRIPTION
M  +2    -0    packages/rkwarddev/NAMESPACE
A  +40   -0    packages/rkwarddev/R/R.comment.R
M  +3    -2    packages/rkwarddev/R/rk-internal.R
M  +1    -1    packages/rkwarddev/R/rkwarddev-package.R
M  +3    -1    packages/rkwarddev/inst/NEWS.Rd
M  +-    --    packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
A  +29   -0    packages/rkwarddev/man/R.comment.Rd
M  +3    -0    packages/rkwarddev/man/i18n.Rd
A  +35   -0    packages/rkwarddev/man/rk.JS.header.Rd
M  +1    -1    packages/rkwarddev/man/rkwarddev-package.Rd

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

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index 73f91a3..fdb6ceb 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -20,12 +20,14 @@ added:
     "comment" or "context" to either produce an i18n comment node or an "i18n_context" attribute
   - new function rk.i18n.comment() to give context for translators
   - new function rk.JS.header() to easily generate JavaScript header code fit for i18n
+  - new function R.comment() to generate JavaScript "comment()" calls
 changed:
   - function i18n() was changed to be used in JavaScript generation only; this breaks code
     using the function introduced with 0.06-4, but that was to be shortlived from the start...
     the i18n features of 0.06-4 will be completely replaced with some proper methods now
   - comment nodes (<!-- foo -->) are now globally allowed as child nodes in XML; important for
     i18n comments
+  - modifier checks now point to rkwarddev:::all.valid.modifiers directly in case of errors
 removed:
   - the functions rk.set.language() rk.get.language() were no longer useful and therefore removed
   - also removed the option "lang" from rk.rkh.doc(), rk.XML.plugin(), rk.XML.pluginmap()
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index 0923ab4..2bd1a58 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -15,7 +15,7 @@ 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.06-6
-Date: 2014-11-30
+Date: 2014-12-01
 Collate:
     '00_class_01_rk.JS.arr.R'
     '00_class_02_rk.JS.var.R'
@@ -26,6 +26,7 @@ Collate:
     'rk.XML.plugin.R'
     'rk.JS.doc.R'
     '00_class_06_rk.plug.comp.R'
+    'R.comment.R'
     'echo.R'
     'i18n.R'
     'id.R'
@@ -35,6 +36,7 @@ Collate:
     'rk.comment.R'
     'rk-internal.R'
     'rk.JS.array.R'
+    'rk.JS.header.R'
     'rk.JS.options.R'
     'rk.JS.optionset.R'
     'rk.JS.saveobj.R'
diff --git a/packages/rkwarddev/NAMESPACE b/packages/rkwarddev/NAMESPACE
index 6d2b03a..fef2ffd 100644
--- a/packages/rkwarddev/NAMESPACE
+++ b/packages/rkwarddev/NAMESPACE
@@ -1,5 +1,6 @@
 # Generated by roxygen2 (4.0.2): do not edit by hand
 
+export(R.comment)
 export(echo)
 export(i18n)
 export(id)
@@ -8,6 +9,7 @@ export(join)
 export(qp)
 export(rk.JS.array)
 export(rk.JS.doc)
+export(rk.JS.header)
 export(rk.JS.options)
 export(rk.JS.optionset)
 export(rk.JS.saveobj)
diff --git a/packages/rkwarddev/R/R.comment.R b/packages/rkwarddev/R/R.comment.R
new file mode 100644
index 0000000..0038e54
--- /dev/null
+++ b/packages/rkwarddev/R/R.comment.R
@@ -0,0 +1,40 @@
+# Copyright 2014 Meik Michalke <meik.michalke at hhu.de>
+#
+# This file is part of the R package rkwarddev.
+#
+# rkwarddev is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# rkwarddev is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rkwarddev.  If not, see <http://www.gnu.org/licenses/>.
+
+#' Create R comment with JavaScript in RKWard plugin code
+#' 
+#' @param ... Character strings to form a comment.
+#' @param indent.by A character string defining the indentation string to use. Note that
+#'    backslashes need to be escaped (e.g. \code{"\\t"} to produce \code{"\t"}).
+#' @param level Integer, which indentation level to use in the resulting R code, minimum is 1.
+#' @param newline Character string, can be set to e.g. \code{"\n"} to force a newline after the call.
+#' @return A character string.
+#' @export
+#' @examples
+#' cat(R.comment("This will become an R comment"))
+
+R.comment <- function(..., indent.by="\\t", level=2, newline=""){
+  message <- paste0(list(...), collapse=" ")
+  if(level > 1){
+    indentation <- paste0(", \"", rep(indent.by, level-1), "\"")
+  } else {
+    indentation <- ""
+  }
+  result <- paste0("comment(\"", message, "\"", indentation, ");", newline)
+
+  return(result)
+}
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index c409dea..b10fa37 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -656,7 +656,7 @@ all.valid.modifiers <- list(
   input=c("text"),
   formula=c("model", "table", "labels", "fixed_factors", "dependent"),
   matrix=c("rows", "columns", "tsv", "cbind"), # TODO: missing a solution for 1,2,3,... here
-  # option=c(),
+  option=c("enabled"),
   optionset=c("row_count", "current_row", "optioncolumn_ids"),
   preview=c("state", "state.not", "state.numeric"),
   radio=c("string", "number"),
@@ -711,7 +711,8 @@ modif.validity <- function(source, modifier, ignore.empty=TRUE, warn.only=TRUE,
   if(any(invalid.modif)){
     if(isTRUE(warn.only)){
       warning(paste0("Some modifier you provided is invalid for '",tag.name,"' and was ignored: ",
-        paste(modifier[invalid.modif], collapse=", ")), call.=FALSE)
+        paste(modifier[invalid.modif], collapse=", "), "\n",
+        "For a list of valid modifiers see rkwarddev:::all.valid.modifiers"), call.=FALSE)
       if(isTRUE(bool)){
         return(!invalid.modif)
       } else {
diff --git a/packages/rkwarddev/R/rkwarddev-package.R b/packages/rkwarddev/R/rkwarddev-package.R
index 48a6d7b..afc4a14 100644
--- a/packages/rkwarddev/R/rkwarddev-package.R
+++ b/packages/rkwarddev/R/rkwarddev-package.R
@@ -4,7 +4,7 @@
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
 #' Version: \tab 0.06-6\cr
-#' Date: \tab 2014-11-30\cr
+#' Date: \tab 2014-12-01\cr
 #' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr
diff --git a/packages/rkwarddev/inst/NEWS.Rd b/packages/rkwarddev/inst/NEWS.Rd
index ac6502b..7cad0ab 100644
--- a/packages/rkwarddev/inst/NEWS.Rd
+++ b/packages/rkwarddev/inst/NEWS.Rd
@@ -1,7 +1,7 @@
 \name{NEWS}
 \title{News for Package 'rkwarddev'}
 \encoding{UTF-8}
-\section{Changes in rkwarddev version 0.06-6 (2014-11-30)}{
+\section{Changes in rkwarddev version 0.06-6 (2014-12-01)}{
   \subsection{fixed}{
     \itemize{
       \item \code{rk.XML.optionset()} does now allow to re-use objects defined in the same
@@ -24,6 +24,8 @@
       \item new attribute \code{"i18n"} added to several XML functions; it takes a list with the named arguments
         \code{"comment"} or \code{"context"} to either produce an i18n comment node or an \code{"i18n_context"} attribute
       \item new function \code{rk.i18n.comment()} to give context for translators
+      \item new function \code{rk.JS.header()} to easily generate JavaScript header code fit for i18n
+      \item new function \code{R.comment()} to generate JavaScript "\code{comment()}" calls
     }
   }
   \subsection{changed}{
diff --git a/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf b/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
index e1dcc32..c73a2f0 100644
Binary files a/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf and b/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf differ
diff --git a/packages/rkwarddev/man/R.comment.Rd b/packages/rkwarddev/man/R.comment.Rd
new file mode 100644
index 0000000..f618751
--- /dev/null
+++ b/packages/rkwarddev/man/R.comment.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{R.comment}
+\alias{R.comment}
+\title{Create R comment with JavaScript in RKWard plugin code}
+\usage{
+R.comment(message, indent.by = "\\\\t", level = 2, newline = "")
+}
+\arguments{
+\item{message}{}
+
+\item{indent.by}{A character string defining the indentation string to use. Note that
+backslashes need to be escaped (e.g. \code{"\\t"} to produce \code{"\t"}).}
+
+\item{level}{Integer, which indentation level to use in the resulting R code,
+      minimum is 1.}
+
+\item{newline}{Character string,
+      can be set to e.g. \code{"\n"} to force a newline after the call.}
+}
+\value{
+A character string.
+}
+\description{
+Create R comment with JavaScript in RKWard plugin code
+}
+\examples{
+cat(R.comment("This will become an R comment"))
+}
+
diff --git a/packages/rkwarddev/man/i18n.Rd b/packages/rkwarddev/man/i18n.Rd
index 217ccf0..bf9cc14 100644
--- a/packages/rkwarddev/man/i18n.Rd
+++ b/packages/rkwarddev/man/i18n.Rd
@@ -22,6 +22,9 @@ placeholder, and the first one has to represent an integer value in the dialog.}
 \item{newline}{Character string,
       can be set to e.g. \code{"\n"} to force a newline after the call.}
 }
+\value{
+An object of class \code{rk.JS.i18n}.
+}
 \description{
 Similar to \code{\link[rkwarddev:echo]{echo}}, this function should help you to write
 your JavaScript portions in R. Depending on the provided values for its arguments,
diff --git a/packages/rkwarddev/man/rk.JS.header.Rd b/packages/rkwarddev/man/rk.JS.header.Rd
new file mode 100644
index 0000000..16503e6
--- /dev/null
+++ b/packages/rkwarddev/man/rk.JS.header.Rd
@@ -0,0 +1,35 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{rk.JS.header}
+\alias{rk.JS.header}
+\title{Generate JavaScript header object}
+\usage{
+rk.JS.header(title, ..., level = NULL, guess.getter = FALSE)
+}
+\arguments{
+\item{title}{Either a character string or object of class \code{rk.JS.i18n}. Will become the header title,
+nested in an i18n() call.}
+
+\item{...}{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
+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.}
+
+\item{guess.getter}{Locigal,
+      if \code{TRUE} try to get a good default getter function for JavaScript
+variable values.}
+}
+\value{
+A character string.
+}
+\description{
+Generate JavaScript header object
+}
+\examples{
+my.cbox <- rk.XML.cbox("This is a test")
+rk.JS.header("Test results", addFromUI=my.cbox)
+}
+
diff --git a/packages/rkwarddev/man/rkwarddev-package.Rd b/packages/rkwarddev/man/rkwarddev-package.Rd
index edc862d..e68a34f 100644
--- a/packages/rkwarddev/man/rkwarddev-package.Rd
+++ b/packages/rkwarddev/man/rkwarddev-package.Rd
@@ -11,7 +11,7 @@ A collection of tools for RKWard plugin development.
 Package: \tab rkwarddev\cr
 Type: \tab Package\cr
 Version: \tab 0.06-6\cr
-Date: \tab 2014-11-30\cr
+Date: \tab 2014-12-01\cr
 Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 Enhances: \tab rkward\cr
 Encoding: \tab UTF-8\cr




More information about the rkward-tracker mailing list