[rkward-cvs] [rkward] packages/rkwarddev: improved the author and maintainer fileds in generated DESCRIPTION files

m.eik michalke meik.michalke at uni-duesseldorf.de
Tue Jan 6 14:57:41 UTC 2015


Git commit 97710a1010f3fa28ed2b06b6a9f3ea3361327b67 by m.eik michalke.
Committed on 06/01/2015 at 14:57.
Pushed by meikm into branch 'master'.

improved the author and maintainer fileds in generated DESCRIPTION files

M  +3    -1    packages/rkwarddev/ChangeLog
M  +42   -0    packages/rkwarddev/R/rk-internal.R
M  +6    -5    packages/rkwarddev/R/rk.plugin.skeleton.R

http://commits.kde.org/rkward/97710a1010f3fa28ed2b06b6a9f3ea3361327b67

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index a761708..0822bf7 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -1,6 +1,6 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.06-6 (2015-01-02)
+changes in version 0.06-6 (2015-01-06)
 fixed:
   - rk.XML.optionset() does now allow to re-use objects defined in the same
     function call (i.e., refer to optioncolumns in the logic section)
@@ -62,6 +62,8 @@ changed:
   - rk.JS.doc() now uses a more robust method to set global variables, namely
     by defining an additional function setGlobalVars() and calling that
     inside preprocess()
+  - updated the generation of author and maintainer fileds in DESCRIPTIONs
+    made by rk.plugin.skeleton(), borrowing get.authors() from roxyPackage
 removed:
   - the functions rk.set.language() rk.get.language() were no longer useful
     and therefore removed
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 637e73f..e8499bd 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -547,6 +547,48 @@ get.by.role <- function(persons, role="aut"){
 } ## end function get.by.role()
 
 
+## function get.authors()
+get.authors <- function(description, maintainer=TRUE, contributor=FALSE, copyright=FALSE){
+  if("Authors at R" %in% names(description)){
+    gotPersons <- TRUE
+    authorsFromDescription <- description[["Authors at R"]]
+  } else if("Author at R" %in% names(description)){
+    gotPersons <- TRUE
+    authorsFromDescription <- description[["Author at R"]]
+  } else {
+    gotPersons <- FALSE
+  }
+  
+  if(isTRUE(gotPersons)){
+    got.aut <- paste(format(get.by.role(eval(parse(text=authorsFromDescription))), include=c("given", "family")), collapse=", ")
+    got.cre <- ifelse(isTRUE(maintainer),
+      paste(format(get.by.role(eval(parse(text=authorsFromDescription)), role="cre"), include=c("given", "family", "email")), collapse=", "),
+      "")
+    got.ctb <- ifelse(isTRUE(contributor),
+      paste(format(get.by.role(eval(parse(text=authorsFromDescription)), role="ctb"), include=c("given", "family")), collapse=", "),
+      "")
+    got.cph <- ifelse(isTRUE(copyright),
+      paste(format(get.by.role(eval(parse(text=authorsFromDescription)), role="cph"), include=c("given", "family")), collapse=", "),
+      "")
+  } else {
+    got.aut <- description[["Author"]]
+    got.cre <- ifelse(isTRUE(maintainer),
+      description[["Maintainer"]],
+      "")
+    # contributors should already be named in got.aut
+    got.ctb <- ""
+    got.cph <- ""
+  }
+  got.cre.clean <- gsub("<([^@]*)@([^>]*)>", "\\\\email{\\1@@\\2}", gsub("\n[[:space:]]*", "\n#' ", got.cre))
+  # append contributors
+  if(isTRUE(contributor) && got.ctb != ""){
+    got.aut <- paste0(got.aut, ", with contributions from ", got.ctb)
+  } else {}
+  gotAuthors <- list(aut=got.aut, cre=got.cre, cre.clean=got.cre.clean, ctb=got.ctb, cph=got.cph)
+  return(gotAuthors)
+} ## end function get.authors()
+
+
 ## function check.ID()
 # - node: a XiMpLe.node to search for an ID
 # - search.environment: if TRUE, the internal environment is searched for the ID
diff --git a/packages/rkwarddev/R/rk.plugin.skeleton.R b/packages/rkwarddev/R/rk.plugin.skeleton.R
index 5766e75..83eb764 100644
--- a/packages/rkwarddev/R/rk.plugin.skeleton.R
+++ b/packages/rkwarddev/R/rk.plugin.skeleton.R
@@ -364,11 +364,12 @@ rk.plugin.skeleton <- function(about, path=tempdir(),
   ## create DESCRIPTION file
   if("desc" %in% create){
     if(isTRUE(checkCreateFiles(description.file, ow=overwrite, action="desc"))){
-      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(authors, role="cre"),
-        include=c("given", "family", "email"), braces=list(email=c("<", ">")))
+      # R replaces the @ with a dot, so we need to rename it as a workaround
+      authors.person <- data.frame(AuthorsR=paste0("c(", XML2person(about.node), ")"), stringsAsFactors=FALSE)
+      colnames(authors.person)[1] <- "Authors at R"
+      authors <- get.authors(authors.person, maintainer=TRUE, contributor=TRUE)
+      all.authors <- authors[["aut"]]
+      all.maintainers <- authors[["cre"]]
 
 ## TODO: check and add the commented values here:
       desc <- data.frame(





More information about the rkward-tracker mailing list