[rkward] packages/XiMpLe: fixed indentation

m.eik michalke meik.michalke at uni-duesseldorf.de
Mon Nov 16 15:14:42 UTC 2015


Git commit c88e9607bc71395bf287709f3b608904cd5d58f1 by m.eik michalke.
Committed on 16/11/2015 at 15:16.
Pushed by meikm into branch 'master'.

fixed indentation

  - well, hopefully so... but it looks much better already!

M  +3    -2    packages/XiMpLe/ChangeLog
M  +2    -2    packages/XiMpLe/DESCRIPTION
M  +1    -1    packages/XiMpLe/NAMESPACE
M  +4    -7    packages/XiMpLe/R/XiMpLe-internal.R
M  +52   -50   packages/XiMpLe/R/pasteXMLTag.R
M  +4    -1    packages/XiMpLe/inst/NEWS.Rd
M  +-    --    packages/XiMpLe/inst/doc/XiMpLe_vignette.pdf
M  +3    -2    packages/XiMpLe/man/XMLGetters-methods.Rd
M  +1    -1    packages/XiMpLe/man/XMLNode.Rd
M  +3    -2    packages/XiMpLe/man/XMLTree.Rd
M  +1    -1    packages/XiMpLe/man/XiMpLe-package.Rd
M  +3    -2    packages/XiMpLe/man/node.Rd
M  +1    -1    packages/XiMpLe/man/parseXMLTree.Rd
M  +2    -2    packages/XiMpLe/man/pasteXML-methods.Rd
M  +1    -1    packages/XiMpLe/man/pasteXMLTag.Rd
M  +1    -1    packages/XiMpLe/man/show-methods.Rd

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

diff --git a/packages/XiMpLe/ChangeLog b/packages/XiMpLe/ChangeLog
index 9ce3f1d..d516f14 100644
--- a/packages/XiMpLe/ChangeLog
+++ b/packages/XiMpLe/ChangeLog
@@ -1,6 +1,6 @@
 ChangeLog for package XiMpLe
 
-changes in version 0.03-23 (2015-10-11)
+changes in version 0.03-23 (2015-11-16)
 unreleased:
   - this release is under development
 changed:
@@ -9,7 +9,8 @@ fixed:
   - XMLScanDeep() was said to examine node names, children and values as well
     as attributes, but in fact it was hard-wired on attributes only. removed
     children from the list and added support for names and values
-  - corrected internal function setMinIndent() for better indentation for comments
+  - corrected internal function setMinIndent() and pasteXMLTag() for better
+    indentation for comments
   - internal function indent() can now handle negative levels
 
 changes in version 0.03-22 (2014-12-02)
