[rkward] packages/rkwarddev: improvements to plugin2script()

m.eik michalke meik.michalke at uni-duesseldorf.de
Thu Oct 8 14:20:31 UTC 2015


Git commit 3b691e42977075a23bc2cb0cf3115a61c64880c5 by m.eik michalke.
Committed on 08/10/2015 at 14:20.
Pushed by meikm into branch 'master'.

improvements to plugin2script()

  - now also takes connections and file paths as input
  - escaping quotes in text nodes

M  +7    -6    packages/rkwarddev/ChangeLog
M  +5    -4    packages/rkwarddev/DESCRIPTION
M  +33   -2    packages/rkwarddev/R/01_methods_01_plugin2script.R
M  +1    -1    packages/rkwarddev/R/rkwarddev-package.R
M  +7    -3    packages/rkwarddev/inst/NEWS.Rd
M  +-    --    packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
M  +16   -2    packages/rkwarddev/man/XiMpLe-methods.Rd
M  +1    -3    packages/rkwarddev/man/rk.XML.text.Rd
M  +1    -1    packages/rkwarddev/man/rkwarddev-package.Rd

http://commits.kde.org/rkward/3b691e42977075a23bc2cb0cf3115a61c64880c5

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index f040db0..47a35c0 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -1,16 +1,17 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.07-4 (2015-10-07)
+changes in version 0.07-4 (2015-10-08)
 unreleased:
   - this version is under development
 fixed:
   - attribute "max_precision" in <spinbox> was misspelled
-  - rk.XML.connect() still handled modifiers for "governor" wrong if it wasn't
-    a XiMpLe node
-  - also fixed how rk.XML.convert() and rk.XML.switch() were handling modifier checking
+  - rk.XML.connect() still handled modifiers for "governor" wrong if it
+    wasn't a XiMpLe node
+  - also fixed how rk.XML.convert() and rk.XML.switch() were handling
+    modifier checking
 added:
-  - new methods plugin2script() to try to translate raw plugin XML
-    into working rkwarddev script calls
+  - new methods plugin2script() to try to translate raw plugin XML into
+    working rkwarddev script calls
 
 changes in version 0.07-3 (2015-06-29)
 fixed:
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index ac5c963..a4b8ec7 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -8,15 +8,16 @@ Depends:
 Suggests:
     testthat
 Enhances: rkward
-Description: Provides functions to create plugin skeletons and XML structures
-    for RKWard.
+Description: Provides functions to create plugin skeletons and XML
+    structures for RKWard.
 License: GPL (>= 3)
 Encoding: UTF-8
 LazyLoad: yes
 URL: https://rkward.kde.org