diff --git a/packages/XiMpLe/DESCRIPTION b/packages/XiMpLe/DESCRIPTION
index fe23647..decfe74 100644
--- a/packages/XiMpLe/DESCRIPTION
+++ b/packages/XiMpLe/DESCRIPTION
@@ -19,7 +19,7 @@ LazyLoad: yes
 URL: http://reaktanz.de/?c=hacking&s=XiMpLe
 Authors at R: c(person(given="Meik", family="Michalke", email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.03-23
-Date: 2015-10-11
+Date: 2015-11-16
 Collate:
     '00_class_01_XiMpLe.node.R'
     '00_class_02_XiMpLe.doc.R'
@@ -29,8 +29,8 @@ Collate:
     '01_method_03_show.R'
     'XMLNode.R'
     'XMLTree.R'
-    'XiMpLe-internal.roxy.all.R'
     'XiMpLe-package.R'
     'parseXMLTree.R'
     'pasteXMLTag.R'
     'zzz_is_get_utils.R'
+RoxygenNote: 5.0.1
diff --git a/packages/XiMpLe/NAMESPACE b/packages/XiMpLe/NAMESPACE
index 464dff6..7fc7573 100644
--- a/packages/XiMpLe/NAMESPACE
+++ b/packages/XiMpLe/NAMESPACE
@@ -1,4 +1,4 @@
-# Generated by roxygen2 (4.1.1): do not edit by hand
+# Generated by roxygen2: do not edit by hand
 
 export("XMLAttrs<-")
 export("XMLChildren<-")
diff --git a/packages/XiMpLe/R/XiMpLe-internal.R b/packages/XiMpLe/R/XiMpLe-internal.R
index 6f576de..b0490b5 100644
--- a/packages/XiMpLe/R/XiMpLe-internal.R
+++ b/packages/XiMpLe/R/XiMpLe-internal.R
@@ -142,16 +142,13 @@ XML.single.tags <- function(tree, drop=NULL){
 ## function setMinIndent()
 # takes a string, determines the minimum number of grouped \t strings,
 # and adjusts it globally to the given level
-setMinIndent <- function(tag, level=1, indent.by="\t", shine=0){
-  if(shine > 0){
-    tag <- gsub("\n([^\t])", paste0("\n",indent.by,"\\1"), tag, perl=TRUE)
-  } else {}
-  currentMinIndent <- min(nchar(unlist(strsplit(tag, "[^\t]+"), use.names=FALSE)))
+setMinIndent <- function(tag, level=1, indent.by="\t"){
+  currentMinIndent <- min(nchar(unlist(strsplit(tag, "[^\t ]+"), use.names=FALSE)))
   indentDiff <- currentMinIndent - level
   tagParts <- unlist(strsplit(tag, "\n"))
   # if currentMinIndent is greater than level, reduce indentation
   if(indentDiff > 0){
-    tagParts <- gsub(paste0("(^|\n)(\t){", indentDiff, "}"), "\\1", tagParts, perl=TRUE)
+    tagParts <- gsub(paste0("(^|\n)([\t ]){", indentDiff+1, "}"), "\\1", tagParts, perl=TRUE)
   } else if(indentDiff < 0){
     tagParts <- paste0(indent(level=level, by=indent.by), tagParts)
   } else {}
@@ -257,7 +254,7 @@ parseXMLAttr <- function(tag){
     separated.tag <- gsub("( ,)?([^[:space:],\"]*)=\"", "\\1\"\\2\"=\"", separated.tag, perl=TRUE)
     ###################################################################################
     ## TODO:
-    ## empty attributes are not valid, force them into atrribute="attribute"
+    ## empty attributes are not valid, force them into attribute="attribute"
     ## does only work partially it the empty attribute is the last in line
     ## and still causes *problems* in matching string in the value of other attributes!
     # separated.tag <- gsub("(, |\\A)([^[:space:],\"=][[:alnum:]]*)", "\\1\"\\2\"=\"\\2\"", separated.tag, perl=TRUE)
diff --git a/packages/XiMpLe/R/pasteXMLTag.R b/packages/XiMpLe/R/pasteXMLTag.R
index 0b7d408..95d3549 100644
--- a/packages/XiMpLe/R/pasteXMLTag.R
+++ b/packages/XiMpLe/R/pasteXMLTag.R
@@ -77,62 +77,64 @@ pasteXMLTag <- function(tag, attr=NULL, child=NULL, empty=TRUE, level=1, allow.e
   if(isTRUE(nchar(tag) == 0) | length(tag) == 0){
     if(isTRUE(tidy)){
       child <- trim(child)
-      child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=level, indent.by=indent.by, shine=shine)))
+      child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=2, indent.by=indent.by)))
     }
     full.tag <- paste0(child, " ")
   } else {
-  switch(tag,
-    "!--"={
-      # clean up value if needed
-      if(!is.null(child)){
-        if(isTRUE(tidy)){
+    switch(tag,
+     "!--"={
+       # clean up value if needed
+       if(!is.null(child)){
+         if(isTRUE(tidy)){
+           child <- trim(child)
+           child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=level, indent.by=indent.by)))
+         }
+       } else {}
+       full.tag <- paste0(new.indent, "<!-- ", new.attr, new.cmmt.indent,
+         child, " ", new.attr, new.attr.indent,
+         "-->", new.node)
+       },
+     "![CDATA["={
+       # clean up value if needed
+       if(!is.null(child)){
           child <- trim(child)
-          child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=level, indent.by=indent.by, shine=shine)))
-        }
-      } else {}
-      full.tag <- paste0(new.indent, "<!-- ", new.attr, new.cmmt.indent,
-        child, " ", new.attr, new.attr.indent,
-        "-->", new.node)},
-    "![CDATA["={
-      # clean up value if needed
-      if(!is.null(child)){
-        child <- trim(child)
-        if(isTRUE(tidy)){
-          child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by))
-        }
-      } else {}
-      full.tag <- paste0(new.indent, "<![CDATA[ ", new.cmmt, comment.indent,
-        child, " ", new.cmmt, new.indent,
-        "]]>", new.node)},
-    "*![CDATA["={
-      # clean up value if needed
-      if(!is.null(child)){
-        child <- trim(child)
-        if(isTRUE(tidy)){
-          child <- gsub("\n", new.cmmt, setMinIndent(child, level=level, indent.by=indent.by))
+          if(isTRUE(tidy)){
+            child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=level, indent.by=indent.by)))
+          }
+        } else {}
+        full.tag <- paste0(new.indent, "<![CDATA[ ", new.cmmt, comment.indent,
+          child, " ", new.cmmt, new.indent,
+          "]]>", new.node)},
+      "*![CDATA["={
+        # clean up value if needed
+        if(!is.null(child)){
+          child <- trim(child)
+          if(isTRUE(tidy)){
+            child <- gsub("\n", new.cmmt, trim(setMinIndent(child, level=level, indent.by=indent.by)))
+          }
+        } else {}
+        # 
+        full.tag <- paste0(new.indent, "/* <![CDATA[ */ ", new.cmmt, comment.indent,
+          child, " ", new.cmmt, new.indent,
+          "/* ]]> */", new.node)},
+      # last but not least, the default value
+      {
+        # only put attributes in new lines if there's more than one
+        new.attr <- ifelse((length(attr) > 1), new.attr, "")
+        new.attr.indent <- ifelse((length(attr) > 1), new.attr.indent, "")
+        new.cmmt.indent <- ifelse((length(attr) > 1), new.cmmt.indent, "")
+        val.indent <- ifelse(shine > 0, indent(level + 1, by=indent.by), "")
+        # empty decides whether this is a empty tag or a pair of start and end tags
+        if(isTRUE(empty)){
+          full.tag <- paste0(new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, " />", new.node)
+        } else {
+          full.tag <- paste0(
+            new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, ">", new.node,
+            if(!is.null(child)){paste0(val.indent, trim(child), new.node)},
+            new.indent, "</", tag, ">", new.node)
         }
-      } else {}
-      # 
-      full.tag <- paste0(new.indent, "/* <![CDATA[ */ ", new.cmmt, comment.indent,
-        child, " ", new.cmmt, new.indent,
-        "/* ]]> */", new.node)},
-    # last but not least, the default value
-    {
-      # only put attributes in new lines if there's more than one
-      new.attr <- ifelse((length(attr) > 1), new.attr, "")
-      new.attr.indent <- ifelse((length(attr) > 1), new.attr.indent, "")
-      new.cmmt.indent <- ifelse((length(attr) > 1), new.cmmt.indent, "")
-      val.indent <- ifelse(shine > 0, indent(level + 1, by=indent.by), "")
-      # empty decides whether this is a empty tag or a pair of start and end tags
-      if(isTRUE(empty)){
-        full.tag <- paste0(new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, " />", new.node)
-      } else {
-        full.tag <- paste0(
-          new.indent, "<", tag, attr.space, new.attr, new.cmmt.indent, all.attributes, new.attr, new.attr.indent, ">", new.node,
-          if(!is.null(child)){paste0(val.indent, trim(child), new.node)},
-          new.indent, "</", tag, ">", new.node)
       }
-    })
+    )
   }
   return(full.tag)
 }