-Authors at R: c(person(given="m.eik", family="michalke", email="meik.michalke at hhu.de", role=c("aut", "cre")))
+Authors at R: c(person(given="m.eik", family="michalke",
+        email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.07-4
-Date: 2015-10-04
+Date: 2015-10-08
 Collate:
     '00_class_01_rk.JS.arr.R'
     '00_class_02_rk.JS.var.R'
diff --git a/packages/rkwarddev/R/01_methods_01_plugin2script.R b/packages/rkwarddev/R/01_methods_01_plugin2script.R
index af9ed72..cfad3c8 100644
--- a/packages/rkwarddev/R/01_methods_01_plugin2script.R
+++ b/packages/rkwarddev/R/01_methods_01_plugin2script.R
@@ -25,12 +25,16 @@
 #' properly into a useful script.
 #' 
 #' You can either use a full XML document (read with \code{\link[XiMpLe:parseXMLTree]{parseXMLTree}})
-#' or single (also nested) XiMpLe XML nodes.
+#' or single (also nested) XiMpLe XML nodes. If you provide a character string, it is assumed to be
+#' the full path to a document to be parsed with \code{parseXMLTree} and then analysed. Connections
+#' are also accepted.
 #' 
-#' @note The methods will probably fail, especially with highly complex plugins. Try to break these
+#' @note The methods might fail, especially with highly complex plugins. Try to break these
 #' into sensible chunks and try those speparately. Sometimes, slightly changing the input file
 #' might also do the trick to get some usable results.
 #'
+#' @param obj Either a character vector (path to a plugin XML file to parse), a connection, an already
+#'    parsed XML tree (class \code{XiMpLe.doc}) or a single \code{XiMpLe.node} object.
 #' @export
 #' @docType methods
 #' @return Either a character vector (if \code{obj} is a single XML node)
@@ -99,6 +103,31 @@ setMethod("plugin2script",
   }
 )
 
+#' @export
+#' @docType methods
+#' @rdname XiMpLe-methods
+#' @aliases plugin2script,character-method
+#' @import XiMpLe
+setMethod("plugin2script",
+  signature(obj="character"),
+  function(obj) {
+    XML.tree <- parseXMLTree(obj)
+    return(plugin2script(XML.tree))
+  }
+)
+
+#' @export
+#' @docType methods
+#' @rdname XiMpLe-methods
+#' @aliases plugin2script,connection-method
+#' @import XiMpLe
+setMethod("plugin2script",
+  signature(obj="connection"),
+  function(obj) {
+    XML.tree <- parseXMLTree(obj)
+    return(plugin2script(XML.tree))
+  }
+)
 
 ## internal functions and objects
 
@@ -375,6 +404,8 @@ p2s <- function(node, indent=TRUE, level=1, prefix="rkdev", drop.defaults=TRUE){
   if(isTRUE(checkText)){
     nodeChildren <- XMLValue(XMLChildren(node)[[1]])
     if(inherits(nodeChildren, "character")){
+      # do some escaping
+      nodeChildren <- gsub("([^\\\\])\"" , "\\1\\\\\\\"", nodeChildren, perl=TRUE)
       rkwdevOptions[[rkwdevText]] <- paste0("\"", nodeChildren, "\"", collapse=" ")
     } else {}
   } else {}
diff --git a/packages/rkwarddev/R/rkwarddev-package.R b/packages/rkwarddev/R/rkwarddev-package.R
index 8c6cc3e..d5b9a90 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.07-4\cr
-#' Date: \tab 2015-10-04\cr
+#' Date: \tab 2015-10-08\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 53f613d..bce56d0 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.07-4 (2015-10-04)}{
+\section{Changes in rkwarddev version 0.07-4 (2015-10-08)}{
   \subsection{unreleased}{
     \itemize{
       \item this version is under development
@@ -10,12 +10,16 @@
   \subsection{fixed}{
     \itemize{
       \item attribute \code{"max_precision"} in <spinbox> was misspelled
+      \item \code{rk.XML.connect()} still handled modifiers for \code{"governor"} wrong if it
+        wasn't a XiMpLe node
+      \item also fixed how \code{rk.XML.convert()} and \code{rk.XML.switch()} were handling
+        modifier checking
     }
   }
   \subsection{added}{
     \itemize{
-      \item new methods \code{plugin2script()} to try to translate raw plugin XML
-        into working rkwarddev script calls
+      \item new methods \code{plugin2script()} to try to translate raw plugin XML into
+        working rkwarddev script calls
     }
   }
 }
diff --git a/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf b/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
index 64f99e7..d60fe17 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/XiMpLe-methods.Rd b/packages/rkwarddev/man/XiMpLe-methods.Rd
index d19170b..5491842 100644
--- a/packages/rkwarddev/man/XiMpLe-methods.Rd
+++ b/packages/rkwarddev/man/XiMpLe-methods.Rd
@@ -5,6 +5,8 @@
 \alias{plugin2script}
 \alias{plugin2script,XiMpLe.doc-method}
 \alias{plugin2script,XiMpLe.node-method}
+\alias{plugin2script,character-method}
+\alias{plugin2script,connection-method}
 \title{Generate script code from XML objects}
 \usage{
 plugin2script(obj)
@@ -12,6 +14,15 @@ plugin2script(obj)
 \S4method{plugin2script}{XiMpLe.doc}(obj)
 
 \S4method{plugin2script}{XiMpLe.node}(obj)
+
+\S4method{plugin2script}{character}(obj)
+
+\S4method{plugin2script}{connection}(obj)
+}
+\arguments{
+\item{obj}{Either a character vector (path to a plugin XML file to parse), a connection,
+      an already
+parsed XML tree (class \code{XiMpLe.doc}) or a single \code{XiMpLe.node} object.}
 }
 \value{
 Either a character vector (if \code{obj} is a single XML node)
@@ -29,10 +40,13 @@ into \code{rkwarddev} scripts. The generated output should not be used as-is,
 properly into a useful script.
 
 You can either use a full XML document (read with \code{\link[XiMpLe:parseXMLTree]{parseXMLTree}})
-or single (also nested) XiMpLe XML nodes.
+or single (also nested) XiMpLe XML nodes. If you provide a character string,
+      it is assumed to be
+the full path to a document to be parsed with \code{parseXMLTree} and then analysed. Connections
+are also accepted.
 }
 \note{
-The methods will probably fail, especially with highly complex plugins. Try to break these
+The methods might fail, especially with highly complex plugins. Try to break these
 into sensible chunks and try those speparately. Sometimes,
       slightly changing the input file
 might also do the trick to get some usable results.
diff --git a/packages/rkwarddev/man/rk.XML.text.Rd b/packages/rkwarddev/man/rk.XML.text.Rd
index b9b8ca2..46e0ea5 100644
--- a/packages/rkwarddev/man/rk.XML.text.Rd
+++ b/packages/rkwarddev/man/rk.XML.text.Rd
@@ -16,9 +16,7 @@ If \code{"auto"}, an ID will be generated automatically from \code{text}.
 If \code{NULL}, no ID will be given.}
 
 \item{i18n}{Either a character string or a named list with the optional elements \code{context}
-or \code{comment},
-      to give some \code{i18n_context} information for this node. If set to \code{FALSE},
-the attribute \code{label} will be renamed into \code{noi18n_label}.}
+or \code{comment}, to give some \code{i18n_context} information for this node.}
 }
 \value{
 An object of class \code{XiMpLe.node}.
diff --git a/packages/rkwarddev/man/rkwarddev-package.Rd b/packages/rkwarddev/man/rkwarddev-package.Rd
index b5ea0e4..53a1886 100644
--- a/packages/rkwarddev/man/rkwarddev-package.Rd
+++ b/packages/rkwarddev/man/rkwarddev-package.Rd
@@ -12,7 +12,7 @@ A Collection of Tools for RKWard Plugin Development.
 Package: \tab rkwarddev\cr
 Type: \tab Package\cr
 Version: \tab 0.07-4\cr
-Date: \tab 2015-10-04\cr
+Date: \tab 2015-10-08\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