diff --git a/packages/XiMpLe/inst/NEWS.Rd b/packages/XiMpLe/inst/NEWS.Rd
index f615ba6..997322a 100644
--- a/packages/XiMpLe/inst/NEWS.Rd
+++ b/packages/XiMpLe/inst/NEWS.Rd
@@ -1,7 +1,7 @@
 \name{NEWS}
 \title{News for Package 'XiMpLe'}
 \encoding{UTF-8}
-\section{Changes in XiMpLe version 0.03-23 (2015-10-11)}{
+\section{Changes in XiMpLe version 0.03-23 (2015-11-16)}{
   \subsection{unreleased}{
     \itemize{
       \item this release is under development
@@ -17,6 +17,9 @@
       \item \code{XMLScanDeep()} was said to examine node names, children and values as well
         as attributes, but in fact it was hard-wired on attributes only. removed
         children from the list and added support for names and values
+      \item corrected internal function \code{setMinIndent()} and \code{pasteXMLTag()} for better
+        indentation for comments
+      \item internal function \code{indent()} can now handle negative levels
     }
   }
 }
diff --git a/packages/XiMpLe/inst/doc/XiMpLe_vignette.pdf b/packages/XiMpLe/inst/doc/XiMpLe_vignette.pdf
index 95a1208..168705f 100644
Binary files a/packages/XiMpLe/inst/doc/XiMpLe_vignette.pdf and b/packages/XiMpLe/inst/doc/XiMpLe_vignette.pdf differ
diff --git a/packages/XiMpLe/man/XMLGetters-methods.Rd b/packages/XiMpLe/man/XMLGetters-methods.Rd
index 12187d2..6801be3 100644
--- a/packages/XiMpLe/man/XMLGetters-methods.Rd
+++ b/packages/XiMpLe/man/XMLGetters-methods.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/zzz_is_get_utils.R
 \docType{methods}
 \name{XMLName}
@@ -183,7 +183,8 @@ Another special method can scan a node/document tree object for appearances of n
 }
 
 Finally,
-      there is a method to scan for certain values in XiMpLe objects and just list them. For instance, it can be used to
+      there is a method to scan for certain values in XiMpLe objects and just list them. For instance,
+      it can be used to
 list all instances of a certain attribute type in a document tree:
 
 \itemize{
diff --git a/packages/XiMpLe/man/XMLNode.Rd b/packages/XiMpLe/man/XMLNode.Rd
index 9e3aee4..dfa3ce8 100644
--- a/packages/XiMpLe/man/XMLNode.Rd
+++ b/packages/XiMpLe/man/XMLNode.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/XMLNode.R, R/zzz_is_get_utils.R
 \name{XMLNode}
 \alias{XMLNode}
diff --git a/packages/XiMpLe/man/XMLTree.Rd b/packages/XiMpLe/man/XMLTree.Rd
index bb650b3..a9954bc 100644
--- a/packages/XiMpLe/man/XMLTree.Rd
+++ b/packages/XiMpLe/man/XMLTree.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/XMLTree.R, R/zzz_is_get_utils.R
 \name{XMLTree}
 \alias{XMLTree}
@@ -18,7 +18,8 @@ which are treated as simple text values.}
       no checking is done.}
 
 \item{dtd}{A named list,
-      doctype definition of the XML tree. Valid elements are \code{doctype} (root element), \code{decl}
+      doctype definition of the XML tree. Valid elements are \code{doctype} (root element),
+      \code{decl}
 ("PUBLIC" or "SYSTEM"), \code{id} (the identifier) and \code{refer} (URI to .dtd).
    Currently just pasted, no checking is done.}
 
diff --git a/packages/XiMpLe/man/XiMpLe-package.Rd b/packages/XiMpLe/man/XiMpLe-package.Rd
index 93885db..27e5fcd 100644
--- a/packages/XiMpLe/man/XiMpLe-package.Rd
+++ b/packages/XiMpLe/man/XiMpLe-package.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/XiMpLe-package.R
 \docType{package}
 \name{XiMpLe-package}
diff --git a/packages/XiMpLe/man/node.Rd b/packages/XiMpLe/man/node.Rd
index fe50966..b3137c3 100644
--- a/packages/XiMpLe/man/node.Rd
+++ b/packages/XiMpLe/man/node.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/01_method_02_node.R
 \docType{methods}
 \name{node}
@@ -34,7 +34,8 @@ node(obj, node = list(), what = NULL, cond.attr = NULL,
 the child of its previous element. duplicate matches will be returned as a list.}
 
 \item{what}{A character string,
-      must be a valid slot name of class \code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}}, like
+      must be a valid slot name of class \code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}},
+      like
 \code{"attributes"} or \code{"value"}. If not \code{NULL},
       only that part of a node will be returned.
 There's also two special properties for this option: \code{what="@path"} will not return the
diff --git a/packages/XiMpLe/man/parseXMLTree.Rd b/packages/XiMpLe/man/parseXMLTree.Rd
index 1e7cd97..11fb967 100644
--- a/packages/XiMpLe/man/parseXMLTree.Rd
+++ b/packages/XiMpLe/man/parseXMLTree.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/parseXMLTree.R
 \name{parseXMLTree}
 \alias{parseXMLTree}
diff --git a/packages/XiMpLe/man/pasteXML-methods.Rd b/packages/XiMpLe/man/pasteXML-methods.Rd
index b9f5426..bb0b331 100644
--- a/packages/XiMpLe/man/pasteXML-methods.Rd
+++ b/packages/XiMpLe/man/pasteXML-methods.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/01_method_01_pasteXML.R
 \docType{methods}
 \name{pasteXML}
@@ -49,7 +49,7 @@ The functions pasteXMLNode() and pasteXMLTree() have been replaced by the pasteX
    They should no longer be used.
 }
 \seealso{
-\code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}},
+\code{\link[XiMpLe:XiMpLe.node-class]{XiMpLe.node}}, 
    \code{\link[XiMpLe:XiMpLe.doc-class]{XiMpLe.doc}}
 }
 \keyword{methods}
diff --git a/packages/XiMpLe/man/pasteXMLTag.Rd b/packages/XiMpLe/man/pasteXMLTag.Rd
index 15c07e8..bbce218 100644
--- a/packages/XiMpLe/man/pasteXMLTag.Rd
+++ b/packages/XiMpLe/man/pasteXMLTag.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/pasteXMLTag.R
 \name{pasteXMLTag}
 \alias{pasteXMLTag}
diff --git a/packages/XiMpLe/man/show-methods.Rd b/packages/XiMpLe/man/show-methods.Rd
index 0f116c0..ea3b3f9 100644
--- a/packages/XiMpLe/man/show-methods.Rd
+++ b/packages/XiMpLe/man/show-methods.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/01_method_03_show.R
 \docType{methods}
 \name{show,XiMpLe.XML-method}



More information about the rkward-tracker mailing list